fix [P-300]: фикс событий с опцией весь день
This commit is contained in:
1 parent
a64c716e5f
commit
58c515ec71
5 files changed
+1059
-346
No files matched your search
Executable → Regular
+183
-173
@@ -1,184 +1,187 @@
|
||||
<template>
|
||||
<v-card class="pa-0" rounded="lg" elevation="8">
|
||||
<!-- Акцентная полоса -->
|
||||
<div :style="{ height: '4px', background: calendarColor }" />
|
||||
<v-dialog v-model="internalShow" max-width="700">
|
||||
<v-card class="pa-4" min-height="400">
|
||||
<!-- Заголовок -->
|
||||
<v-card-title class="pr-0 pl-2 d-flex justify-space-between pb-3">
|
||||
<span class="text-h5 font-weight-medium">Просмотр события</span>
|
||||
<v-icon
|
||||
icon="mdi-close"
|
||||
size="small"
|
||||
color="grey"
|
||||
class="cursor-pointer"
|
||||
@click="closeDialog"
|
||||
/>
|
||||
</v-card-title>
|
||||
|
||||
<!-- Шапка -->
|
||||
<div class="d-flex align-center justify-space-between pa-5 pb-4">
|
||||
<div class="d-flex align-center" style="min-width: 0">
|
||||
<v-avatar :color="calendarColor" size="40" class="mr-3 flex-shrink-0">
|
||||
<v-icon icon="mdi-calendar-text" color="white" size="22" />
|
||||
</v-avatar>
|
||||
<div style="min-width: 0">
|
||||
<div class="text-caption text-medium-emphasis text-uppercase">
|
||||
{{ calendarName }}
|
||||
</div>
|
||||
<div class="text-h6 font-weight-medium text-truncate" :title="eventData.event?.name">
|
||||
{{ eventData.event?.name || 'Без названия' }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<v-divider></v-divider>
|
||||
|
||||
<v-btn icon="mdi-close" variant="text" density="comfortable" size="small" @click="closeDialog" />
|
||||
</div>
|
||||
|
||||
<v-divider />
|
||||
|
||||
<!-- Контент -->
|
||||
<v-card-text class="pa-5">
|
||||
<v-list density="comfortable" bg-color="transparent" class="pa-0">
|
||||
<!-- Дата и время -->
|
||||
<v-list-item class="px-0">
|
||||
<template #prepend>
|
||||
<v-icon icon="mdi-clock-outline" color="medium-emphasis" class="mr-3" />
|
||||
</template>
|
||||
<v-list-item-title class="text-caption text-medium-emphasis">
|
||||
Дата и время
|
||||
</v-list-item-title>
|
||||
<v-list-item-subtitle class="text-body-2 text-high-emphasis mt-1" style="opacity: 1">
|
||||
<span class="font-weight-medium">
|
||||
{{ formatDateTime(eventData.event?.date_start, eventData.event?.allday) }}
|
||||
</span>
|
||||
<v-icon icon="mdi-arrow-right" size="14" class="mx-2" />
|
||||
<span class="font-weight-medium">
|
||||
{{ formatDateTime(eventData.event?.date_end, eventData.event?.allday) }}
|
||||
</span>
|
||||
</v-list-item-subtitle>
|
||||
</v-list-item>
|
||||
|
||||
<v-divider class="my-1" />
|
||||
|
||||
<!-- Повторение -->
|
||||
<template v-if="eventData.event?.period">
|
||||
<v-list-item class="px-0">
|
||||
<template #prepend>
|
||||
<v-icon icon="mdi-refresh" color="medium-emphasis" class="mr-3" />
|
||||
</template>
|
||||
<v-list-item-title class="text-caption text-medium-emphasis">Повтор</v-list-item-title>
|
||||
<v-list-item-subtitle class="text-body-2 mt-1" style="opacity: 1">
|
||||
{{ recurrenceText }}
|
||||
<span v-if="showRepeatEnd" class="text-medium-emphasis ml-2">
|
||||
· до {{ formatRepeatEndDate }}
|
||||
</span>
|
||||
</v-list-item-subtitle>
|
||||
</v-list-item>
|
||||
<v-divider class="my-1" />
|
||||
</template>
|
||||
|
||||
<!-- Участники -->
|
||||
<template v-if="participantsList.length">
|
||||
<v-list-item class="px-0">
|
||||
<template #prepend>
|
||||
<v-icon icon="mdi-account-multiple-outline" color="medium-emphasis" class="mr-3" />
|
||||
</template>
|
||||
<v-list-item-title class="text-caption text-medium-emphasis">
|
||||
Участники
|
||||
<v-chip size="x-small" variant="tonal" class="ml-2">{{ participantsList.length }}</v-chip>
|
||||
</v-list-item-title>
|
||||
<v-list-item-subtitle class="mt-2" style="opacity: 1">
|
||||
<div class="d-flex flex-wrap ga-2">
|
||||
<v-chip
|
||||
v-for="p in participantsList"
|
||||
:key="p.id"
|
||||
size="small"
|
||||
variant="tonal"
|
||||
prepend-icon="mdi-account"
|
||||
>
|
||||
{{ p.title }}
|
||||
</v-chip>
|
||||
<!-- Контент -->
|
||||
<v-card-text class="px-2">
|
||||
<v-row no-gutters class="flex-column">
|
||||
<!-- Название события -->
|
||||
<v-row no-gutters class="align-center border-bottom">
|
||||
<v-col
|
||||
style="font-size: 1.1rem; line-height: 1.4"
|
||||
class="text-body-1 text-text_grey font-weight-medium"
|
||||
lg="3"
|
||||
>
|
||||
Название
|
||||
</v-col>
|
||||
<v-col>
|
||||
<div class="text-body-1" style="font-size: 1.1rem; line-height: 1.4">
|
||||
{{ eventData.event?.name || 'Без названия' }}
|
||||
</div>
|
||||
</v-list-item-subtitle>
|
||||
</v-list-item>
|
||||
<v-divider class="my-1" />
|
||||
</template>
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
<!-- Файлы -->
|
||||
<template v-if="eventData.event?.files?.length">
|
||||
<v-list-item class="px-0">
|
||||
<template #prepend>
|
||||
<v-icon icon="mdi-paperclip" color="medium-emphasis" class="mr-3" />
|
||||
</template>
|
||||
<v-list-item-title class="text-caption text-medium-emphasis">
|
||||
Файлы
|
||||
<v-chip size="x-small" variant="tonal" class="ml-2">
|
||||
{{ eventData.event.files.length }}
|
||||
</v-chip>
|
||||
</v-list-item-title>
|
||||
<v-list-item-subtitle class="mt-2" style="opacity: 1">
|
||||
<v-list density="compact" bg-color="transparent" class="pa-0">
|
||||
<v-list-item
|
||||
<!-- Календарь -->
|
||||
<v-row no-gutters class="align-center pb-3 mb-3 border-bottom">
|
||||
<v-col class="text-body-1 text-text_grey font-weight-medium" lg="3"> Календарь </v-col>
|
||||
<v-col>
|
||||
<div class="d-flex align-center">
|
||||
<v-avatar size="20" :color="calendarColor" class="mr-3" />
|
||||
<span class="text-body-1">{{ calendarName }}</span>
|
||||
</div>
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
<!-- Участники -->
|
||||
<v-row
|
||||
no-gutters
|
||||
class="align-start pb-3 mb-3 border-bottom"
|
||||
v-if="participantsList.length > 0"
|
||||
>
|
||||
<v-col class="text-body-1 text-text_grey font-weight-medium pt-1" lg="3">
|
||||
Участники
|
||||
</v-col>
|
||||
<v-col>
|
||||
<div class="participants-list">
|
||||
<div
|
||||
v-for="participant in participantsList"
|
||||
:key="participant.id"
|
||||
class="text-body-1 mb-1"
|
||||
>
|
||||
• {{ participant.title }}
|
||||
</div>
|
||||
</div>
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
<!-- Дата и время -->
|
||||
<v-row no-gutters class="align-top pb-3 mb-3 border-bottom">
|
||||
<v-col class="text-body-1 text-text_grey font-weight-medium pt-1" lg="3">
|
||||
Дата и время
|
||||
</v-col>
|
||||
<v-col class="d-flex flex-column">
|
||||
<div class="d-flex align-center gap">
|
||||
<div class="text-body-1 font-weight-medium">
|
||||
{{ formatDateTime(eventData.event?.date_start, eventData.event?.allday) }}
|
||||
</div>
|
||||
<v-icon icon="mdi-minus" color="grey" class="mx-3" />
|
||||
<div class="text-body-1 font-weight-medium">
|
||||
{{ formatDateTime(eventData.event?.date_end, eventData.event?.allday) }}
|
||||
</div>
|
||||
</div>
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
<!-- Повторение -->
|
||||
<v-row
|
||||
no-gutters
|
||||
class="align-center pb-3 mb-3 border-bottom"
|
||||
v-if="eventData.event?.period"
|
||||
>
|
||||
<v-col class="text-body-1 text-text_grey font-weight-medium" lg="3"> Повтор события </v-col>
|
||||
<v-col>
|
||||
<div class="text-body-1">{{ recurrenceText }}</div>
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
<!-- Окончание события -->
|
||||
<v-row no-gutters class="align-center pb-3 mb-3 border-bottom" v-if="showRepeatEnd">
|
||||
<v-col class="text-body-1 text-text_grey font-weight-medium" lg="3">
|
||||
Окончание события
|
||||
</v-col>
|
||||
<v-col>
|
||||
<div class="text-body-1">
|
||||
{{ formatRepeatEndDate }}
|
||||
</div>
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
<!-- Файлы -->
|
||||
<v-row
|
||||
no-gutters
|
||||
class="align-top pb-3 mb-3 border-bottom"
|
||||
v-if="eventData.event?.files?.length"
|
||||
>
|
||||
<v-col class="text-body-1 text-text_grey font-weight-medium" lg="3"> Файлы </v-col>
|
||||
<v-col>
|
||||
<div class="files-list">
|
||||
<div
|
||||
v-for="file in eventData.event.files"
|
||||
:key="file.id"
|
||||
:prepend-icon="getFileIcon(file)"
|
||||
:title="truncateFileName(getFileName(file))"
|
||||
append-icon="mdi-download"
|
||||
rounded="md"
|
||||
variant="tonal"
|
||||
density="compact"
|
||||
class="mb-1"
|
||||
class="d-flex align-center mb-2 cursor-pointer"
|
||||
@click="downloadFile(file)"
|
||||
/>
|
||||
</v-list>
|
||||
</v-list-item-subtitle>
|
||||
</v-list-item>
|
||||
<v-divider class="my-1" />
|
||||
</template>
|
||||
>
|
||||
<v-icon :icon="getFileIcon(file)" color="primary" class="mr-2" size="small" />
|
||||
<span class="text-body-1 text-primary text-decoration-underline">
|
||||
{{ truncateFileName(getFileName(file)) }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
<!-- Описание -->
|
||||
<v-list-item v-if="eventData.event?.description" class="px-0">
|
||||
<template #prepend>
|
||||
<v-icon icon="mdi-text" color="medium-emphasis" class="mr-3" />
|
||||
</template>
|
||||
<v-list-item-title class="text-caption text-medium-emphasis">Описание</v-list-item-title>
|
||||
<v-list-item-subtitle class="mt-2" style="opacity: 1">
|
||||
<v-sheet
|
||||
rounded="md"
|
||||
color="surface-light"
|
||||
class="pa-3"
|
||||
:style="{ borderLeft: `3px solid ${calendarColor}`, whiteSpace: 'pre-wrap' }"
|
||||
>
|
||||
{{ eventData.event.description }}
|
||||
</v-sheet>
|
||||
</v-list-item-subtitle>
|
||||
</v-list-item>
|
||||
</v-list>
|
||||
<!-- Описание -->
|
||||
<v-row no-gutters class="align-top pb-3" v-if="eventData.event?.description">
|
||||
<v-col class="text-body-1 text-text_grey font-weight-medium" lg="3"> Описание </v-col>
|
||||
<v-col>
|
||||
<div class="text-body-1 description-text">
|
||||
{{ eventData.event.description }}
|
||||
</div>
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
<!-- Пусто -->
|
||||
<div v-if="!eventData.event?.name" class="text-center py-8">
|
||||
<v-icon size="56" color="grey-lighten-1" icon="mdi-calendar-remove" />
|
||||
<div class="text-body-1 text-medium-emphasis mt-3">Нет данных о событии</div>
|
||||
</div>
|
||||
</v-card-text>
|
||||
<!-- Если нет данных -->
|
||||
<v-row v-if="!eventData.event?.name" class="justify-center mt-8">
|
||||
<v-col class="text-center">
|
||||
<v-icon size="64" color="grey-lighten-1">mdi-calendar-remove</v-icon>
|
||||
<div class="text-h6 text-grey mt-2">Нет данных о событии</div>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-row>
|
||||
</v-card-text>
|
||||
|
||||
<v-divider />
|
||||
|
||||
<!-- Кнопки -->
|
||||
<v-card-actions class="pa-4">
|
||||
<v-spacer />
|
||||
|
||||
<v-btn
|
||||
v-if="canEdit"
|
||||
:color="calendarColor"
|
||||
variant="elevated"
|
||||
prepend-icon="mdi-pencil"
|
||||
@click="onEdit"
|
||||
>
|
||||
Редактировать
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
<!-- Кнопки -->
|
||||
<v-card-actions class="justify-end pa-4 pt-0">
|
||||
<v-btn
|
||||
width="120"
|
||||
@click="closeDialog"
|
||||
color="grey-darken-1"
|
||||
variant="tonal"
|
||||
class="text-body-1"
|
||||
>
|
||||
Закрыть
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { useRecurrence } from '@/components/calendar_of_events/composables/useReccurrence';
|
||||
import { RRule } from 'rrule';
|
||||
import { useCalendarStore } from '../../store/calendarStore';
|
||||
|
||||
export default {
|
||||
name: 'EventCalendarShow',
|
||||
|
||||
props: {
|
||||
show: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
eventData: {
|
||||
type: Object,
|
||||
default: () => ({}),
|
||||
@@ -193,13 +196,30 @@ export default {
|
||||
},
|
||||
},
|
||||
|
||||
emits: ['close'],
|
||||
emits: ['update:show', 'close'],
|
||||
|
||||
setup(props, { emit }) {
|
||||
const internalShow = ref(props.show);
|
||||
const { parseRecurrenceOptions, isRecurringEvent } = useRecurrence();
|
||||
const calendarStore = useCalendarStore();
|
||||
|
||||
const closeDialog = () => emit('close');
|
||||
// Синхронизация с внешним состоянием
|
||||
watch(
|
||||
() => props.show,
|
||||
(newVal) => {
|
||||
internalShow.value = newVal;
|
||||
},
|
||||
);
|
||||
|
||||
watch(internalShow, (newVal) => {
|
||||
if (!newVal) {
|
||||
emit('update:show', false);
|
||||
emit('close');
|
||||
}
|
||||
});
|
||||
|
||||
const closeDialog = () => {
|
||||
internalShow.value = false;
|
||||
};
|
||||
|
||||
const calendarInfo = computed(() => {
|
||||
const calendarId = props.eventData.event?.calendar;
|
||||
@@ -436,16 +456,8 @@ export default {
|
||||
return `${nameWithoutExt.slice(0, 20)}...${extension ? '.' + extension : ''}`;
|
||||
};
|
||||
|
||||
const canEdit = computed(() => {
|
||||
const id = props.eventData?.event?.id;
|
||||
return id ? calendarStore.canEditEvent(id) : false;
|
||||
});
|
||||
|
||||
const onEdit = () => {
|
||||
calendarStore.editFromView();
|
||||
};
|
||||
|
||||
return {
|
||||
internalShow,
|
||||
closeDialog,
|
||||
calendarName,
|
||||
calendarColor,
|
||||
@@ -458,8 +470,6 @@ export default {
|
||||
truncateFileName,
|
||||
showRepeatEnd,
|
||||
formatRepeatEndDate,
|
||||
canEdit,
|
||||
onEdit,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
Executable → Regular
+93
-124
@@ -7,7 +7,7 @@
|
||||
<v-row no-gutters class="mb-2 align-end" style="height: 60px" justify="space-between">
|
||||
<v-col md="5" class="flex-grow-0 d-flex align-center">
|
||||
<template v-if="currentView !== 'listAllEvents'">
|
||||
<div class="pb-1 d-flex align-center">
|
||||
<div class="pb-3 d-flex align-center">
|
||||
<v-btn
|
||||
variant="outlined"
|
||||
class="text-subtitle-2 mr-2"
|
||||
@@ -38,7 +38,7 @@
|
||||
<v-icon size="large">mdi-chevron-right</v-icon>
|
||||
</v-btn>
|
||||
|
||||
<span class="text-h6 text-no-wrap ml-2">
|
||||
<span class="text-h5 text-no-wrap ml-2">
|
||||
{{ currentTitle }}
|
||||
</span>
|
||||
</div>
|
||||
@@ -62,12 +62,12 @@
|
||||
variant="plain"
|
||||
density="comfortable"
|
||||
>
|
||||
<v-btn value="timeGridDay" class="px-2">День</v-btn>
|
||||
<v-btn value="timeGridWeek" class="px-2">Неделя</v-btn>
|
||||
<v-btn value="dayGridMonth" class="px-2">Месяц</v-btn>
|
||||
<v-btn value="multiMonthYear" class="px-2">Год</v-btn>
|
||||
<v-btn value="listWeek" class="px-2">Расписание</v-btn>
|
||||
<v-btn value="listAllEvents" class="px-2">Все события</v-btn>
|
||||
<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 value="listAllEvents">Все события</v-btn>
|
||||
</v-btn-toggle>
|
||||
</v-col>
|
||||
</v-row>
|
||||
@@ -104,21 +104,16 @@ import { useAccountStore } from '@/store/AccountStore';
|
||||
import EventsListView from './EventsListView.vue';
|
||||
import EventListFilters from './EventListFilters.vue';
|
||||
import { useEventListFilters } from '../composables/useEventListFilters';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
export default {
|
||||
name: 'CustomCalendar',
|
||||
|
||||
emits: ['openEventDialog', 'openEventView'],
|
||||
components: {
|
||||
EventsListView,
|
||||
EventListFilters,
|
||||
},
|
||||
|
||||
props: {
|
||||
forHomePage: { type: Boolean, default: false },
|
||||
view: { type: String, default: 'dayGridMonth' },
|
||||
},
|
||||
|
||||
setup(props) {
|
||||
setup(props, { emit }) {
|
||||
const currentView = ref('dayGridMonth');
|
||||
const currentTitle = ref('Календарь');
|
||||
const calendarRef = ref(null);
|
||||
@@ -127,7 +122,6 @@ export default {
|
||||
const calendarStore = useCalendarStore();
|
||||
const { selectedDate, lastUpdatedBy, allEvents, calendarColorMap } = storeToRefs(calendarStore);
|
||||
const { isRecurringEvent, generateRecurringInstances } = useRecurrence();
|
||||
const route = useRoute();
|
||||
|
||||
const calendarApi = computed(() => {
|
||||
return calendarRef.value?.getApi?.() || null;
|
||||
@@ -142,7 +136,11 @@ export default {
|
||||
}));
|
||||
|
||||
const handleEventClick = (info) => {
|
||||
calendarStore.handleEventClick(info);
|
||||
if (calendarStore.canEditEvent(info.event.id)) {
|
||||
emit('openEventDialog', info);
|
||||
} else {
|
||||
emit('openEventView', info.event.id);
|
||||
}
|
||||
};
|
||||
|
||||
const calendarOptions = ref({
|
||||
@@ -157,13 +155,13 @@ export default {
|
||||
initialView: props.forHomePage ? props.view : currentView.value,
|
||||
locales: [ruLocale],
|
||||
locale: 'ru',
|
||||
timeZone: 'Europe/Moscow',
|
||||
timeZone: 'locale',
|
||||
firstDay: 1,
|
||||
headerToolbar: false,
|
||||
height: '80vh',
|
||||
aspectRatio: 1.5,
|
||||
weekNumbers: true,
|
||||
eventDisplay: 'auto',
|
||||
eventDisplay: 'block',
|
||||
eventTimeFormat: {
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
@@ -177,21 +175,19 @@ export default {
|
||||
selectable: true,
|
||||
unselectAuto: false,
|
||||
selectMirror: false,
|
||||
dayCellClassNames: (arg) => {
|
||||
const dayInfo = calendarStore.isNonWorkingDay(arg.date);
|
||||
const classes = [];
|
||||
if (dayInfo.isHoliday) classes.push('non-working-day');
|
||||
if (dayInfo.isWeekendForStyling) classes.push('grey-background');
|
||||
return classes;
|
||||
},
|
||||
dayHeaderClassNames: (arg) => {
|
||||
const dayInfo = calendarStore.isNonWorkingDay(arg.date);
|
||||
const classes = [];
|
||||
if (dayInfo.isHoliday) classes.push('non-working-day');
|
||||
if (dayInfo.isWeekendForStyling) classes.push('grey-background');
|
||||
return classes;
|
||||
},
|
||||
|
||||
dayCellDidMount: (arg) => {
|
||||
const date = arg.date;
|
||||
const dayInfo = calendarStore.isNonWorkingDay(date);
|
||||
|
||||
if (dayInfo.isHoliday === true) {
|
||||
arg.el.classList.add('non-working-day');
|
||||
}
|
||||
|
||||
if (dayInfo.isWeekendForStyling === true) {
|
||||
arg.el.classList.add('grey-background');
|
||||
}
|
||||
},
|
||||
views: {
|
||||
timeGridDay: {
|
||||
type: 'timeGrid',
|
||||
@@ -281,7 +277,7 @@ export default {
|
||||
title: instance.title,
|
||||
start: instance.start,
|
||||
end: instance.end,
|
||||
allDay: instance.allDay,
|
||||
allDay: instance.allday || isMultiDay,
|
||||
textColor: '#ffffff',
|
||||
backgroundColor: eventColor,
|
||||
borderColor: eventColor,
|
||||
@@ -291,12 +287,21 @@ export default {
|
||||
},
|
||||
}));
|
||||
} else {
|
||||
let end = event.date_end;
|
||||
|
||||
if (event.allday) {
|
||||
// Для allDay: просто добавляем 1 день к конечной дате
|
||||
const endDate = new Date(event.date_end);
|
||||
endDate.setDate(endDate.getDate() + 1);
|
||||
end = endDate.toISOString();
|
||||
}
|
||||
|
||||
return [
|
||||
{
|
||||
id: event.id,
|
||||
title: event.name,
|
||||
start: event.date_start,
|
||||
end: event.date_end,
|
||||
end: end,
|
||||
allDay: event.allday,
|
||||
textColor: '#ffffff',
|
||||
backgroundColor: eventColor,
|
||||
@@ -316,6 +321,7 @@ export default {
|
||||
|
||||
successCallback(events);
|
||||
},
|
||||
selectable: true,
|
||||
eventClick: handleEventClick,
|
||||
|
||||
dateClick: (info) => {
|
||||
@@ -327,8 +333,18 @@ export default {
|
||||
|
||||
datesSet: (info) => {
|
||||
if (info.view.type === 'listWeek' && selectedDate.value) {
|
||||
currentTitle.value = formatScheduleTitle(selectedDate.value);
|
||||
} else if (info.view.type !== 'listWeek') {
|
||||
const date = new Date(selectedDate.value);
|
||||
|
||||
const options = {
|
||||
weekday: 'long',
|
||||
day: 'numeric',
|
||||
month: 'long',
|
||||
year: 'numeric',
|
||||
};
|
||||
|
||||
const formattedDate = date.toLocaleDateString('ru-RU', options);
|
||||
currentTitle.value = `Расписание на ${formattedDate}`;
|
||||
} else {
|
||||
currentTitle.value = info.view.title;
|
||||
}
|
||||
|
||||
@@ -388,47 +404,6 @@ export default {
|
||||
selectedDate.value = dateStr;
|
||||
};
|
||||
|
||||
const weekdayMap = {
|
||||
воскресенье: 'воскресенье',
|
||||
понедельник: 'понедельник',
|
||||
вторник: 'вторник',
|
||||
среда: 'среду',
|
||||
четверг: 'четверг',
|
||||
пятница: 'пятницу',
|
||||
суббота: 'субботу',
|
||||
};
|
||||
|
||||
const formatScheduleTitle = (dateValue) => {
|
||||
const date = new Date(dateValue);
|
||||
const weekdayRaw = date.toLocaleDateString('ru-RU', { weekday: 'long' });
|
||||
const weekday = weekdayMap[weekdayRaw] || weekdayRaw;
|
||||
const rest = date.toLocaleDateString('ru-RU', {
|
||||
day: 'numeric',
|
||||
month: 'long',
|
||||
year: 'numeric',
|
||||
});
|
||||
return `Расписание на ${weekday}, ${rest}`;
|
||||
};
|
||||
|
||||
const applyView = async (newView) => {
|
||||
if (newView === 'listAllEvents') {
|
||||
currentTitle.value = 'Все события';
|
||||
return;
|
||||
}
|
||||
if (newView === 'listWeek' && selectedDate.value) {
|
||||
currentTitle.value = formatScheduleTitle(selectedDate.value);
|
||||
}
|
||||
|
||||
await nextTick();
|
||||
if (!calendarApi.value) return;
|
||||
|
||||
calendarApi.value.changeView(newView);
|
||||
|
||||
if (newView !== 'listWeek') {
|
||||
currentTitle.value = calendarApi.value.view.title;
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
const currentYear = new Date().getFullYear();
|
||||
calendarStore.fetchHolidays(currentYear);
|
||||
@@ -436,34 +411,32 @@ export default {
|
||||
await nextTick();
|
||||
|
||||
// Принудительно обновляем события после загрузки праздников
|
||||
if (calendarApi.value && currentView.value !== 'listAllEvents') {
|
||||
if (calendarApi.value) {
|
||||
calendarApi.value.refetchEvents();
|
||||
}
|
||||
|
||||
if (selectedDate.value && currentView.value !== 'listAllEvents') {
|
||||
if (selectedDate.value) {
|
||||
handleDateSelection(selectedDate.value);
|
||||
}
|
||||
});
|
||||
|
||||
watch(currentView, (newView) => {
|
||||
applyView(newView);
|
||||
});
|
||||
|
||||
watch(
|
||||
[() => calendarStore.calendars, () => calendarStore.hiddenCalendarIds],
|
||||
allEvents,
|
||||
() => {
|
||||
// При изменении событий перезагружаем календарь
|
||||
if (currentView.value === 'listAllEvents') return;
|
||||
calendarApi.value?.refetchEvents();
|
||||
if (calendarApi.value) {
|
||||
calendarApi.value.refetchEvents();
|
||||
}
|
||||
},
|
||||
{ deep: true },
|
||||
);
|
||||
|
||||
watch(
|
||||
calendarColorMap,
|
||||
() => {
|
||||
if (currentView.value === 'listAllEvents') return;
|
||||
calendarApi.value?.refetchEvents();
|
||||
(newColorMap, oldColorMap) => {
|
||||
if (calendarRef.value && JSON.stringify(newColorMap) !== JSON.stringify(oldColorMap)) {
|
||||
renderEvents();
|
||||
}
|
||||
},
|
||||
{ deep: true },
|
||||
);
|
||||
@@ -473,13 +446,19 @@ export default {
|
||||
nextTick(() => {
|
||||
calendarApi.value.gotoDate(newDate);
|
||||
handleDateSelection(newDate);
|
||||
if (route.query.date && currentView.value !== 'timeGridDay') {
|
||||
currentView.value = 'timeGridDay';
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
watch(currentView, (newView) => {
|
||||
if (newView === 'listAllEvents') {
|
||||
currentTitle.value = 'Все события';
|
||||
} else if (calendarApi.value) {
|
||||
calendarApi.value.changeView(newView);
|
||||
currentTitle.value = calendarApi.value.view.title;
|
||||
}
|
||||
});
|
||||
|
||||
const handleFiltersUpdate = (newFilters) => {
|
||||
Object.keys(newFilters).forEach((key) => {
|
||||
if (filters[key] !== undefined) {
|
||||
@@ -534,7 +513,7 @@ export default {
|
||||
:deep(.fc-day-today .fc-daygrid-day-number) {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
color: rgb(var(--v-theme-btn_text));
|
||||
color: #00897b;
|
||||
|
||||
&::before {
|
||||
content: '';
|
||||
@@ -544,7 +523,7 @@ export default {
|
||||
transform: translate(-50%, -50%);
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border: 1px solid rgb(var(--v-theme-btn_text));
|
||||
border: 1px solid #00897b;
|
||||
border-radius: 50%;
|
||||
z-index: -1;
|
||||
}
|
||||
@@ -559,7 +538,7 @@ export default {
|
||||
:deep(.fc-day-selected-custom .fc-daygrid-day-number) {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
color: rgb(var(--v-theme-bg_white)) !important;
|
||||
color: white !important;
|
||||
}
|
||||
|
||||
:deep(.fc-day-selected-custom .fc-daygrid-day-number::before) {
|
||||
@@ -570,7 +549,7 @@ export default {
|
||||
transform: translate(-50%, -50%);
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
background-color: rgb(var(--v-theme-btn_text));
|
||||
background-color: #00897b;
|
||||
border-radius: 50%;
|
||||
z-index: -1;
|
||||
}
|
||||
@@ -585,16 +564,11 @@ export default {
|
||||
|
||||
:deep(.v-btn--active) {
|
||||
background-color: transparent !important;
|
||||
color: rgb(var(--v-theme-btn_text)) !important;
|
||||
color: #00897b !important;
|
||||
}
|
||||
|
||||
:deep(.fc .fc-timegrid-col.fc-day-today) {
|
||||
background-color: rgba(var(--v-theme-btn_text), 0.1) !important;
|
||||
}
|
||||
|
||||
:deep(.fc-timegrid-col.non-working-day),
|
||||
:deep(.fc-day.non-working-day:not(.fc-daygrid-day)) {
|
||||
background-color: rgba(var(--v-theme-holiday_text), 0.05) !important;
|
||||
background-color: #e0f2f1 !important;
|
||||
}
|
||||
|
||||
:deep(.fc-highlight) {
|
||||
@@ -606,32 +580,27 @@ export default {
|
||||
}
|
||||
|
||||
:deep(.fc-popover) {
|
||||
background-color: rgb(var(--v-theme-cards)) !important;
|
||||
background-color: rgb(248, 244, 244) !important;
|
||||
}
|
||||
|
||||
:deep(.fc-day.non-working-day .fc-daygrid-day-number),
|
||||
:deep(.fc-day.non-working-day .fc-daygrid-day-top) {
|
||||
color: rgb(var(--v-theme-holiday_text)) !important;
|
||||
.non-working-day {
|
||||
color: red !important;
|
||||
}
|
||||
|
||||
:deep(.fc-col-header-cell.non-working-day),
|
||||
:deep(.fc-col-header-cell.non-working-day .fc-col-header-cell-cushion) {
|
||||
color: rgb(var(--v-theme-holiday_text)) !important;
|
||||
:global(.fc-daygrid-day.non-working-day .fc-daygrid-day-number) {
|
||||
color: #d32f2f !important;
|
||||
}
|
||||
|
||||
:global(.fc-daygrid-day.grey-background.fc-daygrid-day-number) {
|
||||
background-color: rgb(196, 187, 187) !important;
|
||||
}
|
||||
|
||||
.grey-background {
|
||||
background-color: rgb(240, 229, 229) !important;
|
||||
}
|
||||
|
||||
:deep(.grey-background),
|
||||
:deep(.fc-daygrid-day),
|
||||
:deep(.fc-day.grey-background) {
|
||||
background-color: rgb(var(--v-theme-weekend_bg)) !important;
|
||||
}
|
||||
|
||||
:deep(.fc-day.grey-background .fc-daygrid-day-number) {
|
||||
color: rgb(var(--v-theme-weekend_text)) !important;
|
||||
}
|
||||
|
||||
:deep(.fc-col-header-cell.grey-background),
|
||||
:deep(.fc-col-header-cell.grey-background .fc-col-header-cell-cushion) {
|
||||
color: rgb(var(--v-theme-weekend_text)) !important;
|
||||
background-color: #f5f5f5 !important;
|
||||
}
|
||||
|
||||
.custom-calendar {
|
||||
|
||||
Executable → Regular
+10
-35
@@ -13,56 +13,31 @@ import { computed } from 'vue';
|
||||
|
||||
export default {
|
||||
props: {
|
||||
dateEvent: {
|
||||
dateEventStart: {
|
||||
type: Object,
|
||||
default: () => {},
|
||||
},
|
||||
},
|
||||
setup(props, { emit }) {
|
||||
// const newDate = computed({
|
||||
// get() {
|
||||
// return propsDateEvent.value.allday;
|
||||
// },
|
||||
// set(newValue) {
|
||||
// propsDateEvent.value.allday = newValue;
|
||||
// if (newValue === true)
|
||||
// (propsDateEvent.value.date_end = new Date(
|
||||
// new Date(propsDateEvent.value.date_end).setHours(23, 59, 59),
|
||||
// )) &&
|
||||
// (propsDateEvent.value.date_start = new Date(
|
||||
// new Date(propsDateEvent.value.date_start).setHours(0, 0, 0),
|
||||
// ));
|
||||
// },
|
||||
// });
|
||||
|
||||
const newDate = computed({
|
||||
get() {
|
||||
return propsDateEvent.value.allday;
|
||||
},
|
||||
set(newValue) {
|
||||
propsDateEvent.value.allday = newValue;
|
||||
|
||||
const startDate = new Date(propsDateEvent.value.date_start);
|
||||
const endDate = new Date(propsDateEvent.value.date_end);
|
||||
|
||||
if (newValue === true) {
|
||||
// Весь день: 00:00 - 23:59
|
||||
startDate.setHours(0, 0, 0, 0);
|
||||
endDate.setHours(23, 59, 59, 999);
|
||||
} else {
|
||||
// Рабочие часы: 09:00 - 17:00
|
||||
startDate.setHours(9, 0, 0, 0);
|
||||
endDate.setHours(17, 0, 0, 0);
|
||||
}
|
||||
|
||||
propsDateEvent.value.date_start = startDate.toISOString();
|
||||
propsDateEvent.value.date_end = endDate.toISOString();
|
||||
if (newValue === true)
|
||||
(propsDateEvent.value.date_end = new Date(
|
||||
new Date(propsDateEvent.value.date_end).setHours(23, 59, 59),
|
||||
)) &&
|
||||
(propsDateEvent.value.date_start = new Date(
|
||||
new Date(propsDateEvent.value.date_start).setHours(0, 0, 0),
|
||||
));
|
||||
},
|
||||
});
|
||||
|
||||
const propsDateEvent = computed({
|
||||
get: () => props.dateEvent,
|
||||
set: (value) => emit('update:dateEvent', value),
|
||||
get: () => props.dateEventStart,
|
||||
set: (value) => emit('update:dateEventStart', value),
|
||||
});
|
||||
|
||||
return {
|
||||
|
||||
Executable → Regular
+6
-14
@@ -8,18 +8,9 @@ export function useRecurrence() {
|
||||
// Пробуем распарсить как RRULE-строку
|
||||
if (periodString.includes('RRULE:')) {
|
||||
const rrule = RRule.fromString(periodString);
|
||||
const start = new Date(eventDateStart);
|
||||
const localDtstart = new Date(
|
||||
start.getFullYear(),
|
||||
start.getMonth(),
|
||||
start.getDate(),
|
||||
start.getHours(),
|
||||
start.getMinutes(),
|
||||
start.getSeconds(),
|
||||
);
|
||||
return {
|
||||
...rrule.origOptions,
|
||||
dtstart: localDtstart,
|
||||
dtstart: new Date(eventDateStart),
|
||||
interval: rrule.origOptions.interval || 1,
|
||||
};
|
||||
}
|
||||
@@ -71,14 +62,15 @@ export function useRecurrence() {
|
||||
if (!rrule) return [event];
|
||||
|
||||
const dates = rrule.all((date, i) => i < count);
|
||||
const start = new Date(event.date_start);
|
||||
const end = new Date(event.date_end);
|
||||
const duration = end - start;
|
||||
|
||||
const duration = new Date(event.date_end) - new Date(event.date_start);
|
||||
|
||||
return dates.map((date) => ({
|
||||
return dates.map((date, index) => ({
|
||||
id: event.id,
|
||||
title: event.name,
|
||||
start: date,
|
||||
end: date.getTime() + duration,
|
||||
end: (date.getTime() + duration),
|
||||
allDay: event.allday,
|
||||
extendedProps: {
|
||||
originalEventId: event.id,
|
||||
|
||||
@@ -0,0 +1,767 @@
|
||||
<template>
|
||||
<dialog-create
|
||||
:title="titleCard"
|
||||
:newOrOld="isNewEvent"
|
||||
@postData="postData"
|
||||
@closeDialog="$emit('closeDialog')"
|
||||
@delObject="delEvent(propsEvent?.event?.id)"
|
||||
ref="createDialog"
|
||||
>
|
||||
<template v-slot:card_text>
|
||||
<v-row no-gutters class="flex-column">
|
||||
<v-col class="d-flex flex-column">
|
||||
<v-row no-gutters class="align-center">
|
||||
<v-col class="text-body-2 text-text_grey pb-5" lg="2"> Название </v-col>
|
||||
|
||||
<v-col>
|
||||
<v-textarea
|
||||
density="compact"
|
||||
label="Добавить название"
|
||||
row-height="25"
|
||||
rows="1"
|
||||
variant="outlined"
|
||||
v-model="propsEvent.event.name"
|
||||
:rules="rules.name"
|
||||
></v-textarea> </v-col
|
||||
></v-row>
|
||||
|
||||
<v-row no-gutters class="align-center">
|
||||
<v-col class="text-body-2 text-text_grey pb-5" lg="2"> Участники </v-col>
|
||||
<v-col>
|
||||
<calendar-create-select
|
||||
:staff="newStaff"
|
||||
@returnIdParticant="returnIdParticant"
|
||||
:authorID="currentCalendarAuthorId"
|
||||
/> </v-col
|
||||
></v-row>
|
||||
|
||||
<v-row no-gutters class="align-center pb-3">
|
||||
<v-col class="text-body-2 text-text_grey" lg="2"> Календарь</v-col>
|
||||
<v-col>
|
||||
<v-autocomplete
|
||||
v-model="myCalendar"
|
||||
:items="safeCalendars"
|
||||
label="Выберите календарь или найдите по названию"
|
||||
item-title="cl_name"
|
||||
item-value="id"
|
||||
hide-details
|
||||
variant="outlined"
|
||||
density="compact"
|
||||
class="py-3"
|
||||
return-object
|
||||
:rules="rules.calendar"
|
||||
:disabled="'id' in propsEvent.event"
|
||||
auto-select-first
|
||||
>
|
||||
<template v-slot:selection="{ item }">
|
||||
<v-avatar class="cursor-pointer" size="8" :color="item.raw.cl_color" />
|
||||
<span class="pl-2">
|
||||
{{ item.title }}
|
||||
</span>
|
||||
</template>
|
||||
<template v-slot:item="{ item, props }">
|
||||
<v-list-item
|
||||
:key="item.raw.id"
|
||||
:value="item"
|
||||
color="primary"
|
||||
v-bind="props"
|
||||
@click.stop="myCalendar = item.raw"
|
||||
>
|
||||
<template v-slot:prepend>
|
||||
<v-avatar class="cursor-pointer" size="8" :color="item.raw.cl_color" />
|
||||
</template>
|
||||
<!-- {{ item.title }} -->
|
||||
</v-list-item>
|
||||
</template>
|
||||
</v-autocomplete>
|
||||
</v-col></v-row
|
||||
>
|
||||
<v-row no-gutters class="align-top">
|
||||
<v-col class="text-body-2 text-text_grey pt-3" lg="2"> Дата и время </v-col>
|
||||
<v-col class="d-flex flex-column">
|
||||
<v-row no-gutters class="gap">
|
||||
<time-select
|
||||
:rule="selectedRule.rule ? selectedRule.rule.freq : -1"
|
||||
:isAllDay="propsEvent.event.allday"
|
||||
:order="[2, 1]"
|
||||
:dateEvent="String(propsEvent.event.date_start)"
|
||||
:limitation="String(propsEvent.event.date_end)"
|
||||
@update:dateEvent="updateDateStart"
|
||||
@adjustEndDate="handleAutoAdjustEnd"
|
||||
/>
|
||||
<v-col class="order-3 flex-grow-0">
|
||||
<v-icon icon="mdi-minus pt-4" color="grey-darken-1" />
|
||||
</v-col>
|
||||
<time-select
|
||||
:rule="selectedRule.rule ? selectedRule.rule.freq : -1"
|
||||
:isAllDay="propsEvent.event.allday"
|
||||
:order="[4, 5]"
|
||||
:dateEvent="String(propsEvent.event.date_end)"
|
||||
:limitation="String(propsEvent.event.date_start)"
|
||||
@update:dateEvent="updateDateEnd"
|
||||
@adjustEndDate="handleAutoAdjustEnd"
|
||||
/>
|
||||
</v-row>
|
||||
<v-row no-gutters>
|
||||
<period-events
|
||||
:dateEventStart="propsEvent.event"
|
||||
@update:dateEventStart="propsEvent.event = $event"
|
||||
/>
|
||||
<v-col lg="7" class="pt-2 ml-5">
|
||||
<v-autocomplete
|
||||
v-model="selectedRule"
|
||||
:items="repeatRules"
|
||||
variant="outlined"
|
||||
density="compact"
|
||||
return-object
|
||||
item-title="type"
|
||||
item-value="id"
|
||||
@update:model-value="updatePeriodRule"
|
||||
>
|
||||
</v-autocomplete>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-col>
|
||||
<v-row no-gutters class="align-top" style="height: 50px">
|
||||
<v-col class="text-body-2 text-text_grey" lg="2"> Окончание события </v-col>
|
||||
<v-col class="d-flex flex-column">
|
||||
<v-row class="gap" no-gutters>
|
||||
<v-checkbox
|
||||
v-model="showRepeatEnd"
|
||||
:disabled="isRepeatEndDisabled"
|
||||
density="compact"
|
||||
hide-details
|
||||
class="pr-3 pb-3"
|
||||
/>
|
||||
<time-select
|
||||
:showTime="false"
|
||||
v-if="showRepeatEnd"
|
||||
:chek="false"
|
||||
:order="[1, 2]"
|
||||
:dateEvent="repeatEndDate ? String(repeatEndDate) : new Date()"
|
||||
@update:dateEvent="updateRepeatEndDate"
|
||||
/>
|
||||
</v-row>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row
|
||||
no-gutters
|
||||
class="align-start d-flex pt-3 mb-3"
|
||||
style="height: auto; min-height: 100px; max-height: 300px"
|
||||
>
|
||||
<v-col class="text-body-2 text-text_grey pb-5 pt-3" lg="2"> Файлы </v-col>
|
||||
|
||||
<uploading-file
|
||||
v-model:new-files="newFiles"
|
||||
:files="propsEvent.event.files"
|
||||
@update:files="handleFilesUpdate"
|
||||
@postFiles="postFiles"
|
||||
/>
|
||||
</v-row>
|
||||
<v-row no-gutters class="align-center pt-6">
|
||||
<v-col>
|
||||
<v-textarea
|
||||
density="compact"
|
||||
label="Дополнительное описание"
|
||||
rows="3"
|
||||
variant="outlined"
|
||||
auto-grow
|
||||
v-model="propsEvent.event.description"
|
||||
class="scrollable-textarea pt-3"
|
||||
></v-textarea> </v-col
|
||||
></v-row>
|
||||
</v-row>
|
||||
</template>
|
||||
</dialog-create>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { axiosApiInstance } from '@/utils/axios-api';
|
||||
import { useAccountStore } from '@/store/AccountStore';
|
||||
import DialogCreate from '@/components/calendar_of_events/UI_calendar/dialogCreate.vue';
|
||||
import calendarCreateSelect from '@/components/calendar_of_events/calendar-create-select.vue';
|
||||
import TimeSelect from '@/components/calendar_of_events/UI_calendar/timeSelect.vue';
|
||||
import UploadingFile from '@/components/UI/defaultportal/uploading-file.vue';
|
||||
import ReminderEvent from '@/components/calendar_of_events/UI_calendar/reminderEvent.vue';
|
||||
import PeriodEvents from '@/components/calendar_of_events/UI_calendar/periodEvents.vue';
|
||||
import { useAlertStore } from '@/store/UseAlertStore';
|
||||
import { RRule } from 'rrule';
|
||||
import { useRecurrence } from '@/components/calendar_of_events/composables/useReccurrence';
|
||||
import { useCalendarStore } from '../../store/calendarStore';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
calendarCreateSelect,
|
||||
DialogCreate,
|
||||
TimeSelect,
|
||||
UploadingFile,
|
||||
ReminderEvent,
|
||||
PeriodEvents,
|
||||
},
|
||||
|
||||
props: {
|
||||
eventCalendar: {
|
||||
type: Object,
|
||||
default: () => {},
|
||||
},
|
||||
allCalendars: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
selectedRule: {
|
||||
type: Object,
|
||||
default: null,
|
||||
},
|
||||
},
|
||||
|
||||
setup(props, { emit }) {
|
||||
const accountStore = useAccountStore();
|
||||
const calendarStore = useCalendarStore();
|
||||
const createDialog = ref(null);
|
||||
|
||||
const { parseRecurrenceOptions, isRecurringEvent } = useRecurrence();
|
||||
|
||||
const propsEvent = computed({
|
||||
get: () => {
|
||||
return props.eventCalendar;
|
||||
},
|
||||
|
||||
set: (value) => emit('update:eventCalendar', value),
|
||||
});
|
||||
|
||||
const currentCalendarAuthorId = computed(() => {
|
||||
if (isNewEvent.value) {
|
||||
// Для нового события - автор текущего выбранного календаря
|
||||
return myCalendar.value?.author;
|
||||
} else {
|
||||
// Для существующего события - автор календаря события
|
||||
const eventCalendarId = propsEvent.value.event.calendar;
|
||||
const currentCalendar = propsEvent.value.mycalendars?.find(
|
||||
(cal) => parseInt(cal.id) === parseInt(eventCalendarId),
|
||||
);
|
||||
return currentCalendar?.author;
|
||||
}
|
||||
});
|
||||
|
||||
const newStaff = computed({
|
||||
get() {
|
||||
let filteredStaff = [];
|
||||
|
||||
if (isNewEvent.value) {
|
||||
if (myCalendar.value == null) return [];
|
||||
const participants = myCalendar.value.participant || [];
|
||||
const calendarParticipantIds = new Set(participants.map((p) => p.participant_calendar));
|
||||
|
||||
// Мутируем И фильтруем для НОВОГО события
|
||||
filteredStaff = calendarStore.employees
|
||||
.map((department) => {
|
||||
// ФИЛЬТРУЕМ сотрудников - оставляем только тех, кто в календаре
|
||||
const filteredEmployees = department.employees.filter((employee) =>
|
||||
calendarParticipantIds.has(employee.id),
|
||||
);
|
||||
|
||||
// МУТАЦИЯ: устанавливаем selected=true для отфильтрованных сотрудников
|
||||
filteredEmployees.forEach((employee) => {
|
||||
employee.selected = true;
|
||||
});
|
||||
|
||||
return {
|
||||
...department,
|
||||
employees: filteredEmployees,
|
||||
};
|
||||
})
|
||||
.filter((dept) => dept.employees.length > 0);
|
||||
} else {
|
||||
// СУЩЕСТВУЮЩЕЕ СОБЫТИЕ - фильтр по календарю
|
||||
const eventCalendarId = propsEvent.value.event.calendar;
|
||||
const currentCalendar = propsEvent.value.mycalendars?.find(
|
||||
(cal) => parseInt(cal.id) === parseInt(eventCalendarId),
|
||||
);
|
||||
|
||||
if (!currentCalendar?.participant) return [];
|
||||
|
||||
const calendarParticipantIds = new Set(currentCalendar.participant.map((p) => p.id));
|
||||
const eventParticipantIds = new Set(propsEvent.value.event.participant || []);
|
||||
|
||||
// Мутируем И фильтруем для СУЩЕСТВУЮЩЕГО события
|
||||
filteredStaff = calendarStore.employees
|
||||
.map((department) => {
|
||||
// ФИЛЬТРУЕМ сотрудников - оставляем только тех, кто в календаре
|
||||
const filteredEmployees = department.employees.filter((employee) =>
|
||||
calendarParticipantIds.has(employee.id),
|
||||
);
|
||||
|
||||
// МУТАЦИЯ: устанавливаем selected на основе участников события
|
||||
filteredEmployees.forEach((employee) => {
|
||||
employee.selected =
|
||||
employee.id === accountStore.user.is_idEmployee ||
|
||||
eventParticipantIds.has(employee.id);
|
||||
});
|
||||
|
||||
return {
|
||||
...department,
|
||||
employees: filteredEmployees,
|
||||
};
|
||||
})
|
||||
.filter((dept) => dept.employees.length > 0);
|
||||
}
|
||||
|
||||
return filteredStaff;
|
||||
},
|
||||
});
|
||||
|
||||
// ВАЛИДАЦИЯ
|
||||
const rules = {
|
||||
name: [
|
||||
(val) => !!val || 'Поле обязательно для заполнения',
|
||||
(val) => (val && val.length >= 3) || 'Минимум 3 символа',
|
||||
(val) => (val && val.length <= 100) || 'Максимум 100 символов',
|
||||
],
|
||||
calendar: [(val) => !!val || 'Выберите календарь'],
|
||||
};
|
||||
|
||||
const repeatRules = [
|
||||
{ type: 'Не повторять', rule: null, id: 1 },
|
||||
{
|
||||
type: 'Каждый день',
|
||||
rule: { freq: RRule.DAILY },
|
||||
id: 2,
|
||||
},
|
||||
{
|
||||
type: 'Каждую неделю',
|
||||
rule: { freq: RRule.WEEKLY },
|
||||
// По умолчанию - в тот же день недели, что и начальная дата
|
||||
getRule: (startDate) => {
|
||||
const day = new Date(startDate).getDay();
|
||||
// Преобразуем день недели в формат RRule (0 — понедельник)
|
||||
const byweekday = [day === 0 ? RRule.SU : day - 1];
|
||||
return { freq: RRule.WEEKLY, byweekday };
|
||||
},
|
||||
id: 3,
|
||||
},
|
||||
|
||||
{
|
||||
type: 'Каждый месяц',
|
||||
rule: { freq: RRule.MONTHLY },
|
||||
// По умолчанию - в тот же день месяца
|
||||
getRule: (startDate) => ({
|
||||
freq: RRule.MONTHLY,
|
||||
bymonthday: [new Date(startDate).getDate()],
|
||||
}),
|
||||
id: 4,
|
||||
},
|
||||
{
|
||||
type: 'Каждый квартал',
|
||||
rule: { freq: RRule.MONTHLY, interval: 3 },
|
||||
getRule: (startDate) => {
|
||||
const date = new Date(startDate);
|
||||
return {
|
||||
freq: RRule.MONTHLY,
|
||||
interval: 3, // каждые 3 месяца
|
||||
bymonthday: [date.getDate()],
|
||||
};
|
||||
},
|
||||
id: 6,
|
||||
},
|
||||
|
||||
{
|
||||
type: 'Каждый год',
|
||||
rule: { freq: RRule.YEARLY },
|
||||
// По умолчанию - в тот же день и месяц
|
||||
getRule: (startDate) => {
|
||||
const date = new Date(startDate);
|
||||
return {
|
||||
freq: RRule.YEARLY,
|
||||
bymonth: [date.getMonth() + 1],
|
||||
bymonthday: [date.getDate()],
|
||||
};
|
||||
},
|
||||
id: 5,
|
||||
},
|
||||
];
|
||||
|
||||
const selectedRule = ref(repeatRules[0]);
|
||||
const showRepeatEnd = ref(false);
|
||||
const repeatEndDate = ref(new Date());
|
||||
|
||||
// Инициализация повторов при редактировании
|
||||
const initializeRule = () => {
|
||||
if (!propsEvent.value.event.period) {
|
||||
selectedRule.value = repeatRules[0]; // "Не повторять"
|
||||
repeatEndDate.value = propsEvent.value.event.date_end
|
||||
? new Date(propsEvent.value.event.date_end)
|
||||
: new Date();
|
||||
return;
|
||||
}
|
||||
try {
|
||||
// Используем isRecurringEvent для проверки
|
||||
if (isRecurringEvent(propsEvent.value.event)) {
|
||||
// Парсим period с использованием parseRecurrenceOptions
|
||||
const rruleOptions = parseRecurrenceOptions(
|
||||
propsEvent.value.event.period,
|
||||
propsEvent.value.event.date_start,
|
||||
);
|
||||
|
||||
if (rruleOptions) {
|
||||
// ОБНОВЛЕННЫЙ ПОИСК ПРАВИЛА С ПОДДЕРЖКОЙ КВАРТАЛОВ
|
||||
let foundRule;
|
||||
|
||||
// Для квартальных событий (MONTHLY с interval=3)
|
||||
if (rruleOptions.freq === RRule.MONTHLY && rruleOptions.interval === 3) {
|
||||
foundRule = repeatRules.find((rule) => rule.id === 6); // ID квартального правила
|
||||
} else {
|
||||
// Для остальных типов - ищем по freq
|
||||
foundRule = repeatRules.find((rule) => rule.rule?.freq === rruleOptions.freq);
|
||||
}
|
||||
|
||||
selectedRule.value = foundRule || repeatRules[0];
|
||||
|
||||
// ВАЖНО: инициализируем repeatEndDate и showRepeatEnd
|
||||
if (rruleOptions.until) {
|
||||
// Если в RRULE есть UNTIL, используем эту дату
|
||||
repeatEndDate.value = new Date(rruleOptions.until);
|
||||
showRepeatEnd.value = true;
|
||||
} else {
|
||||
// Если нет UNTIL, используем date_end события
|
||||
repeatEndDate.value = propsEvent.value.event.date_end
|
||||
? new Date(propsEvent.value.event.date_end)
|
||||
: new Date();
|
||||
showRepeatEnd.value = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
selectedRule.value = repeatRules[0];
|
||||
showRepeatEnd.value = false;
|
||||
repeatEndDate.value = propsEvent.value.event.date_end
|
||||
? new Date(propsEvent.value.event.date_end)
|
||||
: new Date();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error parsing period:', error, 'Raw period:', propsEvent.value.event.period);
|
||||
selectedRule.value = repeatRules[0];
|
||||
showRepeatEnd.value = false;
|
||||
repeatEndDate.value = propsEvent.value.event.date_end
|
||||
? new Date(propsEvent.value.event.date_end)
|
||||
: new Date();
|
||||
}
|
||||
};
|
||||
|
||||
const isRepeatEndDisabled = computed(() => {
|
||||
return !selectedRule.value.rule; // disabled если правило null (не повторять)
|
||||
});
|
||||
|
||||
const feedalert = useAlertStore().alert;
|
||||
|
||||
const titleCard = computed(() => {
|
||||
if (propsEvent.value.event.hasOwnProperty('id')) {
|
||||
return 'Редактирование события';
|
||||
} else {
|
||||
return 'Новое событие';
|
||||
}
|
||||
});
|
||||
|
||||
const isNewEvent = computed(() => !propsEvent.value.event.hasOwnProperty('id'));
|
||||
|
||||
const myCalendar = ref(null);
|
||||
// const isNewEvent = computed(() => !propsEvent.value.event.id);
|
||||
|
||||
// Computed property с защитой от undefined
|
||||
// const safeCalendars = computed(() => props.allCalendars || []);
|
||||
|
||||
const safeCalendars = computed(() => {
|
||||
const userId = accountStore.user.is_idEmployee;
|
||||
|
||||
return (props.allCalendars || []).filter((calendar) => {
|
||||
// Пользователь - автор календаря (полные права)
|
||||
if (calendar.author === userId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Пользователь - участник с правами редактора
|
||||
const participant = calendar.participant?.find((p) => p.participant_calendar === userId);
|
||||
|
||||
return participant?.editor === true;
|
||||
});
|
||||
});
|
||||
|
||||
const isCalendarsReady = computed(() => safeCalendars.value.length > 0);
|
||||
|
||||
// Computed для календаря события
|
||||
const eventCalendar = computed(() => {
|
||||
if (!propsEvent.value?.event?.calendar || !safeCalendars.value.length) return null;
|
||||
return safeCalendars.value.find((cal) => cal.id === propsEvent.value.event.calendar);
|
||||
});
|
||||
|
||||
// Единоразовая инициализация при монтировании/получении данных
|
||||
const initializeCalendar = () => {
|
||||
if (myCalendar.value) return; // Уже инициализирован
|
||||
|
||||
// Приоритет 1: календарь из события (редактирование)
|
||||
if (eventCalendar.value) {
|
||||
myCalendar.value = eventCalendar.value;
|
||||
return;
|
||||
}
|
||||
|
||||
// Приоритет 2: первый доступный календарь (создание)
|
||||
if (safeCalendars.value.length > 0) {
|
||||
myCalendar.value = safeCalendars.value[0];
|
||||
}
|
||||
};
|
||||
|
||||
// Инициализируем когда все готово
|
||||
watch(
|
||||
[() => safeCalendars.value.length, () => propsEvent.value],
|
||||
() => {
|
||||
initializeCalendar();
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
// Дополнительная защита - вотчер только на смену самого календаря
|
||||
watch(eventCalendar, (newCalendar) => {
|
||||
if (newCalendar && newCalendar.id !== myCalendar.value?.id) {
|
||||
myCalendar.value = newCalendar;
|
||||
}
|
||||
});
|
||||
|
||||
const delEvent = (idev) => {
|
||||
axiosApiInstance.delete(`api/calendar_of_events/my_events/?delid=${idev}`).then((result) => {
|
||||
feedalert.alert = true;
|
||||
feedalert.text = result.data.mess;
|
||||
feedalert.ico = 'mdi-check';
|
||||
feedalert.color = 'orange-accent-1';
|
||||
emit('getCalendar');
|
||||
});
|
||||
emit('closeDialog');
|
||||
};
|
||||
|
||||
const newFiles = ref([]);
|
||||
|
||||
const handleFilesUpdate = (updatedExistingFiles) => {
|
||||
// Сохраняем новые файлы во временную переменную
|
||||
const currentNewFiles = [...newFiles.value];
|
||||
|
||||
// Обновляем существующие файлы
|
||||
propsEvent.value.event.files = updatedExistingFiles;
|
||||
|
||||
// Восстанавливаем новые файлы
|
||||
newFiles.value = currentNewFiles;
|
||||
};
|
||||
|
||||
const postFiles = (updatedFiles) => {
|
||||
newFiles.value = updatedFiles;
|
||||
};
|
||||
|
||||
const returnIdParticant = (idPart) => {
|
||||
idPart.staff.forEach((e) => {
|
||||
if (e.selected == true && !propsEvent.value.event.participant.includes(e.id)) {
|
||||
propsEvent.value.event.participant.push(e.id);
|
||||
} else {
|
||||
let ind = propsEvent.value.event.participant.findIndex((l) => l == e.id);
|
||||
|
||||
if (ind != -1) {
|
||||
propsEvent.value.event.participant.splice(ind, 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const cbSelect = (item, arr) => {
|
||||
item.forEach((e) => {
|
||||
if (!('employees' in e)) {
|
||||
if (!propsEvent.value.event.participant.includes(e.id)) {
|
||||
propsEvent.value.event.participant.push(e.id);
|
||||
}
|
||||
}
|
||||
if ('employees' in e) {
|
||||
cbSelect(e.employees);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const menudate = ref(false);
|
||||
|
||||
const postData = (validate) => {
|
||||
if (validate) {
|
||||
updatePeriodRule(selectedRule.value);
|
||||
propsEvent.value.event.calendar = myCalendar.value.id;
|
||||
|
||||
let postEvent = new FormData();
|
||||
|
||||
postEvent.append(
|
||||
'event',
|
||||
JSON.stringify({ ...propsEvent.value.event, files: propsEvent.value.event.files }),
|
||||
);
|
||||
|
||||
if (propsEvent.value.event.files !== null) {
|
||||
// newFiles.value.forEach((e) => postEvent.append('files', e));
|
||||
newFiles.value.forEach((file) => {
|
||||
postEvent.append('files', file, file.name);
|
||||
});
|
||||
}
|
||||
|
||||
axiosApiInstance.post('api/calendar_of_events/my_events/', postEvent).then((result) => {
|
||||
feedalert.alert = true;
|
||||
feedalert.text = result.data.mess;
|
||||
feedalert.ico = 'mdi-check';
|
||||
feedalert.color = 'green-darken-4';
|
||||
emit('getCalendar');
|
||||
emit('closeDialog');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const handleAutoAdjustEnd = (newEndDate) => {
|
||||
propsEvent.value.event.date_end = newEndDate;
|
||||
};
|
||||
|
||||
const updateRepeatEndDate = (date) => {
|
||||
repeatEndDate.value = date;
|
||||
updatePeriodRule(selectedRule.value); // Пересоздаем правило с новой датой
|
||||
};
|
||||
|
||||
watch(selectedRule, (newRule) => {
|
||||
if (!newRule.rule) {
|
||||
showRepeatEnd.value = false;
|
||||
repeatEndDate.value = null;
|
||||
}
|
||||
});
|
||||
|
||||
const updateDateStart = (newDate) => {
|
||||
// Нормализуем к ISO строке
|
||||
const normalizedDate = new Date(newDate).toISOString();
|
||||
propsEvent.value.event.date_start = normalizedDate;
|
||||
|
||||
// При изменении даты начала - обновляем правило повторений
|
||||
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(); // Тоже ISO
|
||||
}
|
||||
|
||||
if (selectedRule.value.rule) {
|
||||
updatePeriodRule(selectedRule.value);
|
||||
}
|
||||
};
|
||||
|
||||
const updateDateEnd = (newDate) => {
|
||||
// Нормализуем к ISO строке
|
||||
propsEvent.value.event.date_end = new Date(newDate).toISOString();
|
||||
};
|
||||
|
||||
// функция обновления периода
|
||||
const updatePeriodRule = (rule) => {
|
||||
selectedRule.value = rule;
|
||||
|
||||
if (!rule.rule) {
|
||||
propsEvent.value.event.period = null;
|
||||
return;
|
||||
}
|
||||
|
||||
const dtstart = new Date(propsEvent.value.event.date_start);
|
||||
|
||||
const ruleOptions = {
|
||||
...rule.rule,
|
||||
dtstart: dtstart,
|
||||
};
|
||||
|
||||
if (showRepeatEnd.value && repeatEndDate.value) {
|
||||
ruleOptions.until = new Date(repeatEndDate.value);
|
||||
}
|
||||
|
||||
if (rule.rule.freq === RRule.WEEKLY) {
|
||||
const day = new Date(propsEvent.value.event.date_start).getDay();
|
||||
// Преобразуем день недели в формат RRule (0 — понедельник)
|
||||
const byweekday = [day === 0 ? RRule.SU : day - 1];
|
||||
ruleOptions.byweekday = byweekday;
|
||||
}
|
||||
if (rule.rule.freq === RRule.MONTHLY) {
|
||||
ruleOptions.bymonthday = [new Date(propsEvent.value.event.date_start).getDate()];
|
||||
}
|
||||
if (rule.rule.freq === RRule.YEARLY) {
|
||||
const date = new Date(propsEvent.value.event.date_start);
|
||||
ruleOptions.bymonth = [date.getMonth() + 1];
|
||||
ruleOptions.bymonthday = [date.getDate()];
|
||||
}
|
||||
const rrule = new RRule(ruleOptions);
|
||||
|
||||
propsEvent.value.event.period = rrule.toString();
|
||||
};
|
||||
|
||||
watch(
|
||||
() => propsEvent.value.event?.period,
|
||||
(newPeriod) => {
|
||||
if (newPeriod) {
|
||||
initializeRule();
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
return {
|
||||
menudate,
|
||||
titleCard,
|
||||
propsEvent,
|
||||
newStaff,
|
||||
returnIdParticant,
|
||||
postFiles,
|
||||
postData,
|
||||
rules,
|
||||
delEvent,
|
||||
myCalendar,
|
||||
safeCalendars,
|
||||
isCalendarsReady,
|
||||
isNewEvent,
|
||||
currentCalendarAuthorId,
|
||||
isRepeatEndDisabled,
|
||||
|
||||
repeatRules,
|
||||
updatePeriodRule,
|
||||
selectedRule,
|
||||
updateDateEnd,
|
||||
updateDateStart,
|
||||
initializeRule,
|
||||
|
||||
createDialog,
|
||||
handleAutoAdjustEnd,
|
||||
newFiles,
|
||||
handleFilesUpdate,
|
||||
initializeCalendar,
|
||||
updateRepeatEndDate,
|
||||
showRepeatEnd,
|
||||
repeatEndDate,
|
||||
};
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.scrollable-textarea {
|
||||
overflow-y: auto;
|
||||
max-height: 160px;
|
||||
}
|
||||
|
||||
.scrollable-textarea::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
.scrollable-textarea::-webkit-scrollbar-track {
|
||||
background: #f1f1f1;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.scrollable-textarea::-webkit-scrollbar-thumb {
|
||||
background: #c1c1c1;
|
||||
border-radius: 1px;
|
||||
}
|
||||
|
||||
.scrollable-textarea::-webkit-scrollbar-thumb:hover {
|
||||
background: #a8a8a8;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user