fix [P-57]: связка календарей

This commit is contained in:
Inna committed 2025-09-16 14:13:21 +03:00
1 parent 4897db2399
commit 3143d266ee
5 files changed
+377 -250

No files matched your search

@@ -15,9 +15,9 @@
rail rail
> >
</v-navigation-drawer> --> </v-navigation-drawer> -->
<v-dialog v-model="showDialog" max-width="700"> <v-dialog v-model="showEventDialog" max-width="700">
<event-create <event-create
@closeDialog="showDialog = false" @closeDialog="closeEventDialog"
:eventCalendar="eventFromCalendar" :eventCalendar="eventFromCalendar"
@getCalendar="getCalendar" @getCalendar="getCalendar"
@update:eventCalendar="eventFromCalendar = $event" @update:eventCalendar="eventFromCalendar = $event"
@@ -31,17 +31,16 @@
import { ref, onMounted } 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 { useAccountStore } from '@/store/AccountStore';
import CustomCalendar from '@/components/calendar_of_events/UI_calendar/CustomCalendar.vue'; import CustomCalendar from '@/components/calendar_of_events/UI_calendar/CustomCalendar.vue';
import { useCalendarStore } from '@/store/calendarStore'; import { useCalendarStore } from '@/store/calendarStore';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
import MiniCalendar from '@/components/calendar_of_events/UI_calendar/MiniCalendar.vue'; import MiniCalendar from '@/components/calendar_of_events/UI_calendar/MiniCalendar.vue';
import { axiosApiInstance } from '@/utils/axios-api';
import { useAccountStore } from '@/store/AccountStore';
export default { export default {
components: { EventCreate, MiniCalendar, CustomCalendar }, components: { EventCreate, MiniCalendar, CustomCalendar },
setup() { setup() {
// const accountStore = useAccountStore();
const showDialog = ref(false);
const week = useWeekendsStore(); const week = useWeekendsStore();
const selectdate = ref(new Date()); const selectdate = ref(new Date());
const MyYear = ref(selectdate.value.getFullYear()); const MyYear = ref(selectdate.value.getFullYear());
@@ -51,8 +50,9 @@ export default {
const createEvents = ref(null); const createEvents = ref(null);
const calendarStore = useCalendarStore(); const calendarStore = useCalendarStore();
const accountStore = useAccountStore();
const { selectedDate } = storeToRefs(calendarStore); // синхронизируем с date-picker const { selectedDate, showEventDialog } = storeToRefs(calendarStore); // синхронизируем с date-picker
const handleSaveEvent = (eventData) => { const handleSaveEvent = (eventData) => {
if (eventData.id) { if (eventData.id) {
@@ -70,17 +70,40 @@ export default {
}; };
const getCalendar = () => { const getCalendar = () => {
calendarStore.loadCalendars(); calendarStore.loadCalendars();
}; };
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;
});
};
getEvents();
onMounted(() => { onMounted(() => {
week.getWeekend(MyYear.value); week.getWeekend(MyYear.value);
}); });
const closeEventDialog = () => {
calendarStore.closeEventDialog();
};
const CheckingStore = () => { const CheckingStore = () => {
if (MyYear.value in week.week) { if (MyYear.value in week.week) {
@@ -96,44 +119,19 @@ export default {
getYear, getYear,
week, week,
CheckingStore, CheckingStore,
showDialog, showEventDialog,
calendarForMy, calendarForMy,
// accountStore,
getCalendar, getCalendar,
getEvents,
eventFromCalendar, eventFromCalendar,
createEvents, createEvents,
calendarStore, calendarStore,
handleSaveEvent, handleSaveEvent,
accountStore,
closeEventDialog,
}; };
}, },
}; };
</script> </script>
<style scoped> <style scoped></style>
.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;
width: 31px;
}
.minCal .v-btn--icon.v-btn--density-default {
width: calc(var(--v-btn-height) + 12px);
height: calc(var(--v-btn-height) + 6px);
}
.minCal .v-btn__content {
font-weight: 410;
}
.minCal:deep(.v-date-picker-years__content) {
gap: 0;
}
</style>
@@ -97,6 +97,9 @@ export default {
week: 'numeric', week: 'numeric',
}, },
weekNumberCalculation: 'ISO', // ISO стандарт (понедельник - первый день) weekNumberCalculation: 'ISO', // ISO стандарт (понедельник - первый день)
selectable: true,
unselectAuto: false,
selectMirror: false,
views: { views: {
timeGridDay: { timeGridDay: {
type: 'timeGrid', type: 'timeGrid',
@@ -172,70 +175,75 @@ export default {
{ {
title: '10:00 Лотус', title: '10:00 Лотус',
start: new Date('September, 26, 2025').setHours(10, 0, 0), start: new Date('September, 26, 2025').setHours(10, 0, 0),
end: new Date('September, 28, 2025').setHours(11, 0, 0), end: new Date('September, 26, 2025').setHours(11, 0, 0),
color: '#1867C0', color: '#1867C0',
}, },
{ {
title: '14:00 Совещание', title: '14:00 Совещание',
start: new Date('September, 20, 2025').setHours(14, 0, 0), start: new Date('September, 26, 2025').setHours(14, 0, 0),
end: new Date('September, 20, 2025').setHours(15, 0, 0), end: new Date('September, 26, 2025').setHours(15, 0, 0),
color: '#1867C0',
},
{
title: '11:00 Конференция',
start: new Date('October, 02, 2025').setHours(14, 0, 0),
end: new Date('October, 02, 2025').setHours(15, 0, 0),
color: '#1867C0', color: '#1867C0',
}, },
// ПРАЗДНИКИ РОССИИ 2025 // ПРАЗДНИКИ РОССИИ 2025
{ // {
title: '🎄 Новый год', // title: '🎄 Новый год',
start: '2025-01-01', // start: '2025-01-01',
end: '2025-01-08', // Новогодние каникулы // end: '2025-01-08', // Новогодние каникулы
allDay: true, // allDay: true,
className: 'holiday-event', // className: 'holiday-event',
display: 'background', // display: 'background',
textColor: 'white', // },
}, // {
{ // title: '🎅 Рождество',
title: '🎅 Рождество', // start: '2025-01-07',
start: '2025-01-07', // allDay: true,
allDay: true, // className: 'holiday-event',
className: 'holiday-event', // },
}, // {
{ // title: '🪆 День защитника Отечества',
title: '🪆 День защитника Отечества', // start: '2025-02-23',
start: '2025-02-23', // allDay: true,
allDay: true, // className: 'holiday-event',
className: 'holiday-event', // },
}, // {
{ // title: '🌸 Международный женский день',
title: '🌸 Международный женский день', // start: '2025-03-08',
start: '2025-03-08', // allDay: true,
allDay: true, // className: 'holiday-event',
className: 'holiday-event', // },
}, // {
{ // title: '🌷 Майские праздники',
title: '🌷 Майские праздники', // start: '2025-05-01',
start: '2025-05-01', // end: '2025-05-05',
end: '2025-05-05', // allDay: true,
allDay: true, // className: 'holiday-event',
className: 'holiday-event', // display: 'background',
display: 'background', // },
}, // {
{ // title: '🎆 День Победы',
title: '🎆 День Победы', // start: '2025-05-09',
start: '2025-05-09', // allDay: true,
allDay: true, // className: 'holiday-event',
className: 'holiday-event', // },
}, // {
{ // title: '🇷🇺 День России',
title: '🇷🇺 День России', // start: '2025-06-12',
start: '2025-06-12', // allDay: true,
allDay: true, // className: 'holiday-event',
className: 'holiday-event', // },
}, // {
{ // title: '🤝 День народного единства',
title: '🤝 День народного единства', // start: '2025-11-04',
start: '2025-11-04', // allDay: true,
allDay: true, // className: 'holiday-event',
className: 'holiday-event', // },
},
], ],
eventClick: (info) => { eventClick: (info) => {
@@ -243,8 +251,10 @@ export default {
}, },
dateClick: (info) => { dateClick: (info) => {
selectedDate.value - info.dateStr; calendarStore.setSelectedDateFromCalendar(info);
handleDateSelection(info.dateStr);
handleCalendarDateClick(info); handleCalendarDateClick(info);
calendarApi.value?.unselect();
}, },
datesSet: (info) => { datesSet: (info) => {
@@ -263,15 +273,11 @@ export default {
} else { } else {
currentTitle.value = info.view.title; currentTitle.value = info.view.title;
} }
},
dayCellContent: () => {}, if (selectedDate.value) {
}); handleDateSelection(selectedDate.value);
onMounted(() => {
if (calendarRef.value) {
calendarApi.value = calendarRef.value.getApi();
} }
},
}); });
const handleCalendarDateClick = (info) => { const handleCalendarDateClick = (info) => {
@@ -281,36 +287,87 @@ export default {
const handleToday = () => { const handleToday = () => {
calendarApi.value?.today(); calendarApi.value?.today();
// Получаем текущую дату из календаря и передаем в стор
const currentDate = calendarApi.value?.getDate();
if (currentDate) {
// Создаем объект похожий на info из FullCalendar
const todayInfo = {
dateStr: currentDate.toISOString().split('T')[0],
};
calendarStore.setSelectedDateFromCalendar(todayInfo);
}
}; };
const handlePrev = () => { const handlePrev = () => {
calendarApi.value?.prev(); calendarApi.value?.prev();
const currentDate = calendarApi.value?.getDate();
if (currentDate) {
const dateInfo = {
dateStr: currentDate.toISOString().split('T')[0],
};
calendarStore.setSelectedDateFromCalendar(dateInfo);
}
}; };
const handleNext = () => { const handleNext = () => {
calendarApi.value?.next(); calendarApi.value?.next();
const currentDate = calendarApi.value?.getDate();
if (currentDate) {
const dateInfo = {
dateStr: currentDate.toISOString().split('T')[0],
};
calendarStore.setSelectedDateFromCalendar(dateInfo);
}
}; };
watch( // Функция обновления выделения
currentView, const handleDateSelection = (dateStr) => {
(newView) => { // Убираем предыдущее выделение
calendarApi.value?.changeView(newView); const previousSelected = document.querySelectorAll('.fc-day-selected-custom');
}, previousSelected.forEach((el) => el.classList.remove('fc-day-selected-custom'));
{ immediate: true },
);
watch(selectedDate, (newDate) => { // Добавляем новое выделение
if (!newDate) return; const dayElements = document.querySelectorAll(`[data-date="${dateStr}"]`);
dayElements.forEach((el) => el.classList.add('fc-day-selected-custom'));
selectedDate.value = dateStr;
};
onMounted(() => {
nextTick(() => { nextTick(() => {
if (calendarApi.value && lastUpdatedBy.value !== 'calendar') if (calendarRef.value && calendarRef.value.getApi) {
calendarApi.value = calendarRef.value.getApi();
}
if (selectedDate.value) {
handleDateSelection(selectedDate.value);
}
});
});
watch(currentView, (newView) => {
calendarApi.value?.changeView(newView);
});
// Единый watcher для selectedDate
watch(
selectedDate,
(newDate, oldDate) => {
if (!newDate || newDate === oldDate) return;
// Небольшая задержка для гарантии что FullCalendar обновил DOM
setTimeout(() => {
if (calendarApi.value && lastUpdatedBy.value !== 'calendar') {
try { try {
calendarApi.value.gotoDate(newDate); calendarApi.value.gotoDate(newDate);
} catch (error) { } catch (error) {
console.warn('Ошибка при переходе к дате:', error); console.warn('Ошибка при переходе к дате:', error);
} }
}); }
}); }, 50);
},
{ immediate: true },
);
return { return {
currentTitle, currentTitle,
@@ -321,22 +378,109 @@ export default {
handleNext, handleNext,
handlePrev, handlePrev,
handleCalendarDateClick, handleCalendarDateClick,
handleDateSelection,
}; };
}, },
}; };
</script> </script>
<style scoped> <style scoped>
:deep(.fc-daygrid-day-number) {
display: flex !important;
justify-content: center !important;
align-items: center !important;
width: 100% !important;
height: 100% !important;
margin: 0 !important;
padding: 0.6rem !important;
}
/* текущая дата обводка */
:deep(.fc-day-today) {
background-color: transparent !important;
}
:deep(.fc-day-today .fc-daygrid-day-number) {
position: relative;
z-index: 1;
color: #00897b;
&::before {
content: '';
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 32px;
height: 32px;
border: 1px solid #00897b;
border-radius: 50%;
z-index: -1;
}
}
/* Выбранная дата заливка */
:deep(.fc-day-selected-custom) {
background-color: transparent !important;
}
:deep(.fc-day-selected-custom .fc-daygrid-day-number) {
position: relative;
z-index: 1;
color: white !important;
}
:deep(.fc-day-selected-custom .fc-daygrid-day-number::before) {
content: '';
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 32px;
height: 32px;
background-color: #00897b;
border-radius: 50%;
z-index: -1;
}
:deep(.fc-multiMonthYear-view) {
.fc-day-today .fc-daygrid-day-number::before,
.fc-day-selected-custom .fc-daygrid-day-number::before {
width: 24px;
height: 24px;
}
}
:deep(.v-btn--active) { :deep(.v-btn--active) {
background-color: transparent !important; background-color: transparent !important;
color: #00897b !important; color: #00897b !important;
} }
/* Изменение фона текущего дня */
:deep(.fc .fc-daygrid-day.fc-day-today) {
background-color: transparent !important;
}
:deep(.fc .fc-timegrid-col.fc-day-today) { :deep(.fc .fc-timegrid-col.fc-day-today) {
background-color: #e0f2f1 !important; background-color: #e0f2f1 !important;
} }
:deep(.fc-highlight) {
background-color: transparent !important;
}
/* :deep(.fc-daygrid-day-frame) {
position: relative;
min-height: 50px;
}
:deep(.fc-daygrid-more-link) {
position: absolute;
bottom: -6px;
right: 2px;
font-size: 11px;
padding: 1px 3px;
background: rgba(0, 0, 0, 0.05);
border-radius: 3px;
z-index: 3;
}
:deep(.fc-popover) {
} */
</style> </style>
@@ -21,7 +21,7 @@
color="btn_text" color="btn_text"
block block
elevation="1" elevation="1"
@click="createEvent()" @click="openEventDialog"
>Создать событие</v-btn >Создать событие</v-btn
> >
<!-- {{eventFromCalendar}} --> <!-- {{eventFromCalendar}} -->
@@ -43,12 +43,11 @@
<v-col class="flex-column d-flex"> <v-col class="flex-column d-flex">
<v-row no-gutters class="h-0 overflow-auto flex-column flex-nowrap"> <v-row no-gutters class="h-0 overflow-auto flex-column flex-nowrap">
<v-col> <v-col>
<!-- :calendars="myCalendars.filter((e) => e.author != user.is_idEmployee)" -->
<calendar-my :calendars="subscribedCalendars" title="Подписки" />
<!-- :calendars="myCalendars.filter((e) => e.author == user.is_idEmployee)" -->
<calendar-my <calendar-my
:calendars="calendarForMy.filter((e) => e.author != user.is_idEmployee)" :calendars="myCalendars"
title="Подписки"
/>
<calendar-my
:calendars="calendarForMy.filter((e) => e.author == user.is_idEmployee)"
title="Мои календари" title="Мои календари"
@getCalendar="loadCalendars" @getCalendar="loadCalendars"
/> />
@@ -62,7 +61,7 @@
import { useCalendarStore } from '@/store/calendarStore'; import { useCalendarStore } from '@/store/calendarStore';
import { useAccountStore } from '@/store/AccountStore'; import { useAccountStore } from '@/store/AccountStore';
import CalendarMy from '@/components/calendar_of_events/calendar-my.vue'; import CalendarMy from '@/components/calendar_of_events/calendar-my.vue';
import { ref } from 'vue'; import { onMounted, watch } from 'vue';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
export default { export default {
@@ -71,32 +70,72 @@ export default {
setup() { setup() {
const calendarStore = useCalendarStore(); const calendarStore = useCalendarStore();
const accountStore = useAccountStore(); const accountStore = useAccountStore();
const calendarForMy = ref([]); // const calendarForMy = ref([]);
const { selectedDate } = storeToRefs(calendarStore); const { selectedDate, myCalendars, subscribedCalendars } = storeToRefs(calendarStore);
const { user } = storeToRefs(accountStore); const { user } = storeToRefs(accountStore);
const createEvent = () => {
calendarStore.openEventDialog();
};
const loadCalendars = () => {
calendarStore.loadCalendars();
};
const handleDateClick = (date) => { const handleDateClick = (date) => {
calendarStore.setSelectedDateFromPicker(date); calendarStore.setSelectedDateFromPicker(date);
}; };
const openEventDialog = () => {
calendarStore.openEventDialog();
};
const loadCalendars = async () => {
calendarStore.loadCalendars();
};
onMounted(() => {
loadCalendars();
});
// Реакция на изменения пользователя
watch(user, (newUser) => {
if (newUser) {
loadCalendars();
}
});
return { return {
accountStore, accountStore,
user, user,
myCalendars,
subscribedCalendars,
selectedDate, selectedDate,
calendarForMy, openEventDialog,
createEvent,
loadCalendars, loadCalendars,
handleDateClick, handleDateClick,
}; };
}, },
}; };
</script> </script>
<style scoped></style> <style scoped>
/* .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;
width: 31px;
}
.minCal .v-btn--icon.v-btn--density-default {
width: calc(var(--v-btn-height) + 12px);
height: calc(var(--v-btn-height) + 6px);
}
.minCal .v-btn__content {
font-weight: 410;
}
.minCal:deep(.v-date-picker-years__content) {
gap: 0;
}
</style>
@@ -4,7 +4,7 @@
:newOrOld="newEvent" :newOrOld="newEvent"
@postData="postData" @postData="postData"
@closeDialog="$emit('closeDialog')" @closeDialog="$emit('closeDialog')"
@delObject="delEvent(propsEvent.event.id)" @delObject="delEvent(propsEvent?.event?.id)"
ref="createDialog" ref="createDialog"
> >
<template v-slot:card_text> <template v-slot:card_text>
@@ -13,9 +13,7 @@
<v-row no-gutters class="align-center"> <v-row no-gutters class="align-center">
<!-- <my-helper :pretext="propsEvent.event" /> --> <!-- <my-helper :pretext="propsEvent.event" /> -->
<v-col class="text-body-2 text-text_grey pb-5" lg="2"> <v-col class="text-body-2 text-text_grey pb-5" lg="2"> Название </v-col>
Название
</v-col>
<v-col> <v-col>
<v-textarea <v-textarea
@@ -30,9 +28,7 @@
></v-row> ></v-row>
<v-row no-gutters class="align-center"> <v-row no-gutters class="align-center">
<v-col class="text-body-2 text-text_grey pb-5" lg="2"> <v-col class="text-body-2 text-text_grey pb-5" lg="2"> Участники </v-col>
Участники
</v-col>
<v-col> <v-col>
<calendar-create-select <calendar-create-select
:staff="newStaff" :staff="newStaff"
@@ -57,11 +53,7 @@
:disabled="'id' in propsEvent.event" :disabled="'id' in propsEvent.event"
> >
<template v-slot:selection="{ item }"> <template v-slot:selection="{ item }">
<v-avatar <v-avatar class="cursor-pointer" size="8" :color="item.raw.cl_color" />
class="cursor-pointer"
size="8"
:color="item.raw.cl_color"
/>
<span class="pl-2"> <span class="pl-2">
{{ item.title }} {{ item.title }}
</span> </span>
@@ -74,11 +66,7 @@
@click.stop="calendar = item" @click.stop="calendar = item"
> >
<template v-slot:prepend> <template v-slot:prepend>
<v-avatar <v-avatar class="cursor-pointer" size="8" :color="item.raw.cl_color" />
class="cursor-pointer"
size="8"
:color="item.raw.cl_color"
/>
</template> </template>
{{ item.title }} {{ item.title }}
</v-list-item> </v-list-item>
@@ -87,17 +75,11 @@
</v-col></v-row </v-col></v-row
> >
<v-row no-gutters class="align-top"> <v-row no-gutters class="align-top">
<v-col class="text-body-2 text-text_grey pt-3" lg="2"> <v-col class="text-body-2 text-text_grey pt-3" lg="2"> Дата и время </v-col>
Дата и время
</v-col>
<v-col class="d-flex flex-column"> <v-col class="d-flex flex-column">
<v-row no-gutters class="gap"> <v-row no-gutters class="gap">
<time-select <time-select
:rule=" :rule="returnPeriod != repeatRules[0].type ? returnPeriod.rule.freq : -1"
returnPeriod != repeatRules[0].type
? returnPeriod.rule.freq
: -1
"
:chek="propsEvent.event.allday" :chek="propsEvent.event.allday"
:order="[2, 1]" :order="[2, 1]"
:dateEvent="String(propsEvent.event.date_start)" :dateEvent="String(propsEvent.event.date_start)"
@@ -108,11 +90,7 @@
<v-icon icon="mdi-minus pt-4" color="grey-darken-1" /> <v-icon icon="mdi-minus pt-4" color="grey-darken-1" />
</v-col> </v-col>
<time-select <time-select
:rule=" :rule="returnPeriod != repeatRules[0].type ? returnPeriod.rule.freq : -1"
returnPeriod != repeatRules[0].type
? returnPeriod.rule.freq
: -1
"
:chek="propsEvent.event.allday" :chek="propsEvent.event.allday"
:order="[4, 5]" :order="[4, 5]"
:dateEvent="String(propsEvent.event.date_end)" :dateEvent="String(propsEvent.event.date_end)"
@@ -151,9 +129,7 @@
></v-row> ></v-row>
</v-col> </v-col>
<v-row no-gutters class="align-top flex-grow-0"> <v-row no-gutters class="align-top flex-grow-0">
<v-col class="text-body-2 text-text_grey pt-3 h-0" lg="2"> <v-col class="text-body-2 text-text_grey pt-3 h-0" lg="2"> Напоминание </v-col>
Напоминание
</v-col>
<v-col class="d-flex flex-column"> <v-col class="d-flex flex-column">
<v-row no-gutters class="gap flex-grow-0"> <v-row no-gutters class="gap flex-grow-0">
<reminder-event /> <reminder-event />
@@ -198,18 +174,18 @@
</template> </template>
<script> <script>
import { computed, ref } from "vue"; import { computed, ref } from 'vue';
import { axiosApiInstance } from "@/utils/axios-api"; import { axiosApiInstance } from '@/utils/axios-api';
import DialogCreate from "@/components/calendar_of_events/UI_calendar/dialogCreate.vue"; import DialogCreate from '@/components/calendar_of_events/UI_calendar/dialogCreate.vue';
import calendarCreateSelect from "@/components/calendar_of_events/calendar-create-select.vue"; import calendarCreateSelect from '@/components/calendar_of_events/calendar-create-select.vue';
import { formatComa } from "@/utils/universal_functions"; import { formatComa } from '@/utils/universal_functions';
import TimeSelect from "@/components/calendar_of_events/UI_calendar/timeSelect.vue"; import TimeSelect from '@/components/calendar_of_events/UI_calendar/timeSelect.vue';
import { useAccountStore } from "@/store/AccountStore"; import { useAccountStore } from '@/store/AccountStore';
import UploadingFile from "@/components/UI/defaultportal/uploading-file.vue"; import UploadingFile from '@/components/UI/defaultportal/uploading-file.vue';
import ReminderEvent from "@/components/calendar_of_events/UI_calendar/reminderEvent.vue"; import ReminderEvent from '@/components/calendar_of_events/UI_calendar/reminderEvent.vue';
import PeriodEvents from "@/components/calendar_of_events/UI_calendar/periodEvents.vue"; import PeriodEvents from '@/components/calendar_of_events/UI_calendar/periodEvents.vue';
import { useAlertStore } from "@/store/UseAlertStore"; import { useAlertStore } from '@/store/UseAlertStore';
import { RRule } from "rrule"; import { RRule } from 'rrule';
export default { export default {
components: { components: {
@@ -236,33 +212,27 @@ export default {
return props.eventCalendar; return props.eventCalendar;
}, },
set: (value) => emit("update:eventCalendar", value), set: (value) => emit('update:eventCalendar', value),
}); });
const repeatRules = [ const repeatRules = [
{ type: "Не повторять", rule: {}, id: 1 }, { type: 'Не повторять', rule: {}, id: 1 },
{ type: "Каждый день", rule: { freq: 3 }, id: 2 }, { type: 'Каждый день', rule: { freq: 3 }, id: 2 },
{ type: "Каждую неделю", rule: { freq: 2 }, id: 3 }, { type: 'Каждую неделю', rule: { freq: 2 }, id: 3 },
{ type: "Каждый месяц", rule: { freq: 1 }, id: 4 }, { type: 'Каждый месяц', rule: { freq: 1 }, id: 4 },
{ type: "Каждый год", rule: { freq: 0 }, id: 5 }, { type: 'Каждый год', rule: { freq: 0 }, id: 5 },
]; ];
const returnPeriod = computed({ const returnPeriod = computed({
get() { get() {
let select = ""; let select = '';
if (propsEvent.value.event.period != null) { if (propsEvent.value.event.period != null) {
let objRule = JSON.parse(propsEvent.value.event.period); let objRule = JSON.parse(propsEvent.value.event.period);
if (objRule != null) { if (objRule != null) {
drawingRule(objRule.origOptions); drawingRule(objRule.origOptions);
repeatRules.findIndex( repeatRules.findIndex((e) => e.rule.freq == objRule.origOptions.freq);
(e) => e.rule.freq == objRule.origOptions.freq
);
select = select =
repeatRules[ repeatRules[repeatRules.findIndex((e) => e.rule.freq == objRule.origOptions.freq)];
repeatRules.findIndex(
(e) => e.rule.freq == objRule.origOptions.freq
)
];
} }
} else { } else {
select = repeatRules[0].type; select = repeatRules[0].type;
@@ -315,20 +285,12 @@ export default {
: (propsEvent.value.event.period = JSON.stringify(newRulse)); : (propsEvent.value.event.period = JSON.stringify(newRulse));
}; };
const rulleWeek = [ const rulleWeek = [RRule.SU, RRule.MO, RRule.TU, RRule.WE, RRule.TH, RRule.FR, RRule.SA];
RRule.SU,
RRule.MO,
RRule.TU,
RRule.WE,
RRule.TH,
RRule.FR,
RRule.SA,
];
const feedalert = useAlertStore().alert; const feedalert = useAlertStore().alert;
const req = (val) => { const req = (val) => {
return !!val || "Поле обязательно"; return !!val || 'Поле обязательно';
}; };
const rules = { const rules = {
@@ -337,10 +299,7 @@ export default {
const staff = ref([]); const staff = ref([]);
axiosApiInstance axiosApiInstance.get('api/calendar_of_events/get_employees/').then((res) => {
.get("api/calendar_of_events/get_employees/")
.then((res) => {
staff.value = res.data.filter((e) => e.employees.length > 0); staff.value = res.data.filter((e) => e.employees.length > 0);
}); });
@@ -350,9 +309,7 @@ export default {
get() { get() {
let ns = []; let ns = [];
let indCal = propsEvent.value.mycalendars.findIndex( let indCal = propsEvent.value.mycalendars.findIndex((e) => e.id == calendar.value[0].id);
(e) => e.id == calendar.value[0].id
);
staff.value.forEach((e) => { staff.value.forEach((e) => {
let emp = { ...e }; let emp = { ...e };
@@ -365,7 +322,7 @@ export default {
} }
return propsEvent.value.mycalendars[indCal].participant.some( return propsEvent.value.mycalendars[indCal].participant.some(
(part) => part.id === n.id (part) => part.id === n.id,
); );
}); });
@@ -376,16 +333,14 @@ export default {
}); });
const delEvent = (idev) => { const delEvent = (idev) => {
axiosApiInstance axiosApiInstance.delete(`api/calendar_of_events/my_events/?delid=${idev}`).then((result) => {
.delete(`api/calendar_of_events/my_events/?delid=${idev}`)
.then((result) => {
feedalert.alert = true; feedalert.alert = true;
feedalert.text = result.data.mess; feedalert.text = result.data.mess;
feedalert.ico = "mdi-check"; feedalert.ico = 'mdi-check';
feedalert.color = "orange-accent-1"; feedalert.color = 'orange-accent-1';
emit("getCalendar"); emit('getCalendar');
}); });
emit("closeDialog"); emit('closeDialog');
}; };
const files = ref([]); const files = ref([]);
@@ -398,7 +353,7 @@ export default {
let selected = []; let selected = [];
if (propsEvent.value.event.calendar) { if (propsEvent.value.event.calendar) {
let ind = propsEvent.value.mycalendars.findIndex( let ind = propsEvent.value.mycalendars.findIndex(
(e) => e.id == propsEvent.value.event.calendar (e) => e.id == propsEvent.value.event.calendar,
); );
selected.push({ selected.push({
cl_name: propsEvent.value.mycalendars[ind].cl_name, cl_name: propsEvent.value.mycalendars[ind].cl_name,
@@ -423,30 +378,25 @@ export default {
}, },
}); });
const titleCard = ref(""); const titleCard = ref('');
const newEvent = ref(false); const newEvent = ref(false);
const calendarNewOrOld = () => { const calendarNewOrOld = () => {
if (propsEvent.value.event.hasOwnProperty("id")) { if (propsEvent.value.event.hasOwnProperty('id')) {
titleCard.value = "Редактирование события"; titleCard.value = 'Редактирование события';
newEvent.value = false; newEvent.value = false;
} else { } else {
titleCard.value = "Новое событие"; titleCard.value = 'Новое событие';
newEvent.value = true; newEvent.value = true;
} }
}; };
const returnIdParticant = (idPart) => { const returnIdParticant = (idPart) => {
idPart.staff.forEach((e) => { idPart.staff.forEach((e) => {
if ( if (e.selected == true && !propsEvent.value.event.participant.includes(e.id)) {
e.selected == true &&
!propsEvent.value.event.participant.includes(e.id)
) {
propsEvent.value.event.participant.push(e.id); propsEvent.value.event.participant.push(e.id);
} else { } else {
let ind = propsEvent.value.event.participant.findIndex( let ind = propsEvent.value.event.participant.findIndex((l) => l == e.id);
(l) => l == e.id
);
if (ind != -1) { if (ind != -1) {
propsEvent.value.event.participant.splice(ind, 1); propsEvent.value.event.participant.splice(ind, 1);
@@ -457,12 +407,12 @@ export default {
const cbSelect = (item, arr) => { const cbSelect = (item, arr) => {
item.forEach((e) => { item.forEach((e) => {
if (!("employees" in e)) { if (!('employees' in e)) {
if (!propsEvent.value.event.participant.includes(e.id)) { if (!propsEvent.value.event.participant.includes(e.id)) {
propsEvent.value.event.participant.push(e.id); propsEvent.value.event.participant.push(e.id);
} }
} }
if ("employees" in e) { if ('employees' in e) {
cbSelect(e.employees); cbSelect(e.employees);
} }
}); });
@@ -474,7 +424,7 @@ export default {
}, },
set(newValue) { set(newValue) {
let dateParts = newValue.split("."); let dateParts = newValue.split('.');
// let d = new Date(propsEvent.value.event.date_start).setFullYear(parseInt(dateParts[2], 10), parseInt(dateParts[1], 10), parseInt(dateParts[0], 10)) // let d = new Date(propsEvent.value.event.date_start).setFullYear(parseInt(dateParts[2], 10), parseInt(dateParts[1], 10), parseInt(dateParts[0], 10))
// let d = new Date(propsEvent.value.event.date_start).setDate(new Date(2024,01,01)) // let d = new Date(propsEvent.value.event.date_start).setDate(new Date(2024,01,01))
@@ -487,23 +437,18 @@ export default {
const postData = (validate) => { const postData = (validate) => {
if (validate) { if (validate) {
let postEvent = new FormData(); let postEvent = new FormData();
postEvent.append( postEvent.append('event', JSON.stringify({ ...propsEvent.value.event }));
"event",
JSON.stringify({ ...propsEvent.value.event })
);
if (propsEvent.value.event.files !== null) { if (propsEvent.value.event.files !== null) {
files.value.forEach((e) => postEvent.append("files", e)); files.value.forEach((e) => postEvent.append('files', e));
} }
axiosApiInstance axiosApiInstance.post('api/calendar_of_events/my_events/', postEvent).then((result) => {
.post("api/calendar_of_events/my_events/", postEvent)
.then((result) => {
feedalert.alert = true; feedalert.alert = true;
feedalert.text = result.data.mess; feedalert.text = result.data.mess;
feedalert.ico = "mdi-check"; feedalert.ico = 'mdi-check';
feedalert.color = "green-darken-4"; feedalert.color = 'green-darken-4';
emit("getCalendar"); emit('getCalendar');
emit("closeDialog"); emit('closeDialog');
}); });
} }
}; };
@@ -590,7 +535,7 @@ export default {
}; };
const what = (w) => { const what = (w) => {
console.log(w, "?????????????????????????????????"); console.log(w, '?????????????????????????????????');
}; };
const periodDisplayRule = (idItem) => { const periodDisplayRule = (idItem) => {
+1
View File
@@ -51,6 +51,7 @@ export const useCalendarStore = defineStore('calendar', () => {
currentView.value = view; currentView.value = view;
}; };
// Загрузка календарей пользователя // Загрузка календарей пользователя
const loadCalendars = async () => { const loadCalendars = async () => {
try { try {