218 lines
5.2 KiB
Vue
218 lines
5.2 KiB
Vue
<template>
|
|
<full-calendar :options="calendarOptions" />
|
|
|
|
</template>
|
|
|
|
<script>
|
|
import {reactive, ref, onMounted} from 'vue'
|
|
// import '@fullcalendar/core/vdom'
|
|
import FullCalendar from '@fullcalendar/vue3'
|
|
import dayGridPlugin from '@fullcalendar/daygrid'
|
|
import interactionPlugin from '@fullcalendar/interaction'
|
|
import listPlugin from '@fullcalendar/list'
|
|
import timeGridPlugin from '@fullcalendar/interaction'
|
|
import { axiosApiInstance } from '@/utils/axios-api'
|
|
import multiMonthPlugin from '@fullcalendar/multimonth'
|
|
|
|
|
|
export default {
|
|
name: 'calendar-full',
|
|
|
|
props: {
|
|
initial: {
|
|
type: String,
|
|
default: 'multiMonthYear'
|
|
}
|
|
},
|
|
|
|
components: {
|
|
FullCalendar
|
|
},
|
|
|
|
setup(props) {
|
|
|
|
const calendarOptions = reactive({
|
|
plugins: [ dayGridPlugin, interactionPlugin, timeGridPlugin, listPlugin, multiMonthPlugin ],
|
|
initialView: props.initial,
|
|
dayMaxEventRows: 2,
|
|
locale: 'ru',
|
|
buttonText: {
|
|
today: 'Сегодня',
|
|
month: 'Месяц',
|
|
week: 'Неделя',
|
|
day: 'День',
|
|
list: 'Список',
|
|
year: 'Год'
|
|
},
|
|
firstDay:'1',
|
|
events: [],
|
|
// eventDidMount: function(info) {
|
|
|
|
|
|
// const dayEl = info.el.closest('.fc-daygrid-day')
|
|
// dayEl.style.backgroundColor = 'red'
|
|
// },
|
|
// datesRender: function(info) {
|
|
|
|
|
|
// const start = info.view.activeStart
|
|
// const end = info.view.activeEnd
|
|
// let daysEls = document.querySelectorAll('.fc-daygrid-day')
|
|
// console.log(daysEls , ' info-------------');
|
|
// },
|
|
|
|
editable: true,
|
|
headerToolbar: {
|
|
left: 'prev',
|
|
center: 'title',
|
|
right: 'next'
|
|
}
|
|
|
|
,
|
|
eventRender: function(eventObj, $el) {
|
|
$el.popover({
|
|
title: eventObj.title,
|
|
content: eventObj.description,
|
|
trigger: 'hover',
|
|
placement: 'top',
|
|
container: 'body'
|
|
});
|
|
},
|
|
|
|
|
|
// eventDidMount: function(info) {
|
|
// console.log(info.event.extendedProps);
|
|
// {description: "Lecture", department: "BioChemistry"}
|
|
// },
|
|
aspectRatio: 3,
|
|
multiMonthMaxColumns: 2,
|
|
displayEventEnd: true,
|
|
height: '100%',
|
|
stickyHeaderDates: true,
|
|
dayMaxEventRows: 2,
|
|
moreLinkContent: function(arg) {
|
|
return arg.shortText + ' события'
|
|
},
|
|
views: {
|
|
multiMonthYear: {
|
|
|
|
moreLinkContent: function(arg) {
|
|
return arg.num
|
|
},
|
|
|
|
},
|
|
},
|
|
|
|
allDayText: 'Весь день',
|
|
noEventsContent: 'На сегодня событий нет',
|
|
selectable: true,
|
|
|
|
dateClick: (arg) => {
|
|
console.log(arg.date);
|
|
}
|
|
})
|
|
|
|
function f_generalvacation() {
|
|
axiosApiInstance.get('api/general_vacation/generalvacation/')
|
|
.then(data => {
|
|
|
|
for (let x in data.data) {
|
|
|
|
data.data[x].map(e=>{
|
|
let d = new Date(e.planned_date)
|
|
// console.log(, 'e---------d.addDays(e.count_days)--------e')
|
|
calendarOptions.events.push({ description: 'description for All Day Event', title: x, start: e.planned_date, end: new Date(d.setDate(d.getDate() + e.count_days)).toISOString().split('T')[0]})
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
console.log(data.data , 'genvacation--------------------');
|
|
|
|
})
|
|
}
|
|
|
|
onMounted(() => {
|
|
f_generalvacation()
|
|
|
|
|
|
})
|
|
// genvacation.value[0].planned_date
|
|
|
|
|
|
|
|
return { calendarOptions }
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
#fc-dom-1:first-letter {
|
|
text-transform: capitalize;
|
|
}
|
|
|
|
.fc-toolbar {
|
|
/* padding: 0px; */
|
|
background-color: #f8f8f8;
|
|
}
|
|
.fc-day-header {
|
|
font-weight: bold;
|
|
text-align: center;
|
|
}
|
|
.fc-day {
|
|
border: none;
|
|
}
|
|
.fc-time-grid-event {
|
|
background-color: #e6e6e6;
|
|
border: none;
|
|
color: #000;
|
|
}
|
|
.fc-event-title {
|
|
font-weight: bold;
|
|
}
|
|
|
|
.fc .fc-toolbar.fc-header-toolbar {
|
|
padding-bottom: 0.2em;
|
|
margin-bottom: 0px;
|
|
}
|
|
|
|
|
|
|
|
/* .fc .fc-daygrid-day-events {
|
|
margin-top: -7px;
|
|
} */
|
|
.fc {
|
|
background-color: #ffffff;
|
|
}
|
|
|
|
.fc-button {
|
|
|
|
padding: 1px!important;
|
|
border-radius: 1em!important;
|
|
line-height: 0!important;
|
|
background-color: transparent!important;
|
|
border-color: transparent!important;
|
|
|
|
}
|
|
|
|
.fc-icon {
|
|
color: #000;
|
|
display: flex;
|
|
}
|
|
|
|
.fc-button:focus, .fc-icon {
|
|
outline: none!important;
|
|
}
|
|
|
|
.fc-button,
|
|
.fc-buttonactive,
|
|
.fc-button:focus {
|
|
border:none!important;
|
|
}
|
|
|
|
.fc-header-toolbar {
|
|
background: white !important;
|
|
}
|
|
|
|
</style> |