基于vue2使用Fullcalendar实现工作日历

需求背景

要求实现工作日历,以每月形式展示,而且要求不同工单根据类型可以自定义配置是否显示以及显示的颜色,比较世面上的日历插件,Fullcalendar插件比较好用的良心的可以创建日历日程管理的开源组件。
vue框架下,fullcalendar被封装成了不同的版本,这里主要讨论fullcalendar/vue的用法,其他的实现效果并不好。
本文只说明工作日历的简单显示,没有进行日程事件增删改等操作,如果需要请参考官方文档。
UI样式如图
在这里插入图片描述

安装插件

npm install --save @fullcalendar/vue @fullcalendar/core @fullcalendar/daygrid @fullcalendar/interaction @fullcalendar/timegrid
"@fullcalendar/core": "^6.1.14",
"@fullcalendar/daygrid": "^6.1.14",
"@fullcalendar/interaction": "^6.1.14",
"@fullcalendar/timegrid": "^6.1.14",
"@fullcalendar/vue": "^6.1.14",
"moment": "^2.24.0"

部分代码

html

<!-- 因为日历插件的头部不满足我的项目需求 所以选择自己重写一个 -->
<calendar-header ref="calendarHeader" @change="changeMonth"></calendar-header>
<FullCalendar
	class="fullCalendar"
	ref="fullCalendar"
	:options="calendarOptions"
	v-loading="loading"
>
<!-- 每条日程事件的样式 具体请参考官方文档-->
	<template slot="eventContent" slot-scope="arg">
		<event-render
			:event="arg.event"
			@getShowEventList="getShowEventList"
			@eventClick="eventClick"
		></event-render>
	</template>
</FullCalendar>
<!-- 因为插件的moreContent的显示内容样式不符合需求 用fullcalendar的moreContent插槽的话 moreLinkClick事件也触发不到获取不到单元格的日期 所以进行重写 -->
<more-content
	ref="moreContent"
	v-show="isShowMoreContent"
	:currentDate="currentDate"
	:eventList="showEventList"
	:style="{
		top: moreTop + 'px',
		left: moreLeft + 'px'
	}"
></more-content>

JS部分

import calendarHeader from './calendar-header.vue'
import FullCalendar from '@fullcalendar/vue'
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值