refactor [P-57]: add FullCalendar

This commit is contained in:
Inna committed 2025-09-11 12:01:43 +03:00
1 parent 7a6e24fbee
commit c34eabc582
9 files changed
+729 -231

No files matched your search

+8 -1
View File
@@ -36,7 +36,14 @@
"vue3-autocounter": "^1.0.8", "vue3-autocounter": "^1.0.8",
"vuelidate": "^0.7.7", "vuelidate": "^0.7.7",
"vuetify": "^3.7.8", "vuetify": "^3.7.8",
"webfontloader": "^1.6.28" "webfontloader": "^1.6.28",
"@fullcalendar/core": "^6.1.19",
"@fullcalendar/daygrid": "^6.1.19",
"@fullcalendar/interaction": "^6.1.19",
"@fullcalendar/multimonth": "^6.1.19",
"@fullcalendar/timegrid": "^6.1.19",
"@fullcalendar/list": "6.1.19",
"@fullcalendar/vue3": "^6.1.19"
}, },
"devDependencies": { "devDependencies": {
"@commitlint/cli": "^19.7.1", "@commitlint/cli": "^19.7.1",
@@ -1,84 +1,13 @@
<template> <template>
<v-row no-gutters> <v-row no-gutters>
<v-col class="flex-grow-0 d-flex flex-column"> <v-col class="flex-grow-0 d-flex flex-column">
<v-card class="h-100 rounded-0 d-flex flex-colmn" width="250"> <mini-calendar />
<v-row no-gutters class="flex-column">
<v-col class="flex-grow-0 px-2 pt-1">
<v-text-field
density="compact"
clearable
append-inner-icon="mdi-magnify"
hide-details
class="py-3"
label="Найти событие"
rows="1"
no-resize
variant="outlined"
/>
</v-col>
<v-col class="flex-grow-0 px-2">
<v-btn
type="submit"
class="text-subtitle-1 font-weight-light"
color="btn_text"
block
elevation="1"
@click="createEvent()"
>Создать событие</v-btn
>
<!-- {{eventFromCalendar}} -->
</v-col>
<v-col class="w100" lg="3">
<v-locale-provider locale="ru">
<v-date-picker
ref="cal"
v-model="selectdate"
color="btn_text"
class="rounded-0 minCal"
max-width="250"
hide-header
show-adjacent-months
@click="CheckingStore"
@update:month="getMonth"
@update:year="getYear"
>
</v-date-picker>
</v-locale-provider>
</v-col>
<v-col class="flex-column d-flex">
<v-row no-gutters class="h-0 overflow-auto flex-column flex-nowrap">
<v-col>
<calendar-my
:calendars="
calendarForMy.filter((e) => e.author == accountStore.user.is_idEmployee)
"
title="Мои календари"
@getCalendar="getCalendar"
/>
<calendar-my
:calendars="
calendarForMy.filter((e) => e.author != accountStore.user.is_idEmployee)
"
title="Подписки"
/>
</v-col>
</v-row>
</v-col>
</v-row>
</v-card>
</v-col> </v-col>
<v-col class="d-flex flex-column"> <v-col class="d-flex flex-column">
<calendar-full <custom-calendar />
:allEvent="calendarForMy.filter((e) => e.events.length > 0)"
@getEvent="createEvent"
@update:allEvent="infoEvent($event)"
/>
</v-col> </v-col>
<!--
<!-- <v-navigation-drawer <v-navigation-drawer
v-model="drawer_right"
floating floating
permanent permanent
location="right" location="right"
@@ -90,8 +19,8 @@
<event-create <event-create
@closeDialog="showDialog = false" @closeDialog="showDialog = false"
:eventCalendar="eventFromCalendar" :eventCalendar="eventFromCalendar"
@update:eventCalendar="eventFromCalendar = $event"
@getCalendar="getCalendar" @getCalendar="getCalendar"
@update:eventCalendar="eventFromCalendar = $event"
ref="createEvents" ref="createEvents"
/> />
</v-dialog> </v-dialog>
@@ -99,23 +28,21 @@
</template> </template>
<script> <script>
import { ref, onMounted, watch } from 'vue'; import { ref, onMounted } from 'vue';
import { useWeekendsStore } from '@/store/WeekendsStore'; import { useWeekendsStore } from '@/store/WeekendsStore';
import EventCreate from '@/components/calendar_of_events/event-create.vue'; import EventCreate from '@/components/calendar_of_events/event-create.vue';
import CalendarMy from '@/components/calendar_of_events/calendar-my.vue'; // import { useAccountStore } from '@/store/AccountStore';
import { axiosApiInstance } from '@/utils/axios-api'; import CustomCalendar from '@/components/calendar_of_events/UI_calendar/CustomCalendar.vue';
import { useAccountStore } from '@/store/AccountStore'; import { useCalendarStore } from '@/store/calendarStore';
import CalendarFull from '@/components/calendar_of_events/UI_calendar/calendarFull.vue'; import { storeToRefs } from 'pinia';
import MiniCalendar from '@/components/calendar_of_events/UI_calendar/MiniCalendar.vue';
export default { export default {
components: { EventCreate, CalendarMy, CalendarFull }, components: { EventCreate, MiniCalendar, CustomCalendar },
setup() { setup() {
const accountStore = useAccountStore(); // const accountStore = useAccountStore();
const showDialog = ref(false); const showDialog = ref(false);
const week = useWeekendsStore(); const week = useWeekendsStore();
const drawer_right = ref(false);
const cal = ref(null);
const selectdate = ref(new Date()); const selectdate = ref(new Date());
const MyYear = ref(selectdate.value.getFullYear()); const MyYear = ref(selectdate.value.getFullYear());
const MyMonth = ref(selectdate.value.getMonth() + 1); const MyMonth = ref(selectdate.value.getMonth() + 1);
@@ -123,6 +50,18 @@ export default {
const eventFromCalendar = ref({}); const eventFromCalendar = ref({});
const createEvents = ref(null); const createEvents = ref(null);
const calendarStore = useCalendarStore();
const { selectedDate } = storeToRefs(calendarStore); // синхронизируем с date-picker
const handleSaveEvent = (eventData) => {
if (eventData.id) {
calendarStore.updatedEvent(eventData);
} else {
calendarStore.addEvent(eventData);
}
};
const getMonth = (month) => { const getMonth = (month) => {
MyMonth.value = month + 1; MyMonth.value = month + 1;
}; };
@@ -131,79 +70,17 @@ export default {
}; };
const getCalendar = () => { const getCalendar = () => {
axiosApiInstance.get(`api/calendar_of_events/my_calendars/`).then((res) => {
res.data.forEach((e) => (e.visible = accountStore.calendar.includes(e.id) ? false : true)); calendarStore.loadCalendars();
calendarForMy.value = res.data;
});
}; };
getCalendar(); getCalendar();
const getEvents = (idEvent, clik) => {
axiosApiInstance
.get(`api/calendar_of_events/my_events/${idEvent === undefined ? '' : `?id=${idEvent}`}`)
.then((res) => {
if (idEvent === undefined) {
res.data.event = {
name: '',
participant: [accountStore.user.is_idEmployee],
files: [],
date_start: new Date(),
date_end: new Date(),
period: null,
description: '',
calendar: null,
};
}
eventFromCalendar.value = res.data;
if (clik) showDialog.value = true;
});
};
getEvents();
const createEvent = (idEv) => {
getEvents(idEv, true);
if (idEv) {
getCalendar();
}
};
const weekendsData = () => {
cal.value.$el.querySelectorAll('.v-date-picker-month__day').forEach((e) => {
let datas = e.getAttribute('data-v-date');
let weeks = new Date(datas).getDay() === 6 || new Date(datas).getDay() === 0;
if (weeks) {
e.querySelectorAll('span').forEach((n) => {
n.classList.add('text-red');
});
}
if (MyMonth.value in week.week[MyYear.value]) {
if (week.week[MyYear.value][MyMonth.value].includes(datas)) {
e.querySelectorAll('span').forEach((n) => {
n.classList.add('text-red');
if (n.classList.contains('text-red') && weeks) {
n.classList.replace('text-red', 'text-black');
}
});
}
}
});
};
onMounted(() => { onMounted(() => {
week.getWeekend(MyYear.value); week.getWeekend(MyYear.value);
}); });
watch(
() => week.week,
(newValue) => {
if (newValue) {
weekendsData();
}
},
);
const CheckingStore = () => { const CheckingStore = () => {
if (MyYear.value in week.week) { if (MyYear.value in week.week) {
@@ -213,34 +90,36 @@ export default {
} }
}; };
const infoEvent = (i) => {
console.log(i, 'iiiiiiiiii');
};
return { return {
drawer_right, selectedDate,
selectdate,
cal,
getMonth, getMonth,
getYear, getYear,
weekendsData,
week, week,
CheckingStore, CheckingStore,
showDialog, showDialog,
calendarForMy, calendarForMy,
accountStore, // accountStore,
getCalendar, getCalendar,
eventFromCalendar, eventFromCalendar,
createEvent,
infoEvent,
createEvents, createEvents,
calendarStore,
handleSaveEvent,
}; };
}, },
}; };
</script> </script>
<style> <style scoped>
.minCal .v-date-picker-month__day { .minCal:deep(.v-date-picker-month__days) {
/* display: grid !important;
grid-template-columns: repeat(7, 32px) !important;
gap: 3px !important;
width: 250px !important;
justify-content: center !important;
margin: 0 auto !important; */
}
.minCal .v-date-picker-monWth__day {
height: 31px; height: 31px;
width: 31px; width: 31px;
} }
@@ -253,4 +132,8 @@ export default {
.minCal .v-btn__content { .minCal .v-btn__content {
font-weight: 410; font-weight: 410;
} }
.minCal:deep(.v-date-picker-years__content) {
gap: 0;
}
</style> </style>
@@ -0,0 +1,318 @@
<template>
<v-col cols="12">
<v-card>
<v-card-text>
<!-- Контролы навигации -->
<v-row no-gutters class="mb-4" align="center" justify="space-between">
<v-col md="4" class="flex-grow-0 d-flex align-center">
<v-btn
variant="outlined"
class="text-subtitle-2 mr-2"
@click="handleToday"
density="comfortable"
>
Сегодня
</v-btn>
<v-btn
variant="text"
@click="handlePrev"
:elevation="0"
style="border-radius: 4px"
density="compact"
icon
>
<v-icon size="large">mdi-chevron-left</v-icon>
</v-btn>
<v-btn
variant="text"
@click="handleNext"
:elevation="0"
style="border-radius: 4px"
density="compact"
icon
>
<v-icon size="large">mdi-chevron-right</v-icon>
</v-btn>
<span class="text-h6 text-no-wrap ml-2"> {{ currentTitle }} </span>
</v-col>
<v-col class="flex-grow-0 d-flex justify-end">
<v-btn-toggle
v-model="currentView"
mandatory
divided
variant="plain"
density="comfortable"
>
<v-btn value="timeGridDay">День</v-btn>
<v-btn value="timeGridWeek">Неделя</v-btn>
<v-btn value="dayGridMonth">Месяц</v-btn>
<v-btn value="multiMonthYear">Год</v-btn>
<v-btn value="listWeek">Расписание</v-btn>
</v-btn-toggle>
</v-col>
</v-row>
<div class="flex-grow-1">
<!-- VCalendar -->
<FullCalendar ref="calendarRef" :options="calendarOptions" class="compact-calendar" />
<!-- @datesSet="handleDatesSet" -->
</div>
</v-card-text>
</v-card>
</v-col>
</template>
<script>
import { ref, computed, watch, nextTick } from 'vue';
import { storeToRefs } from 'pinia';
import dayGridPlugin from '@fullcalendar/daygrid';
import timeGridPlugin from '@fullcalendar/timegrid';
import multiMonthPlugin from '@fullcalendar/multimonth';
import interactionPlugin from '@fullcalendar/interaction';
import listPlugin from '@fullcalendar/list';
import ruLocale from '@fullcalendar/core/locales/ru';
import { onMounted } from 'vue';
import { useCalendarStore } from '@/store/calendarStore';
export default {
name: 'CustomCalendar',
setup() {
const calendarRef = ref(null);
const currentView = ref('dayGridMonth');
const calendarApi = ref(null);
const calendarStore = useCalendarStore();
const { selectedDate, lastUpdatedBy } = storeToRefs(calendarStore);
const calendarOptions = ref({
plugins: [dayGridPlugin, timeGridPlugin, multiMonthPlugin, interactionPlugin, listPlugin],
initialView: currentView.value,
locales: [ruLocale],
locale: 'ru',
firstDay: 1,
headerToolbar: false,
height: '80vh',
aspectRatio: 1.5,
weekNumbers: true,
weekNumberFormat: {
week: 'numeric',
},
weekNumberCalculation: 'ISO', // ISO стандарт (понедельник - первый день)
views: {
timeGridDay: {
type: 'timeGrid',
duration: { days: 1 },
slotDuration: '01:00:00',
slotLabelInterval: '01:00:00',
slotLabelFormat: {
hour: '2-digit',
minute: '2-digit',
hour12: false,
meridiem: false,
},
allDaySlot: false,
allDaySlot: false,
slotMinTime: '07:00:00',
slotMaxTime: '22:00:00',
expandRows: true,
dayHeaderFormat: {
weekday: 'long',
day: 'numeric',
month: 'long',
omitCommas: true,
},
},
timeGridWeek: {
type: 'timeGrid',
duration: { weeks: 1 },
slotDuration: '01:00:00',
slotMinTime: '07:00:00',
slotMaxTime: '22:00:00',
allDaySlot: false,
expandRows: true,
dayHeaderFormat: { weekday: 'short', day: 'numeric' },
},
dayGridMonth: {
type: 'dayGrid',
fixedWeekCount: false,
dayHeaderFormat: { weekday: 'short' },
weekNumbers: true,
weekNumberFormat: { week: 'numeric' },
weekNumberContent: (arg) => {
return arg.num;
},
weekText: 'Нед.',
},
multiMonthYear: {
type: 'multiMonth',
duration: { years: 1 },
multiMonthMaxColumns: 4,
fixedWeekCount: false,
weekNumbers: false,
},
listWeek: {
type: 'list',
duration: { weeks: 1 },
listDayFormat: {
weekday: 'long',
day: 'numeric',
month: 'long',
},
listDaySideFormat: false,
},
},
events: [
// Обычные события заглушка
{
title: '10:00 Лотус',
start: new Date('September, 26, 2025').setHours(10, 0, 0),
end: new Date('September, 28, 2025').setHours(11, 0, 0),
color: '#1867C0',
},
{
title: '14:00 Совещание',
start: new Date('September, 20, 2025').setHours(14, 0, 0),
end: new Date('September, 20, 2025').setHours(15, 0, 0),
color: '#1867C0',
},
// ПРАЗДНИКИ РОССИИ 2025
{
title: '🎄 Новый год',
start: '2025-01-01',
end: '2025-01-08', // Новогодние каникулы
allDay: true,
className: 'holiday-event',
display: 'background',
textColor: 'white',
},
{
title: '🎅 Рождество',
start: '2025-01-07',
allDay: true,
className: 'holiday-event',
},
{
title: '🪆 День защитника Отечества',
start: '2025-02-23',
allDay: true,
className: 'holiday-event',
},
{
title: '🌸 Международный женский день',
start: '2025-03-08',
allDay: true,
className: 'holiday-event',
},
{
title: '🌷 Майские праздники',
start: '2025-05-01',
end: '2025-05-05',
allDay: true,
className: 'holiday-event',
display: 'background',
},
{
title: '🎆 День Победы',
start: '2025-05-09',
allDay: true,
className: 'holiday-event',
},
{
title: '🇷🇺 День России',
start: '2025-06-12',
allDay: true,
className: 'holiday-event',
},
{
title: '🤝 День народного единства',
start: '2025-11-04',
allDay: true,
className: 'holiday-event',
},
],
eventClick: (info) => {
console.log('Event click', info.event.title);
},
dateClick: (info) => {
handleCalendarDateClick(info);
},
});
onMounted(() => {
if (calendarRef.value) {
calendarApi.value = calendarRef.value.getApi();
}
});
const handleCalendarDateClick = (info) => {
calendarStore.setSelectedDateFromCalendar(info);
};
const handleToday = () => {
calendarApi.value?.today();
};
const handlePrev = () => {
calendarApi.value?.prev();
};
const handleNext = () => {
calendarApi.value?.next();
};
const currentTitle = computed(() => {
return calendarApi.value ? calendarApi.value.view.title : 'Календарь';
});
watch(
currentView,
(newView) => {
calendarApi.value?.changeView(newView);
},
{ immediate: true },
);
watch(selectedDate, (newDate) => {
if (!newDate) return;
nextTick(() => {
if (calendarApi.value && lastUpdatedBy.value !== 'calendar')
try {
calendarApi.value.gotoDate(newDate);
} catch (error) {
console.warn('Ошибка при переходе к дате:', error);
}
});
});
return {
currentTitle,
calendarRef,
currentView,
calendarOptions,
handleToday,
handleNext,
handlePrev,
handleCalendarDateClick,
};
},
};
</script>
<style scoped>
:deep(.v-btn--active) {
background-color: #e0f2f1 !important;
color: #00897b !important;
}
/* Изменение фона текущего дня */
:deep(.fc .fc-daygrid-day.fc-day-today) {
background-color: #e0f2f1 !important;
}
:deep(.fc .fc-timegrid-col.fc-day-today) {
background-color: #e0f2f1 !important;
}
</style>
@@ -0,0 +1,102 @@
<template>
<v-card class="h-100 rounded-0 d-flex flex-colmn">
<v-row no-gutters class="flex-column">
<v-col class="flex-grow-0 px-2 pt-1">
<v-text-field
density="compact"
clearable
append-inner-icon="mdi-magnify"
hide-details
class="py-3"
label="Найти событие"
rows="1"
no-resize
variant="outlined"
/>
</v-col>
<v-col class="flex-grow-0 px-2">
<v-btn
type="submit"
class="text-subtitle-1 font-weight-light"
color="btn_text"
block
elevation="1"
@click="createEvent()"
>Создать событие</v-btn
>
<!-- {{eventFromCalendar}} -->
</v-col>
<v-col lg="3">
<v-locale-provider locale="ru">
<v-date-picker
v-model="selectedDate"
color="btn_text"
class="rounded-0 minCal"
hide-header
show-adjacent-months
@update:modelValue="handleDateClick"
>
</v-date-picker>
</v-locale-provider>
</v-col>
<v-col class="flex-column d-flex">
<v-row no-gutters class="h-0 overflow-auto flex-column flex-nowrap">
<v-col>
<calendar-my
:calendars="calendarForMy.filter((e) => e.author != user.is_idEmployee)"
title="Подписки"
/>
<calendar-my
:calendars="calendarForMy.filter((e) => e.author == user.is_idEmployee)"
title="Мои календари"
@getCalendar="loadCalendars"
/>
</v-col>
</v-row>
</v-col>
</v-row>
</v-card>
</template>
<script>
import { useCalendarStore } from '@/store/calendarStore';
import { useAccountStore } from '@/store/AccountStore';
import CalendarMy from '@/components/calendar_of_events/calendar-my.vue';
import { ref } from 'vue';
import { storeToRefs } from 'pinia';
export default {
name: 'MiniCalendar',
components: { CalendarMy },
setup() {
const calendarStore = useCalendarStore();
const accountStore = useAccountStore();
const calendarForMy = ref([]);
const { selectedDate } = storeToRefs(calendarStore);
const { user } = storeToRefs(accountStore);
const createEvent = () => {
calendarStore.openEventDialog();
};
const loadCalendars = () => {
calendarStore.loadCalendars();
};
const handleDateClick = (date) => {
calendarStore.setSelectedDateFromPicker(date);
};
return {
accountStore,
user,
selectedDate,
calendarForMy,
createEvent,
loadCalendars,
handleDateClick,
};
},
};
</script>
<style scoped></style>
@@ -93,7 +93,7 @@ export default {
{ type: "day", text: "День" }, { type: "day", text: "День" },
{ type: "week", text: "Неделя" }, { type: "week", text: "Неделя" },
{ type: "month", text: "Месяц" }, { type: "month", text: "Месяц" },
{ type: "modntdh", text: "Год" }, // { type: "modntdh", text: "Год" },
{ type: "modnth", text: "Расписание" }, { type: "modnth", text: "Расписание" },
]; ];
@@ -314,7 +314,7 @@ export default {
ev.rule.byweekday[ev.rule.byweekday.length - 1].weekday == 6 ev.rule.byweekday[ev.rule.byweekday.length - 1].weekday == 6
? 0 ? 0
: ev.rule.byweekday[ev.rule.byweekday.length - 1].weekday + 1; : ev.rule.byweekday[ev.rule.byweekday.length - 1].weekday + 1;
if (day.date.getDay() == weeknumS && weeknumS != weeknumE) { if (day.date.getDay() == weeknumS && weeknumS != weeknumE) {
return "rounded-e-lg"; return "rounded-e-lg";
} else if (day.date.getDay() == weeknumE && weeknumS != weeknumE) { } else if (day.date.getDay() == weeknumE && weeknumS != weeknumE) {
@@ -328,7 +328,7 @@ export default {
return "rounded-lg"; return "rounded-lg";
} }
} }
if (ev.rule.freq == 0) { if (ev.rule.freq == 0) {
if (zeroTime(day.date) == zeroTime(ev.start_event)) { if (zeroTime(day.date) == zeroTime(ev.start_event)) {
@@ -342,7 +342,7 @@ export default {
// ev.rule.byweekday[ev.rule.byweekday.length - 1].weekday == 6 // ev.rule.byweekday[ev.rule.byweekday.length - 1].weekday == 6
// ? 0 // ? 0
// : ev.rule.byweekday[ev.rule.byweekday.length - 1].weekday + 1; // : ev.rule.byweekday[ev.rule.byweekday.length - 1].weekday + 1;
// if (day.date.getDay() == weeknumS && weeknumS != weeknumE) { // if (day.date.getDay() == weeknumS && weeknumS != weeknumE) {
// return "rounded-e-lg"; // return "rounded-e-lg";
// } else if (day.date.getDay() == weeknumE && weeknumS != weeknumE) { // } else if (day.date.getDay() == weeknumE && weeknumS != weeknumE) {
@@ -1,12 +1,5 @@
<template> <template>
<v-expansion-panels <v-expansion-panels class="calendar" variant="accordion" flat tile static v-model="openGroup">
class="calendar"
variant="accordion"
flat
tile
static
v-model="openGroup"
>
<v-expansion-panel elevation="0" flat tile static> <v-expansion-panel elevation="0" flat tile static>
<v-expansion-panel-title flat tile static class="py-0 px-3"> <v-expansion-panel-title flat tile static class="py-0 px-3">
<div @click.stop=""> <div @click.stop="">
@@ -47,16 +40,14 @@
</template> </template>
<template v-slot:append> <template v-slot:append>
<transition name="fade"> <transition name="fade">
<v-btn <v-btn
v-if=" v-if="
x.author == accountStore.user.is_idEmployee || x.author == user.is_idEmployee ||
x.participant.some( x.participant.some(
(e) => (e) =>
e.editor == true && e.editor == true &&
e.participant_calendar == e.participant_calendar == user.is_idEmployee,
accountStore.user.is_idEmployee
) )
" "
size="x-small" size="x-small"
@@ -74,21 +65,22 @@
</template> </template>
</v-expansion-panel-text> </v-expansion-panel-text>
</v-expansion-panel> </v-expansion-panel>
<v-dialog v-model="showDialog" min-width="636" max-width="800"> <v-dialog v-model="showDialog" min-width="636" max-width="800">
<calendar-create <calendar-create
@closeDialog = "showDialog = false" @closeDialog="showDialog = false"
:calendar="calendar" :calendar="calendar"
@update:calendar="calendar = $event" @update:calendar="calendar = $event"
@getCalendar="$emit('getCalendar')" @getCalendar="$emit('getCalendar')"
/> />
</v-dialog> </v-dialog>
</v-expansion-panels> </v-expansion-panels>
</template> </template>
<script> <script>
import { ref } from "vue"; import { ref } from 'vue';
import calendarCreate from "@/components/calendar_of_events/calendar-create.vue"; import calendarCreate from '@/components/calendar_of_events/calendar-create.vue';
import { useAccountStore } from "@/store/AccountStore"; import { useAccountStore } from '@/store/AccountStore';
import { storeToRefs } from 'pinia';
export default { export default {
components: { calendarCreate }, components: { calendarCreate },
@@ -99,51 +91,52 @@ export default {
}, },
title: { title: {
typr: String, type: String,
default: "", default: '',
}, },
}, },
setup(props, { emit }) { setup(props, { emit }) {
const showDialog = ref(false); const showDialog = ref(false);
const accountStore = useAccountStore(); const accountStore = useAccountStore();
const { user, calendar: userCalendar } = storeToRefs(accountStore);
const calendar = ref({}); const calendar = ref({});
const openGroup = ref([0]); const openGroup = ref([0]);
const trans = ref(false); const trans = ref(false);
const hover = ref(0); const hover = ref(0);
const editCreatedCalendar = (cal) => { const editCreatedCalendar = (cal) => {
if (cal === undefined) { if (cal === undefined) {
calendar.value = { calendar.value = {
cl_name: "", cl_name: '',
participant: [{ editor: true, participant_calendar: accountStore.user.is_idEmployee }], participant: [{ editor: true, participant_calendar: user.value.is_idEmployee }],
cl_color: "red", cl_color: 'red',
cl_descr: "", cl_descr: '',
}; };
} else { } else {
calendar.value = cal; calendar.value = cal;
} }
showDialog.value = true; showDialog.value = true;
}; };
const chekUpdate = (cal) => { const chekUpdate = (cal) => {
let setcal = new Set(accountStore.calendar); let setcal = new Set(userCalendar.value);
if (cal.visible == false) { if (cal.visible == false) {
setcal.add(cal.id); setcal.add(cal.id);
} else { } else {
setcal.delete(cal.id); setcal.delete(cal.id);
} }
accountStore.calendar = Array.from(setcal); userCalendar.value = Array.from(setcal);
}; };
return { return {
showDialog, accountStore,
user,
calendar, calendar,
showDialog,
editCreatedCalendar, editCreatedCalendar,
chekUpdate, chekUpdate,
accountStore,
openGroup, openGroup,
trans, trans,
hover, hover,
+19 -19
View File
@@ -20,7 +20,7 @@
</template> </template>
<span>F.A.Q.</span> <span>F.A.Q.</span>
</v-tooltip> </v-tooltip>
<v-dialog v-model="LikeDialog" persistent width="800"> <v-dialog v-model="LikeDialog" persistent width="800">
<template v-slot:activator="{ props }"> <template v-slot:activator="{ props }">
@@ -83,11 +83,11 @@
<!-- v-if="!('submenu' in x) || (x.path== '/portal' && accountStore.user.is_staff)" --> <!-- v-if="!('submenu' in x) || (x.path== '/portal' && accountStore.user.is_staff)" -->
<v-list-item v-if="(x.path == '/portal'? accountStore.user.is_superuser : true) && !('submenu' in x) <v-list-item v-if="(x.path == '/portal'? accountStore.user.is_superuser : true) && !('submenu' in x)
" :key="x.key" :title="x.name" :value="x.name" :href="x.link" :disabled="x.path == ''" :to="x.path" " :key="x.key" :title="x.name" :value="x.name" :href="x.link" :disabled="x.path == ''" :to="x.path"
:target="x.link ? '_blank' : ''" :target="x.link ? '_blank' : ''"
color="navigation" color="navigation"
> >
<template v-slot:prepend> <template v-slot:prepend>
<v-icon :icon="x.ico" /> <v-icon :icon="x.ico" />
<v-tooltip v-if="rail" activator="parent" location="top"> <v-tooltip v-if="rail" activator="parent" location="top">
@@ -117,7 +117,7 @@
</v-list> </v-list>
<v-list nav density="compact"> <v-list nav density="compact">
<v-list-item v-for="x of mainmenuStore.portallinks" :key="x.name" :title="x.name" :value="x.name" <v-list-item v-for="x of mainmenuStore.portallinks" :key="x.name" :title="x.name" :value="x.name"
:href="x.link" color="app_bar" :target="x.link ? '_blank' : ''"> :href="x.link" color="app_bar" :target="x.link ? '_blank' : ''">
<template v-slot:prepend> <template v-slot:prepend>
<v-icon :icon="x.imagecode" /> <v-icon :icon="x.imagecode" />
@@ -133,7 +133,7 @@
<v-row class="flex-grow-0" v-if="accountStore.user.is_staff"> <v-row class="flex-grow-0" v-if="accountStore.user.is_staff">
<v-col> <v-col>
<AdminMenu :rail="rail" /> <AdminMenu :rail="rail" />
</v-col> </v-col>
</v-row> </v-row>
<v-row no-gutters class="flex-grow-0"> <v-row no-gutters class="flex-grow-0">
@@ -152,11 +152,11 @@
</v-main> </v-main>
<v-main v-else class="d-flex align-center text-h3 bg-teal-lighten-2"> <v-main v-else class="d-flex align-center text-h3 bg-teal-lighten-2">
<v-card class="h-100 w-100 d-flex justify-center rounded-0 flex-column" :image="`${burl}${scrimg}`"> <v-card class="h-100 w-100 d-flex justify-center rounded-0 flex-column" :image="`${burl}${scrimg}`">
<v-card-text <v-card-text
class="justify-center bgCard h-100 ma-3 d-flex flex-column" class="justify-center bgCard h-100 ma-3 d-flex flex-column"
style="background: rgba(255, 255, 255, 0.3) !important; background-color: rgba(255, 255, 255, 0.3) !important;" style="background: rgba(255, 255, 255, 0.3) !important; background-color: rgba(255, 255, 255, 0.3) !important;"
> >
<v-row <v-row
class="bgText flex-grow-0" class="bgText flex-grow-0"
style="background: rgba(255, 255, 255, 0.5) !important; background-color: rgba(255, 255, 255, 0.5) !important;" style="background: rgba(255, 255, 255, 0.5) !important; background-color: rgba(255, 255, 255, 0.5) !important;"
> >
@@ -164,7 +164,7 @@
Добро пожаловать на портал МИ ФНС России по ЦОД № 2 Добро пожаловать на портал МИ ФНС России по ЦОД № 2
</v-col> </v-col>
</v-row> </v-row>
<v-row <v-row
class="bgText flex-grow-0" class="bgText flex-grow-0"
style="background: rgba(255, 255, 255, 0.5) !important; background-color: rgba(255, 255, 255, 0.5) !important;" style="background: rgba(255, 255, 255, 0.5) !important; background-color: rgba(255, 255, 255, 0.5) !important;"
> >
@@ -258,7 +258,7 @@ export default {
mainmenuStore.loadlinks(); mainmenuStore.loadlinks();
const navigations = ref([ const navigations = ref([
{ {
@@ -303,11 +303,11 @@ export default {
// ], // ],
// }, // },
// { {
// name: "Календарь", name: "Календарь",
// ico: "mdi-calendar", ico: "mdi-calendar",
// path: "/ical", path: "/ical",
// }, },
{ {
name: "Голосование", name: "Голосование",
ico: "mdi-vote", ico: "mdi-vote",
@@ -331,7 +331,7 @@ export default {
path: "/portal", path: "/portal",
}, },
]); ]);
const imageSrc = computed(() => { const imageSrc = computed(() => {
@@ -375,7 +375,7 @@ export default {
navigations, navigations,
imageSrc, imageSrc,
LikeDialog, LikeDialog,
scrimg, scrimg,
rail, rail,
showTooltip, showTooltip,
menuTruncated, menuTruncated,
@@ -384,7 +384,7 @@ export default {
name, name,
closeinfo, closeinfo,
baseURL, baseURL,
message, message,
}; };
}, },
+27 -10
View File
@@ -5,15 +5,32 @@
*/ */
// Plugins // Plugins
import { loadFonts } from './webfontloader' import { loadFonts } from './webfontloader';
import vuetify from './vuetify' import vuetify from './vuetify';
import pinia from '../store' import pinia from '../store';
import router from '../router' import router from '../router';
export function registerPlugins (app) { // FullCalendar
loadFonts() import FullCalendar from '@fullcalendar/vue3';
app import dayGridPlugin from '@fullcalendar/daygrid';
.use(vuetify) import timeGridPlugin from '@fullcalendar/timegrid';
.use(pinia) import multiMonthPlugin from '@fullcalendar/multimonth';
.use(router) import interactionPlugin from '@fullcalendar/interaction';
import listPlugin from '@fullcalendar/list';
import ruLocale from '@fullcalendar/core/locales/ru';
export function registerPlugins(app) {
loadFonts();
app.use(vuetify).use(pinia).use(router);
app.component('FullCalendar', FullCalendar);
app.config.globalProperties.$fullCalendarPlugins = {
dayGridPlugin,
timeGridPlugin,
multiMonthPlugin,
interactionPlugin,
listPlugin,
ruLocale,
};
} }
+178
View File
@@ -0,0 +1,178 @@
import { defineStore } from 'pinia';
import { ref, computed } from 'vue';
import { axiosApiInstance } from '@/utils/axios-api';
import { useAccountStore } from '@/store/AccountStore';
export const useCalendarStore = defineStore('calendar', () => {
const accountStore = useAccountStore();
// State
const selectedDate = ref(new Date());
const events = ref([]);
const selectedEvent = ref(null);
const showEventDialog = ref(false);
const currentView = ref('dayGridMonth'); // Текущий вид календаря
const calendars = ref([]); // Список календарей пользователя
const isLoading = ref(false);
const lastUpdatedBy = ref(null);
// Getters
const formattedSelectedDate = computed(() => selectedDate.value.toISOString().split('T')[0]);
const myCalendars = computed(() =>
calendars.value.filter((e) => e.author === accountStore.user.is_idEmployee),
);
const subscribedCalendars = computed(() =>
calendars.value.filter((e) => e.author !== accountStore.user.is_idEmployee),
);
const eventsForSelectedDate = computed(() =>
events.value.filter((event) => event.date_start.split('T')[0] === formattedSelectedDate.value),
);
// Actions
const setSelectedDate = (date, source = 'unknown') => {
selectedDate.value = new Date(date);
lastUpdatedBy.value = source;
// загрузить события для текущей даты в дальнейшем
};
const setSelectedDateFromCalendar = (info) => {
const date = new Date(info.dateStr);
setSelectedDate(date, 'calendar');
};
const setSelectedDateFromPicker = (date) => {
setSelectedDate(date, 'datepicker');
};
const setCurrentView = (view) => {
currentView.value = view;
};
// Загрузка календарей пользователя
const loadCalendars = async () => {
try {
const response = await axiosApiInstance.get('api/calendar_of_events/my_calendars/');
calendars.value = response.data.map((calendar) => ({
...calendar,
visible: accountStore.calendar.includes(calendar.id),
}));
} catch (error) {
console.error('Ошибка загрузки календарей:', error);
}
};
// Загрузка событий
const loadEvents = async (params = {}) => {
try {
isLoading.value = true;
const response = await axiosApiInstance.get('api/calendar_of_events/my_events/', { params });
events.value = response.data;
} catch (error) {
console.error('Ошибка загрузки событий:', error);
} finally {
isLoading.value = false;
}
};
// Создание события
const createEvent = async (eventData) => {
try {
const response = await axiosApiInstance.post('api/calendar_of_events/my_events/', eventData);
events.value.push(response.data);
return response.data;
} catch (error) {
console.error('Ошибка создания события:', error);
throw error;
}
};
// Обновление события
const updateEvent = async (eventData) => {
try {
const response = await axiosApiInstance.put(
`api/calendar_of_events/my_events/${eventData.id}/`,
eventData,
);
const index = events.value.findIndex((e) => e.id === eventData.id);
if (index !== -1) {
events.value[index] = response.data;
}
return response.data;
} catch (error) {
console.error('Ошибка обновления события:', error);
throw error;
}
};
// Удаление события
const deleteEvent = async (eventId) => {
try {
await axiosApiInstance.delete(`api/calendar_of_events/my_events/${eventId}/`);
events.value = events.value.filter((e) => e.id !== eventId);
} catch (error) {
console.error('Ошибка удаления события:', error);
throw error;
}
};
// Открытие диалога с предзаполненной датой
const openEventDialogWithDate = (date = null) => {
selectedEvent.value = date
? {
date_start: date,
date_end: date,
participant: [accountStore.user.is_idEmployee],
files: [],
calendar: null,
}
: null;
showEventDialog.value = true;
};
// Открыть диалог создания/редактирования
const openEventDialog = (event = null) => {
selectedEvent.value = event;
showEventDialog.value = true;
};
// Закрыть диалог
const closeEventDialog = () => {
showEventDialog.value = false;
selectedEvent.value = null;
};
return {
// State
selectedDate,
events,
selectedEvent,
showEventDialog,
currentView,
calendars,
isLoading,
lastUpdatedBy,
// Getters
formattedSelectedDate,
myCalendars,
subscribedCalendars,
eventsForSelectedDate,
// Actions
setSelectedDate,
setCurrentView,
loadCalendars,
loadEvents,
createEvent,
updateEvent,
deleteEvent,
openEventDialog,
openEventDialogWithDate,
closeEventDialog,
setSelectedDateFromCalendar,
setSelectedDateFromPicker,
};
});