fix [P-297]: модалка события для виджета календаря на главной
This commit is contained in:
1 parent
f268b7bad4
commit
6a200863be
13 files changed
+216
-668
No files matched your search
@@ -1,10 +1,12 @@
|
|||||||
<template>
|
<template>
|
||||||
<!-- Инициализация проекта -->
|
<!-- Инициализация проекта -->
|
||||||
<router-view />
|
<router-view />
|
||||||
|
<CalendarDialogs />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { useAccountStore } from '@/store/AccountStore';
|
import { useAccountStore } from '@/store/AccountStore';
|
||||||
|
import CalendarDialogs from './components/calendar_of_events/UI_calendar/CalendarDialogs.vue';
|
||||||
/**
|
/**
|
||||||
* Получаем информацию о юзере из стора.
|
* Получаем информацию о юзере из стора.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -382,15 +382,15 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.custom-file-input-wrapper {
|
.custom-file-input-wrapper {
|
||||||
border: 1px solid rgba(0, 0, 0, 0.38);
|
border: 1px solid rgba(var(--v-theme-on-surface), 0.38);
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
padding: 12px;
|
padding: 12px;
|
||||||
position: relative;
|
position: relative;
|
||||||
background-color: white;
|
background-color: rgb(var(--v-theme-surface));
|
||||||
}
|
}
|
||||||
|
|
||||||
.custom-file-input-wrapper:focus-within {
|
.custom-file-input-wrapper:focus-within {
|
||||||
border-color: #1976d2;
|
border-color: rgb(var(--v-theme-primary));
|
||||||
border-width: 2px;
|
border-width: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -418,10 +418,12 @@ export default {
|
|||||||
.placeholder {
|
.placeholder {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
color: rgba(0, 0, 0, 0.6);
|
color: rgba(var(--v-theme-on-surface), 0.6);
|
||||||
padding: 8px 0;
|
padding: 8px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.error-messages {
|
.error-messages {
|
||||||
margin-top: 4px;
|
margin-top: 4px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,225 +4,41 @@
|
|||||||
<mini-calendar />
|
<mini-calendar />
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col class="d-flex flex-column">
|
<v-col class="d-flex flex-column">
|
||||||
<custom-calendar
|
<custom-calendar :key="calendarKey" />
|
||||||
:key="calendarKey"
|
|
||||||
@openEventDialog="openEventDialog"
|
|
||||||
@openEventView="openEventView"
|
|
||||||
/>
|
|
||||||
</v-col>
|
</v-col>
|
||||||
|
|
||||||
<v-dialog v-model="showEventDialog" max-width="700">
|
|
||||||
<event-create
|
|
||||||
@closeDialog="closeEventDialog"
|
|
||||||
:eventCalendar="eventFromCalendar"
|
|
||||||
:allCalendars="allCalendars"
|
|
||||||
@getCalendar="getCalendar"
|
|
||||||
@update:eventCalendar="eventFromCalendar = $event"
|
|
||||||
ref="createEvents"
|
|
||||||
:key="eventKey"
|
|
||||||
/>
|
|
||||||
</v-dialog>
|
|
||||||
|
|
||||||
<event-calendar-show
|
|
||||||
v-model:show="showViewDialog"
|
|
||||||
:all-calendars="allCalendars"
|
|
||||||
:event-data="selectedEventForView"
|
|
||||||
@close="handleViewDialogClose"
|
|
||||||
:employees="calendarStore.employees"
|
|
||||||
/>
|
|
||||||
</v-row>
|
</v-row>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { ref, onMounted, watch, computed, provide } from 'vue';
|
import { ref, onMounted, watch } from 'vue';
|
||||||
import EventCreate from '@/components/calendar_of_events/event-create.vue';
|
|
||||||
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 { 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 { useCalendarStore } from '@/store/calendarStore';
|
||||||
import { useAccountStore } from '@/store/AccountStore';
|
import { useAccountStore } from '@/store/AccountStore';
|
||||||
import EventCalendarShow from '@/components/calendar_of_events/event-calendar-show.vue';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: { EventCreate, MiniCalendar, CustomCalendar, EventCalendarShow },
|
components: { MiniCalendar, CustomCalendar },
|
||||||
setup() {
|
setup() {
|
||||||
const selectdate = ref(new Date());
|
|
||||||
const MyYear = ref(selectdate.value.getFullYear());
|
|
||||||
const MyMonth = ref(selectdate.value.getMonth() + 1);
|
|
||||||
const calendarForMy = ref([]);
|
|
||||||
const eventFromCalendar = ref({});
|
|
||||||
const eventKey = ref(0);
|
|
||||||
const calendarKey = ref(0);
|
|
||||||
const miniCalendarRef = ref(null);
|
|
||||||
|
|
||||||
const calendarStore = useCalendarStore();
|
const calendarStore = useCalendarStore();
|
||||||
const accountStore = useAccountStore();
|
const accountStore = useAccountStore();
|
||||||
const showViewDialog = ref(false);
|
const calendarKey = ref(0);
|
||||||
const selectedEventForView = ref({});
|
|
||||||
|
|
||||||
const { selectedDate, showEventDialog } = storeToRefs(calendarStore); // синхронизируем с date-picker
|
|
||||||
|
|
||||||
const getMonth = (month) => {
|
|
||||||
MyMonth.value = month + 1;
|
|
||||||
};
|
|
||||||
const getYear = (year) => {
|
|
||||||
MyYear.value = year;
|
|
||||||
};
|
|
||||||
|
|
||||||
const getCalendar = () => {
|
|
||||||
calendarStore.loadCalendars();
|
|
||||||
};
|
|
||||||
|
|
||||||
const getDictEmployee = () => {
|
|
||||||
calendarStore.loadDictEmployees();
|
|
||||||
};
|
|
||||||
|
|
||||||
const getEmployees = () => {
|
|
||||||
calendarStore.loadEmployees();
|
|
||||||
};
|
|
||||||
|
|
||||||
const allCalendars = computed(() => [
|
|
||||||
...calendarStore.myCalendars,
|
|
||||||
...calendarStore.subscribedCalendars,
|
|
||||||
]);
|
|
||||||
|
|
||||||
const getEvent = (idEvent) => {
|
|
||||||
if (!idEvent) {
|
|
||||||
eventFromCalendar.value = createEmptyEvent();
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
axiosApiInstance.get(`api/calendar_of_events/my_events/?id=${idEvent}`).then((res) => {
|
|
||||||
eventFromCalendar.value = res.data;
|
|
||||||
calendarStore.openEventDialog();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const createEmptyEvent = () => ({
|
|
||||||
event: {
|
|
||||||
name: '',
|
|
||||||
participant: [accountStore.user.is_idEmployee],
|
|
||||||
files: [],
|
|
||||||
date_start: new Date().toISOString(),
|
|
||||||
date_end: new Date().toISOString(),
|
|
||||||
period: null,
|
|
||||||
description: '',
|
|
||||||
calendar: null,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const openEventDialog = (selectedEvent) => {
|
|
||||||
// Всегда сбрасываем данные перед открытием нового диалога
|
|
||||||
if (!selectedEvent) {
|
|
||||||
eventFromCalendar.value = createEmptyEvent();
|
|
||||||
eventKey.value++;
|
|
||||||
}
|
|
||||||
|
|
||||||
getEvent(selectedEvent?.event?.id);
|
|
||||||
calendarStore.openEventDialog();
|
|
||||||
};
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getEvent();
|
const currentYear = new Date().getFullYear();
|
||||||
calendarStore.fetchHolidays(MyYear.value);
|
calendarStore.fetchHolidays(currentYear);
|
||||||
getDictEmployee();
|
calendarStore.loadCalendars();
|
||||||
getCalendar();
|
calendarStore.loadDictEmployees();
|
||||||
getEmployees();
|
calendarStore.loadEmployees();
|
||||||
});
|
});
|
||||||
|
|
||||||
const closeEventDialog = () => {
|
|
||||||
calendarStore.closeEventDialog();
|
|
||||||
|
|
||||||
// При ручном закрытии сбрасываем данные сразу
|
|
||||||
setTimeout(() => {
|
|
||||||
eventFromCalendar.value = createEmptyEvent();
|
|
||||||
eventKey.value++;
|
|
||||||
}, 200);
|
|
||||||
};
|
|
||||||
|
|
||||||
const openCalendarCreate = () => {
|
|
||||||
miniCalendarRef.value?.openCalendarCreate();
|
|
||||||
};
|
|
||||||
|
|
||||||
provide('openCalendarCreate', openCalendarCreate);
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => calendarStore.showEventDialog,
|
|
||||||
(newValue, oldValue) => {
|
|
||||||
if (!newValue && oldValue) {
|
|
||||||
// Диалог был открыт и закрыт не через нашу кнопку
|
|
||||||
// Добавляем проверку чтобы не сбрасывать при инициализации
|
|
||||||
if (eventFromCalendar.value.event?.id) {
|
|
||||||
setTimeout(() => {
|
|
||||||
eventFromCalendar.value = createEmptyEvent();
|
|
||||||
eventKey.value++;
|
|
||||||
}, 200);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => accountStore.user?.id,
|
() => accountStore.user?.id,
|
||||||
(newUserId, oldUserId) => {
|
(newId, oldId) => {
|
||||||
if (newUserId !== oldUserId) {
|
if (newId !== oldId) calendarKey.value += 1;
|
||||||
console.log('User changed, forcing calendar recreation...');
|
|
||||||
calendarKey.value += 1; // Изменяем key для пересоздания компонента
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
const getEventForView = (idEvent) => {
|
return { calendarKey };
|
||||||
if (!idEvent) {
|
|
||||||
selectedEventForView.value = {};
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
axiosApiInstance.get(`api/calendar_of_events/my_events/?id=${idEvent}`).then((res) => {
|
|
||||||
selectedEventForView.value = res.data;
|
|
||||||
showViewDialog.value = true;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const openEventView = (eventId) => {
|
|
||||||
if (eventId) {
|
|
||||||
getEventForView(eventId);
|
|
||||||
} else {
|
|
||||||
console.log('❌ No event ID provided');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Закрытие модалки
|
|
||||||
const handleViewDialogClose = () => {
|
|
||||||
showViewDialog.value = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
return {
|
|
||||||
selectedDate,
|
|
||||||
getMonth,
|
|
||||||
getYear,
|
|
||||||
showEventDialog,
|
|
||||||
calendarForMy,
|
|
||||||
getCalendar,
|
|
||||||
getEvent,
|
|
||||||
eventFromCalendar,
|
|
||||||
calendarStore,
|
|
||||||
accountStore,
|
|
||||||
closeEventDialog,
|
|
||||||
openEventDialog,
|
|
||||||
createEmptyEvent,
|
|
||||||
eventKey,
|
|
||||||
getDictEmployee,
|
|
||||||
openEventView,
|
|
||||||
handleViewDialogClose,
|
|
||||||
showViewDialog,
|
|
||||||
selectedEventForView,
|
|
||||||
allCalendars,
|
|
||||||
eventKey,
|
|
||||||
calendarKey,
|
|
||||||
openCalendarCreate,
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
File renamed without changes.
+27
-1
@@ -91,7 +91,9 @@
|
|||||||
class="align-center pb-3 mb-3 border-bottom"
|
class="align-center pb-3 mb-3 border-bottom"
|
||||||
v-if="eventData.event?.period"
|
v-if="eventData.event?.period"
|
||||||
>
|
>
|
||||||
<v-col class="text-body-1 text-text_grey font-weight-medium" lg="3"> Повтор события </v-col>
|
<v-col class="text-body-1 text-text_grey font-weight-medium" lg="3">
|
||||||
|
Повтор события
|
||||||
|
</v-col>
|
||||||
<v-col>
|
<v-col>
|
||||||
<div class="text-body-1">{{ recurrenceText }}</div>
|
<div class="text-body-1">{{ recurrenceText }}</div>
|
||||||
</v-col>
|
</v-col>
|
||||||
@@ -155,6 +157,17 @@
|
|||||||
|
|
||||||
<!-- Кнопки -->
|
<!-- Кнопки -->
|
||||||
<v-card-actions class="justify-end pa-4 pt-0">
|
<v-card-actions class="justify-end pa-4 pt-0">
|
||||||
|
<v-btn
|
||||||
|
v-if="canEdit"
|
||||||
|
width="140"
|
||||||
|
color="btn_text"
|
||||||
|
variant="elevated"
|
||||||
|
prepend-icon="mdi-pencil"
|
||||||
|
class="text-body-1"
|
||||||
|
@click="onEdit"
|
||||||
|
>
|
||||||
|
Редактировать
|
||||||
|
</v-btn>
|
||||||
<v-btn
|
<v-btn
|
||||||
width="120"
|
width="120"
|
||||||
@click="closeDialog"
|
@click="closeDialog"
|
||||||
@@ -173,6 +186,7 @@
|
|||||||
import { computed, ref, watch } from 'vue';
|
import { computed, ref, watch } from 'vue';
|
||||||
import { useRecurrence } from '@/components/calendar_of_events/composables/useReccurrence';
|
import { useRecurrence } from '@/components/calendar_of_events/composables/useReccurrence';
|
||||||
import { RRule } from 'rrule';
|
import { RRule } from 'rrule';
|
||||||
|
import { useCalendarStore } from '../../store/calendarStore';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'EventCalendarShow',
|
name: 'EventCalendarShow',
|
||||||
@@ -201,6 +215,7 @@ export default {
|
|||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
const internalShow = ref(props.show);
|
const internalShow = ref(props.show);
|
||||||
const { parseRecurrenceOptions, isRecurringEvent } = useRecurrence();
|
const { parseRecurrenceOptions, isRecurringEvent } = useRecurrence();
|
||||||
|
const calendarStore = useCalendarStore();
|
||||||
|
|
||||||
// Синхронизация с внешним состоянием
|
// Синхронизация с внешним состоянием
|
||||||
watch(
|
watch(
|
||||||
@@ -456,6 +471,15 @@ export default {
|
|||||||
return `${nameWithoutExt.slice(0, 20)}...${extension ? '.' + extension : ''}`;
|
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 {
|
return {
|
||||||
internalShow,
|
internalShow,
|
||||||
closeDialog,
|
closeDialog,
|
||||||
@@ -470,6 +494,8 @@ export default {
|
|||||||
truncateFileName,
|
truncateFileName,
|
||||||
showRepeatEnd,
|
showRepeatEnd,
|
||||||
formatRepeatEndDate,
|
formatRepeatEndDate,
|
||||||
|
canEdit,
|
||||||
|
onEdit
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<template>
|
||||||
|
<v-dialog v-model="calendarStore.showEventDialog" max-width="700">
|
||||||
|
<event-create
|
||||||
|
v-if="calendarStore.showEventDialog"
|
||||||
|
:eventCalendar="calendarStore.selectedEvent"
|
||||||
|
:allCalendars="calendarStore.calendars"
|
||||||
|
@closeDialog="calendarStore.closeEventDialog"
|
||||||
|
@getCalendar="calendarStore.loadCalendars"
|
||||||
|
@update:eventCalendar="calendarStore.setSelectedEvent"
|
||||||
|
/>
|
||||||
|
</v-dialog>
|
||||||
|
|
||||||
|
<event-show
|
||||||
|
v-model:show="calendarStore.showViewDialog"
|
||||||
|
:all-calendars="calendarStore.calendars"
|
||||||
|
:event-data="calendarStore.selectedEventForView"
|
||||||
|
:employees="calendarStore.employees"
|
||||||
|
@close="calendarStore.closeEventView"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { useCalendarStore } from '@/store/calendarStore';
|
||||||
|
|
||||||
|
import EventCreate from '../EventCreate.vue';
|
||||||
|
import EventShow from '../EventShow.vue';
|
||||||
|
|
||||||
|
const calendarStore = useCalendarStore();
|
||||||
|
</script>
|
||||||
@@ -107,8 +107,6 @@ import { useEventListFilters } from '../composables/useEventListFilters';
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'CustomCalendar',
|
name: 'CustomCalendar',
|
||||||
|
|
||||||
emits: ['openEventDialog', 'openEventView'],
|
|
||||||
components: {
|
components: {
|
||||||
EventsListView,
|
EventsListView,
|
||||||
EventListFilters,
|
EventListFilters,
|
||||||
@@ -119,7 +117,7 @@ export default {
|
|||||||
view: { type: String, default: 'dayGridMonth' },
|
view: { type: String, default: 'dayGridMonth' },
|
||||||
},
|
},
|
||||||
|
|
||||||
setup(props, { emit }) {
|
setup(props) {
|
||||||
const currentView = ref('dayGridMonth');
|
const currentView = ref('dayGridMonth');
|
||||||
const currentTitle = ref('Календарь');
|
const currentTitle = ref('Календарь');
|
||||||
const calendarRef = ref(null);
|
const calendarRef = ref(null);
|
||||||
@@ -142,11 +140,7 @@ export default {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
const handleEventClick = (info) => {
|
const handleEventClick = (info) => {
|
||||||
if (calendarStore.canEditEvent(info.event.id)) {
|
calendarStore.handleEventClick(info);
|
||||||
emit('openEventDialog', info);
|
|
||||||
} else {
|
|
||||||
emit('openEventView', info.event.id);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const calendarOptions = ref({
|
const calendarOptions = ref({
|
||||||
@@ -621,6 +615,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
:deep(.grey-background),
|
:deep(.grey-background),
|
||||||
|
:deep(.fc-daygrid-day),
|
||||||
:deep(.fc-day.grey-background) {
|
:deep(.fc-day.grey-background) {
|
||||||
background-color: rgb(var(--v-theme-weekend_bg)) !important;
|
background-color: rgb(var(--v-theme-weekend_bg)) !important;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -332,7 +332,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.event-item:hover {
|
.event-item:hover {
|
||||||
background-color: #f5f5f5;
|
background-color: rgba(var(--v-theme-on-surface), 0.08);
|
||||||
transition: background-color 0.2s;
|
transition: background-color 0.2s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -69,6 +69,7 @@
|
|||||||
:key="event.id"
|
:key="event.id"
|
||||||
class="schedule-item"
|
class="schedule-item"
|
||||||
:class="{ 'current-event': isCurrentEvent(event) }"
|
:class="{ 'current-event': isCurrentEvent(event) }"
|
||||||
|
@click="handleEventClick(event)"
|
||||||
>
|
>
|
||||||
<template #prepend>
|
<template #prepend>
|
||||||
<div
|
<div
|
||||||
@@ -348,6 +349,10 @@ export default {
|
|||||||
return dayInfo.isHoliday || dayInfo.isWeekendForStyling;
|
return dayInfo.isHoliday || dayInfo.isWeekendForStyling;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleEventClick = (event) => {
|
||||||
|
calendarStore.handleEventClick({ event: { id: event.id } });
|
||||||
|
};
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
selectedDate.value = formatToLocalDate(new Date());
|
selectedDate.value = formatToLocalDate(new Date());
|
||||||
await calendarStore.fetchHolidays(currentYear);
|
await calendarStore.fetchHolidays(currentYear);
|
||||||
@@ -381,6 +386,7 @@ export default {
|
|||||||
allEvents,
|
allEvents,
|
||||||
expandMultiDayInstance,
|
expandMultiDayInstance,
|
||||||
formatForWidget,
|
formatForWidget,
|
||||||
|
handleEventClick,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -455,19 +461,6 @@ export default {
|
|||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
.day-cell.today {
|
|
||||||
background-color: rgba(var(--v-theme-primary), 0.15);
|
|
||||||
}
|
|
||||||
|
|
||||||
.day-cell.selected {
|
|
||||||
background-color: rgb(var(--v-theme-btn_text));
|
|
||||||
color: rgb(var(--v-theme-bg_white));
|
|
||||||
}
|
|
||||||
|
|
||||||
.day-cell.selected .day-number {
|
|
||||||
color: rgb(var(--v-theme-bg_white));
|
|
||||||
}
|
|
||||||
|
|
||||||
.day-content {
|
.day-content {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@@ -547,7 +540,6 @@ export default {
|
|||||||
.event-time {
|
.event-time {
|
||||||
font-size: 0.8rem;
|
font-size: 0.8rem;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: #302f2f;
|
|
||||||
color: rgb(var(--v-theme-text_carous));
|
color: rgb(var(--v-theme-text_carous));
|
||||||
margin-bottom: 2px;
|
margin-bottom: 2px;
|
||||||
}
|
}
|
||||||
@@ -573,17 +565,17 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.day-schedule::-webkit-scrollbar-track {
|
.day-schedule::-webkit-scrollbar-track {
|
||||||
background: #f1f1f1;
|
background: rgba(var(--v-theme-on-surface), 0.05);
|
||||||
border-radius: 0 8px 8px 0;
|
border-radius: 0 8px 8px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.day-schedule::-webkit-scrollbar-thumb {
|
.day-schedule::-webkit-scrollbar-thumb {
|
||||||
background: #c1c1c1;
|
background: rgba(var(--v-theme-on-surface), 0.25);
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.day-schedule::-webkit-scrollbar-thumb:hover {
|
.day-schedule::-webkit-scrollbar-thumb:hover {
|
||||||
background: #a8a8a8;
|
background: rgba(var(--v-theme-on-surface), 0.4);
|
||||||
}
|
}
|
||||||
|
|
||||||
.non-working-day {
|
.non-working-day {
|
||||||
@@ -598,4 +590,15 @@ export default {
|
|||||||
.day-cell:not(.current-month).non-working-day {
|
.day-cell:not(.current-month).non-working-day {
|
||||||
color: inherit !important;
|
color: inherit !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.day-cell.selected,
|
||||||
|
.day-cell.selected.grey-background,
|
||||||
|
.day-cell.selected.non-working-day {
|
||||||
|
background-color: rgb(var(--v-theme-btn_text)) !important;
|
||||||
|
color: rgb(var(--v-theme-bg_white)) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.day-cell.selected .day-number {
|
||||||
|
color: rgb(var(--v-theme-bg_white)) !important;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -1,402 +0,0 @@
|
|||||||
<template>
|
|
||||||
<v-locale-provider locale="ru">
|
|
||||||
<v-calendar
|
|
||||||
ref="calendar"
|
|
||||||
:events="returnPeriod"
|
|
||||||
:view-mode="type"
|
|
||||||
:month="monthNow"
|
|
||||||
:year="YearNow"
|
|
||||||
:model-value="selectDay"
|
|
||||||
class="h-100"
|
|
||||||
>
|
|
||||||
<template v-slot:header>
|
|
||||||
<v-col class="d-flex flex-column">
|
|
||||||
<v-row no-gutters class="gap">
|
|
||||||
<v-col class="flex-grow-0" lg="2">
|
|
||||||
<v-btn
|
|
||||||
class="text-subtitle-1"
|
|
||||||
variant="outlined"
|
|
||||||
@click="todayDay"
|
|
||||||
>
|
|
||||||
Сегодня
|
|
||||||
</v-btn>
|
|
||||||
<v-btn icon="mdi-menu-left" variant="text" @click="returnDate" />
|
|
||||||
|
|
||||||
<v-btn icon="mdi-menu-right" variant="text" @click="nextDay" />
|
|
||||||
</v-col>
|
|
||||||
<v-col class="text-h6 align-self-center ml-n6">
|
|
||||||
<span class="text-capitalize">
|
|
||||||
{{ getMonthName(monthNow + 1) }}
|
|
||||||
</span>
|
|
||||||
|
|
||||||
{{ YearNow }} г.
|
|
||||||
</v-col>
|
|
||||||
<v-col class="text-end align-self-center">
|
|
||||||
<v-btn
|
|
||||||
v-for="x in types"
|
|
||||||
:key="x"
|
|
||||||
:active="type != null && type == x.type"
|
|
||||||
variant="text"
|
|
||||||
@click="switchCalendar(x.type)"
|
|
||||||
class="text-subtitle-1"
|
|
||||||
:color="
|
|
||||||
type != null && type == x.type ? 'btn_text' : 'text_grey'
|
|
||||||
"
|
|
||||||
>
|
|
||||||
{{ x.text }}
|
|
||||||
</v-btn>
|
|
||||||
</v-col>
|
|
||||||
</v-row>
|
|
||||||
</v-col>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template v-slot:event="{ day, event }">
|
|
||||||
<v-chip
|
|
||||||
v-show="
|
|
||||||
(!event.disable &&
|
|
||||||
new Date(day.date).setHours(0, 0, 0, 0) !=
|
|
||||||
new Date(event.end).setHours(0, 0, 0, 0)) ||
|
|
||||||
(event.disable &&
|
|
||||||
!(
|
|
||||||
new Date(day.date).setHours(0, 0, 0, 0) !=
|
|
||||||
new Date(event.end).setHours(0, 0, 0, 0)
|
|
||||||
))
|
|
||||||
"
|
|
||||||
class="w-100"
|
|
||||||
density="compact"
|
|
||||||
:class="funRoundet(event, day)"
|
|
||||||
:color="event.color"
|
|
||||||
@click="whatDay(event)"
|
|
||||||
>
|
|
||||||
{{ event.title }}
|
|
||||||
</v-chip>
|
|
||||||
</template>
|
|
||||||
</v-calendar>
|
|
||||||
</v-locale-provider>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import { ref, computed } from "vue";
|
|
||||||
import { RRule } from "rrule";
|
|
||||||
|
|
||||||
export default {
|
|
||||||
props: {
|
|
||||||
allEvent: {
|
|
||||||
type: Object,
|
|
||||||
default: () => {},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
setup(props, { emit }) {
|
|
||||||
const type = ref("month");
|
|
||||||
const types = [
|
|
||||||
{ type: "day", text: "День" },
|
|
||||||
{ type: "week", text: "Неделя" },
|
|
||||||
{ type: "month", text: "Месяц" },
|
|
||||||
// { type: "modntdh", text: "Год" },
|
|
||||||
{ type: "modnth", text: "Расписание" },
|
|
||||||
];
|
|
||||||
|
|
||||||
const switchCalendar = (t) => {
|
|
||||||
type.value = t;
|
|
||||||
};
|
|
||||||
|
|
||||||
const propsAllEvent = computed({
|
|
||||||
get: () => props.allEvent,
|
|
||||||
set: (value) => emit("update:allEvent", value),
|
|
||||||
});
|
|
||||||
|
|
||||||
const returnPeriod = computed({
|
|
||||||
get() {
|
|
||||||
let select = [];
|
|
||||||
|
|
||||||
propsAllEvent.value.forEach((e) => {
|
|
||||||
e.events.forEach((i) => {
|
|
||||||
if (i.period == null && new Date(i.date_end) > dayNextMonth.value)
|
|
||||||
i.date_end = dayNextMonth.value;
|
|
||||||
|
|
||||||
let objRule = JSON.parse(i.period);
|
|
||||||
|
|
||||||
|
|
||||||
if (objRule != null) {
|
|
||||||
let startnew =
|
|
||||||
objRule.origOptions.dtstart.split("T")[1].split(":")[0] != 21 &&
|
|
||||||
i.allday == false
|
|
||||||
? new Date(objRule.origOptions.dtstart)
|
|
||||||
: new Date(objRule.origOptions.dtstart.split("T")[0]);
|
|
||||||
|
|
||||||
let rule = new RRule({
|
|
||||||
...objRule.origOptions,
|
|
||||||
|
|
||||||
dtstart: new Date(startnew),
|
|
||||||
until:
|
|
||||||
"until" in objRule.origOptions
|
|
||||||
? new Date(objRule.origOptions.until)
|
|
||||||
: dayNextMonth.value,
|
|
||||||
});
|
|
||||||
|
|
||||||
let actRule = rule.all();
|
|
||||||
|
|
||||||
let lastDateMonth = new Date(
|
|
||||||
new Date(dayNextMonth.value).setDate(
|
|
||||||
new Date(dayNextMonth.value).getDate() - 1
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
actRule
|
|
||||||
.filter(
|
|
||||||
(date) =>
|
|
||||||
new Date(date).getMonth() ===
|
|
||||||
new Date(lastDateMonth).getMonth() &&
|
|
||||||
new Date(date).getYear() ===
|
|
||||||
new Date(lastDateMonth).getYear()
|
|
||||||
)
|
|
||||||
.forEach((r) => {
|
|
||||||
let ev = {
|
|
||||||
rule: objRule.origOptions,
|
|
||||||
title: i.name,
|
|
||||||
color: e.cl_color,
|
|
||||||
start: new Date(r),
|
|
||||||
start_event: new Date(i.date_start),
|
|
||||||
end: new Date(i.date_end),
|
|
||||||
id: i.id,
|
|
||||||
disable:
|
|
||||||
new Date(r).setHours(0, 0, 0, 0) ==
|
|
||||||
new Date(i.date_end).setHours(0, 0, 0, 0),
|
|
||||||
};
|
|
||||||
|
|
||||||
select.push(ev);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
let dates = getDatesBetweenDates(
|
|
||||||
new Date(i.date_start),
|
|
||||||
new Date(i.date_end)
|
|
||||||
);
|
|
||||||
|
|
||||||
dates.forEach((d) => {
|
|
||||||
let ev = {
|
|
||||||
rule: "",
|
|
||||||
title: i.name,
|
|
||||||
color: e.cl_color,
|
|
||||||
start: new Date(d),
|
|
||||||
end: new Date(i.date_end),
|
|
||||||
id: i.id,
|
|
||||||
disable:
|
|
||||||
new Date(d).setHours(0, 0, 0, 0) ==
|
|
||||||
new Date(i.date_end).setHours(0, 0, 0, 0),
|
|
||||||
};
|
|
||||||
select.push(ev);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
return select;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const getDatesBetweenDates = (startDate, endDate) => {
|
|
||||||
let dates = [];
|
|
||||||
let currentDate = new Date(startDate);
|
|
||||||
|
|
||||||
while (currentDate <= endDate) {
|
|
||||||
dates.push(new Date(currentDate));
|
|
||||||
currentDate.setDate(currentDate.getDate() + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return dates;
|
|
||||||
};
|
|
||||||
|
|
||||||
const selectDay = ref([new Date()]);
|
|
||||||
const monthNow = ref(new Date().getMonth());
|
|
||||||
const YearNow = ref(new Date().getFullYear());
|
|
||||||
const endWeek = computed({
|
|
||||||
get() {
|
|
||||||
return 8 - new Date(selectDay.value).getDay();
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const returnDate = () => {
|
|
||||||
if (type.value == "month") {
|
|
||||||
if (monthNow.value != 0) {
|
|
||||||
monthNow.value--;
|
|
||||||
} else {
|
|
||||||
monthNow.value = 11;
|
|
||||||
YearNow.value -= 1;
|
|
||||||
}
|
|
||||||
} else if (type.value == "day") {
|
|
||||||
selectDay.value = new Date(
|
|
||||||
new Date(selectDay.value).setDate(
|
|
||||||
new Date(selectDay.value).getDate() - 1
|
|
||||||
)
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
selectDay.value = new Date(
|
|
||||||
new Date(selectDay.value).setDate(
|
|
||||||
new Date(selectDay.value).getDate() - endWeek.value
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const nextDay = () => {
|
|
||||||
if (type.value == "month") {
|
|
||||||
if (monthNow.value < 11) {
|
|
||||||
monthNow.value++;
|
|
||||||
} else {
|
|
||||||
monthNow.value = 0;
|
|
||||||
YearNow.value += 1;
|
|
||||||
}
|
|
||||||
} else if (type.value == "day") {
|
|
||||||
selectDay.value = new Date(
|
|
||||||
new Date(selectDay.value).setDate(
|
|
||||||
new Date(selectDay.value).getDate() + 1
|
|
||||||
)
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
selectDay.value = new Date(
|
|
||||||
new Date(selectDay.value).setDate(
|
|
||||||
new Date(selectDay.value).getDate() + endWeek.value
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const todayDay = () => {
|
|
||||||
monthNow.value = new Date().getMonth();
|
|
||||||
YearNow.value = new Date().getFullYear();
|
|
||||||
selectDay.value = new Date();
|
|
||||||
};
|
|
||||||
|
|
||||||
const getMonthName = (monthNumber) => {
|
|
||||||
const date = new Date();
|
|
||||||
date.setMonth(monthNumber - 1);
|
|
||||||
|
|
||||||
return date.toLocaleString("ru", {
|
|
||||||
month: "long",
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const whatDay = (e) => {
|
|
||||||
emit("getEvent", e.id);
|
|
||||||
};
|
|
||||||
|
|
||||||
const zeroTime = (date) => {
|
|
||||||
return new Date(date).setHours(0, 0, 0, 0);
|
|
||||||
};
|
|
||||||
|
|
||||||
const funRoundet = (ev, day) => {
|
|
||||||
|
|
||||||
if (ev.rule.freq == 3) {
|
|
||||||
if (
|
|
||||||
zeroTime(day.date) != zeroTime(ev.start_event) &&
|
|
||||||
zeroTime(day.date) != zeroTime(ev.end)
|
|
||||||
) {
|
|
||||||
return "rounded-sm";
|
|
||||||
} else if (
|
|
||||||
zeroTime(day.date) == zeroTime(ev.start_event) &&
|
|
||||||
zeroTime(day.date) == zeroTime(ev.end)
|
|
||||||
) {
|
|
||||||
return "";
|
|
||||||
} else if (zeroTime(day.date) != zeroTime(ev.start_event)) {
|
|
||||||
return "rounded-s-lg";
|
|
||||||
} else if (zeroTime(day.date) == zeroTime(ev.start_event)) {
|
|
||||||
return "rounded-e-lg";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ev.rule.freq == 2) {
|
|
||||||
let weeknumS =
|
|
||||||
ev.rule.byweekday[0].weekday == 6
|
|
||||||
? 0
|
|
||||||
: ev.rule.byweekday[0].weekday + 1;
|
|
||||||
let weeknumE =
|
|
||||||
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) {
|
|
||||||
return "rounded-s-lg";
|
|
||||||
} else if (
|
|
||||||
day.date.getDay() != weeknumS &&
|
|
||||||
day.date.getDay() != weeknumE
|
|
||||||
) {
|
|
||||||
return "rounded-sm";
|
|
||||||
} else {
|
|
||||||
return "rounded-lg";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
if (ev.rule.freq == 0) {
|
|
||||||
if (zeroTime(day.date) == zeroTime(ev.start_event)) {
|
|
||||||
return "rounded-e-lg"
|
|
||||||
}
|
|
||||||
// let weeknumS =
|
|
||||||
// ev.rule.byweekday[0].weekday == 6
|
|
||||||
// ? 0
|
|
||||||
// : ev.rule.byweekday[0].weekday + 1;
|
|
||||||
// let weeknumE =
|
|
||||||
// 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) {
|
|
||||||
// return "rounded-s-lg";
|
|
||||||
// } else if (
|
|
||||||
// day.date.getDay() != weeknumS &&
|
|
||||||
// day.date.getDay() != weeknumE
|
|
||||||
// ) {
|
|
||||||
// return "rounded-sm";
|
|
||||||
// } else {
|
|
||||||
// return "rounded-lg";
|
|
||||||
// }
|
|
||||||
|
|
||||||
return "rounded-sm"
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const dayNextMonth = computed({
|
|
||||||
get() {
|
|
||||||
const firstDayOfNextMonth = new Date(
|
|
||||||
YearNow.value,
|
|
||||||
monthNow.value + 1,
|
|
||||||
1
|
|
||||||
);
|
|
||||||
|
|
||||||
return firstDayOfNextMonth;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
|
||||||
type,
|
|
||||||
types,
|
|
||||||
switchCalendar,
|
|
||||||
|
|
||||||
monthNow,
|
|
||||||
YearNow,
|
|
||||||
returnDate,
|
|
||||||
getMonthName,
|
|
||||||
propsAllEvent,
|
|
||||||
whatDay,
|
|
||||||
nextDay,
|
|
||||||
todayDay,
|
|
||||||
selectDay,
|
|
||||||
returnPeriod,
|
|
||||||
funRoundet,
|
|
||||||
dayNextMonth,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
.v-calendar__container {
|
|
||||||
overflow: auto;
|
|
||||||
height: 87vh;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -27,16 +27,10 @@
|
|||||||
<v-col v-for="(x, key) in color" :key="key">
|
<v-col v-for="(x, key) in color" :key="key">
|
||||||
<v-avatar
|
<v-avatar
|
||||||
class="cursor-pointer"
|
class="cursor-pointer"
|
||||||
|
:class="{ 'avatar-dimmed': propsCalendar.cl_color && propsCalendar.cl_color !== x }"
|
||||||
@click="colorPik(x, key)"
|
@click="colorPik(x, key)"
|
||||||
size="x-small"
|
size="x-small"
|
||||||
:color="x"
|
:color="x"
|
||||||
:variant="
|
|
||||||
propsCalendar.cl_color === null
|
|
||||||
? 'flat'
|
|
||||||
: propsCalendar.cl_color === x
|
|
||||||
? 'flat'
|
|
||||||
: 'tonal'
|
|
||||||
"
|
|
||||||
/> </v-col
|
/> </v-col
|
||||||
></v-row>
|
></v-row>
|
||||||
|
|
||||||
@@ -235,23 +229,6 @@ export default {
|
|||||||
'#22c55e', // Зеленый
|
'#22c55e', // Зеленый
|
||||||
];
|
];
|
||||||
|
|
||||||
// const color = [
|
|
||||||
// '#3b82f6', // Синий
|
|
||||||
// '#10b981', // Зеленый
|
|
||||||
// '#dc2626', // Красный
|
|
||||||
// '#d97706', // Оранжевый
|
|
||||||
// '#7c3aed', // Фиолетовый
|
|
||||||
// '#0ea5e9', // Голубой
|
|
||||||
// '#84cc16', // Лаймовый
|
|
||||||
// '#f59e0b', // Янтарный
|
|
||||||
// '#8b5cf6', // Пурпурный
|
|
||||||
// '#06b6d4', // Бирюзовый
|
|
||||||
// '#f97316', // Теплый оранжевый
|
|
||||||
// '#6366f1', // Фиолетово-синий
|
|
||||||
// '#14b8a6', // Морской волны
|
|
||||||
// '#ec4899', // Розовый
|
|
||||||
// '#64748b', // Серо-синий
|
|
||||||
// ];
|
|
||||||
const colorPik = (col) => {
|
const colorPik = (col) => {
|
||||||
if (propsCalendar.value.cl_color === col) {
|
if (propsCalendar.value.cl_color === col) {
|
||||||
propsCalendar.value.cl_color = null;
|
propsCalendar.value.cl_color = null;
|
||||||
@@ -299,4 +276,13 @@ export default {
|
|||||||
.custom-tooltip {
|
.custom-tooltip {
|
||||||
max-width: 350px; /* Установка максимальной ширины для подсказки */
|
max-width: 350px; /* Установка максимальной ширины для подсказки */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.avatar-dimmed {
|
||||||
|
opacity: 0.45;
|
||||||
|
transition: opacity 0.15s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avatar-dimmed:hover {
|
||||||
|
opacity: 0.8;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -9,8 +9,6 @@ export const useCalendarStore = defineStore('calendarStore', () => {
|
|||||||
// State
|
// State
|
||||||
const selectedDate = ref(new Date());
|
const selectedDate = ref(new Date());
|
||||||
const events = ref([]);
|
const events = ref([]);
|
||||||
const selectedEvent = ref(null);
|
|
||||||
const showEventDialog = ref(false);
|
|
||||||
const currentView = ref('dayGridMonth'); // Текущий вид календаря
|
const currentView = ref('dayGridMonth'); // Текущий вид календаря
|
||||||
const calendars = ref([]); // Список календарей пользователя
|
const calendars = ref([]); // Список календарей пользователя
|
||||||
const lastUpdatedBy = ref(null);
|
const lastUpdatedBy = ref(null);
|
||||||
@@ -20,6 +18,11 @@ export const useCalendarStore = defineStore('calendarStore', () => {
|
|||||||
const dictEmployeesLoaded = ref(false);
|
const dictEmployeesLoaded = ref(false);
|
||||||
const employees = ref([]);
|
const employees = ref([]);
|
||||||
|
|
||||||
|
const selectedEvent = ref(null);
|
||||||
|
const showEventDialog = ref(false);
|
||||||
|
const selectedEventForView = ref(null);
|
||||||
|
const showViewDialog = ref(false);
|
||||||
|
|
||||||
// Массив ID скрытых календарей. Загружаем из localStorage при инициализации.
|
// Массив ID скрытых календарей. Загружаем из localStorage при инициализации.
|
||||||
const hiddenCalendarIds = ref([]);
|
const hiddenCalendarIds = ref([]);
|
||||||
|
|
||||||
@@ -175,7 +178,7 @@ export const useCalendarStore = defineStore('calendarStore', () => {
|
|||||||
return editableEvents.value.some((e) => e.id === id);
|
return editableEvents.value.some((e) => e.id === id);
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchHolidays = async (year) => {
|
const fetchHolidays = async (year) => {
|
||||||
if (holidays.value[year] || loadingYears.value.has(year)) {
|
if (holidays.value[year] || loadingYears.value.has(year)) {
|
||||||
return holidays.value[year];
|
return holidays.value[year];
|
||||||
}
|
}
|
||||||
@@ -192,11 +195,10 @@ const fetchHolidays = async (year) => {
|
|||||||
} finally {
|
} finally {
|
||||||
loadingYears.value.delete(year);
|
loadingYears.value.delete(year);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Метод для проверки, является ли день выходным или праздничным
|
// Метод для проверки, является ли день выходным или праздничным
|
||||||
const isNonWorkingDay = (dateInput) => {
|
const isNonWorkingDay = (dateInput) => {
|
||||||
const date = dateInput instanceof Date ? dateInput : new Date(dateInput);
|
const date = dateInput instanceof Date ? dateInput : new Date(dateInput);
|
||||||
if (isNaN(date.getTime())) {
|
if (isNaN(date.getTime())) {
|
||||||
return { isNonWorking: false, isWeekendForStyling: false, isHoliday: false };
|
return { isNonWorking: false, isWeekendForStyling: false, isHoliday: false };
|
||||||
@@ -215,20 +217,102 @@ const isNonWorkingDay = (dateInput) => {
|
|||||||
isWeekendForStyling: isWeekend,
|
isWeekendForStyling: isWeekend,
|
||||||
isHoliday,
|
isHoliday,
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
// Открыть диалог создания/редактирования
|
|
||||||
const openEventDialog = (event = null) => {
|
|
||||||
selectedEvent.value = event;
|
|
||||||
showEventDialog.value = true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Закрыть диалог
|
const setSelectedEvent = (event) => {
|
||||||
|
selectedEvent.value = event;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Шаблон пустого события (создание)
|
||||||
|
const getEmptyEventWrapper = () => {
|
||||||
|
const now = new Date();
|
||||||
|
const inHour = new Date(now.getTime() + 60 * 60 * 1000);
|
||||||
|
return {
|
||||||
|
event: {
|
||||||
|
name: '',
|
||||||
|
description: '',
|
||||||
|
date_start: now.toISOString(),
|
||||||
|
date_end: inHour.toISOString(),
|
||||||
|
allday: false,
|
||||||
|
period: null,
|
||||||
|
participant: [accountStore.user.is_idEmployee],
|
||||||
|
calendar: null,
|
||||||
|
files: [],
|
||||||
|
},
|
||||||
|
mycalendars: calendars.value,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
// Шаблон обёртки для редактирования
|
||||||
|
const buildEventWrapper = (fullEvent) => {
|
||||||
|
return {
|
||||||
|
event: {
|
||||||
|
...fullEvent,
|
||||||
|
participant: Array.isArray(fullEvent.participant)
|
||||||
|
? fullEvent.participant.map((p) => (typeof p === 'object' ? p.id : p))
|
||||||
|
: [],
|
||||||
|
},
|
||||||
|
mycalendars: calendars.value,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
// Открыть диалог создания/редактирования
|
||||||
|
const openEventDialog = async (eventOrInfo = null) => {
|
||||||
|
if (eventOrInfo === null) {
|
||||||
|
selectedEvent.value = getEmptyEventWrapper();
|
||||||
|
showEventDialog.value = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const id = eventOrInfo?.event?.id ?? eventOrInfo?.id;
|
||||||
|
if (!id) {
|
||||||
|
selectedEvent.value = getEmptyEventWrapper();
|
||||||
|
showEventDialog.value = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const { data } = await axiosApiInstance.get(`api/calendar_of_events/my_events/?id=${id}`);
|
||||||
|
selectedEvent.value = data;
|
||||||
|
showEventDialog.value = true;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Ошибка загрузки события:', error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const closeEventDialog = () => {
|
const closeEventDialog = () => {
|
||||||
showEventDialog.value = false;
|
showEventDialog.value = false;
|
||||||
selectedEvent.value = null;
|
selectedEvent.value = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const openEventView = async (eventId) => {
|
||||||
|
if (!eventId) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const { data } = await axiosApiInstance.get(
|
||||||
|
`api/calendar_of_events/my_events/?id=${eventId}`,
|
||||||
|
);
|
||||||
|
selectedEventForView.value = data;
|
||||||
|
showViewDialog.value = true;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Ошибка загрузки события:', error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const closeEventView = () => {
|
||||||
|
showViewDialog.value = false;
|
||||||
|
selectedEventForView.value = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleEventClick = (info) => {
|
||||||
|
const id = info.event?.id ?? info.id;
|
||||||
|
if (canEditEvent(id)) {
|
||||||
|
openEventDialog(info);
|
||||||
|
} else {
|
||||||
|
openEventView(id);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
// State
|
// State
|
||||||
selectedDate,
|
selectedDate,
|
||||||
@@ -262,6 +346,9 @@ const isNonWorkingDay = (dateInput) => {
|
|||||||
loadCalendars,
|
loadCalendars,
|
||||||
openEventDialog,
|
openEventDialog,
|
||||||
closeEventDialog,
|
closeEventDialog,
|
||||||
|
openEventView,
|
||||||
|
closeEventView,
|
||||||
|
handleEventClick,
|
||||||
setSelectedDateFromCalendar,
|
setSelectedDateFromCalendar,
|
||||||
setSelectedDateFromPicker,
|
setSelectedDateFromPicker,
|
||||||
toggleCalendarVisibility,
|
toggleCalendarVisibility,
|
||||||
@@ -269,5 +356,9 @@ const isNonWorkingDay = (dateInput) => {
|
|||||||
isNonWorkingDay,
|
isNonWorkingDay,
|
||||||
loadDictEmployees,
|
loadDictEmployees,
|
||||||
loadEmployees,
|
loadEmployees,
|
||||||
|
setSelectedEvent,
|
||||||
|
|
||||||
|
getEmptyEventWrapper,
|
||||||
|
buildEventWrapper,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@@ -8,8 +8,8 @@
|
|||||||
|
|
||||||
<div class="flex-grow-1">
|
<div class="flex-grow-1">
|
||||||
<HomeCalendarWidget class="h-100"/>
|
<HomeCalendarWidget class="h-100"/>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col class="d-flex flex-column" lg="5" md="12" cols="12">
|
<v-col class="d-flex flex-column" lg="5" md="12" cols="12">
|
||||||
<v-row>
|
<v-row>
|
||||||
|
|||||||
Reference in new issue
Block a user