fix [P-47]: фикс событий
This commit is contained in:
1 parent
b0b619288c
commit
7095081811
5 files changed
+70
-68
No files matched your search
@@ -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);
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<dialog-create
|
||||
:title="titleCard"
|
||||
:newOrOld="newCalendar"
|
||||
:newOrOld="isNewCalendar"
|
||||
@closeDialog="$emit('closeDialog')"
|
||||
@delObject="delCalendar(propsCalendar.id)"
|
||||
@postData="postCalendar"
|
||||
@@ -150,20 +150,14 @@ export default {
|
||||
cl_descr: [(val) => req(val)],
|
||||
};
|
||||
|
||||
const titleCard = ref('');
|
||||
const newCalendar = ref(false);
|
||||
const isNewCalendar = computed(() => !propsCalendar.value.id);
|
||||
const isAuthor = computed(() => propsCalendar.value.author === accountStore.user.is_idEmployee);
|
||||
|
||||
const calendarNewOrOld = () => {
|
||||
if ('id' in propsCalendar.value) {
|
||||
titleCard.value = 'Редактирование календаря';
|
||||
if (propsCalendar.value.author != accountStore.user.is_idEmployee) newCalendar.value = true;
|
||||
} else {
|
||||
titleCard.value = 'Новый календарь';
|
||||
const titleCard = computed(() =>
|
||||
isNewCalendar.value ? 'Новый календарь' : 'Редактирование календаря',
|
||||
);
|
||||
|
||||
newCalendar.value = true;
|
||||
}
|
||||
};
|
||||
calendarNewOrOld();
|
||||
const newCalendar = computed(() => (isNewCalendar.value ? true : !isAuthor.value));
|
||||
|
||||
const postCalendar = (val) => {
|
||||
if (val) {
|
||||
@@ -213,21 +207,21 @@ export default {
|
||||
});
|
||||
|
||||
const color = [
|
||||
'red',
|
||||
'pink',
|
||||
'deep-orange',
|
||||
'amber',
|
||||
'yellow',
|
||||
'lime',
|
||||
'light-green',
|
||||
'green',
|
||||
'light-blue',
|
||||
'blue',
|
||||
'indigo',
|
||||
'deep-purple',
|
||||
'purple',
|
||||
'blue-grey',
|
||||
'brown',
|
||||
'#3788d8', // Синий (аналог default FullCalendar)
|
||||
'#4caf50', // Зеленый
|
||||
'#ff9800', // Оранжевый
|
||||
'#9c27b0', // Фиолетовый
|
||||
'#2196f3', // Голубой
|
||||
'#795548', // Коричневый
|
||||
'#607d8b', // Серо-голубой
|
||||
'#e91e63', // Розовый
|
||||
'#00bcd4', // Бирюзовый
|
||||
'#8bc34a', // Салатовый
|
||||
'#ff5722', // Красно-оранжевый
|
||||
'#673ab7', // Темно-фиолетовый
|
||||
'#3f51b5', // Индиго
|
||||
'#009688', // Зелено-бирюзовый
|
||||
'#ffc107', // Янтарный
|
||||
];
|
||||
|
||||
const colorPik = (col) => {
|
||||
@@ -266,6 +260,7 @@ export default {
|
||||
titleCard,
|
||||
newCalendar,
|
||||
newStaff,
|
||||
isNewCalendar,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
@@ -148,7 +148,7 @@
|
||||
<v-row
|
||||
no-gutters
|
||||
class="align-start d-flex pt-3 mb-3"
|
||||
style="height: auto; min-height: 200px; max-height: 400px"
|
||||
style="height: auto; min-height: 100px; max-height: 400px"
|
||||
>
|
||||
<v-col class="text-body-2 text-text_grey pb-5 pt-3" lg="2"> Файлы </v-col>
|
||||
|
||||
@@ -518,6 +518,7 @@ export default {
|
||||
JSON.stringify({ ...propsEvent.value.event, files: propsEvent.value.event.files }),
|
||||
);
|
||||
|
||||
console.log([propsEvent.value]);
|
||||
if (propsEvent.value.event.files !== null) {
|
||||
newFiles.value.forEach((e) => postEvent.append('files', e));
|
||||
}
|
||||
@@ -538,15 +539,18 @@ export default {
|
||||
};
|
||||
|
||||
const updateDateStart = (newDate) => {
|
||||
propsEvent.value.event.date_start = newDate;
|
||||
// Нормализуем к ISO строке
|
||||
const normalizedDate = new Date(newDate).toISOString();
|
||||
propsEvent.value.event.date_start = normalizedDate;
|
||||
|
||||
// При изменении даты начала - обновляем правило повторений
|
||||
const startDate = new Date(newDate);
|
||||
const startDate = new Date(normalizedDate);
|
||||
const endDate = new Date(propsEvent.value.event.date_end);
|
||||
|
||||
if (startDate > endDate) {
|
||||
const adjustedEnd = new Date(startDate);
|
||||
adjustedEnd.setHours(startDate.getHours() + 1);
|
||||
propsEvent.value.event.date_end = adjustedEnd.toISOString();
|
||||
propsEvent.value.event.date_end = adjustedEnd.toISOString(); // Тоже ISO
|
||||
}
|
||||
|
||||
if (selectedRule.value.rule) {
|
||||
@@ -555,7 +559,8 @@ export default {
|
||||
};
|
||||
|
||||
const updateDateEnd = (newDate) => {
|
||||
propsEvent.value.event.date_end = newDate;
|
||||
// Нормализуем к ISO строке
|
||||
propsEvent.value.event.date_end = new Date(newDate).toISOString();
|
||||
};
|
||||
|
||||
// функция обновления периода
|
||||
|
||||
@@ -138,15 +138,22 @@ export const useCalendarStore = defineStore('calendarStore', () => {
|
||||
});
|
||||
|
||||
const editableEvents = computed(() => {
|
||||
const calendarsMap = new Map(myCalendars.value.map((cal) => [cal.id, cal]));
|
||||
const currentUserId = accountStore.user.is_idEmployee;
|
||||
|
||||
return allEvents.value.filter((event) => {
|
||||
const calendar = calendarsMap.get(event.calendar);
|
||||
const calendar = event.calendarData;
|
||||
|
||||
if (!calendar) return false;
|
||||
|
||||
// Автор календаря
|
||||
if (calendar?.author == currentUserId) return true;
|
||||
// Участник события
|
||||
return event.participant?.includes(currentUserId);
|
||||
if (calendar.author === currentUserId) return true;
|
||||
|
||||
// Ищем участника с правами редактора
|
||||
const isEditor = calendar.participant?.some(
|
||||
(part) => part.participant_calendar === currentUserId && part.editor === true,
|
||||
);
|
||||
|
||||
return isEditor;
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user