Compare commits
15
Commits
dev-denzel
...
inna-dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
45922643c0 | ||
|
|
3c9c244dc7 | ||
|
|
05a6797a16 | ||
|
|
a89279337c | ||
|
|
27a2e3680b | ||
|
|
1f7dc86728 | ||
|
|
6a200863be | ||
|
|
f268b7bad4 | ||
|
|
8caff79cdb | ||
|
|
8beb68289a | ||
|
|
953ba7fe0f | ||
|
|
e6b97d52b8 | ||
|
|
7a011388db | ||
|
|
17de69cb38 | ||
|
|
cf78e48fc3 |
No files matched your search
@@ -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';
|
||||
/**
|
||||
* Получаем информацию о юзере из стора.
|
||||
*/
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<span class="text-h4">Откликнуться на вакансию</span>
|
||||
</v-card-text>
|
||||
<v-card-text class="d-flex flex-column pt-0">
|
||||
<v-form ref="form_vacancies" @submit.prevent="submit">
|
||||
<v-form ref="form_vacancies" @submit.prevent="submit">
|
||||
<v-row no-gutters class="justify-center">
|
||||
<v-col lg="8">
|
||||
<v-text-field
|
||||
@@ -22,25 +22,13 @@
|
||||
/>
|
||||
</v-col>
|
||||
<v-col>
|
||||
<v-text-field
|
||||
v-model="form.tel"
|
||||
:counter="7"
|
||||
:rules="rules.tel"
|
||||
label="Телефон"
|
||||
/>
|
||||
<v-text-field v-model="form.tel" :counter="7" :rules="rules.tel" label="Телефон" />
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-textarea
|
||||
v-model="form.text"
|
||||
no-resize
|
||||
rows="4"
|
||||
label="Сопроводительное письмо"
|
||||
/>
|
||||
<v-textarea v-model="form.text" no-resize rows="4" label="Сопроводительное письмо" />
|
||||
<v-file-input label="Резюме" hide-details v-model="file" />
|
||||
|
||||
<v-btn block type="submit" class="mt-4 text-none" color="btn_text">
|
||||
Отправить
|
||||
</v-btn>
|
||||
<v-btn block type="submit" class="mt-4 text-none" color="btn_text"> Отправить </v-btn>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-form>
|
||||
@@ -48,77 +36,60 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ref } from "vue";
|
||||
import { useAlertStore } from "@/store/UseAlertStore";
|
||||
import { clearAxios } from "@/utils/axios-api";
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { useAlertStore } from '@/store/UseAlertStore';
|
||||
import { clearAxios } from '@/utils/axios-api';
|
||||
|
||||
export default {
|
||||
props: {
|
||||
idVacations: {
|
||||
type: Number,
|
||||
default: -1,
|
||||
},
|
||||
const props = defineProps({
|
||||
idVacations: {
|
||||
type: Number,
|
||||
default: -1,
|
||||
},
|
||||
setup(props) {
|
||||
const form = ref({ fio: "", email: "", tel: "", text: "" });
|
||||
const feedalert = useAlertStore().alert;
|
||||
});
|
||||
|
||||
const req = (val) => {
|
||||
return !!val || "Поле обязательно";
|
||||
};
|
||||
const alertStore = useAlertStore();
|
||||
|
||||
const rules = {
|
||||
fio: [
|
||||
(val) => req(val),
|
||||
(val) =>
|
||||
val.match(/^[а-яА-ЯЁё ]+$/) !== null || "Имя должно содержать русские буквы",
|
||||
],
|
||||
email: [(val) => req(val)],
|
||||
tel: [
|
||||
(val) => req(val),
|
||||
(val) => val.match(/^[[\d-]*\d[\d-]*$/) !== null || "Номер должен содержать цифры",
|
||||
],
|
||||
text: "",
|
||||
};
|
||||
const form = ref({ fio: '', email: '', tel: '', text: '' });
|
||||
const file = ref(null);
|
||||
const form_vacancies = ref(null);
|
||||
|
||||
const file = ref(null);
|
||||
const form_vacancies = ref(null)
|
||||
const rules = {
|
||||
fio: [
|
||||
(val) => !!val || 'Поле обязательно',
|
||||
(val) => /^[а-яА-ЯЁё ]+$/.test(val) || 'Имя должно содержать русские буквы',
|
||||
],
|
||||
email: [(val) => !!val || 'Поле обязательно'],
|
||||
tel: [
|
||||
(val) => !!val || 'Поле обязательно',
|
||||
(val) => /^[\d-]+$/.test(val) || 'Номер должен содержать только цифры и дефисы',
|
||||
],
|
||||
};
|
||||
|
||||
const submit = () => {
|
||||
const submit = async () => {
|
||||
const { valid } = await form_vacancies.value.validate();
|
||||
if (!valid) return;
|
||||
|
||||
if(form_vacancies.value.isValid) {
|
||||
|
||||
|
||||
const postFile = new FormData();
|
||||
postFile.append(
|
||||
"data",
|
||||
JSON.stringify({ ...form.value, vacancy_id: props.idVacations })
|
||||
);
|
||||
if (file.value !== null) {
|
||||
const postFile = new FormData();
|
||||
postFile.append('data', JSON.stringify({ ...form.value, vacancy_id: props.idVacations }));
|
||||
|
||||
postFile.append("file", file.value[0]);
|
||||
}
|
||||
if (file.value) {
|
||||
const fileToAppend = Array.isArray(file.value) ? file.value[0] : file.value;
|
||||
postFile.append('file', fileToAppend);
|
||||
}
|
||||
|
||||
|
||||
clearAxios
|
||||
.post(`api/about_inspection/postresponsevacancy/`, postFile)
|
||||
.then((data) => {
|
||||
feedalert.alert = true;
|
||||
feedalert.text = data.data;
|
||||
feedalert.color = "teal-lighten-4";
|
||||
feedalert.ico = "mdi-email-outline";
|
||||
});
|
||||
}
|
||||
};
|
||||
try {
|
||||
const result = await clearAxios.post(`api/about_inspection/postresponsevacancy/`, postFile);
|
||||
const message =
|
||||
typeof result.data === 'string' ? result.data : (result.data?.mess ?? 'Отклик отправлен');
|
||||
alertStore.showSuccess(message);
|
||||
|
||||
return {
|
||||
form,
|
||||
file,
|
||||
rules,
|
||||
submit,
|
||||
form_vacancies
|
||||
};
|
||||
},
|
||||
form.value = { fio: '', email: '', tel: '', text: '' };
|
||||
file.value = null;
|
||||
form_vacancies.value.resetValidation();
|
||||
} catch (e) {
|
||||
alertStore.showError('Не удалось отправить отклик');
|
||||
console.error(e);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
@@ -4,229 +4,46 @@
|
||||
<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';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
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);
|
||||
const route = useRoute();
|
||||
|
||||
onMounted(() => {
|
||||
getEvent();
|
||||
week.getWeekend(MyYear.value);
|
||||
getDictEmployee();
|
||||
getCalendar();
|
||||
getEmployees();
|
||||
});
|
||||
|
||||
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);
|
||||
const currentYear = new Date().getFullYear();
|
||||
calendarStore.fetchHolidays(currentYear);
|
||||
calendarStore.loadCalendars();
|
||||
calendarStore.loadDictEmployees();
|
||||
calendarStore.loadEmployees();
|
||||
if (route.query.date) {
|
||||
calendarStore.setSelectedDate(route.query.date);
|
||||
}
|
||||
};
|
||||
|
||||
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,610 @@
|
||||
<template>
|
||||
<dialog-create
|
||||
:title="titleCard"
|
||||
:newOrOld="isNewEvent"
|
||||
@postData="postData"
|
||||
@closeDialog="$emit('closeDialog')"
|
||||
@delObject="delEvent(form.id)"
|
||||
>
|
||||
<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="form.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-3" lg="2"> Участники </v-col>
|
||||
<v-col>
|
||||
<calendar-create-select
|
||||
:staff="newStaff"
|
||||
:selectedIds="selectedIds"
|
||||
:authorID="currentCalendarAuthorId"
|
||||
@change="onParticipantsChange"
|
||||
/> </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 form"
|
||||
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"
|
||||
:data-calendar-id="item.raw.id"
|
||||
>
|
||||
<template v-slot:prepend>
|
||||
<v-avatar class="cursor-pointer" size="8" :color="item.raw.cl_color" />
|
||||
</template>
|
||||
</v-list-item>
|
||||
</template>
|
||||
|
||||
<template v-slot:append-item>
|
||||
<v-divider class="mb-1" />
|
||||
<v-list-item
|
||||
title="➕ Создать календарь"
|
||||
class="text-primary cursor-pointer"
|
||||
@mousedown.prevent="handleCreateCalendar"
|
||||
/></template>
|
||||
|
||||
<template v-slot:no-data>
|
||||
<v-list-item title="Календарей нет" class="text-medium-emphasis text-body-2" />
|
||||
</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="form.allday"
|
||||
:order="[2, 1]"
|
||||
:dateEvent="String(form.date_start)"
|
||||
:limitation="String(form.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="form.allday"
|
||||
:order="[4, 5]"
|
||||
:dateEvent="String(form.date_end)"
|
||||
:limitation="String(form.date_start)"
|
||||
@update:dateEvent="updateDateEnd"
|
||||
@adjustEndDate="handleAutoAdjustEnd"
|
||||
/>
|
||||
</v-row>
|
||||
<v-row no-gutters>
|
||||
<period-events
|
||||
:dateEvent="form"
|
||||
@update:dateEvent="form = $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(form.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="form.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="form.description"
|
||||
class="scrollable-textarea pt-3"
|
||||
></v-textarea> </v-col
|
||||
></v-row>
|
||||
</v-row>
|
||||
</template>
|
||||
</dialog-create>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, nextTick, ref, toRaw, 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 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,
|
||||
});
|
||||
|
||||
const emit = defineEmits(['getCalendar', 'closeDialog']);
|
||||
|
||||
const accountStore = useAccountStore();
|
||||
const calendarStore = useCalendarStore();
|
||||
const alertStore = useAlertStore();
|
||||
|
||||
const { parseRecurrenceOptions, isRecurringEvent } = useRecurrence();
|
||||
const { requestCreateCalendar } = calendarStore;
|
||||
|
||||
const form = ref({});
|
||||
const mycalendars = computed(() => props.eventCalendar?.mycalendars ?? []);
|
||||
|
||||
const selectedIds = ref(new Set());
|
||||
const newFiles = ref([]);
|
||||
const myCalendar = ref(null);
|
||||
const selectedRule = ref(null);
|
||||
const showRepeatEnd = ref(false);
|
||||
const repeatEndDate = ref(new Date());
|
||||
|
||||
const isNewEvent = computed(() => !('id' in form.value));
|
||||
const titleCard = computed(() => ('id' in form.value ? 'Редактирование события' : 'Новое событие'));
|
||||
|
||||
const currentCalendarAuthorId = computed(() => {
|
||||
if (isNewEvent.value) {
|
||||
return myCalendar.value?.author;
|
||||
}
|
||||
const currentCalendar = mycalendars.value.find(
|
||||
(cal) => Number(cal.id) === Number(form.value.calendar),
|
||||
);
|
||||
return currentCalendar?.author;
|
||||
});
|
||||
|
||||
const newStaff = computed(() => {
|
||||
const calendarSource = isNewEvent.value
|
||||
? myCalendar.value
|
||||
: mycalendars.value.find((cal) => Number(cal.id) === Number(form.value.calendar));
|
||||
|
||||
if (!calendarSource) return [];
|
||||
|
||||
const allowedIds = new Set(
|
||||
(calendarSource.participant ?? []).map((p) =>
|
||||
isNewEvent.value ? p.participant_calendar : p.id,
|
||||
),
|
||||
);
|
||||
|
||||
if (!allowedIds.size) return [];
|
||||
return calendarStore.employees
|
||||
.map((dept) => ({
|
||||
...dept,
|
||||
employees: dept.employees.filter((e) => allowedIds.has(e.id)),
|
||||
}))
|
||||
.filter((dept) => dept.employees.length > 0);
|
||||
});
|
||||
|
||||
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();
|
||||
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) => ({
|
||||
freq: RRule.MONTHLY,
|
||||
interval: 3,
|
||||
bymonthday: [new Date(startDate).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,
|
||||
},
|
||||
];
|
||||
|
||||
selectedRule.value = repeatRules[0];
|
||||
|
||||
const isRepeatEndDisabled = computed(() => !selectedRule.value.rule);
|
||||
|
||||
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 initializeRule = () => {
|
||||
if (!form.value.period) {
|
||||
selectedRule.value = repeatRules[0];
|
||||
repeatEndDate.value = form.value.date_end ? new Date(form.value.date_end) : new Date();
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (isRecurringEvent(form.value)) {
|
||||
const rruleOptions = parseRecurrenceOptions(form.value.period, form.value.date_start);
|
||||
if (rruleOptions) {
|
||||
const foundRule =
|
||||
rruleOptions.freq === RRule.MONTHLY && rruleOptions.interval === 3
|
||||
? repeatRules.find((r) => r.id === 6)
|
||||
: repeatRules.find((r) => r.rule?.freq === rruleOptions.freq);
|
||||
|
||||
selectedRule.value = foundRule || repeatRules[0];
|
||||
|
||||
if (rruleOptions.until) {
|
||||
repeatEndDate.value = new Date(rruleOptions.until);
|
||||
showRepeatEnd.value = true;
|
||||
} else {
|
||||
repeatEndDate.value = form.value.date_end ? new Date(form.value.date_end) : new Date();
|
||||
showRepeatEnd.value = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
selectedRule.value = repeatRules[0];
|
||||
showRepeatEnd.value = false;
|
||||
repeatEndDate.value = form.value.date_end ? new Date(form.value.date_end) : new Date();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error parsing period:', error, 'Raw period:', form.value.period);
|
||||
selectedRule.value = repeatRules[0];
|
||||
showRepeatEnd.value = false;
|
||||
repeatEndDate.value = form.value.date_end ? new Date(form.value.date_end) : new Date();
|
||||
}
|
||||
};
|
||||
|
||||
const initializeCalendar = () => {
|
||||
if (myCalendar.value) return;
|
||||
|
||||
const fromEvent = form.value?.calendar
|
||||
? safeCalendars.value.find((cal) => cal.id === form.value.calendar)
|
||||
: null;
|
||||
|
||||
myCalendar.value = fromEvent ?? safeCalendars.value[0] ?? null;
|
||||
};
|
||||
|
||||
const initForm = () => {
|
||||
form.value = structuredClone(toRaw(props.eventCalendar?.event ?? {}));
|
||||
newFiles.value = [];
|
||||
myCalendar.value = null;
|
||||
initializeRule();
|
||||
};
|
||||
|
||||
const delEvent = async (idev) => {
|
||||
try {
|
||||
const result = await axiosApiInstance.delete(`api/calendar_of_events/my_events/?delid=${idev}`);
|
||||
alertStore.showSuccess(result.data.mess);
|
||||
emit('getCalendar');
|
||||
emit('closeDialog');
|
||||
} catch (e) {
|
||||
alertStore.showError('Ошибка удаления события');
|
||||
console.error(e);
|
||||
}
|
||||
};
|
||||
|
||||
const handleFilesUpdate = (updatedExistingFiles) => {
|
||||
const currentNewFiles = [...newFiles.value];
|
||||
form.value.files = updatedExistingFiles;
|
||||
newFiles.value = currentNewFiles;
|
||||
};
|
||||
|
||||
const postFiles = (updatedFiles) => {
|
||||
newFiles.value = updatedFiles;
|
||||
};
|
||||
|
||||
const onParticipantsChange = ({ ids, action }) => {
|
||||
const next = new Set(selectedIds.value);
|
||||
ids.forEach((id) => {
|
||||
if (action === 'add') next.add(id);
|
||||
else if (action === 'remove') next.delete(id);
|
||||
else if (action === 'toggle') next.has(id) ? next.delete(id) : next.add(id);
|
||||
});
|
||||
next.add(accountStore.user.is_idEmployee);
|
||||
selectedIds.value = next;
|
||||
form.value.participant = Array.from(next);
|
||||
};
|
||||
|
||||
const postData = async (validate) => {
|
||||
if (!validate) return;
|
||||
if (!myCalendar.value) {
|
||||
alertStore.showError('Выберите календарь');
|
||||
return;
|
||||
}
|
||||
|
||||
await nextTick();
|
||||
updatePeriodRule(selectedRule.value);
|
||||
form.value.calendar = myCalendar.value.id;
|
||||
|
||||
const postEvent = new FormData();
|
||||
postEvent.append('event', JSON.stringify({ ...form.value, files: form.value.files }));
|
||||
|
||||
if (newFiles.value.length) {
|
||||
newFiles.value.forEach((file) => postEvent.append('files', file, file.name));
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await axiosApiInstance.post('api/calendar_of_events/my_events/', postEvent);
|
||||
alertStore.showSuccess(result.data.mess);
|
||||
emit('getCalendar');
|
||||
emit('closeDialog');
|
||||
} catch (e) {
|
||||
alertStore.showError('Ошибка сохранения события');
|
||||
console.error(e);
|
||||
}
|
||||
};
|
||||
|
||||
const handleAutoAdjustEnd = (newEndDate) => {
|
||||
form.value.date_end = newEndDate;
|
||||
};
|
||||
|
||||
const updateRepeatEndDate = (date) => {
|
||||
repeatEndDate.value = date;
|
||||
updatePeriodRule(selectedRule.value);
|
||||
};
|
||||
|
||||
const updateDateStart = (newDate) => {
|
||||
const normalizedDate = new Date(newDate).toISOString();
|
||||
form.value.date_start = normalizedDate;
|
||||
|
||||
const startDate = new Date(normalizedDate);
|
||||
const endDate = new Date(form.value.date_end);
|
||||
if (startDate > endDate) {
|
||||
const adjustedEnd = new Date(startDate);
|
||||
adjustedEnd.setHours(startDate.getHours() + 1);
|
||||
form.value.date_end = adjustedEnd.toISOString();
|
||||
}
|
||||
|
||||
if (selectedRule.value.rule) updatePeriodRule(selectedRule.value);
|
||||
};
|
||||
|
||||
const updateDateEnd = (newDate) => {
|
||||
form.value.date_end = new Date(newDate).toISOString();
|
||||
};
|
||||
|
||||
const updatePeriodRule = (rule) => {
|
||||
selectedRule.value = rule;
|
||||
|
||||
if (!rule.rule) {
|
||||
showRepeatEnd.value = false;
|
||||
repeatEndDate.value = null;
|
||||
form.value.period = null;
|
||||
return;
|
||||
}
|
||||
|
||||
const dtstart = new Date(form.value.date_start);
|
||||
const localDtstart = new Date(
|
||||
dtstart.getFullYear(),
|
||||
dtstart.getMonth(),
|
||||
dtstart.getDate(),
|
||||
dtstart.getHours(),
|
||||
dtstart.getMinutes(),
|
||||
dtstart.getSeconds(),
|
||||
);
|
||||
|
||||
const base = rule.getRule ? rule.getRule(form.value.date_start) : { ...rule.rule };
|
||||
const ruleOptions = { ...base, dtstart: localDtstart };
|
||||
|
||||
if (showRepeatEnd.value && repeatEndDate.value) {
|
||||
const u = new Date(repeatEndDate.value);
|
||||
ruleOptions.until = new Date(
|
||||
u.getFullYear(),
|
||||
u.getMonth(),
|
||||
u.getDate(),
|
||||
u.getHours(),
|
||||
u.getMinutes(),
|
||||
u.getSeconds(),
|
||||
);
|
||||
}
|
||||
|
||||
form.value.period = new RRule(ruleOptions).toString();
|
||||
};
|
||||
|
||||
async function handleCreateCalendar() {
|
||||
const idsBefore = new Set(safeCalendars.value.map((cal) => cal.id));
|
||||
const created = await requestCreateCalendar();
|
||||
if (!created) return;
|
||||
|
||||
emit('getCalendar');
|
||||
await waitForNewCalendar(idsBefore);
|
||||
}
|
||||
|
||||
function waitForNewCalendar(idsBefore, timeoutMs = 5000) {
|
||||
return new Promise((resolve) => {
|
||||
const checkNow = safeCalendars.value.find((cal) => !idsBefore.has(cal.id));
|
||||
if (checkNow) {
|
||||
myCalendar.value = checkNow;
|
||||
resolve(checkNow);
|
||||
return;
|
||||
}
|
||||
const stop = watch(
|
||||
safeCalendars,
|
||||
(list) => {
|
||||
const fresh = list.find((cal) => !idsBefore.has(cal.id));
|
||||
if (fresh) {
|
||||
myCalendar.value = fresh;
|
||||
stop();
|
||||
clearTimeout(timer);
|
||||
resolve(fresh);
|
||||
}
|
||||
},
|
||||
{ deep: true },
|
||||
);
|
||||
const timer = setTimeout(() => {
|
||||
stop();
|
||||
resolve(null);
|
||||
}, timeoutMs);
|
||||
});
|
||||
}
|
||||
|
||||
// Загрузка/переинициализация при смене редактируемого события
|
||||
watch(() => props.eventCalendar?.event?.id, initForm, { immediate: true });
|
||||
|
||||
// Участники: при смене календаря (новое событие) и при загрузке
|
||||
watch(
|
||||
[myCalendar, () => props.eventCalendar?.event?.id],
|
||||
() => {
|
||||
if (isNewEvent.value) {
|
||||
const participantIds = (myCalendar.value?.participant ?? []).map(
|
||||
(p) => p.participant_calendar,
|
||||
);
|
||||
selectedIds.value = new Set([accountStore.user.is_idEmployee, ...participantIds]);
|
||||
form.value.participant = Array.from(selectedIds.value);
|
||||
} else {
|
||||
const ids = form.value.participant ?? [];
|
||||
selectedIds.value = new Set([accountStore.user.is_idEmployee, ...ids]);
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
// Дефолтный календарь при асинхронном приходе allCalendars
|
||||
watch(
|
||||
[() => safeCalendars.value.length, () => props.eventCalendar?.event?.id],
|
||||
initializeCalendar,
|
||||
{ immediate: true },
|
||||
);
|
||||
</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>
|
||||
+169
-181
@@ -1,187 +1,184 @@
|
||||
<template>
|
||||
<v-dialog v-model="internalShow" max-width="700">
|
||||
<v-card class="pa-4" min-height="400">
|
||||
<!-- Заголовок -->
|
||||
<v-card-title class="pr-0 pl-2 d-flex justify-space-between pb-3">
|
||||
<span class="text-h5 font-weight-medium">Просмотр события</span>
|
||||
<v-icon
|
||||
icon="mdi-close"
|
||||
size="small"
|
||||
color="grey"
|
||||
class="cursor-pointer"
|
||||
@click="closeDialog"
|
||||
/>
|
||||
</v-card-title>
|
||||
<v-card class="pa-0" rounded="lg" elevation="8">
|
||||
<!-- Акцентная полоса -->
|
||||
<div :style="{ height: '4px', background: calendarColor }" />
|
||||
|
||||
<v-divider></v-divider>
|
||||
<!-- Шапка -->
|
||||
<div class="d-flex align-center justify-space-between pa-5 pb-4">
|
||||
<div class="d-flex align-center" style="min-width: 0">
|
||||
<v-avatar :color="calendarColor" size="40" class="mr-3 flex-shrink-0">
|
||||
<v-icon icon="mdi-calendar-text" color="white" size="22" />
|
||||
</v-avatar>
|
||||
<div style="min-width: 0">
|
||||
<div class="text-caption text-medium-emphasis text-uppercase">
|
||||
{{ calendarName }}
|
||||
</div>
|
||||
<div class="text-h6 font-weight-medium text-truncate" :title="eventData.event?.name">
|
||||
{{ eventData.event?.name || 'Без названия' }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Контент -->
|
||||
<v-card-text class="px-2">
|
||||
<v-row no-gutters class="flex-column">
|
||||
<!-- Название события -->
|
||||
<v-row no-gutters class="align-center border-bottom">
|
||||
<v-col
|
||||
style="font-size: 1.1rem; line-height: 1.4"
|
||||
class="text-body-1 text-text_grey font-weight-medium"
|
||||
lg="3"
|
||||
>
|
||||
Название
|
||||
</v-col>
|
||||
<v-col>
|
||||
<div class="text-body-1" style="font-size: 1.1rem; line-height: 1.4">
|
||||
{{ eventData.event?.name || 'Без названия' }}
|
||||
</div>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-btn icon="mdi-close" variant="text" density="comfortable" size="small" @click="closeDialog" />
|
||||
</div>
|
||||
|
||||
<!-- Календарь -->
|
||||
<v-row no-gutters class="align-center pb-3 mb-3 border-bottom">
|
||||
<v-col class="text-body-1 text-text_grey font-weight-medium" lg="3"> Календарь </v-col>
|
||||
<v-col>
|
||||
<div class="d-flex align-center">
|
||||
<v-avatar size="20" :color="calendarColor" class="mr-3" />
|
||||
<span class="text-body-1">{{ calendarName }}</span>
|
||||
</div>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-divider />
|
||||
|
||||
<!-- Участники -->
|
||||
<v-row
|
||||
no-gutters
|
||||
class="align-start pb-3 mb-3 border-bottom"
|
||||
v-if="participantsList.length > 0"
|
||||
>
|
||||
<v-col class="text-body-1 text-text_grey font-weight-medium pt-1" lg="3">
|
||||
<!-- Контент -->
|
||||
<v-card-text class="pa-5">
|
||||
<v-list density="comfortable" bg-color="transparent" class="pa-0">
|
||||
<!-- Дата и время -->
|
||||
<v-list-item class="px-0">
|
||||
<template #prepend>
|
||||
<v-icon icon="mdi-clock-outline" color="medium-emphasis" class="mr-3" />
|
||||
</template>
|
||||
<v-list-item-title class="text-caption text-medium-emphasis">
|
||||
Дата и время
|
||||
</v-list-item-title>
|
||||
<v-list-item-subtitle class="text-body-2 text-high-emphasis mt-1" style="opacity: 1">
|
||||
<span class="font-weight-medium">
|
||||
{{ formatDateTime(eventData.event?.date_start, eventData.event?.allday) }}
|
||||
</span>
|
||||
<v-icon icon="mdi-arrow-right" size="14" class="mx-2" />
|
||||
<span class="font-weight-medium">
|
||||
{{ formatDateTime(eventData.event?.date_end, eventData.event?.allday) }}
|
||||
</span>
|
||||
</v-list-item-subtitle>
|
||||
</v-list-item>
|
||||
|
||||
<v-divider class="my-1" />
|
||||
|
||||
<!-- Повторение -->
|
||||
<template v-if="eventData.event?.period">
|
||||
<v-list-item class="px-0">
|
||||
<template #prepend>
|
||||
<v-icon icon="mdi-refresh" color="medium-emphasis" class="mr-3" />
|
||||
</template>
|
||||
<v-list-item-title class="text-caption text-medium-emphasis">Повтор</v-list-item-title>
|
||||
<v-list-item-subtitle class="text-body-2 mt-1" style="opacity: 1">
|
||||
{{ recurrenceText }}
|
||||
<span v-if="showRepeatEnd" class="text-medium-emphasis ml-2">
|
||||
· до {{ formatRepeatEndDate }}
|
||||
</span>
|
||||
</v-list-item-subtitle>
|
||||
</v-list-item>
|
||||
<v-divider class="my-1" />
|
||||
</template>
|
||||
|
||||
<!-- Участники -->
|
||||
<template v-if="participantsList.length">
|
||||
<v-list-item class="px-0">
|
||||
<template #prepend>
|
||||
<v-icon icon="mdi-account-multiple-outline" color="medium-emphasis" class="mr-3" />
|
||||
</template>
|
||||
<v-list-item-title class="text-caption text-medium-emphasis">
|
||||
Участники
|
||||
</v-col>
|
||||
<v-col>
|
||||
<div class="participants-list">
|
||||
<div
|
||||
v-for="participant in participantsList"
|
||||
:key="participant.id"
|
||||
class="text-body-1 mb-1"
|
||||
<v-chip size="x-small" variant="tonal" class="ml-2">{{ participantsList.length }}</v-chip>
|
||||
</v-list-item-title>
|
||||
<v-list-item-subtitle class="mt-2" style="opacity: 1">
|
||||
<div class="d-flex flex-wrap ga-2">
|
||||
<v-chip
|
||||
v-for="p in participantsList"
|
||||
:key="p.id"
|
||||
size="small"
|
||||
variant="tonal"
|
||||
prepend-icon="mdi-account"
|
||||
>
|
||||
• {{ participant.title }}
|
||||
</div>
|
||||
{{ p.title }}
|
||||
</v-chip>
|
||||
</div>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-list-item-subtitle>
|
||||
</v-list-item>
|
||||
<v-divider class="my-1" />
|
||||
</template>
|
||||
|
||||
<!-- Дата и время -->
|
||||
<v-row no-gutters class="align-top pb-3 mb-3 border-bottom">
|
||||
<v-col class="text-body-1 text-text_grey font-weight-medium pt-1" lg="3">
|
||||
Дата и время
|
||||
</v-col>
|
||||
<v-col class="d-flex flex-column">
|
||||
<div class="d-flex align-center gap">
|
||||
<div class="text-body-1 font-weight-medium">
|
||||
{{ formatDateTime(eventData.event?.date_start, eventData.event?.allday) }}
|
||||
</div>
|
||||
<v-icon icon="mdi-minus" color="grey" class="mx-3" />
|
||||
<div class="text-body-1 font-weight-medium">
|
||||
{{ formatDateTime(eventData.event?.date_end, eventData.event?.allday) }}
|
||||
</div>
|
||||
</div>
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
<!-- Повторение -->
|
||||
<v-row
|
||||
no-gutters
|
||||
class="align-center pb-3 mb-3 border-bottom"
|
||||
v-if="eventData.event?.period"
|
||||
>
|
||||
<v-col class="text-body-1 text-text_grey font-weight-medium" lg="3"> Повтор события </v-col>
|
||||
<v-col>
|
||||
<div class="text-body-1">{{ recurrenceText }}</div>
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
<!-- Окончание события -->
|
||||
<v-row no-gutters class="align-center pb-3 mb-3 border-bottom" v-if="showRepeatEnd">
|
||||
<v-col class="text-body-1 text-text_grey font-weight-medium" lg="3">
|
||||
Окончание события
|
||||
</v-col>
|
||||
<v-col>
|
||||
<div class="text-body-1">
|
||||
{{ formatRepeatEndDate }}
|
||||
</div>
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
<!-- Файлы -->
|
||||
<v-row
|
||||
no-gutters
|
||||
class="align-top pb-3 mb-3 border-bottom"
|
||||
v-if="eventData.event?.files?.length"
|
||||
>
|
||||
<v-col class="text-body-1 text-text_grey font-weight-medium" lg="3"> Файлы </v-col>
|
||||
<v-col>
|
||||
<div class="files-list">
|
||||
<div
|
||||
<!-- Файлы -->
|
||||
<template v-if="eventData.event?.files?.length">
|
||||
<v-list-item class="px-0">
|
||||
<template #prepend>
|
||||
<v-icon icon="mdi-paperclip" color="medium-emphasis" class="mr-3" />
|
||||
</template>
|
||||
<v-list-item-title class="text-caption text-medium-emphasis">
|
||||
Файлы
|
||||
<v-chip size="x-small" variant="tonal" class="ml-2">
|
||||
{{ eventData.event.files.length }}
|
||||
</v-chip>
|
||||
</v-list-item-title>
|
||||
<v-list-item-subtitle class="mt-2" style="opacity: 1">
|
||||
<v-list density="compact" bg-color="transparent" class="pa-0">
|
||||
<v-list-item
|
||||
v-for="file in eventData.event.files"
|
||||
:key="file.id"
|
||||
class="d-flex align-center mb-2 cursor-pointer"
|
||||
:prepend-icon="getFileIcon(file)"
|
||||
:title="truncateFileName(getFileName(file))"
|
||||
append-icon="mdi-download"
|
||||
rounded="md"
|
||||
variant="tonal"
|
||||
density="compact"
|
||||
class="mb-1"
|
||||
@click="downloadFile(file)"
|
||||
>
|
||||
<v-icon :icon="getFileIcon(file)" color="primary" class="mr-2" size="small" />
|
||||
<span class="text-body-1 text-primary text-decoration-underline">
|
||||
{{ truncateFileName(getFileName(file)) }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</v-col>
|
||||
</v-row>
|
||||
/>
|
||||
</v-list>
|
||||
</v-list-item-subtitle>
|
||||
</v-list-item>
|
||||
<v-divider class="my-1" />
|
||||
</template>
|
||||
|
||||
<!-- Описание -->
|
||||
<v-row no-gutters class="align-top pb-3" v-if="eventData.event?.description">
|
||||
<v-col class="text-body-1 text-text_grey font-weight-medium" lg="3"> Описание </v-col>
|
||||
<v-col>
|
||||
<div class="text-body-1 description-text">
|
||||
{{ eventData.event.description }}
|
||||
</div>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<!-- Описание -->
|
||||
<v-list-item v-if="eventData.event?.description" class="px-0">
|
||||
<template #prepend>
|
||||
<v-icon icon="mdi-text" color="medium-emphasis" class="mr-3" />
|
||||
</template>
|
||||
<v-list-item-title class="text-caption text-medium-emphasis">Описание</v-list-item-title>
|
||||
<v-list-item-subtitle class="mt-2" style="opacity: 1">
|
||||
<v-sheet
|
||||
rounded="md"
|
||||
color="surface-light"
|
||||
class="pa-3"
|
||||
:style="{ borderLeft: `3px solid ${calendarColor}`, whiteSpace: 'pre-wrap' }"
|
||||
>
|
||||
{{ eventData.event.description }}
|
||||
</v-sheet>
|
||||
</v-list-item-subtitle>
|
||||
</v-list-item>
|
||||
</v-list>
|
||||
|
||||
<!-- Если нет данных -->
|
||||
<v-row v-if="!eventData.event?.name" class="justify-center mt-8">
|
||||
<v-col class="text-center">
|
||||
<v-icon size="64" color="grey-lighten-1">mdi-calendar-remove</v-icon>
|
||||
<div class="text-h6 text-grey mt-2">Нет данных о событии</div>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-row>
|
||||
</v-card-text>
|
||||
<!-- Пусто -->
|
||||
<div v-if="!eventData.event?.name" class="text-center py-8">
|
||||
<v-icon size="56" color="grey-lighten-1" icon="mdi-calendar-remove" />
|
||||
<div class="text-body-1 text-medium-emphasis mt-3">Нет данных о событии</div>
|
||||
</div>
|
||||
</v-card-text>
|
||||
|
||||
<!-- Кнопки -->
|
||||
<v-card-actions class="justify-end pa-4 pt-0">
|
||||
<v-btn
|
||||
width="120"
|
||||
@click="closeDialog"
|
||||
color="grey-darken-1"
|
||||
variant="tonal"
|
||||
class="text-body-1"
|
||||
>
|
||||
Закрыть
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
<v-divider />
|
||||
|
||||
<!-- Кнопки -->
|
||||
<v-card-actions class="pa-4">
|
||||
<v-spacer />
|
||||
|
||||
<v-btn
|
||||
v-if="canEdit"
|
||||
:color="calendarColor"
|
||||
variant="elevated"
|
||||
prepend-icon="mdi-pencil"
|
||||
@click="onEdit"
|
||||
>
|
||||
Редактировать
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { useRecurrence } from '@/components/calendar_of_events/composables/useReccurrence';
|
||||
import { RRule } from 'rrule';
|
||||
import { useCalendarStore } from '../../store/calendarStore';
|
||||
|
||||
export default {
|
||||
name: 'EventCalendarShow',
|
||||
|
||||
props: {
|
||||
show: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
eventData: {
|
||||
type: Object,
|
||||
default: () => ({}),
|
||||
@@ -196,32 +193,14 @@ export default {
|
||||
},
|
||||
},
|
||||
|
||||
emits: ['update:show', 'close'],
|
||||
emits: ['close'],
|
||||
|
||||
setup(props, { emit }) {
|
||||
const internalShow = ref(props.show);
|
||||
const { parseRecurrenceOptions, isRecurringEvent } = useRecurrence();
|
||||
const calendarStore = useCalendarStore();
|
||||
|
||||
// Синхронизация с внешним состоянием
|
||||
watch(
|
||||
() => props.show,
|
||||
(newVal) => {
|
||||
internalShow.value = newVal;
|
||||
},
|
||||
);
|
||||
const closeDialog = () => emit('close');
|
||||
|
||||
watch(internalShow, (newVal) => {
|
||||
if (!newVal) {
|
||||
emit('update:show', false);
|
||||
emit('close');
|
||||
}
|
||||
});
|
||||
|
||||
const closeDialog = () => {
|
||||
internalShow.value = false;
|
||||
};
|
||||
|
||||
// Информация о календаре - ИСПРАВЛЕНО
|
||||
const calendarInfo = computed(() => {
|
||||
const calendarId = props.eventData.event?.calendar;
|
||||
return props.allCalendars.find((cal) => cal.id == calendarId) || {};
|
||||
@@ -230,7 +209,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,8 +436,16 @@ export default {
|
||||
return `${nameWithoutExt.slice(0, 20)}...${extension ? '.' + extension : ''}`;
|
||||
};
|
||||
|
||||
const canEdit = computed(() => {
|
||||
const id = props.eventData?.event?.id;
|
||||
return id ? calendarStore.canEditEvent(id) : false;
|
||||
});
|
||||
|
||||
const onEdit = () => {
|
||||
calendarStore.editFromView();
|
||||
};
|
||||
|
||||
return {
|
||||
internalShow,
|
||||
closeDialog,
|
||||
calendarName,
|
||||
calendarColor,
|
||||
@@ -472,6 +458,8 @@ export default {
|
||||
truncateFileName,
|
||||
showRepeatEnd,
|
||||
formatRepeatEndDate,
|
||||
canEdit,
|
||||
onEdit,
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
<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>
|
||||
|
||||
<v-dialog v-model="calendarStore.showViewDialog" max-width="700">
|
||||
<event-show
|
||||
v-if="calendarStore.showViewDialog"
|
||||
:event-data="calendarStore.selectedEventForView"
|
||||
:all-calendars="calendarStore.calendars"
|
||||
:employees="calendarStore.employees"
|
||||
@close="calendarStore.closeEventView"
|
||||
/>
|
||||
</v-dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { useCalendarStore } from '@/store/calendarStore';
|
||||
|
||||
import EventCreate from '../EventCreate.vue';
|
||||
import EventShow from '../EventShow.vue';
|
||||
|
||||
const calendarStore = useCalendarStore();
|
||||
</script>
|
||||
@@ -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,18 +62,17 @@
|
||||
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>
|
||||
</div>
|
||||
<div class="flex-grow-1 d-flex">
|
||||
<!-- VCalendar -->
|
||||
<div class="flex-grow-1 d-flex" ref="calWrap">
|
||||
<FullCalendar
|
||||
v-if="currentView !== 'listAllEvents'"
|
||||
ref="calendarRef"
|
||||
@@ -87,405 +86,341 @@
|
||||
</v-card>
|
||||
</v-col>
|
||||
</template>
|
||||
<script>
|
||||
import { ref, watch, nextTick, computed } from 'vue';
|
||||
<script setup>
|
||||
import { ref, computed, watch, nextTick, onMounted, onBeforeUnmount } from 'vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
import dayGridPlugin from '@fullcalendar/daygrid';
|
||||
import timeGridPlugin from '@fullcalendar/timegrid';
|
||||
import multiMonthPlugin from '@fullcalendar/multimonth';
|
||||
import interactionPlugin from '@fullcalendar/interaction';
|
||||
import listPlugin from '@fullcalendar/list';
|
||||
import ruLocale from '@fullcalendar/core/locales/ru';
|
||||
import rrulePlugin from '@fullcalendar/rrule';
|
||||
import { onMounted } from 'vue';
|
||||
import ruLocale from '@fullcalendar/core/locales/ru';
|
||||
|
||||
import { useCalendarStore } from '@/store/calendarStore';
|
||||
import { useRecurrence } from '@/components/calendar_of_events/composables/useReccurrence';
|
||||
import { useAccountStore } from '@/store/AccountStore';
|
||||
import { useRecurrence } from '@/components/calendar_of_events/composables/useReccurrence';
|
||||
import { useEventListFilters } from '../composables/useEventListFilters';
|
||||
import EventsListView from './EventsListView.vue';
|
||||
import EventListFilters from './EventListFilters.vue';
|
||||
import { useEventListFilters } from '../composables/useEventListFilters';
|
||||
|
||||
export default {
|
||||
name: 'CustomCalendar',
|
||||
defineOptions({ name: 'CustomCalendar' });
|
||||
|
||||
emits: ['openEventDialog', 'openEventView'],
|
||||
components: {
|
||||
EventsListView,
|
||||
EventListFilters,
|
||||
const props = defineProps({
|
||||
forHomePage: { type: Boolean, default: false },
|
||||
view: { type: String, default: 'dayGridMonth' },
|
||||
});
|
||||
|
||||
const calendarStore = useCalendarStore();
|
||||
const accountStore = useAccountStore();
|
||||
const route = useRoute();
|
||||
const { selectedDate, lastUpdatedBy, allEvents, calendarColorMap } = storeToRefs(calendarStore);
|
||||
const { isRecurringEvent, generateRecurringInstances } = useRecurrence();
|
||||
const filters = useEventListFilters();
|
||||
|
||||
const currentView = ref('dayGridMonth');
|
||||
const currentTitle = ref('Календарь');
|
||||
const calendarRef = ref(null);
|
||||
const calWrap = ref(null);
|
||||
|
||||
const calendarApi = computed(() => calendarRef.value?.getApi?.() || null);
|
||||
const unwrappedFilters = computed(() => ({
|
||||
dateRange: filters.dateRange.value,
|
||||
sortOrder: filters.sortOrder.value,
|
||||
}));
|
||||
|
||||
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 handleDateSelection = (dateStr) => {
|
||||
document
|
||||
.querySelectorAll('.fc-day-selected-custom')
|
||||
.forEach((el) => el.classList.remove('fc-day-selected-custom'));
|
||||
document
|
||||
.querySelectorAll(`[data-date="${dateStr}"]`)
|
||||
.forEach((el) => el.classList.add('fc-day-selected-custom'));
|
||||
selectedDate.value = dateStr;
|
||||
};
|
||||
|
||||
const updateSelectedDateFromCalendar = () => {
|
||||
const currentDate = calendarApi.value?.getDate();
|
||||
if (currentDate) {
|
||||
calendarStore.setSelectedDateFromCalendar({
|
||||
dateStr: currentDate.toISOString().split('T')[0],
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const handleEventClick = (info) => calendarStore.handleEventClick(info);
|
||||
|
||||
const handleCalendarDateClick = (info) => {
|
||||
calendarStore.setSelectedDateFromCalendar(info);
|
||||
currentTitle.value = info.view.title;
|
||||
if (calendarApi.value) {
|
||||
calendarApi.value.gotoDate(info.date);
|
||||
calendarApi.value.changeView('listWeek');
|
||||
currentView.value = 'listWeek';
|
||||
}
|
||||
};
|
||||
|
||||
const handleToday = () => {
|
||||
calendarApi.value?.today();
|
||||
updateSelectedDateFromCalendar();
|
||||
};
|
||||
const handlePrev = () => {
|
||||
calendarApi.value?.prev();
|
||||
updateSelectedDateFromCalendar();
|
||||
};
|
||||
const handleNext = () => {
|
||||
calendarApi.value?.next();
|
||||
updateSelectedDateFromCalendar();
|
||||
};
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
const handleFiltersUpdate = (newFilters) => {
|
||||
Object.keys(newFilters).forEach((key) => {
|
||||
if (filters[key] !== undefined) filters[key].value = newFilters[key];
|
||||
});
|
||||
};
|
||||
|
||||
// Ресайз контейнера
|
||||
let ro = null;
|
||||
let rafId = null;
|
||||
const updateSize = () => calendarRef.value?.getApi()?.updateSize();
|
||||
const scheduleUpdate = () => {
|
||||
cancelAnimationFrame(rafId);
|
||||
rafId = requestAnimationFrame(updateSize);
|
||||
};
|
||||
|
||||
const dayClassNames = (arg) => {
|
||||
const info = calendarStore.isNonWorkingDay(arg.date);
|
||||
const classes = [];
|
||||
if (info.isHoliday) classes.push('non-working-day');
|
||||
if (info.isWeekendForStyling) classes.push('grey-background');
|
||||
return classes;
|
||||
};
|
||||
|
||||
const buildEvents = (fetchInfo, successCallback) => {
|
||||
const events = allEvents.value.flatMap((event) => {
|
||||
const eventColor = calendarColorMap.value.get(event.calendar) || '#3788d8';
|
||||
|
||||
if (isRecurringEvent(event)) {
|
||||
return generateRecurringInstances(event, 52).map((instance) => ({
|
||||
id: instance.id,
|
||||
title: instance.title,
|
||||
start: instance.start,
|
||||
end: instance.end,
|
||||
allDay: instance.allDay,
|
||||
textColor: '#ffffff',
|
||||
backgroundColor: eventColor,
|
||||
borderColor: eventColor,
|
||||
extendedProps: {
|
||||
...instance.extendedProps,
|
||||
_userHash: accountStore.user?.id || 'anonymous',
|
||||
},
|
||||
}));
|
||||
}
|
||||
|
||||
return [
|
||||
{
|
||||
id: event.id,
|
||||
title: event.name,
|
||||
start: event.date_start,
|
||||
end: event.date_end,
|
||||
allDay: event.allday,
|
||||
textColor: '#ffffff',
|
||||
backgroundColor: eventColor,
|
||||
borderColor: eventColor,
|
||||
extendedProps: {
|
||||
originalEventId: event.id,
|
||||
description: event.description,
|
||||
participant: event.participant,
|
||||
calendar: event.calendar,
|
||||
files: event.files,
|
||||
_userHash: accountStore.user?.id || 'anonymous',
|
||||
},
|
||||
},
|
||||
];
|
||||
});
|
||||
successCallback(events);
|
||||
};
|
||||
|
||||
const calendarViews = {
|
||||
timeGridDay: {
|
||||
type: 'timeGrid',
|
||||
duration: { days: 1 },
|
||||
slotDuration: '01:00:00',
|
||||
slotLabelInterval: '01:00:00',
|
||||
slotLabelFormat: { hour: '2-digit', minute: '2-digit', hour12: false, meridiem: false },
|
||||
allDaySlot: true,
|
||||
slotMinTime: '07:00:00',
|
||||
slotMaxTime: '22:00:00',
|
||||
expandRows: true,
|
||||
dayHeaderFormat: { weekday: 'long', day: 'numeric', month: 'long', omitCommas: true },
|
||||
},
|
||||
setup(props, { emit }) {
|
||||
const currentView = ref('dayGridMonth');
|
||||
const currentTitle = ref('Календарь');
|
||||
const calendarRef = ref(null);
|
||||
const accountStore = useAccountStore();
|
||||
|
||||
const calendarStore = useCalendarStore();
|
||||
const { selectedDate, lastUpdatedBy, allEvents, calendarColorMap } = storeToRefs(calendarStore);
|
||||
const { isRecurringEvent, generateRecurringInstances } = useRecurrence();
|
||||
|
||||
const calendarApi = computed(() => {
|
||||
return calendarRef.value?.getApi?.() || null;
|
||||
});
|
||||
|
||||
const filters = useEventListFilters();
|
||||
|
||||
// Создаем развернутую версию фильтров для передачи в EventsListView
|
||||
const unwrappedFilters = computed(() => ({
|
||||
dateRange: filters.dateRange.value,
|
||||
sortOrder: filters.sortOrder.value,
|
||||
}));
|
||||
|
||||
const handleEventClick = (info) => {
|
||||
if (calendarStore.canEditEvent(info.event.id)) {
|
||||
emit('openEventDialog', info);
|
||||
} else {
|
||||
emit('openEventView', info.event.id);
|
||||
}
|
||||
};
|
||||
|
||||
const calendarOptions = ref({
|
||||
plugins: [
|
||||
dayGridPlugin,
|
||||
timeGridPlugin,
|
||||
multiMonthPlugin,
|
||||
interactionPlugin,
|
||||
listPlugin,
|
||||
rrulePlugin,
|
||||
],
|
||||
initialView: props.forHomePage ? props.view : currentView.value,
|
||||
locales: [ruLocale],
|
||||
locale: 'ru',
|
||||
timeZone: 'local',
|
||||
firstDay: 1,
|
||||
headerToolbar: false,
|
||||
height: '80vh',
|
||||
aspectRatio: 1.5,
|
||||
weekNumbers: true,
|
||||
eventDisplay: 'block',
|
||||
eventTimeFormat: {
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
hour12: false,
|
||||
meridiem: false,
|
||||
},
|
||||
weekNumberFormat: {
|
||||
week: 'numeric',
|
||||
},
|
||||
weekNumberCalculation: 'ISO', // ISO стандарт (понедельник - первый день)
|
||||
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');
|
||||
}
|
||||
},
|
||||
views: {
|
||||
timeGridDay: {
|
||||
type: 'timeGrid',
|
||||
duration: { days: 1 },
|
||||
slotDuration: '01:00:00',
|
||||
slotLabelInterval: '01:00:00',
|
||||
slotLabelFormat: {
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
hour12: false,
|
||||
meridiem: false,
|
||||
},
|
||||
allDaySlot: true,
|
||||
slotMinTime: '07:00:00',
|
||||
slotMaxTime: '22:00:00',
|
||||
expandRows: true,
|
||||
dayHeaderFormat: {
|
||||
weekday: 'long',
|
||||
day: 'numeric',
|
||||
month: 'long',
|
||||
omitCommas: true,
|
||||
},
|
||||
},
|
||||
|
||||
timeGridWeek: {
|
||||
type: 'timeGrid',
|
||||
duration: { weeks: 1 },
|
||||
slotDuration: '01:00:00',
|
||||
slotMinTime: '07:00:00',
|
||||
slotMaxTime: '22:00:00',
|
||||
allDaySlot: true,
|
||||
expandRows: true,
|
||||
|
||||
dayHeaderFormat: { weekday: 'short', day: 'numeric' },
|
||||
titleFormat: {
|
||||
day: 'numeric',
|
||||
month: 'long',
|
||||
omitCommas: true,
|
||||
},
|
||||
},
|
||||
dayGridMonth: {
|
||||
type: 'dayGrid',
|
||||
fixedWeekCount: false,
|
||||
dayHeaderFormat: { weekday: 'short' },
|
||||
weekNumbers: true,
|
||||
|
||||
weekNumberFormat: { week: 'numeric' },
|
||||
weekNumberContent: (arg) => {
|
||||
return arg.num;
|
||||
},
|
||||
weekText: 'Нед.',
|
||||
eventTimeFormat: {
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
hour12: false,
|
||||
omitZeroMinute: false,
|
||||
},
|
||||
},
|
||||
multiMonthYear: {
|
||||
type: 'multiMonth',
|
||||
duration: { years: 1 },
|
||||
multiMonthMaxColumns: 4,
|
||||
fixedWeekCount: false,
|
||||
weekNumbers: false,
|
||||
},
|
||||
listWeek: {
|
||||
type: 'list',
|
||||
duration: { days: 1 },
|
||||
listDayFormat: {
|
||||
weekday: 'long',
|
||||
day: 'numeric',
|
||||
month: 'long',
|
||||
},
|
||||
listDaySideFormat: false,
|
||||
},
|
||||
},
|
||||
events: function (fetchInfo, successCallback) {
|
||||
const events = allEvents.value.flatMap((event) => {
|
||||
const eventColor = calendarColorMap.value.get(event.calendar) || '#3788d8';
|
||||
const startDate = new Date(event.date_start);
|
||||
const endDate = new Date(event.date_end);
|
||||
const isMultiDay = startDate.toDateString() !== endDate.toDateString();
|
||||
|
||||
if (isRecurringEvent(event)) {
|
||||
return generateRecurringInstances(event, 52).map((instance) => ({
|
||||
id: instance.id,
|
||||
title: instance.title,
|
||||
start: instance.start,
|
||||
end: instance.end,
|
||||
allDay: instance.allDay || isMultiDay,
|
||||
textColor: '#ffffff',
|
||||
backgroundColor: eventColor,
|
||||
borderColor: eventColor,
|
||||
extendedProps: {
|
||||
...instance.extendedProps,
|
||||
_userHash: accountStore.user?.id || 'anonymous',
|
||||
},
|
||||
}));
|
||||
} else {
|
||||
return [
|
||||
{
|
||||
id: event.id,
|
||||
title: event.name,
|
||||
start: new Date(event.date_start),
|
||||
end: new Date(event.date_end),
|
||||
allDay: event.all_day,
|
||||
textColor: '#ffffff',
|
||||
backgroundColor: eventColor,
|
||||
borderColor: eventColor,
|
||||
allDay: isMultiDay,
|
||||
extendedProps: {
|
||||
originalEventId: event.id,
|
||||
description: event.description,
|
||||
participant: event.participant,
|
||||
calendar: event.calendar,
|
||||
files: event.files,
|
||||
_userHash: accountStore.user?.id || 'anonymous',
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
});
|
||||
|
||||
successCallback(events);
|
||||
},
|
||||
editable: true,
|
||||
selectable: true,
|
||||
eventClick: handleEventClick,
|
||||
|
||||
dateClick: (info) => {
|
||||
calendarStore.setSelectedDateFromCalendar(info);
|
||||
handleDateSelection(info.dateStr);
|
||||
handleCalendarDateClick(info);
|
||||
calendarApi.value?.unselect();
|
||||
},
|
||||
|
||||
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 = info.view.title;
|
||||
}
|
||||
|
||||
if (selectedDate?.value) {
|
||||
handleDateSelection(selectedDate.value);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const handleCalendarDateClick = (info) => {
|
||||
calendarStore.setSelectedDateFromCalendar(info);
|
||||
currentTitle.value = info.view.title;
|
||||
|
||||
if (calendarApi.value) {
|
||||
calendarApi.value.gotoDate(info.date);
|
||||
calendarApi.value.changeView('listWeek');
|
||||
currentView.value = 'listWeek';
|
||||
}
|
||||
};
|
||||
|
||||
const handleToday = () => {
|
||||
calendarApi.value?.today();
|
||||
// Получаем текущую дату из календаря и передаем в стор
|
||||
updateSelectedDateFromCalendar();
|
||||
};
|
||||
|
||||
const handlePrev = () => {
|
||||
calendarApi.value?.prev();
|
||||
updateSelectedDateFromCalendar();
|
||||
};
|
||||
|
||||
const handleNext = () => {
|
||||
calendarApi.value?.next();
|
||||
updateSelectedDateFromCalendar();
|
||||
};
|
||||
|
||||
const updateSelectedDateFromCalendar = () => {
|
||||
const currentDate = calendarApi.value?.getDate();
|
||||
if (currentDate) {
|
||||
const todayInfo = {
|
||||
dateStr: currentDate.toISOString().split('T')[0],
|
||||
};
|
||||
calendarStore.setSelectedDateFromCalendar(todayInfo);
|
||||
}
|
||||
};
|
||||
|
||||
// Функция обновления выделения
|
||||
const handleDateSelection = (dateStr) => {
|
||||
// Убираем предыдущее выделение
|
||||
const previousSelected = document.querySelectorAll('.fc-day-selected-custom');
|
||||
previousSelected.forEach((el) => el.classList.remove('fc-day-selected-custom'));
|
||||
|
||||
// Добавляем новое выделение
|
||||
const dayElements = document.querySelectorAll(`[data-date="${dateStr}"]`);
|
||||
dayElements.forEach((el) => el.classList.add('fc-day-selected-custom'));
|
||||
|
||||
selectedDate.value = dateStr;
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
const currentYear = new Date().getFullYear();
|
||||
calendarStore.fetchHolidays(currentYear);
|
||||
// Ждем следующего тика для гарантии, что календарь инициализирован
|
||||
await nextTick();
|
||||
|
||||
// Принудительно обновляем события после загрузки праздников
|
||||
if (calendarApi.value) {
|
||||
calendarApi.value.refetchEvents();
|
||||
}
|
||||
|
||||
if (selectedDate.value) {
|
||||
handleDateSelection(selectedDate.value);
|
||||
}
|
||||
});
|
||||
|
||||
watch(
|
||||
allEvents,
|
||||
() => {
|
||||
// При изменении событий перезагружаем календарь
|
||||
if (calendarApi.value) {
|
||||
calendarApi.value.refetchEvents();
|
||||
}
|
||||
},
|
||||
{ deep: true },
|
||||
);
|
||||
|
||||
watch(
|
||||
calendarColorMap,
|
||||
(newColorMap, oldColorMap) => {
|
||||
if (calendarRef.value && JSON.stringify(newColorMap) !== JSON.stringify(oldColorMap)) {
|
||||
renderEvents();
|
||||
}
|
||||
},
|
||||
{ deep: true },
|
||||
);
|
||||
|
||||
watch(selectedDate, (newDate) => {
|
||||
if (newDate && calendarApi.value && lastUpdatedBy.value !== 'calendar') {
|
||||
nextTick(() => {
|
||||
calendarApi.value.gotoDate(newDate);
|
||||
handleDateSelection(newDate);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
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) {
|
||||
filters[key].value = newFilters[key];
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// Сброс фильтров при выходе из кастомного вида
|
||||
watch(currentView, (newView, oldView) => {
|
||||
if (oldView === 'listAllEvents' && newView !== 'listAllEvents') {
|
||||
filters.resetFilters();
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
currentTitle,
|
||||
calendarRef,
|
||||
calendarApi,
|
||||
currentView,
|
||||
calendarOptions,
|
||||
handleToday,
|
||||
handleNext,
|
||||
handlePrev,
|
||||
handleCalendarDateClick,
|
||||
handleDateSelection,
|
||||
handleEventClick,
|
||||
calendarStore,
|
||||
filters,
|
||||
handleFiltersUpdate,
|
||||
unwrappedFilters,
|
||||
};
|
||||
timeGridWeek: {
|
||||
type: 'timeGrid',
|
||||
duration: { weeks: 1 },
|
||||
slotDuration: '01:00:00',
|
||||
slotMinTime: '07:00:00',
|
||||
slotMaxTime: '22:00:00',
|
||||
allDaySlot: true,
|
||||
expandRows: true,
|
||||
dayHeaderFormat: { weekday: 'short', day: 'numeric' },
|
||||
titleFormat: { day: 'numeric', month: 'long', omitCommas: true },
|
||||
},
|
||||
dayGridMonth: {
|
||||
type: 'dayGrid',
|
||||
fixedWeekCount: false,
|
||||
dayHeaderFormat: { weekday: 'short' },
|
||||
weekNumbers: true,
|
||||
weekNumberFormat: { week: 'numeric' },
|
||||
weekNumberContent: (arg) => arg.num,
|
||||
weekText: 'Нед.',
|
||||
eventTimeFormat: { hour: '2-digit', minute: '2-digit', hour12: false, omitZeroMinute: false },
|
||||
},
|
||||
multiMonthYear: {
|
||||
type: 'multiMonth',
|
||||
duration: { years: 1 },
|
||||
multiMonthMaxColumns: 4,
|
||||
fixedWeekCount: false,
|
||||
weekNumbers: false,
|
||||
},
|
||||
listWeek: {
|
||||
type: 'list',
|
||||
duration: { days: 1 },
|
||||
listDayFormat: { weekday: 'long', day: 'numeric', month: 'long' },
|
||||
listDaySideFormat: false,
|
||||
},
|
||||
};
|
||||
|
||||
const calendarOptions = ref({
|
||||
plugins: [
|
||||
dayGridPlugin,
|
||||
timeGridPlugin,
|
||||
multiMonthPlugin,
|
||||
interactionPlugin,
|
||||
listPlugin,
|
||||
rrulePlugin,
|
||||
],
|
||||
initialView: props.forHomePage ? props.view : currentView.value,
|
||||
locales: [ruLocale],
|
||||
locale: 'ru',
|
||||
timeZone: 'Europe/Moscow',
|
||||
firstDay: 1,
|
||||
headerToolbar: false,
|
||||
height: '80vh',
|
||||
aspectRatio: 1.5,
|
||||
weekNumbers: true,
|
||||
eventDisplay: 'auto',
|
||||
eventTimeFormat: { hour: '2-digit', minute: '2-digit', hour12: false, meridiem: false },
|
||||
weekNumberFormat: { week: 'numeric' },
|
||||
weekNumberCalculation: 'ISO',
|
||||
selectable: true,
|
||||
unselectAuto: false,
|
||||
selectMirror: false,
|
||||
dayCellClassNames: dayClassNames,
|
||||
dayHeaderClassNames: dayClassNames,
|
||||
views: calendarViews,
|
||||
events: buildEvents,
|
||||
eventClick: handleEventClick,
|
||||
dateClick: (info) => {
|
||||
calendarStore.setSelectedDateFromCalendar(info);
|
||||
handleDateSelection(info.dateStr);
|
||||
handleCalendarDateClick(info);
|
||||
calendarApi.value?.unselect();
|
||||
},
|
||||
datesSet: (info) => {
|
||||
if (info.view.type === 'listWeek' && selectedDate.value) {
|
||||
currentTitle.value = formatScheduleTitle(selectedDate.value);
|
||||
} else if (info.view.type !== 'listWeek') {
|
||||
currentTitle.value = info.view.title;
|
||||
}
|
||||
if (selectedDate?.value) handleDateSelection(selectedDate.value);
|
||||
},
|
||||
});
|
||||
|
||||
/* ──────────── Вотчеры ──────────── */
|
||||
watch(currentView, (newView, oldView) => {
|
||||
applyView(newView);
|
||||
if (oldView === 'listAllEvents' && newView !== 'listAllEvents') filters.resetFilters();
|
||||
});
|
||||
|
||||
watch(
|
||||
[() => calendarStore.calendars, () => calendarStore.hiddenCalendarIds],
|
||||
() => {
|
||||
if (currentView.value !== 'listAllEvents') calendarApi.value?.refetchEvents();
|
||||
},
|
||||
{ deep: true },
|
||||
);
|
||||
|
||||
watch(
|
||||
calendarColorMap,
|
||||
() => {
|
||||
if (currentView.value !== 'listAllEvents') calendarApi.value?.refetchEvents();
|
||||
},
|
||||
{ deep: true },
|
||||
);
|
||||
|
||||
watch(selectedDate, (newDate) => {
|
||||
if (newDate && calendarApi.value && lastUpdatedBy.value !== 'calendar') {
|
||||
nextTick(() => {
|
||||
calendarApi.value.gotoDate(newDate);
|
||||
handleDateSelection(newDate);
|
||||
if (route.query.date && currentView.value !== 'timeGridDay') {
|
||||
currentView.value = 'timeGridDay';
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
onMounted(async () => {
|
||||
ro = new ResizeObserver(scheduleUpdate);
|
||||
if (calWrap.value) ro.observe(calWrap.value);
|
||||
|
||||
calendarStore.fetchHolidays(new Date().getFullYear());
|
||||
await nextTick();
|
||||
|
||||
if (currentView.value !== 'listAllEvents') {
|
||||
if (calendarApi.value) calendarApi.value.refetchEvents();
|
||||
if (selectedDate.value) handleDateSelection(selectedDate.value);
|
||||
}
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
cancelAnimationFrame(rafId);
|
||||
ro?.disconnect();
|
||||
});
|
||||
</script>
|
||||
<style scoped>
|
||||
:deep(.fc-daygrid-day-number) {
|
||||
@@ -506,7 +441,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 +451,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 +466,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 +477,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 +492,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 +513,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;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
<template>
|
||||
<v-card class="home-calendar-widget" elevation="2">
|
||||
<v-card elevation="2">
|
||||
<v-card-text class="pa-4">
|
||||
<v-row no-gutters class="calendar-pair">
|
||||
<!-- Месячный календарь -->
|
||||
<v-col cols="7" class="pr-2">
|
||||
<div class="calendar-header">
|
||||
<v-btn icon size="small" @click="prevMonth" class="nav-btn">
|
||||
<v-btn icon size="small" class="nav-btn" @click="prevMonth">
|
||||
<v-icon>mdi-chevron-left</v-icon>
|
||||
</v-btn>
|
||||
<span class="month-title">{{ currentMonth }}</span>
|
||||
<v-btn icon size="small" @click="nextMonth" class="nav-btn">
|
||||
<v-btn icon size="small" class="nav-btn" @click="nextMonth">
|
||||
<v-icon>mdi-chevron-right</v-icon>
|
||||
</v-btn>
|
||||
</div>
|
||||
@@ -17,13 +17,11 @@
|
||||
<v-table class="month-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th v-for="day in russianWeekdays" :key="day" class="weekday-header">
|
||||
{{ day }}
|
||||
</th>
|
||||
<th v-for="day in WEEKDAYS" :key="day" class="weekday-header">{{ day }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="(week, weekIndex) in calendarWeeks" :key="weekIndex">
|
||||
<tr v-for="(week, i) in calendarWeeks" :key="i">
|
||||
<td
|
||||
v-for="day in week"
|
||||
:key="day.date"
|
||||
@@ -32,10 +30,11 @@
|
||||
'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)"
|
||||
@click="selectedDate = day.date"
|
||||
@dblclick.stop="goToDay(day.date)"
|
||||
>
|
||||
<div class="day-content">
|
||||
<span class="day-number">{{ day.day }}</span>
|
||||
@@ -45,7 +44,7 @@
|
||||
:key="event.id"
|
||||
class="event-indicator"
|
||||
:style="{ backgroundColor: event.color }"
|
||||
></span>
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
@@ -64,28 +63,25 @@
|
||||
|
||||
<v-card variant="outlined" class="day-schedule" elevation="0">
|
||||
<v-list density="comfortable" class="py-0">
|
||||
<v-list-item
|
||||
v-for="event in dayEvents"
|
||||
:key="event.id"
|
||||
class="schedule-item"
|
||||
:class="{ 'current-event': isCurrentEvent(event) }"
|
||||
>
|
||||
<template #prepend>
|
||||
<div
|
||||
class="event-color-indicator"
|
||||
:style="{ backgroundColor: event.color }"
|
||||
></div>
|
||||
</template>
|
||||
<template v-if="dayEvents.length">
|
||||
<v-list-item
|
||||
v-for="event in dayEvents"
|
||||
:key="event.id"
|
||||
class="schedule-item"
|
||||
:class="{ 'current-event': isCurrentEvent(event) }"
|
||||
@click="calendarStore.handleEventClick({ event: { id: event.id } })"
|
||||
>
|
||||
<template #prepend>
|
||||
<div class="event-color-indicator" :style="{ backgroundColor: event.color }" />
|
||||
</template>
|
||||
<v-list-item-title class="event-time">{{
|
||||
formatTime(event.start)
|
||||
}}</v-list-item-title>
|
||||
<v-list-item-subtitle class="event-title">{{ event.title }}</v-list-item-subtitle>
|
||||
</v-list-item>
|
||||
</template>
|
||||
|
||||
<v-list-item-title class="event-time">
|
||||
{{ formatTime(event.start) }}
|
||||
</v-list-item-title>
|
||||
<v-list-item-subtitle class="event-title">
|
||||
{{ event.title }}
|
||||
</v-list-item-subtitle>
|
||||
</v-list-item>
|
||||
|
||||
<v-list-item v-if="dayEvents.length === 0" class="no-events">
|
||||
<v-list-item v-else class="no-events">
|
||||
<v-list-item-title class="text-grey text-center">
|
||||
На этот день событий нет
|
||||
</v-list-item-title>
|
||||
@@ -98,308 +94,190 @@
|
||||
</v-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ref, computed, onMounted, watch } from 'vue';
|
||||
<script setup>
|
||||
import { ref, computed, onMounted } from 'vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useCalendarStore } from '@/store/calendarStore';
|
||||
import { useRecurrence } from '@/components/calendar_of_events/composables/useReccurrence';
|
||||
|
||||
export default {
|
||||
name: 'HomeCalendarWidget',
|
||||
const WEEKDAYS = ['Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб', 'Вс'];
|
||||
|
||||
setup() {
|
||||
// Реактивные данные
|
||||
const currentDate = ref(new Date());
|
||||
const selectedDate = ref(''); // Будет установлено в формате YYYY-MM-DD
|
||||
const currentYear = new Date().getFullYear();
|
||||
|
||||
// Работа с хранилищем
|
||||
const calendarStore = useCalendarStore();
|
||||
const { allEvents, calendarColorMap } = storeToRefs(calendarStore);
|
||||
const { generateRecurringInstances, isRecurringEvent } = useRecurrence();
|
||||
|
||||
// Утилиты для работы с датами (главный источник проблем!)
|
||||
const formatToLocalDate = (date) => {
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(date.getDate()).padStart(2, '0');
|
||||
return `${year}-${month}-${day}`;
|
||||
};
|
||||
|
||||
const getStartOfDay = (date) => {
|
||||
const newDate = new Date(date);
|
||||
newDate.setHours(0, 0, 0, 0);
|
||||
return newDate;
|
||||
};
|
||||
|
||||
const areDatesEqual = (date1, date2) => {
|
||||
return getStartOfDay(date1).getTime() === getStartOfDay(date2).getTime();
|
||||
};
|
||||
|
||||
const events = computed(() => {
|
||||
const expandedEvents = allEvents.value.flatMap((event) => {
|
||||
const startDate = new Date(event.date_start);
|
||||
const endDate = new Date(event.date_end);
|
||||
const isMultiDay = startDate.toDateString() !== endDate.toDateString();
|
||||
const hasRecurrence = event.period && event.period !== 'null';
|
||||
|
||||
// 1. Периодичное + многодневное
|
||||
if (hasRecurrence && isMultiDay) {
|
||||
const instances = generateRecurringInstances(event, 12);
|
||||
return instances.flatMap((instance) => expandMultiDayInstance(event, instance));
|
||||
}
|
||||
|
||||
// 2. Периодичное + однодневное
|
||||
if (hasRecurrence && !isMultiDay) {
|
||||
const instances = generateRecurringInstances(event, 12);
|
||||
return instances.map((instance) => ({
|
||||
...event,
|
||||
id: instance.id,
|
||||
date_start: instance.date_start || instance.start,
|
||||
date_end: instance.date_end || instance.end,
|
||||
isRecurringInstance: true,
|
||||
}));
|
||||
}
|
||||
|
||||
// 3. Непериодичное + многодневное
|
||||
if (!hasRecurrence && isMultiDay) {
|
||||
return expandMultiDayInstance(event, event);
|
||||
}
|
||||
|
||||
// 4. Непериодичное + однодневное
|
||||
return event;
|
||||
});
|
||||
|
||||
return expandedEvents.map((event) => formatForWidget(event));
|
||||
});
|
||||
|
||||
// Разбивает многодневный экземпляр на дни
|
||||
const expandMultiDayInstance = (originalEvent, instance) => {
|
||||
const startDate = new Date(instance.date_start || instance.start);
|
||||
const endDate = new Date(instance.date_end || instance.end);
|
||||
const days = [];
|
||||
const currentDay = new Date(startDate);
|
||||
|
||||
while (currentDay < endDate) {
|
||||
const dayStart = new Date(currentDay);
|
||||
const dayEnd = new Date(currentDay);
|
||||
dayEnd.setDate(dayEnd.getDate() + 1);
|
||||
|
||||
days.push({
|
||||
...originalEvent,
|
||||
id: instance.id, // ID от экземпляра периодичности
|
||||
date_start: dayStart.toISOString(),
|
||||
date_end: dayEnd.toISOString(),
|
||||
allday: true,
|
||||
isMultiDayPart: true,
|
||||
isRecurringInstance: instance.isRecurringInstance || false,
|
||||
originalStart: instance.date_start || instance.start,
|
||||
originalEnd: instance.date_end || instance.end,
|
||||
});
|
||||
|
||||
currentDay.setDate(currentDay.getDate() + 1);
|
||||
}
|
||||
|
||||
return days;
|
||||
};
|
||||
|
||||
// Форматирование для виджета
|
||||
const formatForWidget = (event) => {
|
||||
const eventColor =
|
||||
event.calendarData?.cl_color || calendarColorMap.value?.get(event.calendar) || '#1976d2';
|
||||
|
||||
return {
|
||||
id: event.id,
|
||||
title: event.name || 'Без названия',
|
||||
start: event.date_start,
|
||||
end: event.date_end,
|
||||
description: event.description,
|
||||
color: eventColor,
|
||||
calendar: event.calendar,
|
||||
calendarData: event.calendarData,
|
||||
isRecurringInstance: event.isRecurringInstance || false,
|
||||
isMultiDayPart: event.isMultiDayPart || false,
|
||||
};
|
||||
};
|
||||
|
||||
const russianWeekdays = ['Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб', 'Вс'];
|
||||
|
||||
// Генерация календаря
|
||||
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 = [];
|
||||
|
||||
// Находим понедельник первой недели
|
||||
const startDay = new Date(firstDay);
|
||||
startDay.setDate(startDay.getDate() - ((startDay.getDay() + 6) % 7));
|
||||
|
||||
// Генерируем 6 недель (фиксированное количество для стабильности)
|
||||
for (let i = 0; i < 42; i++) {
|
||||
const currentDay = new Date(startDay);
|
||||
currentDay.setDate(startDay.getDate() + i);
|
||||
|
||||
week.push({
|
||||
day: currentDay.getDate(),
|
||||
date: formatToLocalDate(currentDay),
|
||||
isCurrentMonth: currentDay.getMonth() === month,
|
||||
});
|
||||
|
||||
if (week.length === 7) {
|
||||
weeks.push([...week]);
|
||||
week = [];
|
||||
}
|
||||
}
|
||||
|
||||
return weeks;
|
||||
});
|
||||
|
||||
const currentMonth = computed(() => {
|
||||
return currentDate.value.toLocaleDateString('ru-RU', {
|
||||
month: 'long',
|
||||
year: 'numeric',
|
||||
});
|
||||
});
|
||||
|
||||
const formattedSelectedDate = computed(() => {
|
||||
if (!selectedDate.value) return '';
|
||||
|
||||
// Добавляем время для избежания смещения часовых поясов
|
||||
const date = new Date(selectedDate.value + 'T12:00:00');
|
||||
return date.toLocaleDateString('ru-RU', {
|
||||
day: 'numeric',
|
||||
month: 'long',
|
||||
year: 'numeric',
|
||||
});
|
||||
});
|
||||
|
||||
const dayEvents = computed(() => {
|
||||
if (!selectedDate.value) return [];
|
||||
|
||||
const selected = new Date(selectedDate.value + 'T12:00:00');
|
||||
|
||||
return events.value
|
||||
.filter((event) => {
|
||||
const eventDate = new Date(event.start);
|
||||
return areDatesEqual(eventDate, selected);
|
||||
})
|
||||
.sort((a, b) => new Date(a.start).getTime() - new Date(b.start).getTime());
|
||||
});
|
||||
|
||||
// Методы
|
||||
const isToday = (date) => {
|
||||
const today = new Date();
|
||||
const checkDate = new Date(date + 'T12:00:00');
|
||||
return areDatesEqual(today, checkDate);
|
||||
};
|
||||
|
||||
const isSelected = (date) => {
|
||||
return date === selectedDate.value;
|
||||
};
|
||||
|
||||
const getDayEvents = (date) => {
|
||||
const checkDate = new Date(date + 'T12:00:00');
|
||||
|
||||
return events.value.filter((event) => {
|
||||
const eventDate = new Date(event.start);
|
||||
return areDatesEqual(eventDate, checkDate);
|
||||
});
|
||||
};
|
||||
|
||||
const isCurrentEvent = (event) => {
|
||||
const now = new Date();
|
||||
const start = new Date(event.start);
|
||||
const end = new Date(event.end);
|
||||
return now >= start && now <= end;
|
||||
};
|
||||
|
||||
const formatTime = (dateString) => {
|
||||
return new Date(dateString).toLocaleTimeString('ru-RU', {
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
});
|
||||
};
|
||||
|
||||
const onDateClick = (date) => {
|
||||
selectedDate.value = date;
|
||||
};
|
||||
|
||||
const prevMonth = () => {
|
||||
const date = new Date(currentDate.value);
|
||||
date.setMonth(date.getMonth() - 1);
|
||||
currentDate.value = date;
|
||||
};
|
||||
|
||||
const nextMonth = () => {
|
||||
const date = new Date(currentDate.value);
|
||||
date.setMonth(date.getMonth() + 1);
|
||||
currentDate.value = date;
|
||||
};
|
||||
|
||||
const isWeekendOrHoliday = (dateString) => {
|
||||
const dayInfo = calendarStore.isNonWorkingDay(dateString);
|
||||
return dayInfo.isHoliday || dayInfo.isWeekendForStyling;
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
selectedDate.value = formatToLocalDate(new Date());
|
||||
calendarStore.fetchHolidays(currentYear);
|
||||
});
|
||||
|
||||
watch(
|
||||
calendarColorMap,
|
||||
(newMap) => {
|
||||
newMap.value;
|
||||
},
|
||||
{ deep: true },
|
||||
);
|
||||
|
||||
return {
|
||||
// Реактивные данные
|
||||
currentDate,
|
||||
selectedDate,
|
||||
|
||||
// Вычисляемые свойства
|
||||
events,
|
||||
russianWeekdays,
|
||||
calendarWeeks,
|
||||
currentMonth,
|
||||
formattedSelectedDate,
|
||||
dayEvents,
|
||||
isWeekendOrHoliday,
|
||||
|
||||
// Методы
|
||||
isToday,
|
||||
isSelected,
|
||||
getDayEvents,
|
||||
isCurrentEvent,
|
||||
formatTime,
|
||||
onDateClick,
|
||||
prevMonth,
|
||||
nextMonth,
|
||||
|
||||
calendarStore,
|
||||
allEvents,
|
||||
expandMultiDayInstance,
|
||||
formatForWidget,
|
||||
};
|
||||
},
|
||||
const toLocalDateStr = (date) => {
|
||||
const y = date.getFullYear();
|
||||
const m = String(date.getMonth() + 1).padStart(2, '0');
|
||||
const d = String(date.getDate()).padStart(2, '0');
|
||||
return `${y}-${m}-${d}`;
|
||||
};
|
||||
|
||||
const startOfDay = (date) => {
|
||||
const d = new Date(date);
|
||||
d.setHours(0, 0, 0, 0);
|
||||
return d;
|
||||
};
|
||||
|
||||
const datesEqual = (a, b) => startOfDay(a).getTime() === startOfDay(b).getTime();
|
||||
|
||||
const router = useRouter();
|
||||
const calendarStore = useCalendarStore();
|
||||
const { allEvents, calendarColorMap } = storeToRefs(calendarStore);
|
||||
const { generateRecurringInstances } = useRecurrence();
|
||||
|
||||
const currentDate = ref(new Date());
|
||||
const selectedDate = ref('');
|
||||
|
||||
const prevMonth = () => {
|
||||
const d = new Date(currentDate.value);
|
||||
d.setMonth(d.getMonth() - 1);
|
||||
currentDate.value = d;
|
||||
};
|
||||
|
||||
const nextMonth = () => {
|
||||
const d = new Date(currentDate.value);
|
||||
d.setMonth(d.getMonth() + 1);
|
||||
currentDate.value = d;
|
||||
};
|
||||
|
||||
const goToDay = (date) => {
|
||||
calendarStore.setSelectedDate(date);
|
||||
router.push({ name: 'Calendar', query: { date, view: 'day' } });
|
||||
};
|
||||
|
||||
const expandMultiDay = (originalEvent, instance) => {
|
||||
const start = new Date(instance.date_start || instance.start);
|
||||
const end = new Date(instance.date_end || instance.end);
|
||||
const days = [];
|
||||
const cur = new Date(start);
|
||||
|
||||
while (cur < end) {
|
||||
const dayEnd = new Date(cur);
|
||||
dayEnd.setDate(dayEnd.getDate() + 1);
|
||||
days.push({
|
||||
...originalEvent,
|
||||
id: instance.id,
|
||||
date_start: new Date(cur).toISOString(),
|
||||
date_end: dayEnd.toISOString(),
|
||||
allday: true,
|
||||
isMultiDayPart: true,
|
||||
isRecurringInstance: instance.isRecurringInstance || false,
|
||||
});
|
||||
cur.setDate(cur.getDate() + 1);
|
||||
}
|
||||
return days;
|
||||
};
|
||||
|
||||
const toWidgetEvent = (event) => ({
|
||||
id: event.id,
|
||||
title: event.name || 'Без названия',
|
||||
start: event.date_start,
|
||||
end: event.date_end,
|
||||
color: event.calendarData?.cl_color || calendarColorMap.value?.get(event.calendar) || '#1976d2',
|
||||
description: event.description,
|
||||
calendar: event.calendar,
|
||||
isRecurringInstance: event.isRecurringInstance || false,
|
||||
isMultiDayPart: event.isMultiDayPart || false,
|
||||
});
|
||||
|
||||
const events = computed(() =>
|
||||
allEvents.value
|
||||
.flatMap((event) => {
|
||||
const start = new Date(event.date_start);
|
||||
const end = new Date(event.date_end);
|
||||
const isMultiDay = start.toDateString() !== end.toDateString();
|
||||
const hasRecur = event.period && event.period !== 'null';
|
||||
|
||||
if (hasRecur && isMultiDay) {
|
||||
return generateRecurringInstances(event, 12).flatMap((inst) => expandMultiDay(event, inst));
|
||||
}
|
||||
if (hasRecur && !isMultiDay) {
|
||||
return generateRecurringInstances(event, 12).map((inst) => ({
|
||||
...event,
|
||||
id: inst.id,
|
||||
date_start: inst.date_start || inst.start,
|
||||
date_end: inst.date_end || inst.end,
|
||||
isRecurringInstance: true,
|
||||
}));
|
||||
}
|
||||
if (!hasRecur && isMultiDay) return expandMultiDay(event, event);
|
||||
return event;
|
||||
})
|
||||
.map(toWidgetEvent),
|
||||
);
|
||||
|
||||
const calendarWeeks = computed(() => {
|
||||
const year = currentDate.value.getFullYear();
|
||||
const month = currentDate.value.getMonth();
|
||||
const start = new Date(year, month, 1);
|
||||
start.setDate(start.getDate() - ((start.getDay() + 6) % 7));
|
||||
|
||||
const weeks = [];
|
||||
let week = [];
|
||||
|
||||
for (let i = 0; i < 42; i++) {
|
||||
const day = new Date(start);
|
||||
day.setDate(start.getDate() + i);
|
||||
const info = calendarStore.isNonWorkingDay(day);
|
||||
|
||||
week.push({
|
||||
day: day.getDate(),
|
||||
date: toLocalDateStr(day),
|
||||
isCurrentMonth: day.getMonth() === month,
|
||||
isHoliday: info.isHoliday,
|
||||
isWeekend: info.isWeekendForStyling,
|
||||
});
|
||||
|
||||
if (week.length === 7) {
|
||||
weeks.push([...week]);
|
||||
week = [];
|
||||
}
|
||||
}
|
||||
return weeks;
|
||||
});
|
||||
|
||||
const currentMonth = computed(() =>
|
||||
currentDate.value.toLocaleDateString('ru-RU', { month: 'long', year: 'numeric' }),
|
||||
);
|
||||
|
||||
const formattedSelectedDate = computed(() => {
|
||||
if (!selectedDate.value) return '';
|
||||
return new Date(`${selectedDate.value}T12:00:00`).toLocaleDateString('ru-RU', {
|
||||
day: 'numeric',
|
||||
month: 'long',
|
||||
year: 'numeric',
|
||||
});
|
||||
});
|
||||
|
||||
const dayEvents = computed(() => {
|
||||
if (!selectedDate.value) return [];
|
||||
const sel = new Date(`${selectedDate.value}T12:00:00`);
|
||||
return events.value
|
||||
.filter((e) => datesEqual(new Date(e.start), sel))
|
||||
.sort((a, b) => new Date(a.start) - new Date(b.start));
|
||||
});
|
||||
|
||||
const isToday = (date) => datesEqual(new Date(), new Date(`${date}T12:00:00`));
|
||||
const isSelected = (date) => date === selectedDate.value;
|
||||
|
||||
const getDayEvents = (date) => {
|
||||
const d = new Date(`${date}T12:00:00`);
|
||||
return events.value.filter((e) => datesEqual(new Date(e.start), d));
|
||||
};
|
||||
|
||||
const isCurrentEvent = (event) => {
|
||||
const now = new Date();
|
||||
return now >= new Date(event.start) && now <= new Date(event.end);
|
||||
};
|
||||
|
||||
const formatTime = (dateStr) =>
|
||||
new Date(dateStr).toLocaleTimeString('ru-RU', { hour: '2-digit', minute: '2-digit' });
|
||||
|
||||
onMounted(async () => {
|
||||
selectedDate.value = toLocalDateStr(new Date());
|
||||
await calendarStore.fetchHolidays(new Date().getFullYear());
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.home-calendar-widget {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
font-family: 'Roboto', sans-serif;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.calendar-pair {
|
||||
height: 100%;
|
||||
}
|
||||
@@ -416,7 +294,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 +311,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 +328,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 +390,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 +404,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 +412,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 +428,7 @@ export default {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
color: #1b1b1b;
|
||||
color: rgb(var(--v-theme-text_carous));
|
||||
}
|
||||
|
||||
.no-events {
|
||||
@@ -578,28 +444,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>
|
||||
@@ -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">
|
||||
@@ -33,7 +33,7 @@
|
||||
</v-col>
|
||||
|
||||
<v-col class="flex-column d-flex">
|
||||
<v-row no-gutters class=" overflow-hidden flex-column flex-nowrap">
|
||||
<v-row no-gutters class="overflow-hidden flex-column flex-nowrap">
|
||||
<v-col>
|
||||
<calendar-my
|
||||
:calendars="myCalendars"
|
||||
@@ -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>
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<v-card min-height="436" max-height="80%" class="pa-3" max-width="50vw">
|
||||
<v-card min-height="436" max-height="80%" class="pa-2" max-width="50vw">
|
||||
<v-card-title class="pr-0 pl-2 d-flex justify-space-between">
|
||||
{{ title }}
|
||||
<v-icon
|
||||
|
||||
@@ -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-time-picker
|
||||
v-if="menutime"
|
||||
:model-value="timeEvent"
|
||||
@update:model-value="onTimePickerChange"
|
||||
full-width
|
||||
format="24hr"
|
||||
></v-time-picker>
|
||||
<v-locale-provider locale="ru">
|
||||
<v-time-picker
|
||||
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>
|
||||
@@ -1,446 +1,327 @@
|
||||
<template>
|
||||
<div>
|
||||
<!-- -->
|
||||
|
||||
<v-autocomplete
|
||||
v-model="selectedStaff"
|
||||
:items="staffed"
|
||||
v-model="selectedItems"
|
||||
:items="visibleDepartments"
|
||||
label="Выберите из списка или найдите по ФИО"
|
||||
item-title="title"
|
||||
item-value="id"
|
||||
:search-input.sync="filtered"
|
||||
@update:search="(val) => (filtered = val)"
|
||||
@update:search="(val) => (searchQuery = val ?? '')"
|
||||
multiple
|
||||
hide-details
|
||||
variant="outlined"
|
||||
density="compact"
|
||||
class="max-height-select py-3"
|
||||
return-object
|
||||
:custom-filter="customFilterFn"
|
||||
:custom-filter="searchInDepartment"
|
||||
>
|
||||
<!-- :custom-filter="onFilter" -->
|
||||
<template v-slot:selection="{ item }">
|
||||
<v-chip class="me-2" color="teal-darken-3" size="small" label>
|
||||
<span> {{ item.title }}</span>
|
||||
<span>{{ item.title }}</span>
|
||||
<v-icon
|
||||
v-if="!isAuthor(item.raw)"
|
||||
icon="mdi-close-circle"
|
||||
size="x-small"
|
||||
class="ml-3"
|
||||
@click.stop="selectedStaff = item.raw"
|
||||
@click.stop="selectedItems = item.raw"
|
||||
/>
|
||||
</v-chip>
|
||||
</template>
|
||||
|
||||
<template v-slot:prepend-item>
|
||||
<v-list-item
|
||||
:disabled="staffed.length == 1 && staffed[0].employees.length == 1"
|
||||
:disabled="isOnlyOneEmployee"
|
||||
class="text-body-2"
|
||||
@click.stop="allUser()"
|
||||
@click.stop="toggleAllEmployees"
|
||||
>
|
||||
<span class="text-body-2"> ВСЕ СОТРУДНИКИ </span>
|
||||
|
||||
<span class="text-body-2">ВСЕ СОТРУДНИКИ</span>
|
||||
<template v-slot:prepend>
|
||||
<v-checkbox-btn
|
||||
:model-value="staffed.every((e) => e[okey] == true)"
|
||||
:disabled="staffed.length == 1 && staffed[0].employees.length == 1"
|
||||
></v-checkbox-btn>
|
||||
<v-checkbox-btn :model-value="areAllSelected" :disabled="isOnlyOneEmployee" />
|
||||
</template>
|
||||
</v-list-item>
|
||||
<!-- ВСЕ НАЧАЛЬНИКИ -->
|
||||
|
||||
<v-list-item
|
||||
:disabled="!hasBossesInStaff"
|
||||
class="text-body-2"
|
||||
@click.stop="toggleByPosition('начальник')"
|
||||
@click.stop="toggleByPosition('boss')"
|
||||
>
|
||||
<span class="text-body-2"> ВСЕ НАЧАЛЬНИКИ </span>
|
||||
<span class="text-body-2">ВСЕ НАЧАЛЬНИКИ</span>
|
||||
<template v-slot:prepend>
|
||||
<v-checkbox-btn
|
||||
:model-value="hasBossesSelected"
|
||||
:disabled="!hasBossesInStaff"
|
||||
></v-checkbox-btn>
|
||||
<v-checkbox-btn :model-value="areAllBossesSelected" :disabled="!hasBossesInStaff" />
|
||||
</template>
|
||||
</v-list-item>
|
||||
|
||||
<!-- ВСЕ ЗАМЕСТИТЕЛИ -->
|
||||
<v-list-item
|
||||
:disabled="!hasDeputiesInStaff"
|
||||
class="text-body-2"
|
||||
@click.stop="toggleByPosition('заместитель')"
|
||||
@click.stop="toggleByPosition('deputy')"
|
||||
>
|
||||
<span class="text-body-2"> ВСЕ ЗАМЕСТИТЕЛИ </span>
|
||||
<span class="text-body-2">ВСЕ ЗАМЕСТИТЕЛИ</span>
|
||||
<template v-slot:prepend>
|
||||
<v-checkbox-btn
|
||||
:model-value="hasDeputiesSelected"
|
||||
:disabled="!hasDeputiesInStaff"
|
||||
></v-checkbox-btn>
|
||||
<v-checkbox-btn :model-value="areAllDeputiesSelected" :disabled="!hasDeputiesInStaff" />
|
||||
</template>
|
||||
</v-list-item>
|
||||
<v-divider class="mt-2"></v-divider>
|
||||
|
||||
<v-divider class="mt-2" />
|
||||
</template>
|
||||
|
||||
<template v-slot:item="{ props, item }">
|
||||
<v-list-group v-bind="props" :value="item.raw.title">
|
||||
<template v-slot:activator="{ props }">
|
||||
<v-list-item v-bind="props" @click.stop="" density="compact" class="text-body-2">
|
||||
<template v-slot:item="{ props: itemProps, item }">
|
||||
<v-list-group v-bind="itemProps" :value="item.raw.title">
|
||||
<template v-slot:activator="{ props: activatorProps }">
|
||||
<v-list-item v-bind="activatorProps" density="compact" class="text-body-2" @click.stop>
|
||||
<template v-slot:prepend>
|
||||
<v-checkbox-btn
|
||||
@click.stop="selectedStaff = item.raw"
|
||||
:color="'indigo-darken-4'"
|
||||
color="indigo-darken-4"
|
||||
:true-value="true"
|
||||
:false-value="false"
|
||||
:disabled="disable(item.raw) || isAuthor(item.raw)"
|
||||
:indeterminate="
|
||||
item.raw.employees.some((e) => e[okey] == true) &&
|
||||
!item.raw.employees.every((e) => e[okey] == true)
|
||||
"
|
||||
:model-value="item.raw[okey]"
|
||||
></v-checkbox-btn>
|
||||
:disabled="isDepartmentLocked(item.raw)"
|
||||
:indeterminate="isDepartmentIndeterminate(item.raw)"
|
||||
:model-value="isSelected(item.raw)"
|
||||
@click.stop="selectedItems = item.raw"
|
||||
/>
|
||||
</template>
|
||||
</v-list-item>
|
||||
</template>
|
||||
|
||||
<v-list-item
|
||||
v-for="x in item.raw.employees.filter((e) =>
|
||||
e.title.toLowerCase().includes(filtered.toLowerCase()),
|
||||
)"
|
||||
:key="x.id"
|
||||
:value="x.title"
|
||||
@click.stop="selectedStaff = x"
|
||||
:disabled=" isAuthor(x)"
|
||||
v-for="employee in filterEmployees(item.raw.employees)"
|
||||
:key="employee.id"
|
||||
:value="employee.title"
|
||||
density="compact"
|
||||
:disabled="isAuthor(employee)"
|
||||
@click.stop="selectedItems = employee"
|
||||
>
|
||||
<template v-slot:prepend>
|
||||
<v-checkbox-btn
|
||||
:disabled="isAuthor(x)"
|
||||
:disabled="isAuthor(employee)"
|
||||
color="indigo-darken-4"
|
||||
:model-value="x[okey]"
|
||||
></v-checkbox-btn>
|
||||
:model-value="isSelected(employee)"
|
||||
/>
|
||||
</template>
|
||||
<span class="text-body-2"> {{ x.title }} </span>
|
||||
<span class="text-body-2">{{ employee.title }}</span>
|
||||
</v-list-item>
|
||||
</v-list-group>
|
||||
</template>
|
||||
</v-autocomplete>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ref, computed } from 'vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { splitname } from '@/utils/universal_functions';
|
||||
<script setup>
|
||||
import { computed, ref } from 'vue';
|
||||
import { useAccountStore } from '@/store/AccountStore';
|
||||
import { useCalendarStore } from '@/store/calendarStore';
|
||||
|
||||
export default {
|
||||
props: {
|
||||
staff: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
okey: {
|
||||
type: String,
|
||||
default: 'selected',
|
||||
},
|
||||
authorID: {
|
||||
type: Number,
|
||||
default: null,
|
||||
},
|
||||
const props = defineProps({
|
||||
staff: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
mode: {
|
||||
type: String,
|
||||
default: 'participants',
|
||||
validator: (val) => ['participants', 'editors'].includes(val),
|
||||
},
|
||||
authorID: {
|
||||
type: Number,
|
||||
default: null,
|
||||
},
|
||||
selectedIds: {
|
||||
type: Set,
|
||||
default: null,
|
||||
},
|
||||
editorIds: {
|
||||
type: Set,
|
||||
default: null,
|
||||
},
|
||||
});
|
||||
|
||||
setup(props, { emit }) {
|
||||
const filtered = ref('');
|
||||
const emit = defineEmits(['change']);
|
||||
|
||||
const accountStore = useAccountStore();
|
||||
const calendarStore = useCalendarStore();
|
||||
const { dictEmployeesLoaded } = storeToRefs(calendarStore);
|
||||
const accountStore = useAccountStore();
|
||||
const calendarStore = useCalendarStore();
|
||||
|
||||
const back = ref([]);
|
||||
const searchQuery = ref('');
|
||||
|
||||
const staffed = computed({
|
||||
get() {
|
||||
if (props.okey == 'editor') {
|
||||
let ns = [];
|
||||
props.staff.forEach((e) => {
|
||||
let emp = { ...e };
|
||||
emp.employees = e.employees.filter(
|
||||
(n) => n.selected == true || n.isCurrentUser == true,
|
||||
);
|
||||
if (emp.employees.length > 0) ns.push(emp);
|
||||
});
|
||||
const isSelected = (item) => {
|
||||
if ('employees' in item) {
|
||||
if (item.employees.length === 0) return false;
|
||||
return item.employees.every((e) => isSelected(e));
|
||||
}
|
||||
const targetSet = props.mode === 'editors' ? props.editorIds : props.selectedIds;
|
||||
return targetSet?.has(item.id) ?? false;
|
||||
};
|
||||
|
||||
ns.forEach((e) => {
|
||||
if (e.employees.every((w) => w.editor == true)) {
|
||||
e.editor = true;
|
||||
}
|
||||
});
|
||||
const visibleDepartments = computed(() => {
|
||||
if (props.mode !== 'editors') return props.staff;
|
||||
|
||||
return ns;
|
||||
}
|
||||
const isInParticipants = (employee) => props.selectedIds?.has(employee.id) ?? false;
|
||||
return props.staff
|
||||
.map((dept) => ({
|
||||
...dept,
|
||||
employees: dept.employees.filter(isInParticipants),
|
||||
}))
|
||||
.filter((dept) => dept.employees.length > 0);
|
||||
});
|
||||
|
||||
return props.staff;
|
||||
},
|
||||
});
|
||||
|
||||
const selectedStaff = computed({
|
||||
get() {
|
||||
let selected = [];
|
||||
props.staff.forEach((e) => {
|
||||
if (e.employees.length != 1 && e.employees.every((n) => n[props.okey] == true)) {
|
||||
e[props.okey] = true;
|
||||
selected.push(e);
|
||||
} else if (e.employees.length == 1) {
|
||||
const singleEmployee = e.employees[0];
|
||||
if (singleEmployee[props.okey] === true) {
|
||||
selected.push(singleEmployee);
|
||||
}
|
||||
// Состояние отдела должно вычисляться на основе сотрудника
|
||||
e[props.okey] = singleEmployee[props.okey] === true;
|
||||
// e[props.okey] = true;
|
||||
// selected.push(...e.employees.filter((n) => n[props.okey] == true));
|
||||
} else {
|
||||
e[props.okey] = false;
|
||||
selected.push(...e.employees.filter((n) => n[props.okey] == true));
|
||||
}
|
||||
});
|
||||
return selected;
|
||||
},
|
||||
|
||||
set(item) {
|
||||
// Если нажимать на пользователя с disable, то срабатывает
|
||||
// set и отправляет данные которые не нужны, но выдает только в виде массива.
|
||||
// Остальные данные передаются объектом, кроме выбора ВСЕХ ПОЛЬЗОВАТЕЛЕЙ, для него написан отдельный клик на обработку
|
||||
// Таким образом предотсвращаем клик на автокомплид (хз понятно или нет)
|
||||
if (!Array.isArray(item)) {
|
||||
emitUp(item);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const emitUp = (part) => {
|
||||
if ('employees' in part) {
|
||||
part.employees.forEach((e) => {
|
||||
if (e.id != accountStore.user.is_idEmployee) {
|
||||
e[props.okey] = !part[props.okey];
|
||||
}
|
||||
});
|
||||
emit('returnIdParticant', {
|
||||
okey: props.okey,
|
||||
staff: part.employees,
|
||||
select: [],
|
||||
});
|
||||
} else if (part.length) {
|
||||
if (part[0].id != accountStore.user.is_idEmployee) {
|
||||
let val = part.every((e) => e[props.okey] == true) ? false : true;
|
||||
cbstaff(part, val);
|
||||
emit('returnIdParticant', {
|
||||
okey: props.okey,
|
||||
staff: back.value,
|
||||
select: [],
|
||||
});
|
||||
back.value = [];
|
||||
}
|
||||
const selectedItems = computed({
|
||||
get() {
|
||||
const chips = [];
|
||||
props.staff.forEach((dept) => {
|
||||
if (dept.employees.length > 1 && isSelected(dept)) {
|
||||
chips.push(dept);
|
||||
} else if (dept.employees.length === 1) {
|
||||
const only = dept.employees[0];
|
||||
if (isSelected(only)) chips.push(only);
|
||||
} else {
|
||||
part[props.okey] = !part[props.okey];
|
||||
emit('returnIdParticant', {
|
||||
okey: props.okey,
|
||||
staff: [part],
|
||||
select: [],
|
||||
});
|
||||
chips.push(...dept.employees.filter((e) => isSelected(e)));
|
||||
}
|
||||
};
|
||||
|
||||
const cbstaff = (item, value) => {
|
||||
item.forEach((e) => {
|
||||
if (e.id !== accountStore.user.is_idEmployee) {
|
||||
e[props.okey] = value;
|
||||
}
|
||||
if (!('employees' in e)) {
|
||||
back.value.push(e);
|
||||
}
|
||||
if ('employees' in e) {
|
||||
cbstaff(e.employees, value);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const customFilterFn = (item, queryText, itemText) => {
|
||||
if (!queryText) return true;
|
||||
|
||||
const searchText = queryText.toLowerCase();
|
||||
const target = item.raw || item;
|
||||
|
||||
// Создаем Map для быстрого поиска отделов по названию
|
||||
const departmentMap = new Map(staffed.value.map((dept) => [dept.title, dept]));
|
||||
|
||||
let department;
|
||||
|
||||
if (typeof target === 'string') {
|
||||
// Ищем отдел по названию
|
||||
department = departmentMap.get(target);
|
||||
} else if (target.title) {
|
||||
// Уже имеем объект отдела
|
||||
department = target;
|
||||
}
|
||||
|
||||
if (department && department.employees) {
|
||||
return department.employees.some((employee) =>
|
||||
employee.title?.toLowerCase().includes(searchText),
|
||||
);
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
const disable = (department) => {
|
||||
return department.id == accountStore.user.id_dict_department &&
|
||||
department.employees.length == 1
|
||||
? true
|
||||
: false;
|
||||
};
|
||||
|
||||
// Функция проверки является ли сотрудник создателем
|
||||
const isAuthor = (item) => {
|
||||
if (!props.authorID) return false;
|
||||
|
||||
// Если это отдел - проверяем всех сотрудников
|
||||
if ('employees' in item) {
|
||||
return item.employees.some((emp) => emp.id === props.authorID);
|
||||
}
|
||||
|
||||
// Если это сотрудник - проверяем напрямую
|
||||
return item.id === props.authorID;
|
||||
};
|
||||
|
||||
const allUser = () => {
|
||||
emitUp(staffed.value);
|
||||
};
|
||||
|
||||
// Проверяем выбраны ли все начальники (с исключениями)
|
||||
const hasBossesSelected = computed(() => {
|
||||
const bosses = findEmployeesByPosition(['начальник', 'и.о'], ['заместитель', 'зам.']);
|
||||
return bosses.length > 0 && bosses.every((emp) => emp[props.okey] === true);
|
||||
});
|
||||
|
||||
// Проверяем выбраны ли все заместители (с исключениями)
|
||||
const hasDeputiesSelected = computed(() => {
|
||||
const deputies = findEmployeesByPosition(['заместитель', 'зам.'], []);
|
||||
return deputies.length > 0 && deputies.every((emp) => emp[props.okey] === true);
|
||||
});
|
||||
|
||||
// Toggle функция с исключением
|
||||
const toggleByPosition = (positionType) => {
|
||||
let keywords = [];
|
||||
let excludeKeywords = [];
|
||||
|
||||
if (positionType === 'начальник') {
|
||||
keywords = ['начальник', 'и.о'];
|
||||
excludeKeywords = ['заместитель', 'зам.'];
|
||||
} else if (positionType === 'заместитель') {
|
||||
keywords = ['заместитель', 'зам.'];
|
||||
excludeKeywords = [];
|
||||
}
|
||||
|
||||
const employeesToToggle = findEmployeesByPosition(keywords, excludeKeywords);
|
||||
const shouldSelect = !employeesToToggle.every((emp) => emp[props.okey] === true);
|
||||
|
||||
// if (employeesToToggle.length > 0) {
|
||||
// employeesToToggle.forEach((employee) => {
|
||||
// if (employee[props.okey] !== shouldSelect) {
|
||||
// emitUp(employee);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
if (employeesToToggle.length > 0) {
|
||||
// ФИЛЬТРУЕМ - убираем создателя события из массовых операций
|
||||
const filteredEmployees = employeesToToggle.filter(
|
||||
(employee) => employee.id !== props.authorID, //
|
||||
);
|
||||
|
||||
if (filteredEmployees.length > 0) {
|
||||
filteredEmployees.forEach((employee) => {
|
||||
if (employee[props.okey] !== shouldSelect) {
|
||||
selectedStaff.value = employee;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Обновленная функция поиска с исключением
|
||||
const findEmployeesByPosition = (positionKeywords, excludeKeywords = []) => {
|
||||
const foundEmployees = [];
|
||||
|
||||
props.staff.forEach((department) => {
|
||||
department.employees.forEach((employee) => {
|
||||
if (department.id == 1) {
|
||||
return;
|
||||
}
|
||||
if (employee.id === accountStore.user.is_idEmployee) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (props.okey === 'editor' && employee.selected !== true) {
|
||||
return;
|
||||
}
|
||||
|
||||
const employeeData = calendarStore.dictEmployees.find((de) => de.id === employee.id);
|
||||
|
||||
if (employeeData && employeeData.post) {
|
||||
const post = employeeData.post.toLowerCase();
|
||||
|
||||
// Ищем включения и исключения
|
||||
const hasInclude = positionKeywords.some((keyword) =>
|
||||
post.includes(keyword.toLowerCase()),
|
||||
);
|
||||
const hasExclude = excludeKeywords.some((exclude) =>
|
||||
post.includes(exclude.toLowerCase()),
|
||||
);
|
||||
|
||||
if (hasInclude && !hasExclude) {
|
||||
foundEmployees.push(employee);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return foundEmployees;
|
||||
};
|
||||
// Проверяем есть ли начальники в staff
|
||||
const hasBossesInStaff = computed(() => {
|
||||
return (
|
||||
findEmployeesByPosition(['начальник', 'и.о. начальника'], ['заместитель', 'зам.']).length >
|
||||
0
|
||||
);
|
||||
});
|
||||
|
||||
// Проверяем есть ли заместители в staff
|
||||
const hasDeputiesInStaff = computed(() => {
|
||||
return (
|
||||
findEmployeesByPosition(['заместитель начальника', 'зам. начальника', 'заместитель'])
|
||||
.length > 0
|
||||
);
|
||||
});
|
||||
|
||||
return {
|
||||
isAuthor,
|
||||
staffed,
|
||||
filtered,
|
||||
accountStore,
|
||||
selectedStaff,
|
||||
splitname,
|
||||
disable,
|
||||
allUser,
|
||||
customFilterFn,
|
||||
findEmployeesByPosition,
|
||||
toggleByPosition,
|
||||
hasBossesInStaff,
|
||||
hasBossesSelected,
|
||||
hasDeputiesInStaff,
|
||||
hasDeputiesSelected,
|
||||
dictEmployeesLoaded,
|
||||
};
|
||||
return chips;
|
||||
},
|
||||
set(value) {
|
||||
if (!Array.isArray(value)) {
|
||||
emitChange(value);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const emitChange = (item) => {
|
||||
// Клик по отделу
|
||||
if ('employees' in item) {
|
||||
const wasSelected = isSelected(item);
|
||||
const action = wasSelected ? 'remove' : 'add';
|
||||
const ids = item.employees.filter((e) => e.id !== props.authorID).map((e) => e.id);
|
||||
|
||||
if (ids.length) emit('change', { ids, action });
|
||||
return;
|
||||
}
|
||||
|
||||
// Массив (групповые операции типа "Все сотрудники")
|
||||
if (Array.isArray(item)) {
|
||||
if (!item.length) return;
|
||||
|
||||
// Собираем плоский список всех сотрудников из массива департаментов
|
||||
const allEmployees = [];
|
||||
item.forEach((entry) => {
|
||||
if ('employees' in entry) {
|
||||
allEmployees.push(...entry.employees);
|
||||
} else {
|
||||
allEmployees.push(entry);
|
||||
}
|
||||
});
|
||||
|
||||
const targets = allEmployees.filter((e) => e.id !== props.authorID);
|
||||
if (!targets.length) return;
|
||||
|
||||
const wasAllSelected = targets.every((e) => isSelected(e));
|
||||
const action = wasAllSelected ? 'remove' : 'add';
|
||||
const ids = targets.map((e) => e.id);
|
||||
|
||||
emit('change', { ids, action });
|
||||
return;
|
||||
}
|
||||
|
||||
// Клик по отдельному сотруднику
|
||||
if (item.id === props.authorID) return;
|
||||
emit('change', { ids: [item.id], action: 'toggle' });
|
||||
};
|
||||
|
||||
const searchInDepartment = (_value, queryText, item) => {
|
||||
if (!queryText) return true;
|
||||
const query = queryText.toLowerCase();
|
||||
const target = item.raw ?? item;
|
||||
|
||||
const dept = visibleDepartments.value.find((d) => d.title === target.title) ?? target;
|
||||
return dept.employees?.some((e) => e.title?.toLowerCase().includes(query)) ?? false;
|
||||
};
|
||||
|
||||
const filterEmployees = (employees) => {
|
||||
if (!searchQuery.value) return employees;
|
||||
const query = searchQuery.value.toLowerCase();
|
||||
return employees.filter((e) => e.title?.toLowerCase().includes(query));
|
||||
};
|
||||
|
||||
const isAuthor = (item) => {
|
||||
if (!props.authorID) return false;
|
||||
if ('employees' in item) {
|
||||
return item.employees.some((e) => e.id === props.authorID);
|
||||
}
|
||||
return item.id === props.authorID;
|
||||
};
|
||||
|
||||
const isDepartmentLocked = (dept) =>
|
||||
dept.id === accountStore.user.id_dict_department && dept.employees.length === 1;
|
||||
|
||||
const isOnlyOneEmployee = computed(
|
||||
() => visibleDepartments.value.length === 1 && visibleDepartments.value[0].employees.length === 1,
|
||||
);
|
||||
|
||||
const isDepartmentIndeterminate = (dept) => {
|
||||
const some = dept.employees.some((e) => isSelected(e));
|
||||
const all = dept.employees.every((e) => isSelected(e));
|
||||
return some && !all;
|
||||
};
|
||||
|
||||
const areAllSelected = computed(
|
||||
() =>
|
||||
visibleDepartments.value.length > 0 &&
|
||||
visibleDepartments.value.every((dept) => isSelected(dept)),
|
||||
);
|
||||
|
||||
const areAllBossesSelected = computed(
|
||||
() => bosses.value.length > 0 && bosses.value.every((e) => isSelected(e)),
|
||||
);
|
||||
|
||||
const areAllDeputiesSelected = computed(
|
||||
() => deputies.value.length > 0 && deputies.value.every((e) => isSelected(e)),
|
||||
);
|
||||
|
||||
const toggleAllEmployees = () => {
|
||||
emitChange(visibleDepartments.value);
|
||||
};
|
||||
|
||||
// Все начальники / Все заместители
|
||||
const findEmployeesByPosition = (includeKeywords, excludeKeywords = []) => {
|
||||
const found = [];
|
||||
|
||||
props.staff.forEach((dept) => {
|
||||
if (dept.id === 1) return;
|
||||
|
||||
dept.employees.forEach((employee) => {
|
||||
if (employee.id === accountStore.user.is_idEmployee) return;
|
||||
if (props.mode === 'editors' && !props.selectedIds?.has(employee.id)) return;
|
||||
|
||||
const meta = calendarStore.dictEmployees.find((d) => d.id === employee.id);
|
||||
if (!meta?.post) return;
|
||||
|
||||
const post = meta.post.toLowerCase();
|
||||
const hasInclude = includeKeywords.some((k) => post.includes(k.toLowerCase()));
|
||||
const hasExclude = excludeKeywords.some((k) => post.includes(k.toLowerCase()));
|
||||
|
||||
if (hasInclude && !hasExclude) found.push(employee);
|
||||
});
|
||||
});
|
||||
|
||||
return found;
|
||||
};
|
||||
|
||||
const bosses = computed(() =>
|
||||
findEmployeesByPosition(['начальник', 'и.о'], ['заместитель', 'зам.']),
|
||||
);
|
||||
const deputies = computed(() => findEmployeesByPosition(['заместитель', 'зам.'], []));
|
||||
|
||||
const hasBossesInStaff = computed(() => bosses.value.length > 0);
|
||||
const hasDeputiesInStaff = computed(() => deputies.value.length > 0);
|
||||
|
||||
const toggleByPosition = (type) => {
|
||||
const list = type === 'boss' ? bosses.value : deputies.value;
|
||||
const targets = list.filter((e) => e.id !== props.authorID);
|
||||
if (!targets.length) return;
|
||||
|
||||
const wasAllSelected = targets.every((e) => isSelected);
|
||||
const action = wasAllSelected ? 'remove' : 'add';
|
||||
|
||||
const ids = targets.map((e) => e.id);
|
||||
emit('change', { ids, action });
|
||||
};
|
||||
</script>
|
||||
@@ -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>
|
||||
|
||||
@@ -44,9 +38,10 @@
|
||||
<v-col class="text-body-2 text-text_grey" lg="2"> Участники </v-col>
|
||||
<v-col>
|
||||
<calendar-create-select
|
||||
:staff="newStaff"
|
||||
@returnIdParticant="returnIdParticant"
|
||||
:staff="staff"
|
||||
:selectedIds="selectedIds"
|
||||
:authorID="calendarAuthorId"
|
||||
@change="onParticipantsChange"
|
||||
/> </v-col
|
||||
></v-row>
|
||||
</v-col>
|
||||
@@ -67,10 +62,12 @@
|
||||
<v-col class="text-body-2 text-text_grey" lg="2"> Редакторы </v-col>
|
||||
<v-col>
|
||||
<calendar-create-select
|
||||
:staff="newStaff"
|
||||
:okey="'editor'"
|
||||
@returnIdParticant="returnIdParticant"
|
||||
:staff="staff"
|
||||
mode="editors"
|
||||
:selectedIds="selectedIds"
|
||||
:editorIds="editorIds"
|
||||
:authorID="calendarAuthorId"
|
||||
@change="onEditorsChange"
|
||||
/>
|
||||
</v-col>
|
||||
<v-col lg="1" class="text-center">
|
||||
@@ -90,213 +87,191 @@
|
||||
</dialog-create>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { computed, ref } from 'vue';
|
||||
<script setup>
|
||||
import { computed, ref, onMounted } from 'vue';
|
||||
import { axiosApiInstance } from '@/utils/axios-api';
|
||||
import calendarCreateSelect from '@/components/calendar_of_events/calendar-create-select.vue';
|
||||
import { useAlertStore } from '@/store/UseAlertStore';
|
||||
import DialogCreate from './UI_calendar/dialogCreate.vue';
|
||||
import { useAccountStore } from '@/store/AccountStore';
|
||||
|
||||
export default {
|
||||
components: { calendarCreateSelect, DialogCreate },
|
||||
|
||||
props: {
|
||||
calendar: {
|
||||
type: Object,
|
||||
default: () => {},
|
||||
},
|
||||
const props = defineProps({
|
||||
calendar: {
|
||||
type: Object,
|
||||
default: () => ({}),
|
||||
},
|
||||
});
|
||||
|
||||
setup(props, { emit }) {
|
||||
const accountStore = useAccountStore();
|
||||
const emit = defineEmits(['update:calendar', 'getCalendar', 'closeDialog']);
|
||||
|
||||
const calendarAuthorId = computed(() => {
|
||||
// Для нового календаря - текущий пользователь
|
||||
if (isNewCalendar.value) {
|
||||
return accountStore.user.is_idEmployee;
|
||||
}
|
||||
// Для существующего - автор из props
|
||||
return propsCalendar.value.author;
|
||||
});
|
||||
const accountStore = useAccountStore();
|
||||
const staff = ref([]);
|
||||
|
||||
const returnIdParticant = (idPart) => {
|
||||
idPart.staff.forEach((e) => {
|
||||
let indx = propsCalendar.value.participant.findIndex((l) => l.participant_calendar == e.id);
|
||||
let ind = propsCalendar.value.participant.find((l) => l.participant_calendar == e.id);
|
||||
if (idPart.okey == 'editor') {
|
||||
ind.editor = e.editor;
|
||||
} else {
|
||||
if (e.selected == true) {
|
||||
if (e.id != accountStore.user.is_idEmployee) {
|
||||
if (indx == -1) {
|
||||
propsCalendar.value.participant.push({
|
||||
editor: false,
|
||||
participant_calendar: e.id,
|
||||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let ind = propsCalendar.value.participant.findIndex(
|
||||
(l) => l.participant_calendar == e.id,
|
||||
);
|
||||
const calendarAuthorId = computed(() => {
|
||||
// Для нового календаря - текущий пользователь
|
||||
if (isNewCalendar.value) {
|
||||
return accountStore.user.is_idEmployee;
|
||||
}
|
||||
// Для существующего - автор из props
|
||||
return propsCalendar.value.author;
|
||||
});
|
||||
|
||||
if (ind != -1) {
|
||||
propsCalendar.value.participant.splice(ind, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
const propsCalendar = computed(() => props.calendar);
|
||||
|
||||
const propsCalendar = computed({
|
||||
get: () => props.calendar,
|
||||
set: (value) => emit('update:calendar', value),
|
||||
});
|
||||
const alertStore = useAlertStore();
|
||||
|
||||
const feedalert = useAlertStore().alert;
|
||||
const req = (val) => {
|
||||
return !!val || 'Поле обязательно';
|
||||
};
|
||||
|
||||
const rules = {
|
||||
cl_name: [(val) => req(val)],
|
||||
cl_descr: [(val) => req(val)],
|
||||
};
|
||||
const rules = {
|
||||
cl_name: [(val) => req(val)],
|
||||
cl_descr: [(val) => req(val)],
|
||||
};
|
||||
|
||||
const isNewCalendar = computed(() => !propsCalendar.value.id);
|
||||
const isAuthor = computed(() => propsCalendar.value.author === accountStore.user.is_idEmployee);
|
||||
|
||||
const titleCard = computed(() =>
|
||||
isNewCalendar.value ? 'Новый календарь' : 'Редактирование календаря',
|
||||
const isNewCalendar = computed(() => !propsCalendar.value?.id);
|
||||
const titleCard = computed(() =>
|
||||
isNewCalendar.value ? 'Новый календарь' : 'Редактирование календаря',
|
||||
);
|
||||
|
||||
const loadStaff = async () => {
|
||||
try {
|
||||
const res = await axiosApiInstance.get('api/calendar_of_events/get_employees/');
|
||||
staff.value = res.data.filter((e) => e.employees.length > 0);
|
||||
} catch (e) {
|
||||
console.error('Ошибка загрузки сотрудников, ', e);
|
||||
}
|
||||
};
|
||||
|
||||
const selectedIds = computed(
|
||||
() => new Set((propsCalendar.value?.participant ?? []).map((p) => p.participant_calendar)),
|
||||
);
|
||||
|
||||
const editorIds = computed(
|
||||
() =>
|
||||
new Set(
|
||||
(propsCalendar.value?.participant ?? [])
|
||||
.filter((p) => p.editor === true)
|
||||
.map((p) => p.participant_calendar),
|
||||
),
|
||||
);
|
||||
const onParticipantsChange = ({ ids, action }) => {
|
||||
ids.forEach((id) => {
|
||||
if (id === accountStore.user.is_idEmployee) return;
|
||||
|
||||
const existingIdx = propsCalendar.value.participant.findIndex(
|
||||
(p) => p.participant_calendar === id,
|
||||
);
|
||||
|
||||
const newCalendar = computed(() => (isNewCalendar.value ? true : !isAuthor.value));
|
||||
|
||||
const postCalendar = (val) => {
|
||||
if (val) {
|
||||
axiosApiInstance
|
||||
.post(`api/calendar_of_events/my_calendars/`, {
|
||||
...props.calendar,
|
||||
participant: propsCalendar.value.participant,
|
||||
})
|
||||
.then((result) => {
|
||||
feedalert.alert = true;
|
||||
feedalert.text = result.data.mess;
|
||||
feedalert.ico = 'mdi-check';
|
||||
feedalert.color = 'green-darken-4';
|
||||
emit('getCalendar');
|
||||
emit('closeDialog');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const staff = ref([]);
|
||||
|
||||
axiosApiInstance.get('api/calendar_of_events/get_employees/').then((res) => {
|
||||
staff.value = res.data.filter((e) => e.employees.length > 0);
|
||||
});
|
||||
|
||||
const newStaff = computed({
|
||||
get() {
|
||||
staff.value.forEach((e) => {
|
||||
if (propsCalendar.value.participant.length > 0) {
|
||||
e.employees.forEach((empl) => {
|
||||
let ab = propsCalendar.value.participant.find(
|
||||
(a) => a.participant_calendar === empl.id,
|
||||
);
|
||||
if (ab) {
|
||||
empl.selected = true;
|
||||
empl.editor = ab.editor;
|
||||
} else {
|
||||
empl.selected = false;
|
||||
empl.editor = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
if (action === 'add') {
|
||||
if (existingIdx === -1) {
|
||||
propsCalendar.value.participant.push({
|
||||
editor: false,
|
||||
participant_calendar: id,
|
||||
});
|
||||
}
|
||||
} else if (action === 'remove') {
|
||||
if (existingIdx !== -1) {
|
||||
propsCalendar.value.participant.splice(existingIdx, 1);
|
||||
}
|
||||
} else if (action === 'toggle') {
|
||||
if (existingIdx === -1) {
|
||||
propsCalendar.value.participant.push({
|
||||
editor: false,
|
||||
participant_calendar: id,
|
||||
});
|
||||
} else {
|
||||
propsCalendar.value.participant.splice(existingIdx, 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
return staff.value;
|
||||
},
|
||||
});
|
||||
const onEditorsChange = ({ ids, action }) => {
|
||||
ids.forEach((id) => {
|
||||
const existing = propsCalendar.value.participant.find((p) => p.participant_calendar === id);
|
||||
if (!existing) return; // нельзя быть редактором, не будучи участником
|
||||
|
||||
// const color = [
|
||||
// '#0ea5e9', // Яркий голубой
|
||||
// '#3b82f6', // Королевский синий
|
||||
// '#10b981', // Изумрудно-зеленый
|
||||
// '#f59e0b', // Теплый янтарный
|
||||
// '#ef4444', // Акцентный красный
|
||||
// '#8b5cf6', // Фиолетовый
|
||||
// '#4f46e5', // Индиго (профессиональный синий)
|
||||
// '#06b6d4', // Бирюзовый
|
||||
// '#84cc16', // Лаймовый
|
||||
// '#f97316', // Оранжевый
|
||||
// '#ec4899', // Розовый
|
||||
// '#6366f1', // Фиолетово-синий
|
||||
// '#14b8a6', // Бирюзово-зеленый
|
||||
// '#eab308', // Золотисто-желтый
|
||||
// '#22c55e', // Зеленый
|
||||
// ];
|
||||
if (action === 'add') existing.editor = true;
|
||||
else if (action === 'remove') existing.editor = false;
|
||||
else if (action === 'toggle') existing.editor = !existing.editor;
|
||||
});
|
||||
};
|
||||
|
||||
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;
|
||||
} else {
|
||||
propsCalendar.value.cl_color = col;
|
||||
}
|
||||
};
|
||||
|
||||
const delCalendar = (idcal) => {
|
||||
axiosApiInstance
|
||||
.delete(`api/calendar_of_events/my_calendars/?delid=${idcal}`)
|
||||
.then((result) => {
|
||||
feedalert.alert = true;
|
||||
feedalert.text = result.data.mess;
|
||||
feedalert.ico = 'mdi-check';
|
||||
feedalert.color = 'orange-accent-1';
|
||||
emit('getCalendar');
|
||||
});
|
||||
emit('closeDialog');
|
||||
};
|
||||
|
||||
const req = (val) => {
|
||||
return !!val || 'Поле обязательно';
|
||||
};
|
||||
|
||||
return {
|
||||
postCalendar,
|
||||
color,
|
||||
colorPik,
|
||||
returnIdParticant,
|
||||
propsCalendar,
|
||||
delCalendar,
|
||||
rules,
|
||||
titleCard,
|
||||
newCalendar,
|
||||
newStaff,
|
||||
isNewCalendar,
|
||||
calendarAuthorId,
|
||||
};
|
||||
},
|
||||
const colorPik = (col) => {
|
||||
if (propsCalendar.value.cl_color === col) {
|
||||
propsCalendar.value.cl_color = null;
|
||||
} else {
|
||||
propsCalendar.value.cl_color = col;
|
||||
}
|
||||
};
|
||||
|
||||
const postCalendar = async (val) => {
|
||||
if (!val) return;
|
||||
|
||||
try {
|
||||
const result = await axiosApiInstance.post(`api/calendar_of_events/my_calendars/`, {
|
||||
...props.calendar,
|
||||
participant: propsCalendar.value.participant,
|
||||
});
|
||||
alertStore.showSuccess(result.data.mess);
|
||||
emit('getCalendar');
|
||||
emit('closeDialog');
|
||||
} catch (e) {
|
||||
alertStore.showError('Ошибка сохранения календаря');
|
||||
console.error(e);
|
||||
}
|
||||
};
|
||||
|
||||
const delCalendar = async (idcal) => {
|
||||
try {
|
||||
const result = await axiosApiInstance.delete(
|
||||
`api/calendar_of_events/my_calendars/?delid=${idcal}`,
|
||||
);
|
||||
alertStore.showWarning(result.data.mess);
|
||||
emit('getCalendar');
|
||||
emit('closeDialog');
|
||||
} catch (e) {
|
||||
alertStore.showError('Ошибка удаления календаря');
|
||||
console.error(e);
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
loadStaff();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.custom-tooltip {
|
||||
max-width: 350px; /* Установка максимальной ширины для подсказки */
|
||||
}
|
||||
|
||||
.avatar-dimmed {
|
||||
opacity: 0.45;
|
||||
transition: opacity 0.15s ease;
|
||||
}
|
||||
|
||||
.avatar-dimmed:hover {
|
||||
opacity: 0.8;
|
||||
}
|
||||
</style>
|
||||
@@ -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,92 +73,97 @@
|
||||
</v-expansion-panels>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
<script setup>
|
||||
import { 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: '',
|
||||
},
|
||||
},
|
||||
const showDialog = ref(false);
|
||||
const accountStore = useAccountStore();
|
||||
const { user } = storeToRefs(accountStore);
|
||||
const calendarStore = useCalendarStore();
|
||||
|
||||
setup(props) {
|
||||
const showDialog = ref(false);
|
||||
const accountStore = useAccountStore();
|
||||
const { user } = storeToRefs(accountStore);
|
||||
const calendarStore = useCalendarStore();
|
||||
const { toggleCalendarVisibility, hiddenCalendarIds } = calendarStore;
|
||||
const { hiddenCalendarIds, showCreateCalendarDialog, createCalendarInitial } =
|
||||
storeToRefs(calendarStore);
|
||||
|
||||
const calendar = ref(null);
|
||||
const openGroup = ref([0]);
|
||||
const trans = ref(false);
|
||||
const hover = ref(0);
|
||||
const { toggleCalendarVisibility, resolveCreateCalendar } = calendarStore;
|
||||
|
||||
const editCreatedCalendar = (cal) => {
|
||||
if (cal === undefined) {
|
||||
calendar.value = {
|
||||
cl_name: '',
|
||||
participant: [{ editor: true, participant_calendar: user.value.is_idEmployee }],
|
||||
cl_color: 'red',
|
||||
cl_descr: '',
|
||||
};
|
||||
} else {
|
||||
calendar.value = { ...cal };
|
||||
}
|
||||
showDialog.value = true;
|
||||
const calendar = ref(null);
|
||||
const openGroup = ref([0]);
|
||||
const hover = ref(0);
|
||||
|
||||
const editCreatedCalendar = (cal) => {
|
||||
if (!cal) {
|
||||
calendar.value = {
|
||||
cl_name: '',
|
||||
participant: [{ editor: true, participant_calendar: user.value.is_idEmployee }],
|
||||
cl_color: 'red',
|
||||
cl_descr: '',
|
||||
};
|
||||
|
||||
const handleCloseDialog = () => {
|
||||
showDialog.value = false;
|
||||
};
|
||||
|
||||
const resetCalendar = () => {
|
||||
calendar.value = {};
|
||||
};
|
||||
|
||||
const toggleVisiblityEvents = (cal) => {
|
||||
toggleCalendarVisibility(cal.id);
|
||||
};
|
||||
|
||||
watch(hiddenCalendarIds, (newHiddenIds) => {}, { deep: true });
|
||||
|
||||
watch(
|
||||
() => props.calendars,
|
||||
(newCalendars) => {},
|
||||
{ deep: true },
|
||||
);
|
||||
|
||||
return {
|
||||
accountStore,
|
||||
user,
|
||||
calendar,
|
||||
showDialog,
|
||||
editCreatedCalendar,
|
||||
toggleVisiblityEvents,
|
||||
openGroup,
|
||||
trans,
|
||||
hover,
|
||||
handleCloseDialog,
|
||||
resetCalendar,
|
||||
};
|
||||
},
|
||||
} else {
|
||||
calendar.value = { ...cal };
|
||||
}
|
||||
showDialog.value = true;
|
||||
};
|
||||
|
||||
const handleCloseDialog = () => {
|
||||
const isValid = calendar.value?.cl_name?.length > 1;
|
||||
if (showCreateCalendarDialog.value) {
|
||||
resolveCreateCalendar(isValid ? JSON.parse(JSON.stringify(calendar.value)) : null);
|
||||
}
|
||||
|
||||
showDialog.value = false;
|
||||
};
|
||||
|
||||
const toggleVisiblityEvents = (cal) => {
|
||||
toggleCalendarVisibility(cal.id);
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.calendars,
|
||||
(newCalendars) => {},
|
||||
{ deep: true },
|
||||
);
|
||||
|
||||
watch(showDialog, (open) => {
|
||||
if (!open && showCreateCalendarDialog.value) {
|
||||
resolveCreateCalendar(null);
|
||||
}
|
||||
});
|
||||
|
||||
watch(showCreateCalendarDialog, (open) => {
|
||||
if (open && props.title === 'Мои календари') {
|
||||
editCreatedCalendar(createCalendarInitial.value);
|
||||
}
|
||||
});
|
||||
</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;
|
||||
|
||||
@@ -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>
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
|
||||
|
||||
<div>
|
||||
<v-btn @click="f_feedbackdata"> ical</v-btn>
|
||||
|
||||
@@ -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("");
|
||||
@@ -42,15 +40,15 @@ export default {
|
||||
|
||||
|
||||
onMounted(()=>{
|
||||
|
||||
|
||||
cal.value.$el.querySelectorAll(".v-date-picker-month__day").forEach((e)=>{
|
||||
if (hol.includes(e.getAttribute("data-v-date"))) {
|
||||
e.querySelectorAll("span").forEach(n=>{n.classList.add("text-red")})
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
})
|
||||
|
||||
function f_feedbackdata() {
|
||||
@@ -59,7 +57,7 @@ export default {
|
||||
participants: participant.value,
|
||||
calendar: calendar.value,
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
||||
const handleFilesUpload = (event) => {
|
||||
|
||||
@@ -3,22 +3,21 @@
|
||||
<v-card-title>
|
||||
<span class="text-h5">Обратная связь</span>
|
||||
</v-card-title>
|
||||
<v-card-text class="px-2 py-0">
|
||||
|
||||
<v-card-text class="px-2 py-0">
|
||||
<v-container>
|
||||
<v-row>
|
||||
<v-col class="flex-grow-0 py-0 text-no-wrap align-self-center text-button">
|
||||
Оцените сайт
|
||||
|
||||
<v-col class="flex-grow-0 py-0 text-no-wrap align-self-center text-button">
|
||||
Оцените сайт
|
||||
</v-col>
|
||||
<v-divider class="pb-3"/>
|
||||
<v-divider class="pb-3" />
|
||||
</v-row>
|
||||
<feedstar-like
|
||||
:rating=feedbackdata
|
||||
@update:rating="feedbackdata.nowrating = $event"
|
||||
/>
|
||||
|
||||
<feedstar-like :rating="feedbackdata" @update:rating="feedbackdata.nowrating = $event" />
|
||||
|
||||
<v-row class="mt-6">
|
||||
<v-col class="pa-0 px-3">
|
||||
<v-textarea
|
||||
<v-textarea
|
||||
label="Ваши комментарии сделают портал лучше"
|
||||
hide-details
|
||||
variant="outlined"
|
||||
@@ -30,149 +29,115 @@
|
||||
</v-row>
|
||||
</v-container>
|
||||
</v-card-text>
|
||||
|
||||
<v-card-actions class="pt-0">
|
||||
<small v-if="average < 5 || feedbackdata.nowcomment.id!=null" class="pl-5">
|
||||
Вы оценили сайт на <span class="font-weight-black">{{average}}</span> {{myLabel()}}
|
||||
<small v-if="average < 5 || feedbackdata.nowcomment.id !== null" class="pl-5">
|
||||
Вы оценили сайт на <span class="font-weight-black">{{ average }}</span>
|
||||
{{ ratingLabel }}
|
||||
</small>
|
||||
<v-spacer/>
|
||||
<v-btn
|
||||
color="modal_btn"
|
||||
rounded="xl"
|
||||
text="Закрыть"
|
||||
@click="menusCloses"
|
||||
/>
|
||||
<v-spacer />
|
||||
<v-btn color="modal_btn" rounded="xl" text="Закрыть" @click="closeMenu" />
|
||||
<v-btn
|
||||
color="modal_btn"
|
||||
variant="text"
|
||||
:text="feedbackdata.nowcomment.id==null?'Отправить':'Обновить'"
|
||||
@click="feedSend"
|
||||
:text="feedbackdata.nowcomment.id === null ? 'Отправить' : 'Обновить'"
|
||||
@click="sendFeedback"
|
||||
/>
|
||||
|
||||
|
||||
</v-card-actions>
|
||||
|
||||
</v-card>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ref, onMounted, computed } from 'vue'
|
||||
import { axiosApiInstance } from '@/utils/axios-api'
|
||||
<script setup>
|
||||
import { ref, computed, onMounted } from 'vue';
|
||||
import { axiosApiInstance } from '@/utils/axios-api';
|
||||
import FeedstarLike from '@/components/UI/feedback/feedstar-like.vue';
|
||||
import { useAlertStore } from '@/store/UseAlertStore';
|
||||
|
||||
import FeedstarLike from '@/components/UI/feedback/feedstar-like.vue'
|
||||
import { useAlertStore } from '@/store/UseAlertStore'
|
||||
defineProps({
|
||||
LikeDialog: { type: Boolean, default: false },
|
||||
});
|
||||
|
||||
export default {
|
||||
components: { FeedstarLike },
|
||||
const emit = defineEmits(['menusClose']);
|
||||
|
||||
props: {
|
||||
LikeDialog: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
const alertStore = useAlertStore();
|
||||
|
||||
|
||||
const feedbackdata = ref({
|
||||
nowcomment: { comment: '', id: null },
|
||||
nowrating: [],
|
||||
});
|
||||
|
||||
setup(props, {emit}) {
|
||||
const feedalert = useAlertStore().alert
|
||||
const feedbackdata= ref({nowcomment: {comment: '' }, nowrating: []})
|
||||
const loadFeedback = async () => {
|
||||
try {
|
||||
const { data } = await axiosApiInstance.get('api/feedback/feedbackdata/');
|
||||
feedbackdata.value = data;
|
||||
|
||||
function f_feedbackdata() {
|
||||
axiosApiInstance.get('api/feedback/feedbackdata/')
|
||||
.then(data => {
|
||||
feedbackdata.value = data.data
|
||||
if (feedbackdata.value.nowrating.length == 0) {
|
||||
for (let x of feedbackdata.value.basecrit) {
|
||||
feedbackdata.value.nowrating.push({rating: x.rating, crit: x.id, id: null})
|
||||
}
|
||||
if (feedbackdata.value.nowrating.length === 0) {
|
||||
for (const x of feedbackdata.value.basecrit) {
|
||||
feedbackdata.value.nowrating.push({
|
||||
rating: x.rating,
|
||||
crit: x.id,
|
||||
id: null,
|
||||
});
|
||||
}
|
||||
if (feedbackdata.value.nowcomment === null) {
|
||||
feedbackdata.value.nowcomment = { comment: '', id: null}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
f_feedbackdata()
|
||||
})
|
||||
|
||||
const average = computed(()=> {
|
||||
const sum = feedbackdata.value.nowrating.reduce((total, obj)=> total + obj.rating, 0)
|
||||
const sumlen = sum/feedbackdata.value.nowrating.length
|
||||
const ukr = Number.isInteger(sumlen)?sumlen:sumlen.toFixed(1)
|
||||
return ukr
|
||||
})
|
||||
|
||||
function myLabel() {
|
||||
let labels = ''
|
||||
if (average.value > 0 && average.value <= 3)
|
||||
labels = 'УПС-С! Мы обязательно все исправим'
|
||||
else if (average.value > 2 && average.value <= 4)
|
||||
labels = 'Спасибо за обратную связь, мы обратим на это внимание'
|
||||
else if (average.value > 4 && average.value < 5)
|
||||
labels = 'Класс, будем стараться до 5'
|
||||
else
|
||||
labels = "Спасибо за отзыв и высокую оценку ^__^"
|
||||
return labels
|
||||
}
|
||||
|
||||
function menusCloses() {
|
||||
emit('menusClose')
|
||||
}
|
||||
|
||||
function feedSend() {
|
||||
|
||||
axiosApiInstance.post(`api/feedback/feedbackdata/`, {
|
||||
nowrating: feedbackdata.value.nowrating,
|
||||
nowcomment: feedbackdata.value.nowcomment
|
||||
}).then(data => {})
|
||||
feedalert.alert = true
|
||||
textFromAlert()
|
||||
menusCloses()
|
||||
|
||||
}
|
||||
|
||||
const textFromAlert = () => {
|
||||
if (feedbackdata.value.nowcomment.id ==null) {
|
||||
feedalert.text = "Оценка отправлена, спасибо за участие"
|
||||
feedalert.ico = "mdi-redo-variant"
|
||||
feedalert.color = "green-darken-4"
|
||||
}
|
||||
|
||||
else {
|
||||
feedalert.text = "Оценка обновлена"
|
||||
feedalert.ico = "mdi-refresh"
|
||||
feedalert.color="light-blue-darken-4"
|
||||
if (feedbackdata.value.nowcomment === null) {
|
||||
feedbackdata.value.nowcomment = { comment: '', id: null };
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Ошибка загрузки фидбэка:', e);
|
||||
alertStore.showError('Не удалось загрузить данные обратной связи');
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
return {
|
||||
feedbackdata,
|
||||
average,
|
||||
menusCloses,
|
||||
myLabel,
|
||||
feedSend,
|
||||
feedalert
|
||||
|
||||
const average = computed(() => {
|
||||
const ratings = feedbackdata.value.nowrating;
|
||||
if (!ratings.length) return 0;
|
||||
|
||||
const sum = ratings.reduce((total, obj) => total + obj.rating, 0);
|
||||
const avg = sum / ratings.length;
|
||||
return Number.isInteger(avg) ? avg : Number(avg.toFixed(1));
|
||||
});
|
||||
|
||||
const ratingLabel = computed(() => {
|
||||
const avg = average.value;
|
||||
if (avg > 0 && avg <= 3) return 'УПС-С! Мы обязательно все исправим';
|
||||
if (avg > 2 && avg <= 4) return 'Спасибо за обратную связь, мы обратим на это внимание';
|
||||
if (avg > 4 && avg < 5) return 'Класс, будем стараться до 5';
|
||||
return 'Спасибо за отзыв и высокую оценку ^__^';
|
||||
});
|
||||
|
||||
const closeMenu = () => emit('menusClose');
|
||||
|
||||
const sendFeedback = async () => {
|
||||
const isUpdate = feedbackdata.value.nowcomment.id !== null;
|
||||
|
||||
try {
|
||||
await axiosApiInstance.post('api/feedback/feedbackdata/', {
|
||||
nowrating: feedbackdata.value.nowrating,
|
||||
nowcomment: feedbackdata.value.nowcomment,
|
||||
});
|
||||
|
||||
if (isUpdate) {
|
||||
alertStore.show({
|
||||
text: 'Оценка обновлена',
|
||||
ico: 'mdi-refresh',
|
||||
color: 'light-blue-darken-4',
|
||||
});
|
||||
} else {
|
||||
alertStore.show({
|
||||
text: 'Оценка отправлена, спасибо за участие',
|
||||
ico: 'mdi-redo-variant',
|
||||
color: 'green-darken-4',
|
||||
});
|
||||
}
|
||||
|
||||
await loadFeedback();
|
||||
closeMenu();
|
||||
} catch (e) {
|
||||
console.error('Ошибка отправки фидбэка:', e);
|
||||
alertStore.showError('Не удалось отправить отзыв');
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
onMounted(loadFeedback);
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.custom_subtitle {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.v-selection-control__input {
|
||||
width: 46%!important;
|
||||
height: 46%!important;
|
||||
border-radius: 0!important;
|
||||
}
|
||||
|
||||
</style>
|
||||
Executable → Regular
File mode changed.
@@ -1,118 +1,106 @@
|
||||
<template>
|
||||
<v-row no-gutters class="gap ma-3 flex-column">
|
||||
<v-col lg=2 class='w100 d-flex flex-column'>
|
||||
<v-row no-gutters class="gap ma-3 flex-column">
|
||||
<v-col lg="2" class="w100 d-flex flex-column">
|
||||
<v-row no-gutters class="gap">
|
||||
<v-col lg="4">
|
||||
<v-card class="h-100">
|
||||
<v-card-title> Ежедневная статистика по сотрудникам </v-card-title>
|
||||
<v-row no-gutters class="gap">
|
||||
<v-col lg=4>
|
||||
<v-card class="h-100">
|
||||
<v-card-title>
|
||||
Ежедневная статистика по сотрудникам
|
||||
</v-card-title>
|
||||
<v-row no-gutters class="gap">
|
||||
<v-col class="flex-grow-0">
|
||||
<v-card-subtitle class="mt-2 align-self-end">
|
||||
1. Скачать файл ежедневной статистики
|
||||
</v-card-subtitle>
|
||||
</v-col>
|
||||
<v-col class="flex-grow-0">
|
||||
<v-icon
|
||||
icon="mdi-file-excel"
|
||||
color="green-darken-3"
|
||||
@click="excelOp('excround')"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row no-gutters class="gap mt-5">
|
||||
<v-col class="flex-grow-0">
|
||||
<v-card-subtitle class="mt-3 align-self-end">
|
||||
2. Загрузить данные на сервер
|
||||
</v-card-subtitle>
|
||||
</v-col>
|
||||
<v-col >
|
||||
<v-file-input
|
||||
accept=".xlsx"
|
||||
v-model="dailyfiles"
|
||||
variant="underlined"
|
||||
density="compact"
|
||||
label="Прикрепить файл"
|
||||
hide-details
|
||||
/>
|
||||
</v-col>
|
||||
<v-col class="flex-grow-0 pr-2">
|
||||
<v-icon
|
||||
icon="mdi-chevron-double-right"
|
||||
color="blue-grey-darken-2"
|
||||
@click="onPickFile('roundfilse')"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-card>
|
||||
</v-col>
|
||||
<v-col class="flex-grow-0">
|
||||
<v-card-subtitle class="mt-2 align-self-end">
|
||||
1. Скачать файл ежедневной статистики
|
||||
</v-card-subtitle>
|
||||
</v-col>
|
||||
<v-col class="flex-grow-0">
|
||||
<v-icon icon="mdi-file-excel" color="green-darken-3" @click="excelOp('excround')" />
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row no-gutters class="gap mt-5">
|
||||
<v-col class="flex-grow-0">
|
||||
<v-card-subtitle class="mt-3 align-self-end">
|
||||
2. Загрузить данные на сервер
|
||||
</v-card-subtitle>
|
||||
</v-col>
|
||||
<v-col>
|
||||
<v-file-input
|
||||
accept=".xlsx"
|
||||
v-model="dailyfiles"
|
||||
variant="underlined"
|
||||
density="compact"
|
||||
label="Прикрепить файл"
|
||||
hide-details
|
||||
/>
|
||||
</v-col>
|
||||
<v-col class="flex-grow-0 pr-2">
|
||||
<v-icon
|
||||
icon="mdi-chevron-double-right"
|
||||
color="blue-grey-darken-2"
|
||||
@click="onPickFile('roundfilse')"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-card>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-row>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ref } from 'vue'
|
||||
import { baseURL } from '@/utils/axios-api'
|
||||
import { axiosApiInstance } from '@/utils/axios-api'
|
||||
import { useAlertStore } from '@/store/UseAlertStore'
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { baseURL, axiosApiInstance } from '@/utils/axios-api';
|
||||
import { useAlertStore } from '@/store/UseAlertStore';
|
||||
|
||||
export default {
|
||||
const dailyfiles = ref([]);
|
||||
const alertStore = useAlertStore();
|
||||
|
||||
setup(){
|
||||
const excelOp = async (ex) => {
|
||||
try {
|
||||
const result = await axiosApiInstance.get(`api/general_vacation/dailyroundup/?excel=${ex}`);
|
||||
const link = document.createElement('a');
|
||||
link.href = baseURL + result.data.path;
|
||||
link.click();
|
||||
link.remove();
|
||||
} catch (e) {
|
||||
alertStore.showError('Не удалось получить файл');
|
||||
console.error(e);
|
||||
}
|
||||
};
|
||||
|
||||
const dailyfiles = ref([])
|
||||
const feedalert = useAlertStore().alert
|
||||
const onPickFile = async (ex) => {
|
||||
const sdata = new FormData();
|
||||
sdata.append('dailyfiles', dailyfiles.value);
|
||||
|
||||
const excelOp = (ex) => {
|
||||
axiosApiInstance.get(`api/general_vacation/dailyroundup/?excel=${ex}`).then(result => {
|
||||
let link = document.createElement("a")
|
||||
link.href = baseURL+result.data.path
|
||||
link.click()
|
||||
link.remove()
|
||||
})
|
||||
}
|
||||
try {
|
||||
const result = await axiosApiInstance.post(
|
||||
`api/general_vacation/dailyroundup/?excel=${ex}`,
|
||||
sdata,
|
||||
);
|
||||
|
||||
const onPickFile = (ex) => {
|
||||
const sdata = new FormData()
|
||||
sdata.append('dailyfiles', dailyfiles.value)
|
||||
axiosApiInstance.post(`api/general_vacation/dailyroundup/?excel=${ex}`, sdata).then(result => {
|
||||
textFromAlert(result.data['mess'])
|
||||
})
|
||||
dailyfiles.value = []
|
||||
}
|
||||
|
||||
const textFromAlert = (info) => {
|
||||
feedalert.alert = true
|
||||
if (info == "Файл загружен") {
|
||||
feedalert.text = "Файл загружен"
|
||||
feedalert.ico = "mdi-check"
|
||||
feedalert.color ="green-darken-4"
|
||||
}
|
||||
else {
|
||||
feedalert.text = "Ошибка загрузки"
|
||||
feedalert.ico = "mdi-alert-circle-outline"
|
||||
feedalert.color="pink-accent-4"
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
excelOp,
|
||||
baseURL,
|
||||
dailyfiles,
|
||||
onPickFile,
|
||||
feedalert
|
||||
}
|
||||
if (result.data.mess === 'Файл загружен') {
|
||||
alertStore.showSuccess('Файл загружен');
|
||||
} else {
|
||||
alertStore.showError(result.data.mess ?? 'Ошибка загрузки');
|
||||
}
|
||||
} catch (e) {
|
||||
alertStore.showError('Ошибка загрузки');
|
||||
console.error(e);
|
||||
} finally {
|
||||
dailyfiles.value = [];
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
defineExpose({
|
||||
excelOp,
|
||||
baseURL,
|
||||
dailyfiles,
|
||||
onPickFile,
|
||||
alertStore,
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.mhight {
|
||||
height: 150px;
|
||||
height: 150px;
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
</style>
|
||||
@@ -1,128 +1,101 @@
|
||||
<template>
|
||||
<v-row class="">
|
||||
<v-col class="flex-column d-flex pa-0">
|
||||
<v-row class="mt-0 mx-3 h-0 overflow-auto ">
|
||||
<v-col
|
||||
v-for="(x, key) in newsAll"
|
||||
:key="key"
|
||||
class="py-1"
|
||||
lg=12
|
||||
md=6
|
||||
sm=6
|
||||
>
|
||||
<NewsCard :news="x"/>
|
||||
|
||||
<v-row class="">
|
||||
<v-col class="flex-column d-flex pa-0">
|
||||
<v-row class="mt-0 mx-3 h-0 overflow-auto">
|
||||
<v-col v-for="(x, key) in newsAll" :key="key" class="py-1" lg="12" md="6" sm="6">
|
||||
<NewsCard :news="x" />
|
||||
|
||||
<v-dialog
|
||||
v-model="dialogfotoOne"
|
||||
width="w-100"
|
||||
height="900"
|
||||
class="flex-column "
|
||||
>
|
||||
<v-card class="pa-4 h-100 flex-column d-flex">
|
||||
<v-dialog v-model="dialogfotoOne" width="w-100" height="900" class="flex-column">
|
||||
<v-card class="pa-4 h-100 flex-column d-flex">
|
||||
<v-row class="flex-grow-0 justify-end">
|
||||
<v-col class="pa-0 flex-grow-0">
|
||||
<v-btn
|
||||
density="compact"
|
||||
variant="text"
|
||||
icon="mdi-close"
|
||||
@click="dialogfotoOne = false"
|
||||
|
||||
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row>
|
||||
|
||||
<v-col class="flex-column h_cards pa-0">
|
||||
<v-img
|
||||
class="d-flex"
|
||||
:src="`${burl}${galleryimges}`"
|
||||
/>
|
||||
|
||||
</v-col>
|
||||
|
||||
</v-row>
|
||||
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
|
||||
<v-col class="pa-0 flex-grow-0">
|
||||
<v-btn
|
||||
density="compact"
|
||||
variant="text"
|
||||
icon="mdi-close"
|
||||
@click="dialogfotoOne = false"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-divider class="mt-3"/>
|
||||
<v-row class="flex-grow-0 ma-0 align-items-center">
|
||||
<v-col class="flex-column d-flex pa-0 align-end">
|
||||
<v-btn
|
||||
size="small"
|
||||
variant="text"
|
||||
icon="mdi-newspaper"
|
||||
color="teal-darken-4"
|
||||
:to='`/news`'
|
||||
/>
|
||||
</v-row>
|
||||
<v-row>
|
||||
<v-col class="flex-column h_cards pa-0">
|
||||
<v-img class="d-flex" :src="`${burl}${galleryimges}`" />
|
||||
</v-col>
|
||||
<v-col class="py-0 pl-0 flex-grow-0 text-end align-self-center text-caption font-weight-bold text-no-wrap">
|
||||
Всего новостей: {{countetnews}}
|
||||
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-row>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-row>
|
||||
<v-divider class="mt-3" />
|
||||
<v-row class="flex-grow-0 ma-0 align-items-center">
|
||||
<v-col class="flex-column d-flex pa-0 align-end">
|
||||
<v-btn
|
||||
size="small"
|
||||
variant="text"
|
||||
icon="mdi-newspaper"
|
||||
color="teal-darken-4"
|
||||
:to="`/news`"
|
||||
/>
|
||||
</v-col>
|
||||
<v-col
|
||||
class="py-0 pl-0 flex-grow-0 text-end align-self-center text-caption font-weight-bold text-no-wrap"
|
||||
>
|
||||
Всего новостей: {{ countetnews }}
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ref } from 'vue'
|
||||
import { axiosApiInstance } from '@/utils/axios-api'
|
||||
import { useRoute } from 'vue-router'
|
||||
import NewsCard from './UI/NewsCard.vue'
|
||||
import { ref } from 'vue';
|
||||
import { axiosApiInstance } from '@/utils/axios-api';
|
||||
import { useRoute } from 'vue-router';
|
||||
import NewsCard from './UI/NewsCard.vue';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
NewsCard,
|
||||
},
|
||||
|
||||
components: {
|
||||
NewsCard
|
||||
},
|
||||
setup() {
|
||||
const newsAll = ref([]);
|
||||
const countetnews = ref(0);
|
||||
const page = ref(1);
|
||||
const countpage = ref(8);
|
||||
const route = useRoute();
|
||||
const galleryimges = ref('');
|
||||
const dialogfotoOne = ref(false);
|
||||
|
||||
setup(){
|
||||
const loadNewsAll = () => {
|
||||
axiosApiInstance
|
||||
.get(
|
||||
`api/navigation/newscrossroad/?name=${route.path}&page=${page.value - 1}&countpage=${countpage.value}`,
|
||||
)
|
||||
.then((result) => {
|
||||
newsAll.value = result.data.result;
|
||||
countetnews.value = result.data.countpage;
|
||||
});
|
||||
};
|
||||
|
||||
const newsAll=ref([])
|
||||
const countetnews = ref(0)
|
||||
const page = ref(1)
|
||||
const countpage = ref(8)
|
||||
const route = useRoute()
|
||||
const galleryimges=ref('')
|
||||
const dialogfotoOne = ref(false)
|
||||
loadNewsAll();
|
||||
|
||||
const loadNewsAll = () => {
|
||||
axiosApiInstance.get( `api/navigation/newscrossroad/?name=${route.path}&page=${page.value-1}&countpage=${countpage.value}`).then(result => {
|
||||
newsAll.value= result.data.result
|
||||
countetnews.value = result.data.countpage
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
loadNewsAll()
|
||||
|
||||
const openOneImg = (idimg) => {
|
||||
dialogfotoOne.value = true
|
||||
galleryimges.value = idimg
|
||||
|
||||
|
||||
}
|
||||
const openOneImg = (idimg) => {
|
||||
dialogfotoOne.value = true;
|
||||
galleryimges.value = idimg;
|
||||
};
|
||||
|
||||
return {
|
||||
newsAll,
|
||||
countetnews,
|
||||
page,
|
||||
countpage,
|
||||
loadNewsAll,
|
||||
galleryimges,
|
||||
dialogfotoOne,
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
newsAll,
|
||||
countetnews,
|
||||
page,
|
||||
countpage,
|
||||
loadNewsAll,
|
||||
galleryimges,
|
||||
dialogfotoOne,
|
||||
};
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
<style></style>
|
||||
@@ -1,9 +1,26 @@
|
||||
<template>
|
||||
<v-app>
|
||||
<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-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="'/'"
|
||||
/>
|
||||
<template v-slot:append>
|
||||
<div class="fns-actions">
|
||||
<vcard-user :author="accountStore.user" />
|
||||
@@ -62,18 +79,19 @@
|
||||
permanent
|
||||
v-model="drawer"
|
||||
class="text-white px-2"
|
||||
style="background-color: #335455 !important;"
|
||||
style="background-color: #335455 !important"
|
||||
>
|
||||
|
||||
<v-row class="my-0 h-100">
|
||||
<v-col class="flex-column d-flex pa-2">
|
||||
<v-row>
|
||||
<v-col>
|
||||
<v-list nav density="compact" class="fns-nav-list">
|
||||
<template v-for="(x, key) in navigations" :key="key">
|
||||
|
||||
<v-list-item
|
||||
v-if="(x.path === '/portal' ? accountStore.user.is_superuser : true) && !('submenu' in x)"
|
||||
v-if="
|
||||
(x.path === '/portal' ? accountStore.user.is_superuser : true) &&
|
||||
!('submenu' in x)
|
||||
"
|
||||
:key="x.key"
|
||||
:title="x.name"
|
||||
:value="x.name"
|
||||
@@ -87,7 +105,9 @@
|
||||
>
|
||||
<template v-slot:prepend>
|
||||
<v-icon :icon="x.ico" size="17" />
|
||||
<v-tooltip v-if="rail" activator="parent" location="top">{{ x.name }}</v-tooltip>
|
||||
<v-tooltip v-if="rail" activator="parent" location="top">{{
|
||||
x.name
|
||||
}}</v-tooltip>
|
||||
</template>
|
||||
</v-list-item>
|
||||
|
||||
@@ -106,7 +126,9 @@
|
||||
class="fns-nav-item"
|
||||
rounded="lg"
|
||||
>
|
||||
<v-tooltip v-if="rail" activator="parent" location="top">{{ x.name }}</v-tooltip>
|
||||
<v-tooltip v-if="rail" activator="parent" location="top">{{
|
||||
x.name
|
||||
}}</v-tooltip>
|
||||
</v-list-item>
|
||||
</template>
|
||||
<v-list-item
|
||||
@@ -121,7 +143,9 @@
|
||||
class="fns-nav-item fns-nav-item--child"
|
||||
rounded="lg"
|
||||
>
|
||||
<v-tooltip v-if="rail" activator="parent" location="top">{{ child.name }}</v-tooltip>
|
||||
<v-tooltip v-if="rail" activator="parent" location="top">{{
|
||||
child.name
|
||||
}}</v-tooltip>
|
||||
</v-list-item>
|
||||
</v-list-group>
|
||||
</template>
|
||||
@@ -143,7 +167,9 @@
|
||||
>
|
||||
<template v-slot:prepend>
|
||||
<v-icon :icon="x.imagecode" size="17" />
|
||||
<v-tooltip v-if="rail" activator="parent" location="top">{{ x.name }}</v-tooltip>
|
||||
<v-tooltip v-if="rail" activator="parent" location="top">{{
|
||||
x.name
|
||||
}}</v-tooltip>
|
||||
</template>
|
||||
</v-list-item>
|
||||
</v-list>
|
||||
@@ -167,7 +193,7 @@
|
||||
</v-row>
|
||||
</v-navigation-drawer>
|
||||
|
||||
<v-main v-if="accountStore.cod2user" class="d-flex" style="background-color: #f4f9f9;">
|
||||
<v-main v-if="accountStore.cod2user" class="d-flex" style="background-color: #f4f9f9">
|
||||
<router-view />
|
||||
<alert-default />
|
||||
</v-main>
|
||||
@@ -187,7 +213,6 @@
|
||||
>
|
||||
<Online-users />
|
||||
</v-navigation-drawer>
|
||||
|
||||
</v-app>
|
||||
</template>
|
||||
|
||||
@@ -206,9 +231,10 @@ import PageCounter from '@/components/UI/defaultportal/page-counter.vue';
|
||||
import AdminMenu from '@/layouts/default/AdminMenu.vue';
|
||||
import { useDisplay } from 'vuetify';
|
||||
import LoginPage from '../../views/LoginPage.vue';
|
||||
import alertDefault from './alertDefault.vue';
|
||||
|
||||
export default {
|
||||
components: { LoginPage, AuthForm, OnlineUsers, CardLike, VcardUser, PageCounter, AdminMenu },
|
||||
components: { LoginPage, AuthForm, OnlineUsers, CardLike, VcardUser, PageCounter, AdminMenu, alertDefault },
|
||||
mixins: [uf],
|
||||
|
||||
setup() {
|
||||
@@ -286,8 +312,6 @@ export default {
|
||||
ico: 'mdi-information-variant',
|
||||
path: '/portal',
|
||||
},
|
||||
|
||||
|
||||
]);
|
||||
|
||||
const imageSrc = computed(() => {
|
||||
@@ -299,9 +323,25 @@ export default {
|
||||
};
|
||||
|
||||
return {
|
||||
theme, mainmenuStore, accountStore, drawer, drawer_right, toggleTheme,
|
||||
navigations, imageSrc, LikeDialog, scrimg, rail, showTooltip,
|
||||
menuTruncated, alert, burl, name, closeinfo, baseURL, message,
|
||||
theme,
|
||||
mainmenuStore,
|
||||
accountStore,
|
||||
drawer,
|
||||
drawer_right,
|
||||
toggleTheme,
|
||||
navigations,
|
||||
imageSrc,
|
||||
LikeDialog,
|
||||
scrimg,
|
||||
rail,
|
||||
showTooltip,
|
||||
menuTruncated,
|
||||
alert,
|
||||
burl,
|
||||
name,
|
||||
closeinfo,
|
||||
baseURL,
|
||||
message,
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -334,7 +374,7 @@ export default {
|
||||
transition: background var(--fns-transition);
|
||||
|
||||
&:hover {
|
||||
background: rgba(255, 255, 255, 0.10);
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -467,7 +507,7 @@ export default {
|
||||
padding: 3px 8px 3px 6px;
|
||||
font-size: 10px;
|
||||
font-weight: 600;
|
||||
color: rgba(255, 255, 255, 0.90);
|
||||
color: rgba(255, 255, 255, 0.9);
|
||||
letter-spacing: 0.04em;
|
||||
}
|
||||
|
||||
@@ -569,7 +609,6 @@ export default {
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
|
||||
/* Герб */
|
||||
.fns-login-emblem {
|
||||
width: 72px;
|
||||
@@ -614,7 +653,7 @@ export default {
|
||||
|
||||
.fns-login-footer {
|
||||
font-size: 10.5px;
|
||||
color: rgba(255, 255, 255, 0.40);
|
||||
color: rgba(255, 255, 255, 0.4);
|
||||
text-align: center;
|
||||
letter-spacing: 0.02em;
|
||||
margin: 4px 0 0;
|
||||
|
||||
@@ -1,52 +1,26 @@
|
||||
<template>
|
||||
<v-snackbar
|
||||
v-model="isOpen"
|
||||
:timeout="3000"
|
||||
v-model="feedalert.alert"
|
||||
:color="feedalert.color"
|
||||
:icon="feedalert.ico"
|
||||
|
||||
|
||||
:color="alert.color"
|
||||
>
|
||||
<v-icon :icon="feedalert.ico" />
|
||||
|
||||
<span class="pl-2 text-body-2">
|
||||
{{ feedalert.text }}
|
||||
</span>
|
||||
|
||||
<v-icon :icon="alert.ico" />
|
||||
<span class="pl-2 text-body-2">{{ alert.text }}</span>
|
||||
</v-snackbar>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { watch } from "vue";
|
||||
import { useAlertStore } from "@/store/UseAlertStore";
|
||||
<script setup>
|
||||
import { computed } from 'vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useAlertStore } from '@/store/UseAlertStore';
|
||||
|
||||
export default {
|
||||
name: "AlertDefault",
|
||||
setup() {
|
||||
const feedalert = useAlertStore().alert;
|
||||
const alertStore = useAlertStore();
|
||||
const { alert } = storeToRefs(alertStore);
|
||||
|
||||
watch(
|
||||
|
||||
() => feedalert,
|
||||
() => {
|
||||
setTimeout(function () {
|
||||
feedalert.text = "";
|
||||
feedalert.ico = "";
|
||||
|
||||
|
||||
feedalert.color = "";
|
||||
feedalert.alert = false;
|
||||
}, 8000);
|
||||
},
|
||||
{ deep: true }
|
||||
);
|
||||
|
||||
return {
|
||||
feedalert,
|
||||
};
|
||||
const isOpen = computed({
|
||||
get: () => alert.value.alert,
|
||||
set: (value) => {
|
||||
if (!value) alertStore.hide();
|
||||
},
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
<style></style>
|
||||
Executable → Regular
+15
-11
@@ -2,18 +2,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 { createVuetify } from 'vuetify';
|
||||
import { ru } from 'vuetify/locale';
|
||||
|
||||
export default createVuetify({
|
||||
|
||||
locale: {
|
||||
messages: { ru, },
|
||||
messages: { ru },
|
||||
},
|
||||
components: {
|
||||
// VCalendar,
|
||||
|
||||
},
|
||||
theme: {
|
||||
defaultTheme: 'light',
|
||||
@@ -23,7 +21,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 +41,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 +52,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 +77,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,14 +1,32 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { ref } from 'vue'
|
||||
import { defineStore } from 'pinia';
|
||||
import { ref } from 'vue';
|
||||
|
||||
export const useAlertStore = defineStore('uniAlert', () => {
|
||||
export const useAlertStore = defineStore('uniAlert', () => {
|
||||
const alert = ref({ alert: false, text: '', ico: 'mdi-plus', color: '#6366F1' });
|
||||
|
||||
const alert = ref({ "alert": false,
|
||||
"text": '',
|
||||
"ico": 'mdi-plus',
|
||||
"color": ''
|
||||
})
|
||||
|
||||
return { alert }
|
||||
const show = ({ text, ico = 'mdi-information-outline', color = '' }) => {
|
||||
alert.value = { alert: true, text, ico, color };
|
||||
};
|
||||
|
||||
})
|
||||
const showSuccess = (text) => {
|
||||
show({ text, ico: 'mdi-check-circle-outline', color: '#10B981' });
|
||||
};
|
||||
|
||||
const showError = (text = 'Произошла ошибка') => {
|
||||
show({ text, ico: 'mdi-alert-circle-outline', color: '#EF4444' });
|
||||
};
|
||||
|
||||
const showWarning = (text) => {
|
||||
show({ text, ico: 'mdi-alert-outline', color: '#F59E0B' });
|
||||
};
|
||||
|
||||
const showInfo = (text) => {
|
||||
show({ text, ico: 'mdi-information-outline', color: '#6366F1' });
|
||||
};
|
||||
|
||||
const hide = () => {
|
||||
alert.value.alert = false;
|
||||
};
|
||||
|
||||
return { alert, show, showSuccess, showError, showWarning, hide };
|
||||
});
|
||||
Executable → Regular
File mode changed.
@@ -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,24 @@ 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 selectedEventForView = ref(null);
|
||||
const showEventDialog = ref(false);
|
||||
const showViewDialog = ref(false);
|
||||
|
||||
const showCreateCalendarDialog = ref(false);
|
||||
const createCalendarInitial = ref(null);
|
||||
let createCalendarResolver = null;
|
||||
|
||||
// Массив ID скрытых календарей. Загружаем из localStorage при инициализации.
|
||||
const hiddenCalendarIds = ref([]);
|
||||
|
||||
@@ -43,7 +51,6 @@ export const useCalendarStore = defineStore('calendarStore', () => {
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
const subscribedCalendars = computed(() => {
|
||||
const userId = accountStore.user.is_idEmployee;
|
||||
|
||||
@@ -176,90 +183,187 @@ 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;
|
||||
showEventDialog.value = true;
|
||||
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?.event ? data : { event: 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 (id) {
|
||||
openEventView(id);
|
||||
}
|
||||
};
|
||||
|
||||
const editFromView = () => {
|
||||
if (!selectedEventForView.value) return;
|
||||
selectedEvent.value = selectedEventForView.value;
|
||||
showViewDialog.value = false;
|
||||
selectedEventForView.value = null;
|
||||
showEventDialog.value = true;
|
||||
};
|
||||
|
||||
const requestCreateCalendar = (initial = null) => {
|
||||
// Если уже открыт — резолвим предыдущий запрос как отменённый
|
||||
if (createCalendarResolver) {
|
||||
createCalendarResolver(null);
|
||||
createCalendarResolver = null;
|
||||
}
|
||||
|
||||
createCalendarInitial.value = initial;
|
||||
showCreateCalendarDialog.value = true;
|
||||
|
||||
return new Promise((resolve) => {
|
||||
createCalendarResolver = resolve;
|
||||
});
|
||||
};
|
||||
|
||||
const resolveCreateCalendar = (createdCalendar = null) => {
|
||||
if (createCalendarResolver) {
|
||||
createCalendarResolver(createdCalendar);
|
||||
createCalendarResolver = null;
|
||||
}
|
||||
showCreateCalendarDialog.value = false;
|
||||
createCalendarInitial.value = null;
|
||||
};
|
||||
|
||||
return {
|
||||
// State
|
||||
selectedDate,
|
||||
events,
|
||||
selectedEvent,
|
||||
selectedEventForView,
|
||||
showEventDialog,
|
||||
showViewDialog,
|
||||
currentView,
|
||||
calendars,
|
||||
lastUpdatedBy,
|
||||
hiddenCalendarIds,
|
||||
holidays,
|
||||
dictEmployeesLoaded,
|
||||
showCreateCalendarDialog,
|
||||
createCalendarInitial,
|
||||
|
||||
// Getters
|
||||
formattedSelectedDate,
|
||||
@@ -281,6 +385,9 @@ export const useCalendarStore = defineStore('calendarStore', () => {
|
||||
loadCalendars,
|
||||
openEventDialog,
|
||||
closeEventDialog,
|
||||
openEventView,
|
||||
closeEventView,
|
||||
handleEventClick,
|
||||
setSelectedDateFromCalendar,
|
||||
setSelectedDateFromPicker,
|
||||
toggleCalendarVisibility,
|
||||
@@ -288,5 +395,9 @@ export const useCalendarStore = defineStore('calendarStore', () => {
|
||||
isNonWorkingDay,
|
||||
loadDictEmployees,
|
||||
loadEmployees,
|
||||
setSelectedEvent,
|
||||
editFromView,
|
||||
requestCreateCalendar,
|
||||
resolveCreateCalendar,
|
||||
};
|
||||
});
|
||||
Executable → Regular
+3
-3
@@ -24,7 +24,7 @@
|
||||
class="flex-grow-1 ma-0"
|
||||
style="min-height: 0; margin: 0;"
|
||||
>
|
||||
<v-col cols="12" md="8" lg="6" class="d-flex flex-column pa-1" style="min-height: 0;">
|
||||
<v-col cols="12" md="8" lg="6" class="d-flex flex-column" style="min-height: 0;">
|
||||
<div class="modern-card flex-grow-1 d-flex flex-column" style="overflow: hidden;">
|
||||
<news-home />
|
||||
</div>
|
||||
@@ -32,10 +32,10 @@
|
||||
|
||||
<v-col
|
||||
cols="12" md="4" lg="6"
|
||||
class="d-flex flex-column pa-0"
|
||||
class="d-flex flex-column"
|
||||
style="min-height: 0; margin: 0;"
|
||||
>
|
||||
<div class="flex-grow-1" style="overflow: hidden;">
|
||||
<div class="flex-grow-1 d-flex flex-column" style="overflow: hidden;">
|
||||
<HomeCalendarWidget />
|
||||
</div>
|
||||
</v-col>
|
||||
|
||||
Reference in new issue
Block a user