Files
PORTAL_COD2/front/src/components/UI/Calendar.vue
T
2023-09-21 16:58:52 +03:00

114 lines
3.0 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'
export default {
name: 'Calendar',
components: {
FullCalendar
},
setup() {
const calendarOptions = reactive({
plugins: [ dayGridPlugin, interactionPlugin, timeGridPlugin, listPlugin ],
initialView: 'dayGridMonth',
locale: 'ru',
buttonText: {
today: 'Сегодня',
month: 'Месяц',
week: 'Неделя',
day: 'День',
list: 'Список'
},
firstDay:'1',
events: [],
editable: true,
headerToolbar: {
left: 'prev, next, today',
center: 'title',
right: 'dayGridMonth, dayGridWeek, dayGridDay, listDay'
},
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({ 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>
.red {
background: rgb(235, 77, 77) !important;
color: whitesmoke !important;
}
.blue {
background: rgb(59, 59, 163) !important;
color: whitesmoke !important;
}
.orange {
background: orange !important;
color: white !important;
}
.green {
background: rgb(49, 155, 49) !important;
color: white !important;
}
.blue,
.orange,
.red,
.green {
font-size: 13px;
font-weight: 500;
text-transform: capitalize;
}
.event-item {
padding: 2px 0 2px 4px !important;
}
</style>