From 13e20dd4d0bce63e96ff18a588a1d999b80edefc Mon Sep 17 00:00:00 2001 From: Inna Date: Thu, 11 Sep 2025 12:01:43 +0300 Subject: [PATCH 01/43] refactor [P-57]: add FullCalendar --- src/front/package.json | 9 +- .../calendar_of_events/BigCalendar.vue | 209 +++--------- .../UI_calendar/CustomCalendar.vue | 318 ++++++++++++++++++ .../UI_calendar/MiniCalendar.vue | 102 ++++++ .../{calendarFull.vue => calendarFuldl.vue} | 8 +- .../calendar_of_events/calendar-my.vue | 61 ++-- .../src/layouts/default/DefaultPortal.vue | 38 +-- src/front/src/plugins/index.js | 37 +- src/front/src/store/calendarStore.js | 178 ++++++++++ 9 files changed, 729 insertions(+), 231 deletions(-) create mode 100644 src/front/src/components/calendar_of_events/UI_calendar/CustomCalendar.vue create mode 100644 src/front/src/components/calendar_of_events/UI_calendar/MiniCalendar.vue rename src/front/src/components/calendar_of_events/UI_calendar/{calendarFull.vue => calendarFuldl.vue} (99%) create mode 100644 src/front/src/store/calendarStore.js diff --git a/src/front/package.json b/src/front/package.json index 939fc18e3..c2c0f6b40 100644 --- a/src/front/package.json +++ b/src/front/package.json @@ -36,7 +36,14 @@ "vue3-autocounter": "^1.0.8", "vuelidate": "^0.7.7", "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": { "@commitlint/cli": "^19.7.1", diff --git a/src/front/src/components/calendar_of_events/BigCalendar.vue b/src/front/src/components/calendar_of_events/BigCalendar.vue index e3015ba7c..c0408cb25 100644 --- a/src/front/src/components/calendar_of_events/BigCalendar.vue +++ b/src/front/src/components/calendar_of_events/BigCalendar.vue @@ -1,84 +1,13 @@ + + diff --git a/src/front/src/components/calendar_of_events/UI_calendar/MiniCalendar.vue b/src/front/src/components/calendar_of_events/UI_calendar/MiniCalendar.vue new file mode 100644 index 000000000..b273d911e --- /dev/null +++ b/src/front/src/components/calendar_of_events/UI_calendar/MiniCalendar.vue @@ -0,0 +1,102 @@ + + + diff --git a/src/front/src/components/calendar_of_events/UI_calendar/calendarFull.vue b/src/front/src/components/calendar_of_events/UI_calendar/calendarFuldl.vue similarity index 99% rename from src/front/src/components/calendar_of_events/UI_calendar/calendarFull.vue rename to src/front/src/components/calendar_of_events/UI_calendar/calendarFuldl.vue index abcc692b5..5ff2c0573 100644 --- a/src/front/src/components/calendar_of_events/UI_calendar/calendarFull.vue +++ b/src/front/src/components/calendar_of_events/UI_calendar/calendarFuldl.vue @@ -93,7 +93,7 @@ export default { { type: "day", text: "День" }, { type: "week", text: "Неделя" }, { type: "month", text: "Месяц" }, - { type: "modntdh", text: "Год" }, + // { type: "modntdh", text: "Год" }, { type: "modnth", text: "Расписание" }, ]; @@ -314,7 +314,7 @@ export default { ev.rule.byweekday[ev.rule.byweekday.length - 1].weekday == 6 ? 0 : ev.rule.byweekday[ev.rule.byweekday.length - 1].weekday + 1; - + if (day.date.getDay() == weeknumS && weeknumS != weeknumE) { return "rounded-e-lg"; } else if (day.date.getDay() == weeknumE && weeknumS != weeknumE) { @@ -328,7 +328,7 @@ export default { return "rounded-lg"; } - + } if (ev.rule.freq == 0) { if (zeroTime(day.date) == zeroTime(ev.start_event)) { @@ -342,7 +342,7 @@ export default { // ev.rule.byweekday[ev.rule.byweekday.length - 1].weekday == 6 // ? 0 // : ev.rule.byweekday[ev.rule.byweekday.length - 1].weekday + 1; - + // if (day.date.getDay() == weeknumS && weeknumS != weeknumE) { // return "rounded-e-lg"; // } else if (day.date.getDay() == weeknumE && weeknumS != weeknumE) { diff --git a/src/front/src/components/calendar_of_events/calendar-my.vue b/src/front/src/components/calendar_of_events/calendar-my.vue index 6db399e3c..a6db4782e 100644 --- a/src/front/src/components/calendar_of_events/calendar-my.vue +++ b/src/front/src/components/calendar_of_events/calendar-my.vue @@ -1,12 +1,5 @@ From 3143d266ee454702bc6c71c75fc377ecde1b67de Mon Sep 17 00:00:00 2001 From: Inna Date: Tue, 16 Sep 2025 14:13:21 +0300 Subject: [PATCH 03/43] =?UTF-8?q?fix=20[P-57]:=20=D1=81=D0=B2=D1=8F=D0=B7?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=BA=D0=B0=D0=BB=D0=B5=D0=BD=D0=B4=D0=B0=D1=80?= =?UTF-8?q?=D0=B5=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../calendar_of_events/BigCalendar.vue | 72 ++-- .../UI_calendar/CustomCalendar.vue | 314 +++++++++++++----- .../UI_calendar/MiniCalendar.vue | 79 +++-- .../calendar_of_events/event-create.vue | 187 ++++------- src/front/src/store/calendarStore.js | 1 + 5 files changed, 390 insertions(+), 263 deletions(-) diff --git a/src/front/src/components/calendar_of_events/BigCalendar.vue b/src/front/src/components/calendar_of_events/BigCalendar.vue index c0408cb25..4257003eb 100644 --- a/src/front/src/components/calendar_of_events/BigCalendar.vue +++ b/src/front/src/components/calendar_of_events/BigCalendar.vue @@ -15,9 +15,9 @@ rail > --> - + { if (eventData.id) { @@ -70,17 +70,40 @@ export default { }; const getCalendar = () => { - calendarStore.loadCalendars(); }; 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(() => { week.getWeekend(MyYear.value); }); + const closeEventDialog = () => { + calendarStore.closeEventDialog(); + }; const CheckingStore = () => { if (MyYear.value in week.week) { @@ -96,44 +119,19 @@ export default { getYear, week, CheckingStore, - showDialog, + showEventDialog, calendarForMy, - // accountStore, getCalendar, + getEvents, eventFromCalendar, createEvents, calendarStore, handleSaveEvent, + accountStore, + closeEventDialog, }; }, }; - + 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 784c1260f..d4e6fd2ec 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 @@ -97,6 +97,9 @@ export default { week: 'numeric', }, weekNumberCalculation: 'ISO', // ISO стандарт (понедельник - первый день) + selectable: true, + unselectAuto: false, + selectMirror: false, views: { timeGridDay: { type: 'timeGrid', @@ -172,70 +175,75 @@ export default { { title: '10:00 Лотус', 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', }, { title: '14:00 Совещание', - start: new Date('September, 20, 2025').setHours(14, 0, 0), - end: new Date('September, 20, 2025').setHours(15, 0, 0), + start: new Date('September, 26, 2025').setHours(14, 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', }, // ПРАЗДНИКИ РОССИИ 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', - }, + // { + // title: '🎄 Новый год', + // start: '2025-01-01', + // end: '2025-01-08', // Новогодние каникулы + // allDay: true, + // className: 'holiday-event', + // display: 'background', + // }, + // { + // 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) => { @@ -243,8 +251,10 @@ export default { }, dateClick: (info) => { - selectedDate.value - info.dateStr; + calendarStore.setSelectedDateFromCalendar(info); + handleDateSelection(info.dateStr); handleCalendarDateClick(info); + calendarApi.value?.unselect(); }, datesSet: (info) => { @@ -263,15 +273,11 @@ export default { } else { currentTitle.value = info.view.title; } + + if (selectedDate.value) { + handleDateSelection(selectedDate.value); + } }, - - dayCellContent: () => {}, - }); - - onMounted(() => { - if (calendarRef.value) { - calendarApi.value = calendarRef.value.getApi(); - } }); const handleCalendarDateClick = (info) => { @@ -281,37 +287,88 @@ export default { const handleToday = () => { 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 = () => { calendarApi.value?.prev(); + const currentDate = calendarApi.value?.getDate(); + if (currentDate) { + const dateInfo = { + dateStr: currentDate.toISOString().split('T')[0], + }; + calendarStore.setSelectedDateFromCalendar(dateInfo); + } }; const handleNext = () => { calendarApi.value?.next(); + + const currentDate = calendarApi.value?.getDate(); + if (currentDate) { + const dateInfo = { + dateStr: currentDate.toISOString().split('T')[0], + }; + calendarStore.setSelectedDateFromCalendar(dateInfo); + } }; + // Функция обновления выделения + const handleDateSelection = (dateStr) => { + // Убираем предыдущее выделение + const previousSelected = document.querySelectorAll('.fc-day-selected-custom'); + previousSelected.forEach((el) => el.classList.remove('fc-day-selected-custom')); + + // Добавляем новое выделение + const dayElements = document.querySelectorAll(`[data-date="${dateStr}"]`); + dayElements.forEach((el) => el.classList.add('fc-day-selected-custom')); + + selectedDate.value = dateStr; + }; + + onMounted(() => { + nextTick(() => { + 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( - currentView, - (newView) => { - calendarApi.value?.changeView(newView); + selectedDate, + (newDate, oldDate) => { + if (!newDate || newDate === oldDate) return; + + // Небольшая задержка для гарантии что FullCalendar обновил DOM + setTimeout(() => { + if (calendarApi.value && lastUpdatedBy.value !== 'calendar') { + try { + calendarApi.value.gotoDate(newDate); + } catch (error) { + console.warn('Ошибка при переходе к дате:', error); + } + } + }, 50); }, { 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, @@ -321,22 +378,109 @@ export default { handleNext, handlePrev, handleCalendarDateClick, + handleDateSelection, }; }, }; diff --git a/src/front/src/components/calendar_of_events/UI_calendar/MiniCalendar.vue b/src/front/src/components/calendar_of_events/UI_calendar/MiniCalendar.vue index b273d911e..2fe1a6c44 100644 --- a/src/front/src/components/calendar_of_events/UI_calendar/MiniCalendar.vue +++ b/src/front/src/components/calendar_of_events/UI_calendar/MiniCalendar.vue @@ -21,7 +21,7 @@ color="btn_text" block elevation="1" - @click="createEvent()" + @click="openEventDialog" >Создать событие @@ -43,12 +43,11 @@