diff --git a/src/front/src/components/calendar_of_events/BigCalendar.vue b/src/front/src/components/calendar_of_events/BigCalendar.vue index 293097b39..2cc5e707f 100644 --- a/src/front/src/components/calendar_of_events/BigCalendar.vue +++ b/src/front/src/components/calendar_of_events/BigCalendar.vue @@ -42,6 +42,7 @@ export default { const calendarForMy = ref([]); const eventFromCalendar = ref({}); const eventKey = ref(0); + const isClosingDialog = ref(false); const calendarStore = useCalendarStore(); const accountStore = useAccountStore(); @@ -59,26 +60,6 @@ export default { calendarStore.loadCalendars(); }; - // const getEvent = (idEvent) => { - // 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; - // }); - // }; - const getEvent = (idEvent) => { if (!idEvent) { eventFromCalendar.value = createEmptyEvent(); @@ -96,8 +77,8 @@ export default { name: '', participant: [accountStore.user.is_idEmployee], files: [], - date_start: new Date(), - date_end: new Date(), + date_start: new Date().toISOString(), + date_end: new Date().toISOString(), period: null, description: '', calendar: null, @@ -105,8 +86,13 @@ export default { }); const openEventDialog = (selectedEvent) => { - getEvent(selectedEvent.event.id); + // Всегда сбрасываем данные перед открытием нового диалога + if (!selectedEvent) { + eventFromCalendar.value = createEmptyEvent(); + eventKey.value++; + } + getEvent(selectedEvent?.event?.id); calendarStore.openEventDialog(); }; @@ -118,7 +104,11 @@ export default { const closeEventDialog = () => { calendarStore.closeEventDialog(); - eventFromCalendar.value = createEmptyEvent(); // Очищаем событие + // При ручном закрытии сбрасываем данные сразу + setTimeout(() => { + eventFromCalendar.value = createEmptyEvent(); + eventKey.value++; + }, 200); }; const CheckingStore = () => { @@ -131,10 +121,16 @@ export default { watch( () => calendarStore.showEventDialog, - (newValue) => { - if (!newValue) { - // Когда диалог закрывается (любым способом), очищаем данные - eventFromCalendar.value = createEmptyEvent(); + (newValue, oldValue) => { + if (!newValue && oldValue) { + // Диалог был открыт и закрыт не через нашу кнопку + // Добавляем проверку чтобы не сбрасывать при инициализации + if (eventFromCalendar.value.event?.id) { + setTimeout(() => { + eventFromCalendar.value = createEmptyEvent(); + eventKey.value++; + }, 200); + } } }, ); diff --git a/src/front/src/components/calendar_of_events/UI_calendar/CustomCalendar.vue b/src/front/src/components/calendar_of_events/UI_calendar/CustomCalendar.vue index 0b9789f71..e645f3cd1 100644 --- a/src/front/src/components/calendar_of_events/UI_calendar/CustomCalendar.vue +++ b/src/front/src/components/calendar_of_events/UI_calendar/CustomCalendar.vue @@ -336,14 +336,13 @@ export default { const baseEvent = { id: event.id, title: event.name, - start: new Date(event.date_start), + start:new Date(event.date_start), end: new Date(event.date_end), allDay: event.all_day, textColor: '#ffffff', backgroundColor: eventColor, borderColor: eventColor, }; - if (!rruleOptions) { api.addEvent(baseEvent); return; diff --git a/src/front/src/components/calendar_of_events/calendar-create.vue b/src/front/src/components/calendar_of_events/calendar-create.vue index d0d9ecf3a..d80d55469 100644 --- a/src/front/src/components/calendar_of_events/calendar-create.vue +++ b/src/front/src/components/calendar_of_events/calendar-create.vue @@ -1,7 +1,7 @@