Compare commits
32
Commits
dev-denzel
..
test
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0eade588e4 | ||
|
|
d9defd0528 | ||
|
|
45768f1921 | ||
|
|
5418359a3d | ||
|
|
bc2a40f6af | ||
|
|
5fb02ace96 | ||
|
|
92a9cb59dc | ||
|
|
e4674be071 | ||
|
|
ceb398c070 | ||
|
|
6cb204b3ac | ||
|
|
0a9f1cd510 | ||
|
|
f62e6f175f | ||
|
|
ee66b1c8d6 | ||
|
|
472d67d50c | ||
|
|
751538189d | ||
|
|
cd570a6c4b | ||
|
|
d5f62e67df | ||
|
|
7176420082 | ||
|
|
11ba78edb2 | ||
|
|
403d611660 | ||
|
|
3ae3295d12 | ||
|
|
58c515ec71 | ||
|
|
a64c716e5f | ||
|
|
4359b023e2 | ||
|
|
0cfc8f1dea | ||
|
|
8355e62d4e | ||
|
|
8595b3e75b | ||
|
|
27b5a7c953 | ||
|
|
587cc6a307 | ||
|
|
98dc1d51e9 | ||
|
|
de5b01e2aa | ||
|
|
13f135f98a |
No files matched your search
@@ -10,10 +10,7 @@ WORKDIR /app
|
||||
|
||||
COPY ${SOURCE_DIR}/* ./
|
||||
|
||||
RUN npm config set fetch-retries 5 \
|
||||
&& npm config set fetch-retry-mintimeout 20000 \
|
||||
&& npm config set fetch-retry-maxtimeout 120000 \
|
||||
&& npm install --prefer-offline --no-audit --no-fund
|
||||
RUN npm cache clean --force && npm install
|
||||
|
||||
# Копируем остальные файлы приложения
|
||||
# COPY ${SOURCE_DIR} ./
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
<template>
|
||||
<!-- Инициализация проекта -->
|
||||
<router-view />
|
||||
<CalendarDialogs />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { useAccountStore } from '@/store/AccountStore';
|
||||
import CalendarDialogs from './components/calendar_of_events/UI_calendar/CalendarDialogs.vue';
|
||||
/**
|
||||
* Получаем информацию о юзере из стора.
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,23 @@
|
||||
<template>
|
||||
<v-dialog
|
||||
v-model="menuAuthDialog"
|
||||
persistent
|
||||
width="400"
|
||||
scrim="teal-darken-9"
|
||||
>
|
||||
<template v-slot:activator="{ props }">
|
||||
<v-btn
|
||||
v-bind="props"
|
||||
append-icon="mdi-login"
|
||||
color="black_and_white"
|
||||
>
|
||||
Войти
|
||||
<template v-slot:append>
|
||||
<v-icon color="teal-darken-4"/>
|
||||
</template>
|
||||
</v-btn>
|
||||
</template>
|
||||
|
||||
<v-card @keyup.enter="logging" class="text-white" style="background-color: rgb(25 42 43);">
|
||||
<v-card-text>
|
||||
<v-container>
|
||||
@@ -30,7 +49,7 @@
|
||||
</v-row>
|
||||
</v-container>
|
||||
</v-card-text>
|
||||
<v-card-actions class="justify-end">
|
||||
<v-card-actions class="text-center">
|
||||
<v-btn
|
||||
color="white"
|
||||
variant="text"
|
||||
@@ -55,6 +74,9 @@
|
||||
<v-icon icon="mdi-alert-outline" class="pt-1"/>
|
||||
</template>
|
||||
</v-alert>
|
||||
</v-dialog>
|
||||
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
@@ -382,15 +382,15 @@ export default {
|
||||
}
|
||||
|
||||
.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;
|
||||
padding: 12px;
|
||||
position: relative;
|
||||
background-color: white;
|
||||
background-color: rgb(var(--v-theme-surface));
|
||||
}
|
||||
|
||||
.custom-file-input-wrapper:focus-within {
|
||||
border-color: #1976d2;
|
||||
border-color: rgb(var(--v-theme-primary));
|
||||
border-width: 2px;
|
||||
}
|
||||
|
||||
@@ -418,10 +418,12 @@ export default {
|
||||
.placeholder {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
color: rgba(0, 0, 0, 0.6);
|
||||
color: rgba(var(--v-theme-on-surface), 0.6);
|
||||
padding: 8px 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.error-messages {
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
Executable → Regular
+13
-201
@@ -4,229 +4,41 @@
|
||||
<mini-calendar />
|
||||
</v-col>
|
||||
<v-col class="d-flex flex-column">
|
||||
<custom-calendar
|
||||
:key="calendarKey"
|
||||
@openEventDialog="openEventDialog"
|
||||
@openEventView="openEventView"
|
||||
/>
|
||||
<custom-calendar :key="calendarKey" />
|
||||
</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>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ref, onMounted, watch, computed } from 'vue';
|
||||
import { useWeekendsStore } from '@/store/WeekendsStore';
|
||||
import EventCreate from '@/components/calendar_of_events/event-create.vue';
|
||||
import { ref, onMounted, watch } from '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 { axiosApiInstance } from '@/utils/axios-api';
|
||||
import { useCalendarStore } from '@/store/calendarStore';
|
||||
import { useAccountStore } from '@/store/AccountStore';
|
||||
import EventCalendarShow from '@/components/calendar_of_events/event-calendar-show.vue';
|
||||
|
||||
export default {
|
||||
components: { EventCreate, MiniCalendar, CustomCalendar, EventCalendarShow },
|
||||
components: { MiniCalendar, CustomCalendar },
|
||||
setup() {
|
||||
const week = useWeekendsStore();
|
||||
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 calendarStore = useCalendarStore();
|
||||
const accountStore = useAccountStore();
|
||||
const showViewDialog = ref(false);
|
||||
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();
|
||||
};
|
||||
const calendarKey = ref(0);
|
||||
|
||||
onMounted(() => {
|
||||
getEvent();
|
||||
week.getWeekend(MyYear.value);
|
||||
getDictEmployee();
|
||||
getCalendar();
|
||||
getEmployees();
|
||||
const currentYear = new Date().getFullYear();
|
||||
calendarStore.fetchHolidays(currentYear);
|
||||
calendarStore.loadCalendars();
|
||||
calendarStore.loadDictEmployees();
|
||||
calendarStore.loadEmployees();
|
||||
});
|
||||
|
||||
const closeEventDialog = () => {
|
||||
calendarStore.closeEventDialog();
|
||||
|
||||
// При ручном закрытии сбрасываем данные сразу
|
||||
setTimeout(() => {
|
||||
eventFromCalendar.value = createEmptyEvent();
|
||||
eventKey.value++;
|
||||
}, 200);
|
||||
};
|
||||
|
||||
const CheckingStore = () => {
|
||||
if (MyYear.value in week.week) {
|
||||
weekendsData();
|
||||
} else {
|
||||
week.getWeekend(MyYear.value);
|
||||
}
|
||||
};
|
||||
|
||||
watch(
|
||||
() => calendarStore.showEventDialog,
|
||||
(newValue, oldValue) => {
|
||||
if (!newValue && oldValue) {
|
||||
// Диалог был открыт и закрыт не через нашу кнопку
|
||||
// Добавляем проверку чтобы не сбрасывать при инициализации
|
||||
if (eventFromCalendar.value.event?.id) {
|
||||
setTimeout(() => {
|
||||
eventFromCalendar.value = createEmptyEvent();
|
||||
eventKey.value++;
|
||||
}, 200);
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
watch(
|
||||
() => accountStore.user?.id,
|
||||
(newUserId, oldUserId) => {
|
||||
if (newUserId !== oldUserId) {
|
||||
console.log('User changed, forcing calendar recreation...');
|
||||
calendarKey.value += 1; // Изменяем key для пересоздания компонента
|
||||
}
|
||||
(newId, oldId) => {
|
||||
if (newId !== oldId) calendarKey.value += 1;
|
||||
},
|
||||
);
|
||||
|
||||
const getEventForView = (idEvent) => {
|
||||
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,
|
||||
week,
|
||||
CheckingStore,
|
||||
showEventDialog,
|
||||
calendarForMy,
|
||||
getCalendar,
|
||||
getEvent,
|
||||
eventFromCalendar,
|
||||
calendarStore,
|
||||
accountStore,
|
||||
closeEventDialog,
|
||||
openEventDialog,
|
||||
createEmptyEvent,
|
||||
eventKey,
|
||||
getDictEmployee,
|
||||
openEventView,
|
||||
handleViewDialogClose,
|
||||
showViewDialog,
|
||||
selectedEventForView,
|
||||
allCalendars,
|
||||
eventKey,
|
||||
calendarKey,
|
||||
};
|
||||
return { calendarKey };
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -0,0 +1,786 @@
|
||||
<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 my-select"
|
||||
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="handleCalendarSelect(item.raw)"
|
||||
:data-calendar-id="item.raw.id"
|
||||
>
|
||||
<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
|
||||
:dateEvent="propsEvent.event"
|
||||
@update:dateEvent="propsEvent.event = $event"
|
||||
/>
|
||||
</v-row>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-col>
|
||||
<v-row no-gutters class="align-top mt-3">
|
||||
<v-col class="text-body-2 text-text_grey" lg="2"> Повтор события </v-col>
|
||||
<v-col class="d-flex flex-column">
|
||||
<!-- Выбор типа повторения -->
|
||||
<v-autocomplete
|
||||
v-model="selectedRule"
|
||||
:items="repeatRules"
|
||||
variant="outlined"
|
||||
density="compact"
|
||||
return-object
|
||||
item-title="type"
|
||||
item-value="id"
|
||||
@update:model-value="updatePeriodRule"
|
||||
hide-details
|
||||
/>
|
||||
|
||||
<!-- Окончание повторения -->
|
||||
<v-row class="align-center mt-2" style="height: 54px" no-gutters>
|
||||
<v-col cols="5">
|
||||
<v-checkbox
|
||||
v-model="showRepeatEnd"
|
||||
:disabled="isRepeatEndDisabled"
|
||||
density="compact"
|
||||
hide-details
|
||||
label="Окончание повторения"
|
||||
/>
|
||||
</v-col>
|
||||
<v-col cols="4">
|
||||
<time-select
|
||||
:showTime="false"
|
||||
:order="[1, 2]"
|
||||
:dateEvent="repeatEndDate ? String(repeatEndDate) : String(new Date())"
|
||||
@update:dateEvent="updateRepeatEndDate"
|
||||
class="wide-time-select"
|
||||
:limitation="String(propsEvent.event.date_start)"
|
||||
:isEndDateEnabled="!showRepeatEnd"
|
||||
/>
|
||||
</v-col>
|
||||
</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 setup>
|
||||
import { computed, nextTick, onMounted, 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';
|
||||
|
||||
const props = defineProps({
|
||||
eventCalendar: Object,
|
||||
allCalendars: Array,
|
||||
selectedRule: Object,
|
||||
});
|
||||
|
||||
const emit = defineEmits(['update:eventCalendar', 'getCalendar', 'closeDialog']);
|
||||
|
||||
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 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;
|
||||
// });
|
||||
|
||||
let filtered = (props.allCalendars || []).filter((calendar) => {
|
||||
if (calendar.author === userId) return true;
|
||||
const participant = calendar.participant?.find((p) => p.participant_calendar === userId);
|
||||
return participant?.editor === true;
|
||||
});
|
||||
|
||||
// Добавляем пункт "Создать календарь"
|
||||
filtered.push({
|
||||
id: 'create_new',
|
||||
cl_name: '➕ Создать календарь',
|
||||
isFake: true,
|
||||
});
|
||||
|
||||
return filtered;
|
||||
});
|
||||
|
||||
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];
|
||||
const firstRealCalendar = safeCalendars.value.find((cal) => cal.id !== 'create_new');
|
||||
if (firstRealCalendar) {
|
||||
myCalendar.value = firstRealCalendar;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Инициализируем когда все готово
|
||||
watch(
|
||||
[() => safeCalendars.value.length, () => propsEvent.value],
|
||||
(newCalendar) => {
|
||||
initializeCalendar();
|
||||
},
|
||||
{ immediate: true, deep: 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 postData = async (validate) => {
|
||||
if (validate) {
|
||||
await nextTick();
|
||||
|
||||
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 localDtstart = new Date(
|
||||
dtstart.getFullYear(),
|
||||
dtstart.getMonth(),
|
||||
dtstart.getDate(),
|
||||
dtstart.getHours(),
|
||||
dtstart.getMinutes(),
|
||||
dtstart.getSeconds(),
|
||||
);
|
||||
|
||||
const ruleOptions = {
|
||||
...rule.rule,
|
||||
dtstart: localDtstart,
|
||||
};
|
||||
|
||||
if (showRepeatEnd.value && repeatEndDate.value) {
|
||||
const untilDate = new Date(repeatEndDate.value);
|
||||
ruleOptions.until = new Date(
|
||||
untilDate.getFullYear(),
|
||||
untilDate.getMonth(),
|
||||
untilDate.getDate(),
|
||||
untilDate.getHours(),
|
||||
untilDate.getMinutes(),
|
||||
untilDate.getSeconds(),
|
||||
);
|
||||
}
|
||||
|
||||
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 },
|
||||
);
|
||||
|
||||
watch([safeCalendars, myCalendar], (newCalendar) => {}, { deep: true, immediate: true });
|
||||
|
||||
function handleCalendarSelect(calendar) {
|
||||
if (calendar.id === 'create_new') {
|
||||
if (window.$createCalendar) {
|
||||
// Запоминаем максимальный ID до создания
|
||||
const maxIdBefore = Math.max(
|
||||
...safeCalendars.value.filter((cal) => cal.id !== 'create_new').map((cal) => cal.id),
|
||||
);
|
||||
|
||||
window.$createCalendar();
|
||||
|
||||
// Следим за появлением календаря с ID больше максимального
|
||||
const unwatch = watch(
|
||||
safeCalendars,
|
||||
(newCalendars) => {
|
||||
const realCalendars = newCalendars.filter((cal) => cal.id !== 'create_new');
|
||||
const newCalendar = realCalendars.find((cal) => cal.id > maxIdBefore);
|
||||
|
||||
if (newCalendar) {
|
||||
myCalendar.value = newCalendar;
|
||||
unwatch();
|
||||
}
|
||||
},
|
||||
{ deep: true },
|
||||
);
|
||||
|
||||
setTimeout(() => unwatch(), 5000);
|
||||
}
|
||||
return;
|
||||
}
|
||||
myCalendar.value = calendar;
|
||||
}
|
||||
</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>
|
||||
Executable → Regular
+27
-3
@@ -91,7 +91,9 @@
|
||||
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 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>
|
||||
@@ -155,6 +157,17 @@
|
||||
|
||||
<!-- Кнопки -->
|
||||
<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
|
||||
width="120"
|
||||
@click="closeDialog"
|
||||
@@ -173,6 +186,7 @@
|
||||
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',
|
||||
@@ -201,6 +215,7 @@ export default {
|
||||
setup(props, { emit }) {
|
||||
const internalShow = ref(props.show);
|
||||
const { parseRecurrenceOptions, isRecurringEvent } = useRecurrence();
|
||||
const calendarStore = useCalendarStore();
|
||||
|
||||
// Синхронизация с внешним состоянием
|
||||
watch(
|
||||
@@ -221,7 +236,6 @@ export default {
|
||||
internalShow.value = false;
|
||||
};
|
||||
|
||||
// Информация о календаре - ИСПРАВЛЕНО
|
||||
const calendarInfo = computed(() => {
|
||||
const calendarId = props.eventData.event?.calendar;
|
||||
return props.allCalendars.find((cal) => cal.id == calendarId) || {};
|
||||
@@ -230,7 +244,6 @@ export default {
|
||||
const calendarName = computed(() => calendarInfo.value.cl_name || 'Неизвестный календарь');
|
||||
const calendarColor = computed(() => calendarInfo.value.cl_color || 'grey');
|
||||
|
||||
// Участники - ИСПРАВЛЕНО
|
||||
const participantsList = computed(() => {
|
||||
const participantIds = props.eventData.event?.participant || [];
|
||||
|
||||
@@ -458,6 +471,15 @@ 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,
|
||||
@@ -472,6 +494,8 @@ export default {
|
||||
truncateFileName,
|
||||
showRepeatEnd,
|
||||
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>
|
||||
Executable → Regular
+120
-87
@@ -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-3 d-flex align-center">
|
||||
<div class="pb-1 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-h5 text-no-wrap ml-2">
|
||||
<span class="text-h6 text-no-wrap ml-2">
|
||||
{{ currentTitle }}
|
||||
</span>
|
||||
</div>
|
||||
@@ -62,12 +62,12 @@
|
||||
variant="plain"
|
||||
density="comfortable"
|
||||
>
|
||||
<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 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-toggle>
|
||||
</v-col>
|
||||
</v-row>
|
||||
@@ -107,13 +107,17 @@ import { useEventListFilters } from '../composables/useEventListFilters';
|
||||
|
||||
export default {
|
||||
name: 'CustomCalendar',
|
||||
|
||||
emits: ['openEventDialog', 'openEventView'],
|
||||
components: {
|
||||
EventsListView,
|
||||
EventListFilters,
|
||||
},
|
||||
setup(props, { emit }) {
|
||||
|
||||
props: {
|
||||
forHomePage: { type: Boolean, default: false },
|
||||
view: { type: String, default: 'dayGridMonth' },
|
||||
},
|
||||
|
||||
setup(props) {
|
||||
const currentView = ref('dayGridMonth');
|
||||
const currentTitle = ref('Календарь');
|
||||
const calendarRef = ref(null);
|
||||
@@ -136,11 +140,7 @@ export default {
|
||||
}));
|
||||
|
||||
const handleEventClick = (info) => {
|
||||
if (calendarStore.canEditEvent(info.event.id)) {
|
||||
emit('openEventDialog', info);
|
||||
} else {
|
||||
emit('openEventView', info.event.id);
|
||||
}
|
||||
calendarStore.handleEventClick(info);
|
||||
};
|
||||
|
||||
const calendarOptions = ref({
|
||||
@@ -155,13 +155,13 @@ export default {
|
||||
initialView: props.forHomePage ? props.view : currentView.value,
|
||||
locales: [ruLocale],
|
||||
locale: 'ru',
|
||||
timeZone: 'local',
|
||||
timeZone: 'Europe/Moscow',
|
||||
firstDay: 1,
|
||||
headerToolbar: false,
|
||||
height: '80vh',
|
||||
aspectRatio: 1.5,
|
||||
weekNumbers: true,
|
||||
eventDisplay: 'block',
|
||||
eventDisplay: 'auto',
|
||||
eventTimeFormat: {
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
@@ -175,19 +175,21 @@ export default {
|
||||
selectable: true,
|
||||
unselectAuto: false,
|
||||
selectMirror: false,
|
||||
|
||||
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');
|
||||
}
|
||||
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;
|
||||
},
|
||||
|
||||
views: {
|
||||
timeGridDay: {
|
||||
type: 'timeGrid',
|
||||
@@ -277,7 +279,7 @@ export default {
|
||||
title: instance.title,
|
||||
start: instance.start,
|
||||
end: instance.end,
|
||||
allDay: instance.allDay || isMultiDay,
|
||||
allDay: instance.allDay,
|
||||
textColor: '#ffffff',
|
||||
backgroundColor: eventColor,
|
||||
borderColor: eventColor,
|
||||
@@ -291,13 +293,12 @@ export default {
|
||||
{
|
||||
id: event.id,
|
||||
title: event.name,
|
||||
start: new Date(event.date_start),
|
||||
end: new Date(event.date_end),
|
||||
allDay: event.all_day,
|
||||
start: event.date_start,
|
||||
end: event.date_end,
|
||||
allDay: event.allday,
|
||||
textColor: '#ffffff',
|
||||
backgroundColor: eventColor,
|
||||
borderColor: eventColor,
|
||||
allDay: isMultiDay,
|
||||
extendedProps: {
|
||||
originalEventId: event.id,
|
||||
description: event.description,
|
||||
@@ -313,8 +314,6 @@ export default {
|
||||
|
||||
successCallback(events);
|
||||
},
|
||||
editable: true,
|
||||
selectable: true,
|
||||
eventClick: handleEventClick,
|
||||
|
||||
dateClick: (info) => {
|
||||
@@ -326,18 +325,8 @@ export default {
|
||||
|
||||
datesSet: (info) => {
|
||||
if (info.view.type === 'listWeek' && selectedDate.value) {
|
||||
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 = formatScheduleTitle(selectedDate.value);
|
||||
} else if (info.view.type !== 'listWeek') {
|
||||
currentTitle.value = info.view.title;
|
||||
}
|
||||
|
||||
@@ -397,6 +386,47 @@ 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);
|
||||
@@ -404,32 +434,34 @@ export default {
|
||||
await nextTick();
|
||||
|
||||
// Принудительно обновляем события после загрузки праздников
|
||||
if (calendarApi.value) {
|
||||
if (calendarApi.value && currentView.value !== 'listAllEvents') {
|
||||
calendarApi.value.refetchEvents();
|
||||
}
|
||||
|
||||
if (selectedDate.value) {
|
||||
if (selectedDate.value && currentView.value !== 'listAllEvents') {
|
||||
handleDateSelection(selectedDate.value);
|
||||
}
|
||||
});
|
||||
|
||||
watch(currentView, (newView) => {
|
||||
applyView(newView);
|
||||
});
|
||||
|
||||
watch(
|
||||
allEvents,
|
||||
() => {
|
||||
// При изменении событий перезагружаем календарь
|
||||
if (calendarApi.value) {
|
||||
calendarApi.value.refetchEvents();
|
||||
}
|
||||
if (currentView.value === 'listAllEvents') return;
|
||||
calendarApi.value?.refetchEvents();
|
||||
},
|
||||
{ deep: true },
|
||||
);
|
||||
|
||||
watch(
|
||||
calendarColorMap,
|
||||
(newColorMap, oldColorMap) => {
|
||||
if (calendarRef.value && JSON.stringify(newColorMap) !== JSON.stringify(oldColorMap)) {
|
||||
renderEvents();
|
||||
}
|
||||
() => {
|
||||
if (currentView.value === 'listAllEvents') return;
|
||||
calendarApi.value?.refetchEvents();
|
||||
},
|
||||
{ deep: true },
|
||||
);
|
||||
@@ -443,15 +475,6 @@ export default {
|
||||
}
|
||||
});
|
||||
|
||||
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) {
|
||||
@@ -506,7 +529,7 @@ export default {
|
||||
:deep(.fc-day-today .fc-daygrid-day-number) {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
color: #00897b;
|
||||
color: rgb(var(--v-theme-btn_text));
|
||||
|
||||
&::before {
|
||||
content: '';
|
||||
@@ -516,7 +539,7 @@ export default {
|
||||
transform: translate(-50%, -50%);
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border: 1px solid #00897b;
|
||||
border: 1px solid rgb(var(--v-theme-btn_text));
|
||||
border-radius: 50%;
|
||||
z-index: -1;
|
||||
}
|
||||
@@ -531,7 +554,7 @@ export default {
|
||||
:deep(.fc-day-selected-custom .fc-daygrid-day-number) {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
color: white !important;
|
||||
color: rgb(var(--v-theme-bg_white)) !important;
|
||||
}
|
||||
|
||||
:deep(.fc-day-selected-custom .fc-daygrid-day-number::before) {
|
||||
@@ -542,7 +565,7 @@ export default {
|
||||
transform: translate(-50%, -50%);
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
background-color: #00897b;
|
||||
background-color: rgb(var(--v-theme-btn_text));
|
||||
border-radius: 50%;
|
||||
z-index: -1;
|
||||
}
|
||||
@@ -557,11 +580,16 @@ export default {
|
||||
|
||||
:deep(.v-btn--active) {
|
||||
background-color: transparent !important;
|
||||
color: #00897b !important;
|
||||
color: rgb(var(--v-theme-btn_text)) !important;
|
||||
}
|
||||
|
||||
:deep(.fc .fc-timegrid-col.fc-day-today) {
|
||||
background-color: #e0f2f1 !important;
|
||||
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;
|
||||
}
|
||||
|
||||
:deep(.fc-highlight) {
|
||||
@@ -573,27 +601,32 @@ export default {
|
||||
}
|
||||
|
||||
:deep(.fc-popover) {
|
||||
background-color: rgb(248, 244, 244) !important;
|
||||
background-color: rgb(var(--v-theme-cards)) !important;
|
||||
}
|
||||
|
||||
.non-working-day {
|
||||
color: red !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;
|
||||
}
|
||||
|
||||
: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(.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;
|
||||
}
|
||||
|
||||
:deep(.grey-background),
|
||||
:deep(.fc-daygrid-day),
|
||||
:deep(.fc-day.grey-background) {
|
||||
background-color: #f5f5f5 !important;
|
||||
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;
|
||||
}
|
||||
|
||||
.custom-calendar {
|
||||
|
||||
@@ -201,7 +201,7 @@ export default {
|
||||
};
|
||||
|
||||
const formatEventTime = (event) => {
|
||||
if (event.all_day) return 'Весь день'; // Исправлено: было allday, должно быть all_day
|
||||
if (event.all_day) return 'Весь день';
|
||||
|
||||
const start = event.startDate.toLocaleTimeString('ru-RU', {
|
||||
hour: '2-digit',
|
||||
@@ -332,7 +332,7 @@ export default {
|
||||
}
|
||||
|
||||
.event-item:hover {
|
||||
background-color: #f5f5f5;
|
||||
background-color: rgba(var(--v-theme-on-surface), 0.08);
|
||||
transition: background-color 0.2s;
|
||||
}
|
||||
|
||||
|
||||
Executable → Regular
+46
-47
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<v-card class="home-calendar-widget" elevation="2">
|
||||
<v-card class="home-calendar-widget" elevation="2" rounded="lg">
|
||||
<v-card-text class="pa-4">
|
||||
<v-row no-gutters class="calendar-pair">
|
||||
<!-- Месячный календарь -->
|
||||
@@ -32,8 +32,8 @@
|
||||
'current-month': day.isCurrentMonth,
|
||||
today: isToday(day.date),
|
||||
selected: isSelected(day.date),
|
||||
'non-working-day': calendarStore.isNonWorkingDay(day.date).isHoliday,
|
||||
'grey-background': calendarStore.isNonWorkingDay(day.date).isWeekendForStyling,
|
||||
'non-working-day': day.isHoliday,
|
||||
'grey-background': day.isWeekend,
|
||||
}"
|
||||
@click="onDateClick(day.date)"
|
||||
>
|
||||
@@ -69,6 +69,7 @@
|
||||
:key="event.id"
|
||||
class="schedule-item"
|
||||
:class="{ 'current-event': isCurrentEvent(event) }"
|
||||
@click="handleEventClick(event)"
|
||||
>
|
||||
<template #prepend>
|
||||
<div
|
||||
@@ -228,9 +229,7 @@ export default {
|
||||
const calendarWeeks = computed(() => {
|
||||
const year = currentDate.value.getFullYear();
|
||||
const month = currentDate.value.getMonth();
|
||||
|
||||
const firstDay = new Date(year, month, 1);
|
||||
const lastDay = new Date(year, month + 1, 0);
|
||||
|
||||
const weeks = [];
|
||||
let week = [];
|
||||
@@ -244,10 +243,14 @@ export default {
|
||||
const currentDay = new Date(startDay);
|
||||
currentDay.setDate(startDay.getDate() + i);
|
||||
|
||||
const dayInfo = calendarStore.isNonWorkingDay(currentDay);
|
||||
|
||||
week.push({
|
||||
day: currentDay.getDate(),
|
||||
date: formatToLocalDate(currentDay),
|
||||
isCurrentMonth: currentDay.getMonth() === month,
|
||||
isHoliday: dayInfo.isHoliday,
|
||||
isWeekend: dayInfo.isWeekendForStyling,
|
||||
});
|
||||
|
||||
if (week.length === 7) {
|
||||
@@ -346,19 +349,15 @@ export default {
|
||||
return dayInfo.isHoliday || dayInfo.isWeekendForStyling;
|
||||
};
|
||||
|
||||
const handleEventClick = (event) => {
|
||||
calendarStore.handleEventClick({ event: { id: event.id } });
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
selectedDate.value = formatToLocalDate(new Date());
|
||||
calendarStore.fetchHolidays(currentYear);
|
||||
await calendarStore.fetchHolidays(currentYear);
|
||||
});
|
||||
|
||||
watch(
|
||||
calendarColorMap,
|
||||
(newMap) => {
|
||||
newMap.value;
|
||||
},
|
||||
{ deep: true },
|
||||
);
|
||||
|
||||
return {
|
||||
// Реактивные данные
|
||||
currentDate,
|
||||
@@ -387,6 +386,7 @@ export default {
|
||||
allEvents,
|
||||
expandMultiDayInstance,
|
||||
formatForWidget,
|
||||
handleEventClick,
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -397,7 +397,6 @@ export default {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
font-family: 'Roboto', sans-serif;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.calendar-pair {
|
||||
@@ -416,7 +415,7 @@ export default {
|
||||
.month-title {
|
||||
font-size: 1.1rem;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
color: rgb(var(--v-theme-text_carous));
|
||||
text-transform: capitalize;
|
||||
}
|
||||
|
||||
@@ -433,10 +432,10 @@ export default {
|
||||
.weekday-header {
|
||||
font-size: 0.8rem;
|
||||
font-weight: 600;
|
||||
color: #666;
|
||||
text-align: center;
|
||||
padding: 8px 4px;
|
||||
border-bottom: 1px solid #afadad;
|
||||
color: rgb(var(--v-theme-text_grey));
|
||||
border-bottom: 1px solid rgb(var(--v-theme-btn_gray));
|
||||
}
|
||||
|
||||
.day-cell {
|
||||
@@ -450,28 +449,16 @@ export default {
|
||||
}
|
||||
|
||||
.day-cell:hover {
|
||||
background-color: #f5f5f5;
|
||||
background-color: rgba(var(--v-theme-on-surface), 0.04);
|
||||
}
|
||||
|
||||
.day-cell.current-month {
|
||||
color: #333;
|
||||
color: rgb(var(--v-theme-text_carous));
|
||||
}
|
||||
|
||||
.day-cell:not(.current-month) {
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
.day-cell.today {
|
||||
background-color: #e3f2fd;
|
||||
}
|
||||
|
||||
.day-cell.selected {
|
||||
background-color: #00897b;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.day-cell.selected .day-number {
|
||||
color: white;
|
||||
color: rgb(var(--v-theme-text_grey));
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.day-content {
|
||||
@@ -524,13 +511,13 @@ export default {
|
||||
font-size: 1.2rem;
|
||||
font-weight: 600;
|
||||
margin: 0;
|
||||
color: #333;
|
||||
color: rgb(var(--v-theme-text_carous));
|
||||
}
|
||||
|
||||
.day-schedule {
|
||||
height: 90%;
|
||||
overflow-y: auto;
|
||||
border: 1px solid #e0e0e0;
|
||||
border: 1px solid rgb(var(--v-theme-btn_gray));
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
@@ -538,7 +525,7 @@ export default {
|
||||
min-height: 48px;
|
||||
padding: 8px 12px;
|
||||
border-left: 4px solid transparent;
|
||||
border-bottom: 1px solid #d3cecede;
|
||||
border-bottom: 1px solid rgb(var(--v-theme-btn_gray));
|
||||
}
|
||||
|
||||
.schedule-item:last-child {
|
||||
@@ -546,14 +533,14 @@ export default {
|
||||
}
|
||||
|
||||
.schedule-item.current-event {
|
||||
border-left-color: #2196f3;
|
||||
background-color: #f8f9fa;
|
||||
border-left-color: rgb(var(--v-theme-primary));
|
||||
background-color: rgba(var(--v-theme-primary), 0.05);
|
||||
}
|
||||
|
||||
.event-time {
|
||||
font-size: 0.8rem;
|
||||
font-weight: 600;
|
||||
color: #302f2f;
|
||||
color: rgb(var(--v-theme-text_carous));
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
@@ -562,7 +549,7 @@ export default {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
color: #1b1b1b;
|
||||
color: rgb(var(--v-theme-text_carous));
|
||||
}
|
||||
|
||||
.no-events {
|
||||
@@ -578,28 +565,40 @@ export default {
|
||||
}
|
||||
|
||||
.day-schedule::-webkit-scrollbar-track {
|
||||
background: #f1f1f1;
|
||||
background: rgba(var(--v-theme-on-surface), 0.05);
|
||||
border-radius: 0 8px 8px 0;
|
||||
}
|
||||
|
||||
.day-schedule::-webkit-scrollbar-thumb {
|
||||
background: #c1c1c1;
|
||||
background: rgba(var(--v-theme-on-surface), 0.25);
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.day-schedule::-webkit-scrollbar-thumb:hover {
|
||||
background: #a8a8a8;
|
||||
background: rgba(var(--v-theme-on-surface), 0.4);
|
||||
}
|
||||
|
||||
.non-working-day {
|
||||
color: red !important;
|
||||
color: rgb(var(--v-theme-holiday_text)) !important;
|
||||
}
|
||||
|
||||
.grey-background {
|
||||
background-color: rgb(243, 243, 243) !important;
|
||||
background-color: rgb(var(--v-theme-weekend_bg)) !important;
|
||||
color: rgb(var(--v-theme-weekend_text)) !important;
|
||||
}
|
||||
|
||||
.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>
|
||||
Executable → Regular
+22
-37
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<v-card class="h-100 rounded-0 d-flex flex-colmn">
|
||||
<v-card class="h-100 rounded-0 d-flex flex-column">
|
||||
<v-row no-gutters class="flex-column">
|
||||
<v-col class="flex-grow-0 px-2 pt-1">
|
||||
<SearchEvents />
|
||||
@@ -13,9 +13,9 @@
|
||||
block
|
||||
elevation="1"
|
||||
@click="openEventDialog"
|
||||
:disabled="!myCalendars || myCalendars.length === 0"
|
||||
>Создать событие</v-btn
|
||||
>
|
||||
<!-- :disabled="!myCalendars || myCalendars.length === 0" -->
|
||||
</v-col>
|
||||
<v-col lg="3">
|
||||
<v-locale-provider locale="ru">
|
||||
@@ -56,7 +56,7 @@ import { useCalendarStore } from '@/store/calendarStore';
|
||||
import { useAccountStore } from '@/store/AccountStore';
|
||||
import CalendarMy from '@/components/calendar_of_events/calendar-my.vue';
|
||||
import SearchEvents from '@/components/calendar_of_events/UI_calendar/SearchEvents.vue';
|
||||
import { onMounted, watch, nextTick, ref } from 'vue';
|
||||
import { onMounted, watch, nextTick, ref, onBeforeUnmount } from 'vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
|
||||
export default {
|
||||
@@ -67,10 +67,10 @@ export default {
|
||||
const accountStore = useAccountStore();
|
||||
|
||||
const { selectedDate, myCalendars, subscribedCalendars } = storeToRefs(calendarStore);
|
||||
|
||||
const { user } = storeToRefs(accountStore);
|
||||
|
||||
const currentDisplay = ref(null);
|
||||
let observer = null;
|
||||
|
||||
const handleDateClick = (date) => {
|
||||
calendarStore.setSelectedDateFromPicker(date);
|
||||
@@ -85,12 +85,6 @@ export default {
|
||||
calendarStore.loadCalendars();
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
loadCalendars();
|
||||
|
||||
updateCalendarDays();
|
||||
});
|
||||
|
||||
// Реакция на изменения пользователя
|
||||
watch(user, (newUser) => {
|
||||
if (newUser) {
|
||||
@@ -181,32 +175,31 @@ export default {
|
||||
);
|
||||
|
||||
watch(
|
||||
[myCalendars, subscribedCalendars],
|
||||
() => [calendarStore.myCalendars, calendarStore.subscribedCalendars],
|
||||
() => {
|
||||
updateCalendarDays();
|
||||
},
|
||||
{ deep: true },
|
||||
);
|
||||
|
||||
// При смене месяца через кнопки навигации
|
||||
const observer = new MutationObserver((mutations) => {
|
||||
mutations.forEach((mutation) => {
|
||||
if (mutation.type === 'childList') {
|
||||
updateCalendarDays();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
loadCalendars();
|
||||
updateCalendarDays();
|
||||
// Наблюдаем за изменениями в DOM date-picker
|
||||
const datePicker = document.querySelector('.minCal');
|
||||
if (datePicker) {
|
||||
observer = new MutationObserver(() => updateCalendarDays());
|
||||
observer.observe(datePicker, { childList: true, subtree: true });
|
||||
}
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
observer?.disconnect();
|
||||
});
|
||||
|
||||
return {
|
||||
accountStore,
|
||||
calendarStore,
|
||||
user,
|
||||
myCalendars,
|
||||
subscribedCalendars,
|
||||
@@ -221,16 +214,7 @@ export default {
|
||||
};
|
||||
</script>
|
||||
<style scoped>
|
||||
/* .minCal:deep(.v-date-picker-month__days) {
|
||||
display: grid !important;
|
||||
grid-template-columns: repeat(7, 40px) !important;
|
||||
gap: 3px !important;
|
||||
width: 250px !important;
|
||||
justify-content: center !important;
|
||||
margin: 0 auto !important;
|
||||
} */
|
||||
|
||||
.minCal .v-date-picker-monWth__day {
|
||||
.minCal .v-date-picker-month__day {
|
||||
height: 31px;
|
||||
width: 31px;
|
||||
}
|
||||
@@ -251,23 +235,24 @@ export default {
|
||||
/* СТИЛИ ДЛЯ ВЫХОДНЫХ И ПРАЗДНИКОВ */
|
||||
|
||||
.minCal:deep(.weekend-day .v-btn__content) {
|
||||
color: #666 !important;
|
||||
color: rgb(var(--v-theme-weekend_text)) !important;
|
||||
}
|
||||
|
||||
.minCal:deep(.holiday-day .v-btn__content) {
|
||||
color: #ff4444 !important;
|
||||
font-weight: bold !important;
|
||||
color: rgb(var(--v-theme-holiday_text)) !important;
|
||||
font-weight: 600 !important;
|
||||
}
|
||||
|
||||
.minCal:deep(.weekend-day.holiday-day) {
|
||||
background-color: #ffe0e0 !important;
|
||||
.minCal:deep(.weekend-day.holiday-day) .v-btn {
|
||||
background-color: rgba(var(--v-theme-holiday_text), 0.12) !important;
|
||||
}
|
||||
|
||||
.minCal:deep(.weekend-day.holiday-day .v-btn__content) {
|
||||
color: #cc0000 !important;
|
||||
color: rgb(var(--v-theme-holiday_text)) !important;
|
||||
font-weight: 600 !important;
|
||||
}
|
||||
|
||||
search-dropdown {
|
||||
.search-dropdown {
|
||||
max-height: 300px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
Executable → Regular
+37
-16
@@ -2,46 +2,67 @@
|
||||
<v-col class="pb-2 pt-2 d-flex flex-column ml-n3" lg="3">
|
||||
<v-row no-gutters class="gap">
|
||||
<v-col>
|
||||
<v-checkbox-btn
|
||||
v-model="newDate"
|
||||
color="indigo-darken-4"
|
||||
label="Весь день"
|
||||
/>
|
||||
<v-checkbox-btn v-model="newDate" color="indigo-darken-4" label="Весь день" />
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-col>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { computed, ref } from "vue";
|
||||
import { computed } from 'vue';
|
||||
|
||||
export default {
|
||||
props: {
|
||||
dateEventStart: {
|
||||
dateEvent: {
|
||||
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;
|
||||
if (newValue == true)
|
||||
(propsDateEvent.value.date_end = new Date(
|
||||
new Date(propsDateEvent.value.date_end).setHours(23, 59, 0)
|
||||
)) &&
|
||||
(propsDateEvent.value.date_start = new Date(
|
||||
new Date(propsDateEvent.value.date_start).setHours(0, 0, 0)
|
||||
));
|
||||
|
||||
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();
|
||||
},
|
||||
});
|
||||
|
||||
const propsDateEvent = computed({
|
||||
get: () => props.dateEventStart,
|
||||
set: (value) => emit("update:dateEventStart", value),
|
||||
get: () => props.dateEvent,
|
||||
set: (value) => emit('update:dateEvent', value),
|
||||
});
|
||||
|
||||
return {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<v-col lg="3" :class="`order-${order[0]}`">
|
||||
<v-col :class="`order-${order[0]}`">
|
||||
<v-menu
|
||||
v-model="menudate"
|
||||
:nudge-right="40"
|
||||
@@ -19,6 +19,7 @@
|
||||
v-bind="props"
|
||||
readonly
|
||||
hide-details
|
||||
:disabled="isEndDateEnabled"
|
||||
>
|
||||
<template v-slot:prepend-inner>
|
||||
<v-icon v-bind="props" icon="mdi-calendar-today" color="cyan-darken-3" size="x-small" />
|
||||
@@ -52,7 +53,7 @@
|
||||
:active="menutime"
|
||||
:focus="menutime"
|
||||
hide-details
|
||||
:disabled="chek"
|
||||
:disabled="isAllDay"
|
||||
>
|
||||
</v-textarea>
|
||||
<v-menu
|
||||
@@ -61,21 +62,25 @@
|
||||
activator="parent"
|
||||
transition="scale-transition"
|
||||
>
|
||||
<v-locale-provider locale="ru">
|
||||
<v-time-picker
|
||||
v-if="menutime"
|
||||
v-if="menutime && !isAllDay"
|
||||
:model-value="timeEvent"
|
||||
@update:model-value="onTimePickerChange"
|
||||
full-width
|
||||
format="24hr"
|
||||
:disabled="isAllDay"
|
||||
></v-time-picker>
|
||||
</v-locale-provider>
|
||||
</v-menu>
|
||||
</v-col>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ref, computed, watch } from 'vue';
|
||||
import { ref, computed } from 'vue';
|
||||
import { formatComa } from '@/utils/universal_functions';
|
||||
export default {
|
||||
inheritAttrs: false,
|
||||
props: {
|
||||
dateEvent: {
|
||||
type: String,
|
||||
@@ -91,7 +96,7 @@ export default {
|
||||
type: Array,
|
||||
default: [0, 0],
|
||||
},
|
||||
chek: {
|
||||
isAllDay: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
@@ -103,16 +108,14 @@ export default {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
// Новый проп - ограничение по времени (для окончания повторений)
|
||||
timeLimit: {
|
||||
type: String,
|
||||
default: '23:59',
|
||||
},
|
||||
// Новый проп - режим работы (обычный или для окончания повторений)
|
||||
showTime: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
isEndDateEnabled: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
|
||||
emits: ['update:dateEvent', 'adjustEndDate'],
|
||||
@@ -159,7 +162,7 @@ export default {
|
||||
const startDate = new Date(props.limitation);
|
||||
if (newDate <= startDate) {
|
||||
const correctedDate = new Date(startDate);
|
||||
correctedDate.setHours(startDate.getHours() + 1);
|
||||
correctedDate.setMinutes(startDate.getMinutes() + 30);
|
||||
propsDateEvent.value = correctedDate;
|
||||
} else {
|
||||
propsDateEvent.value = newDate;
|
||||
@@ -169,7 +172,7 @@ export default {
|
||||
const currentEnd = new Date(props.limitation);
|
||||
if (newDate > currentEnd) {
|
||||
const newEnd = new Date(newDate);
|
||||
newEnd.setHours(newDate.getHours() + 1);
|
||||
newEnd.setMinutes(newDate.getMinutes() + 30);
|
||||
emit('adjustEndDate', newEnd.toISOString());
|
||||
}
|
||||
}
|
||||
@@ -190,7 +193,7 @@ export default {
|
||||
const startDate = new Date(props.limitation);
|
||||
if (newDate <= startDate) {
|
||||
const correctedDate = new Date(startDate);
|
||||
correctedDate.setHours(startDate.getHours() + 1);
|
||||
correctedDate.setMinutes(startDate.getMinutes() + 30);
|
||||
propsDateEvent.value = correctedDate;
|
||||
} else {
|
||||
propsDateEvent.value = newDate;
|
||||
@@ -200,7 +203,7 @@ export default {
|
||||
const currentEnd = new Date(props.limitation);
|
||||
if (newDate > currentEnd) {
|
||||
const newEnd = new Date(newDate);
|
||||
newEnd.setHours(newDate.getHours() + 1);
|
||||
newEnd.setMinutes(newDate.getMinutes() + 30);
|
||||
emit('adjustEndDate', newEnd.toISOString());
|
||||
}
|
||||
}
|
||||
@@ -237,4 +240,19 @@ export default {
|
||||
};
|
||||
</script>
|
||||
|
||||
<style></style>
|
||||
<style>
|
||||
.wide-time-select :deep(.v-col.lg-3) {
|
||||
flex: 1 !important;
|
||||
max-width: none !important;
|
||||
min-width: 200px !important;
|
||||
}
|
||||
|
||||
.wide-time-select :deep(.v-textarea) {
|
||||
width: 100% !important;
|
||||
min-width: 200px !important;
|
||||
}
|
||||
|
||||
.wide-time-select :deep(.v-menu) {
|
||||
width: 100% !important;
|
||||
}
|
||||
</style>
|
||||
Executable → Regular
+25
-39
@@ -27,16 +27,10 @@
|
||||
<v-col v-for="(x, key) in color" :key="key">
|
||||
<v-avatar
|
||||
class="cursor-pointer"
|
||||
:class="{ 'avatar-dimmed': propsCalendar.cl_color && propsCalendar.cl_color !== x }"
|
||||
@click="colorPik(x, key)"
|
||||
size="x-small"
|
||||
:color="x"
|
||||
:variant="
|
||||
propsCalendar.cl_color === null
|
||||
? 'flat'
|
||||
: propsCalendar.cl_color === x
|
||||
? 'flat'
|
||||
: 'tonal'
|
||||
"
|
||||
/> </v-col
|
||||
></v-row>
|
||||
|
||||
@@ -161,7 +155,7 @@ export default {
|
||||
cl_descr: [(val) => req(val)],
|
||||
};
|
||||
|
||||
const isNewCalendar = computed(() => !propsCalendar.value.id);
|
||||
const isNewCalendar = computed(() => !propsCalendar.value?.id);
|
||||
const isAuthor = computed(() => propsCalendar.value.author === accountStore.user.is_idEmployee);
|
||||
|
||||
const titleCard = computed(() =>
|
||||
@@ -217,41 +211,24 @@ export default {
|
||||
},
|
||||
});
|
||||
|
||||
// const color = [
|
||||
// '#0ea5e9', // Яркий голубой
|
||||
// '#3b82f6', // Королевский синий
|
||||
// '#10b981', // Изумрудно-зеленый
|
||||
// '#f59e0b', // Теплый янтарный
|
||||
// '#ef4444', // Акцентный красный
|
||||
// '#8b5cf6', // Фиолетовый
|
||||
// '#4f46e5', // Индиго (профессиональный синий)
|
||||
// '#06b6d4', // Бирюзовый
|
||||
// '#84cc16', // Лаймовый
|
||||
// '#f97316', // Оранжевый
|
||||
// '#ec4899', // Розовый
|
||||
// '#6366f1', // Фиолетово-синий
|
||||
// '#14b8a6', // Бирюзово-зеленый
|
||||
// '#eab308', // Золотисто-желтый
|
||||
// '#22c55e', // Зеленый
|
||||
// ];
|
||||
|
||||
const color = [
|
||||
'#3b82f6', // Синий
|
||||
'#10b981', // Зеленый
|
||||
'#dc2626', // Красный
|
||||
'#d97706', // Оранжевый
|
||||
'#7c3aed', // Фиолетовый
|
||||
'#0ea5e9', // Голубой
|
||||
'#84cc16', // Лаймовый
|
||||
'#f59e0b', // Янтарный
|
||||
'#8b5cf6', // Пурпурный
|
||||
'#0ea5e9', // Яркий голубой
|
||||
'#3b82f6', // Королевский синий
|
||||
'#10b981', // Изумрудно-зеленый
|
||||
'#f59e0b', // Теплый янтарный
|
||||
'#ef4444', // Акцентный красный
|
||||
'#8b5cf6', // Фиолетовый
|
||||
'#4f46e5', // Индиго (профессиональный синий)
|
||||
'#06b6d4', // Бирюзовый
|
||||
'#f97316', // Теплый оранжевый
|
||||
'#6366f1', // Фиолетово-синий
|
||||
'#14b8a6', // Морской волны
|
||||
'#84cc16', // Лаймовый
|
||||
'#f97316', // Оранжевый
|
||||
'#ec4899', // Розовый
|
||||
'#64748b', // Серо-синий
|
||||
'#6366f1', // Фиолетово-синий
|
||||
'#14b8a6', // Бирюзово-зеленый
|
||||
'#eab308', // Золотисто-желтый
|
||||
'#22c55e', // Зеленый
|
||||
];
|
||||
|
||||
const colorPik = (col) => {
|
||||
if (propsCalendar.value.cl_color === col) {
|
||||
propsCalendar.value.cl_color = null;
|
||||
@@ -299,4 +276,13 @@ const color = [
|
||||
.custom-tooltip {
|
||||
max-width: 350px; /* Установка максимальной ширины для подсказки */
|
||||
}
|
||||
|
||||
.avatar-dimmed {
|
||||
opacity: 0.45;
|
||||
transition: opacity 0.15s ease;
|
||||
}
|
||||
|
||||
.avatar-dimmed:hover {
|
||||
opacity: 0.8;
|
||||
}
|
||||
</style>
|
||||
Executable → Regular
+42
-38
@@ -7,14 +7,13 @@
|
||||
</div>
|
||||
|
||||
<v-btn
|
||||
v-if="title == 'Мои календари'"
|
||||
size="x-small"
|
||||
v-if="title === 'Мои календари'"
|
||||
icon="mdi-plus"
|
||||
variant="text"
|
||||
class="pa-0"
|
||||
class="simple-hover"
|
||||
@click.stop="editCreatedCalendar()"
|
||||
></v-btn>
|
||||
</v-expansion-panel-title>
|
||||
|
||||
<v-expansion-panel-text flat tile static>
|
||||
<template v-if="Object.keys(calendars).length > 0">
|
||||
<v-list-item
|
||||
@@ -60,7 +59,7 @@
|
||||
</v-list-item>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="text-caption text-grey text-center">Календарей нет</div>
|
||||
<div class="text-caption text-grey text-center pa-3">Календарей нет</div>
|
||||
</template>
|
||||
</v-expansion-panel-text>
|
||||
</v-expansion-panel>
|
||||
@@ -74,29 +73,20 @@
|
||||
</v-expansion-panels>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ref, watch } from 'vue';
|
||||
<script setup>
|
||||
import { onMounted, ref, watch } from 'vue';
|
||||
import calendarCreate from '@/components/calendar_of_events/calendar-create.vue';
|
||||
import { useAccountStore } from '@/store/AccountStore';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useCalendarStore } from '@/store/calendarStore';
|
||||
|
||||
export default {
|
||||
components: { calendarCreate },
|
||||
const props = defineProps({
|
||||
calendars: Array,
|
||||
title: String,
|
||||
});
|
||||
|
||||
props: {
|
||||
calendars: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
const emit = defineEmits(['getCalendar']);
|
||||
|
||||
title: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
},
|
||||
|
||||
setup(props) {
|
||||
const showDialog = ref(false);
|
||||
const accountStore = useAccountStore();
|
||||
const { user } = storeToRefs(accountStore);
|
||||
@@ -105,7 +95,7 @@ export default {
|
||||
|
||||
const calendar = ref(null);
|
||||
const openGroup = ref([0]);
|
||||
const trans = ref(false);
|
||||
// const trans = ref(false);
|
||||
const hover = ref(0);
|
||||
|
||||
const editCreatedCalendar = (cal) => {
|
||||
@@ -122,7 +112,21 @@ export default {
|
||||
showDialog.value = true;
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
window.$createCalendar = () => {
|
||||
editCreatedCalendar();
|
||||
};
|
||||
});
|
||||
|
||||
const handleCloseDialog = () => {
|
||||
if (calendar.value.cl_name.length > 1) {
|
||||
const calendarData = JSON.parse(JSON.stringify(calendar.value));
|
||||
window.dispatchEvent(
|
||||
new CustomEvent('calendarCreated', {
|
||||
detail: calendarData,
|
||||
}),
|
||||
);
|
||||
}
|
||||
showDialog.value = false;
|
||||
};
|
||||
|
||||
@@ -141,25 +145,25 @@ export default {
|
||||
(newCalendars) => {},
|
||||
{ deep: true },
|
||||
);
|
||||
|
||||
return {
|
||||
accountStore,
|
||||
user,
|
||||
calendar,
|
||||
showDialog,
|
||||
editCreatedCalendar,
|
||||
toggleVisiblityEvents,
|
||||
openGroup,
|
||||
trans,
|
||||
hover,
|
||||
handleCloseDialog,
|
||||
resetCalendar,
|
||||
};
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.simple-hover {
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
width: 22px !important;
|
||||
height: 22px !important;
|
||||
border-radius: 3px !important;
|
||||
margin-left: 0.5rem;
|
||||
background-color: #00897b !important;
|
||||
color: white;
|
||||
margin-bottom: 2px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.simple-hover:hover {
|
||||
background-color: #004d40 !important;
|
||||
transform: scale(1.1);
|
||||
}
|
||||
.fade-enter-active,
|
||||
.fade-leave-active {
|
||||
transition: opacity 0.1s;
|
||||
|
||||
Executable → Regular
+15
-7
@@ -8,9 +8,18 @@ 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: new Date(eventDateStart),
|
||||
dtstart: localDtstart,
|
||||
interval: rrule.origOptions.interval || 1,
|
||||
};
|
||||
}
|
||||
@@ -62,15 +71,14 @@ 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;
|
||||
|
||||
return dates.map((date, index) => ({
|
||||
const duration = new Date(event.date_end) - new Date(event.date_start);
|
||||
|
||||
return dates.map((date) => ({
|
||||
id: event.id,
|
||||
title: event.name,
|
||||
start: new Date(date),
|
||||
end: new Date(date.getTime() + duration),
|
||||
start: date,
|
||||
end: date.getTime() + duration,
|
||||
allDay: event.allday,
|
||||
extendedProps: {
|
||||
originalEventId: event.id,
|
||||
|
||||
@@ -1,768 +0,0 @@
|
||||
<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"
|
||||
:chek="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"
|
||||
:chek="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>
|
||||
@@ -23,13 +23,11 @@ import { axiosApiInstance } from "@/utils/axios-api";
|
||||
import { ref, onMounted } from "vue";
|
||||
|
||||
import ical from "ical.js";
|
||||
import { useWeekendsStore } from '@/store/WeekendsStore'
|
||||
|
||||
// const burl = baseURL.slice(0, -1);
|
||||
|
||||
export default {
|
||||
setup() {
|
||||
const week= useWeekendsStore()
|
||||
const drawer_right = ref(false);
|
||||
const cal = ref(null)
|
||||
const participant = ref("");
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
<v-app-bar v-if="accountStore.cod2user" density="compact" color="#263f40" class="pl-4" style="box-shadow: none">
|
||||
<v-icon class="px-3" size="20"
|
||||
:icon="rail ? 'mdi-chevron-right' : 'mdi-chevron-left'" @click="rail = !rail" />
|
||||
<v-card class="bg-transparent" density="compact" :prepend-avatar="imageSrc" title="Портал МИ ФНС России по ЦОД № 2" variant="text" :to="'/'" />
|
||||
<v-card class="bg-transparent" density="compact"
|
||||
:prepend-avatar="imageSrc" title="Портал МИ ФНС России по ЦОД № 2" variant="text" :to="'/'" />
|
||||
<template v-slot:append>
|
||||
<div class="fns-actions">
|
||||
<vcard-user :author="accountStore.user" />
|
||||
|
||||
Executable → Regular
+19
-16
@@ -1,19 +1,16 @@
|
||||
import '@mdi/font/css/materialdesignicons.css'
|
||||
import 'vuetify/styles'
|
||||
// import { VCalendar } from 'vuetify/labs/VCalendar'
|
||||
|
||||
import { createVuetify } from 'vuetify'
|
||||
import { ru } from 'vuetify/locale'
|
||||
import '@mdi/font/css/materialdesignicons.css';
|
||||
import 'vuetify/styles';
|
||||
import { VCalendar } from 'vuetify/components';
|
||||
|
||||
import { createVuetify } from 'vuetify';
|
||||
import { ru } from 'vuetify/locale';
|
||||
|
||||
export default createVuetify({
|
||||
|
||||
locale: {
|
||||
messages: { ru, },
|
||||
messages: { ru },
|
||||
},
|
||||
components: {
|
||||
// VCalendar,
|
||||
|
||||
VCalendar,
|
||||
},
|
||||
theme: {
|
||||
defaultTheme: 'light',
|
||||
@@ -23,7 +20,7 @@ export default createVuetify({
|
||||
lampa: '#FFFFFF',
|
||||
primary: '#1867C0',
|
||||
secondary: '#5CBBF6',
|
||||
main_theme: "#f7f7f7",
|
||||
main_theme: '#f7f7f7',
|
||||
scrollbar: '#367F8A',
|
||||
cards: '#F5F5F5',
|
||||
text_grey: '#7A7A7A', //Цвет серого текста
|
||||
@@ -43,7 +40,10 @@ export default createVuetify({
|
||||
insert_table: '#FAFAFA',
|
||||
btn_text: '#00897B', // фигма, текст кнопки с иконкой
|
||||
select_list: '#E0EAE8',
|
||||
btn_gray: '#E0E0E0'
|
||||
btn_gray: '#E0E0E0',
|
||||
weekend_text: '#D32F2F', // красный для сб/вс
|
||||
holiday_text: '#B71C1C', // насыщеннее для праздников
|
||||
weekend_bg: '#FAFAFA', // лёгкий серый фон для выходных
|
||||
},
|
||||
},
|
||||
dark: {
|
||||
@@ -51,7 +51,7 @@ export default createVuetify({
|
||||
lampa: '#121212',
|
||||
primary: '#1E88E5',
|
||||
secondary: '#64B5F6',
|
||||
main_theme: "#121212",
|
||||
main_theme: '#121212',
|
||||
scrollbar: '#4DB6AC',
|
||||
cards: '#1E1E1E',
|
||||
text_grey: '#B0BEC5',
|
||||
@@ -76,12 +76,15 @@ export default createVuetify({
|
||||
background: '#121212',
|
||||
'on-background': '#FFFFFF',
|
||||
'on-surface': '#FFFFFF',
|
||||
'card-background': '#1E1E1E'
|
||||
'card-background': '#1E1E1E',
|
||||
weekend_text: '#EF5350',
|
||||
holiday_text: '#FF5252',
|
||||
weekend_bg: '#2A2A2A',
|
||||
},
|
||||
},
|
||||
options: {
|
||||
customProperties: true
|
||||
customProperties: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
});
|
||||
@@ -1,17 +0,0 @@
|
||||
import { axiosApiInstance } from "@/utils/axios-api";
|
||||
import { defineStore } from "pinia";
|
||||
import { ref } from "vue";
|
||||
|
||||
export const useWeekendsStore = defineStore("weekends", () => {
|
||||
|
||||
const week = ref({});
|
||||
|
||||
function getWeekend(year) {
|
||||
axiosApiInstance
|
||||
.get(`api/calendar_of_events/exclusion_dates/?year=${year}`, {})
|
||||
.then((data) => {
|
||||
week.value = data.data;
|
||||
});
|
||||
}
|
||||
return { week, getWeekend };
|
||||
});
|
||||
Executable → Regular
+117
-45
@@ -1,5 +1,5 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { ref, computed, watch } from 'vue';
|
||||
import { ref, computed } from 'vue';
|
||||
import { axiosApiInstance } from '@/utils/axios-api';
|
||||
import { useAccountStore } from '@/store/AccountStore';
|
||||
|
||||
@@ -9,16 +9,20 @@ export const useCalendarStore = defineStore('calendarStore', () => {
|
||||
// State
|
||||
const selectedDate = ref(new Date());
|
||||
const events = ref([]);
|
||||
const selectedEvent = ref(null);
|
||||
const showEventDialog = ref(false);
|
||||
const currentView = ref('dayGridMonth'); // Текущий вид календаря
|
||||
const calendars = ref([]); // Список календарей пользователя
|
||||
const lastUpdatedBy = ref(null);
|
||||
const holidays = ref([]);
|
||||
const holidays = ref({});
|
||||
const loadingYears = ref(new Set());
|
||||
const dictEmployees = ref([]);
|
||||
const dictEmployeesLoaded = ref(false);
|
||||
const employees = ref([]);
|
||||
|
||||
const selectedEvent = ref(null);
|
||||
const showEventDialog = ref(false);
|
||||
const selectedEventForView = ref(null);
|
||||
const showViewDialog = ref(false);
|
||||
|
||||
// Массив ID скрытых календарей. Загружаем из localStorage при инициализации.
|
||||
const hiddenCalendarIds = ref([]);
|
||||
|
||||
@@ -43,7 +47,6 @@ export const useCalendarStore = defineStore('calendarStore', () => {
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
const subscribedCalendars = computed(() => {
|
||||
const userId = accountStore.user.is_idEmployee;
|
||||
|
||||
@@ -176,78 +179,140 @@ export const useCalendarStore = defineStore('calendarStore', () => {
|
||||
};
|
||||
|
||||
const fetchHolidays = async (year) => {
|
||||
if (holidays.value[year] || loadingYears.value.has(year)) {
|
||||
return holidays.value[year];
|
||||
}
|
||||
loadingYears.value.add(year);
|
||||
try {
|
||||
const response = await axiosApiInstance.get(
|
||||
const { data } = await axiosApiInstance.get(
|
||||
`api/calendar_of_events/exclusion_dates/?year=${year}`,
|
||||
);
|
||||
holidays.value = response.data;
|
||||
return holidays.value;
|
||||
holidays.value = { ...holidays.value, ...data };
|
||||
return holidays.value[year];
|
||||
} catch (err) {
|
||||
console.error('Ошибка загрузки праздников:', err);
|
||||
throw err;
|
||||
} finally {
|
||||
loadingYears.value.delete(year);
|
||||
}
|
||||
};
|
||||
|
||||
// Метод для проверки, является ли день выходным или праздничным
|
||||
const isNonWorkingDay = (dateInput) => {
|
||||
let date;
|
||||
|
||||
// Если входные данные — это строка в формате 'YYYY-MM-DD'
|
||||
if (typeof dateInput === 'string') {
|
||||
date = new Date(dateInput);
|
||||
}
|
||||
// Если входные данные — это объект Date
|
||||
else if (dateInput instanceof Date) {
|
||||
date = new Date(dateInput);
|
||||
}
|
||||
// Если входные данные некорректны
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Проверяем, что дата корректна
|
||||
const date = dateInput instanceof Date ? dateInput : new Date(dateInput);
|
||||
if (isNaN(date.getTime())) {
|
||||
return false;
|
||||
return { isNonWorking: false, isWeekendForStyling: false, isHoliday: false };
|
||||
}
|
||||
|
||||
const year = date.getFullYear();
|
||||
const month = date.getMonth() + 1;
|
||||
const iso = `${year}-${String(month).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`;
|
||||
|
||||
const day = date.getDay();
|
||||
|
||||
// Проверка на выходной (суббота или воскресенье)
|
||||
const isWeekend = day === 0 || day === 6;
|
||||
const isHoliday = (holidays.value[year]?.[month] ?? []).includes(iso);
|
||||
|
||||
// Получаем год, месяц и день
|
||||
const year = date.getFullYear();
|
||||
const month = date.getMonth() + 1; // Месяцы в JS начинаются с 0
|
||||
const dayOfMonth = date.getDate();
|
||||
return {
|
||||
isNonWorking: isWeekend || isHoliday,
|
||||
isWeekendForStyling: isWeekend,
|
||||
isHoliday,
|
||||
};
|
||||
};
|
||||
|
||||
const normalizedCurrentDate = `${year}-${String(month).padStart(2, '0')}-${String(dayOfMonth).padStart(2, '0')}`;
|
||||
// Проверяем, что данные о праздничных днях существуют для текущего года и месяца
|
||||
const holidaysForYear = holidays.value[year] || {};
|
||||
const holidaysForMonth = holidaysForYear[month] || [];
|
||||
const setSelectedEvent = (event) => {
|
||||
selectedEvent.value = event;
|
||||
};
|
||||
|
||||
// Проверка на исключение (рабочая суббота или праздничный будний день)
|
||||
const isExceptionDay = holidaysForMonth.includes(normalizedCurrentDate);
|
||||
// Шаблон пустого события (создание)
|
||||
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 result = {
|
||||
isNonWorking: (isWeekend && !isExceptionDay) || (!isWeekend && isExceptionDay),
|
||||
isWeekendForStyling: isWeekend && !isExceptionDay,
|
||||
isHoliday: !isWeekend && isExceptionDay,
|
||||
// Шаблон обёртки для редактирования
|
||||
const buildEventWrapper = (fullEvent) => {
|
||||
return {
|
||||
event: {
|
||||
...fullEvent,
|
||||
participant: Array.isArray(fullEvent.participant)
|
||||
? fullEvent.participant.map((p) => (typeof p === 'object' ? p.id : p))
|
||||
: [],
|
||||
},
|
||||
mycalendars: calendars.value,
|
||||
};
|
||||
return result;
|
||||
};
|
||||
|
||||
// Открыть диалог создания/редактирования
|
||||
const openEventDialog = (event = null) => {
|
||||
selectedEvent.value = event;
|
||||
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 = () => {
|
||||
showEventDialog.value = false;
|
||||
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 {
|
||||
// State
|
||||
selectedDate,
|
||||
@@ -281,6 +346,9 @@ export const useCalendarStore = defineStore('calendarStore', () => {
|
||||
loadCalendars,
|
||||
openEventDialog,
|
||||
closeEventDialog,
|
||||
openEventView,
|
||||
closeEventView,
|
||||
handleEventClick,
|
||||
setSelectedDateFromCalendar,
|
||||
setSelectedDateFromPicker,
|
||||
toggleCalendarVisibility,
|
||||
@@ -288,5 +356,9 @@ export const useCalendarStore = defineStore('calendarStore', () => {
|
||||
isNonWorkingDay,
|
||||
loadDictEmployees,
|
||||
loadEmployees,
|
||||
setSelectedEvent,
|
||||
|
||||
getEmptyEventWrapper,
|
||||
buildEventWrapper,
|
||||
};
|
||||
});
|
||||
@@ -1,22 +1,20 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
# Загружаем переменные окружения
|
||||
source ".env.base"
|
||||
if [[ -f .env.local ]]; then
|
||||
source ".env.local"
|
||||
fi
|
||||
if [ $# -eq 0 ]; then
|
||||
arg='db_backup.sql.gz'
|
||||
else
|
||||
arg="$1" # Если аргумент передан, используем его
|
||||
fi
|
||||
|
||||
# Файл бэкапа – либо первый аргумент, либо значение по умолчанию
|
||||
BACKUP_FILE="${1:-db_backup.sql.gz}"
|
||||
|
||||
echo "Ожидание готовности контейнера с БД..."
|
||||
until docker compose -f docker-compose.yml exec -T db sh -c "
|
||||
gunzip < /backup/$BACKUP_FILE | mysql -u ${DB_USER} -p${DB_PASSWORD} ${DB_NAME} 2>/dev/null
|
||||
"
|
||||
echo "Ожидаю выполнения Восстановления базы данных"
|
||||
until docker compose -f docker-compose.yml exec db sh -c "
|
||||
gunzip < /backup/$arg | mysql -u ${DB_USER} -p${DB_PASSWORD} ${DB_NAME}"
|
||||
do
|
||||
echo "Контейнер ещё не готов, повтор через 2 секунды..."
|
||||
echo "Ожидаю выполнения Дампа"
|
||||
sleep 2
|
||||
done
|
||||
|
||||
echo "База данных успешно восстановлена из $BACKUP_FILE"
|
||||
Reference in new issue
Block a user