Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0eade588e4 | ||
|
|
d9defd0528 | ||
|
|
45768f1921 | ||
|
|
5418359a3d | ||
|
|
bc2a40f6af | ||
|
|
5fb02ace96 | ||
|
|
92a9cb59dc | ||
|
|
e4674be071 | ||
|
|
ceb398c070 | ||
|
|
6cb204b3ac | ||
|
|
0a9f1cd510 | ||
|
|
f62e6f175f | ||
|
|
ee66b1c8d6 | ||
|
|
472d67d50c | ||
|
|
751538189d | ||
|
|
cd570a6c4b | ||
|
|
d5f62e67df | ||
|
|
7176420082 | ||
|
|
11ba78edb2 | ||
|
|
403d611660 | ||
|
|
3ae3295d12 | ||
|
|
58c515ec71 | ||
|
|
a64c716e5f | ||
|
|
4359b023e2 | ||
|
|
0cfc8f1dea | ||
|
|
8355e62d4e | ||
|
|
8595b3e75b | ||
|
|
27b5a7c953 | ||
|
|
587cc6a307 | ||
|
|
98dc1d51e9 | ||
|
|
de5b01e2aa | ||
|
|
13f135f98a |
No files matched your search
@@ -10,10 +10,7 @@ WORKDIR /app
|
|||||||
|
|
||||||
COPY ${SOURCE_DIR}/* ./
|
COPY ${SOURCE_DIR}/* ./
|
||||||
|
|
||||||
RUN npm config set fetch-retries 5 \
|
RUN npm cache clean --force && npm install
|
||||||
&& npm config set fetch-retry-mintimeout 20000 \
|
|
||||||
&& npm config set fetch-retry-maxtimeout 120000 \
|
|
||||||
&& npm install --prefer-offline --no-audit --no-fund
|
|
||||||
|
|
||||||
# Копируем остальные файлы приложения
|
# Копируем остальные файлы приложения
|
||||||
# COPY ${SOURCE_DIR} ./
|
# COPY ${SOURCE_DIR} ./
|
||||||
|
|||||||
@@ -1,4 +1,23 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<v-dialog
|
||||||
|
v-model="menuAuthDialog"
|
||||||
|
persistent
|
||||||
|
width="400"
|
||||||
|
scrim="teal-darken-9"
|
||||||
|
>
|
||||||
|
<template v-slot:activator="{ props }">
|
||||||
|
<v-btn
|
||||||
|
v-bind="props"
|
||||||
|
append-icon="mdi-login"
|
||||||
|
color="black_and_white"
|
||||||
|
>
|
||||||
|
Войти
|
||||||
|
<template v-slot:append>
|
||||||
|
<v-icon color="teal-darken-4"/>
|
||||||
|
</template>
|
||||||
|
</v-btn>
|
||||||
|
</template>
|
||||||
|
|
||||||
<v-card @keyup.enter="logging" class="text-white" style="background-color: rgb(25 42 43);">
|
<v-card @keyup.enter="logging" class="text-white" style="background-color: rgb(25 42 43);">
|
||||||
<v-card-text>
|
<v-card-text>
|
||||||
<v-container>
|
<v-container>
|
||||||
@@ -30,7 +49,7 @@
|
|||||||
</v-row>
|
</v-row>
|
||||||
</v-container>
|
</v-container>
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
<v-card-actions class="justify-end">
|
<v-card-actions class="text-center">
|
||||||
<v-btn
|
<v-btn
|
||||||
color="white"
|
color="white"
|
||||||
variant="text"
|
variant="text"
|
||||||
@@ -55,6 +74,9 @@
|
|||||||
<v-icon icon="mdi-alert-outline" class="pt-1"/>
|
<v-icon icon="mdi-alert-outline" class="pt-1"/>
|
||||||
</template>
|
</template>
|
||||||
</v-alert>
|
</v-alert>
|
||||||
|
</v-dialog>
|
||||||
|
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|||||||
@@ -22,13 +22,25 @@
|
|||||||
/>
|
/>
|
||||||
</v-col>
|
</v-col>
|
||||||
<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-col>
|
||||||
</v-row>
|
</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-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-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
</v-form>
|
</v-form>
|
||||||
@@ -36,60 +48,77 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script>
|
||||||
import { ref } from 'vue';
|
import { ref } from "vue";
|
||||||
import { useAlertStore } from '@/store/UseAlertStore';
|
import { useAlertStore } from "@/store/UseAlertStore";
|
||||||
import { clearAxios } from '@/utils/axios-api';
|
import { clearAxios } from "@/utils/axios-api";
|
||||||
|
|
||||||
const props = defineProps({
|
export default {
|
||||||
|
props: {
|
||||||
idVacations: {
|
idVacations: {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: -1,
|
default: -1,
|
||||||
},
|
},
|
||||||
});
|
},
|
||||||
|
setup(props) {
|
||||||
|
const form = ref({ fio: "", email: "", tel: "", text: "" });
|
||||||
|
const feedalert = useAlertStore().alert;
|
||||||
|
|
||||||
const alertStore = useAlertStore();
|
const req = (val) => {
|
||||||
|
return !!val || "Поле обязательно";
|
||||||
const form = ref({ fio: '', email: '', tel: '', text: '' });
|
};
|
||||||
const file = ref(null);
|
|
||||||
const form_vacancies = ref(null);
|
|
||||||
|
|
||||||
const rules = {
|
const rules = {
|
||||||
fio: [
|
fio: [
|
||||||
(val) => !!val || 'Поле обязательно',
|
(val) => req(val),
|
||||||
(val) => /^[а-яА-ЯЁё ]+$/.test(val) || 'Имя должно содержать русские буквы',
|
(val) =>
|
||||||
|
val.match(/^[а-яА-ЯЁё ]+$/) !== null || "Имя должно содержать русские буквы",
|
||||||
],
|
],
|
||||||
email: [(val) => !!val || 'Поле обязательно'],
|
email: [(val) => req(val)],
|
||||||
tel: [
|
tel: [
|
||||||
(val) => !!val || 'Поле обязательно',
|
(val) => req(val),
|
||||||
(val) => /^[\d-]+$/.test(val) || 'Номер должен содержать только цифры и дефисы',
|
(val) => val.match(/^[[\d-]*\d[\d-]*$/) !== null || "Номер должен содержать цифры",
|
||||||
],
|
],
|
||||||
|
text: "",
|
||||||
};
|
};
|
||||||
|
|
||||||
const submit = async () => {
|
const file = ref(null);
|
||||||
const { valid } = await form_vacancies.value.validate();
|
const form_vacancies = ref(null)
|
||||||
if (!valid) return;
|
|
||||||
|
const submit = () => {
|
||||||
|
|
||||||
|
if(form_vacancies.value.isValid) {
|
||||||
|
|
||||||
|
|
||||||
const postFile = new FormData();
|
const postFile = new FormData();
|
||||||
postFile.append('data', JSON.stringify({ ...form.value, vacancy_id: props.idVacations }));
|
postFile.append(
|
||||||
|
"data",
|
||||||
|
JSON.stringify({ ...form.value, vacancy_id: props.idVacations })
|
||||||
|
);
|
||||||
|
if (file.value !== null) {
|
||||||
|
|
||||||
if (file.value) {
|
postFile.append("file", file.value[0]);
|
||||||
const fileToAppend = Array.isArray(file.value) ? file.value[0] : file.value;
|
|
||||||
postFile.append('file', fileToAppend);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
form.value = { fio: '', email: '', tel: '', text: '' };
|
clearAxios
|
||||||
file.value = null;
|
.post(`api/about_inspection/postresponsevacancy/`, postFile)
|
||||||
form_vacancies.value.resetValidation();
|
.then((data) => {
|
||||||
} catch (e) {
|
feedalert.alert = true;
|
||||||
alertStore.showError('Не удалось отправить отклик');
|
feedalert.text = data.data;
|
||||||
console.error(e);
|
feedalert.color = "teal-lighten-4";
|
||||||
|
feedalert.ico = "mdi-email-outline";
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
form,
|
||||||
|
file,
|
||||||
|
rules,
|
||||||
|
submit,
|
||||||
|
form_vacancies
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
Executable → Regular
-5
@@ -15,7 +15,6 @@ import CustomCalendar from '@/components/calendar_of_events/UI_calendar/CustomCa
|
|||||||
import MiniCalendar from '@/components/calendar_of_events/UI_calendar/MiniCalendar.vue';
|
import MiniCalendar from '@/components/calendar_of_events/UI_calendar/MiniCalendar.vue';
|
||||||
import { useCalendarStore } from '@/store/calendarStore';
|
import { useCalendarStore } from '@/store/calendarStore';
|
||||||
import { useAccountStore } from '@/store/AccountStore';
|
import { useAccountStore } from '@/store/AccountStore';
|
||||||
import { useRoute } from 'vue-router';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: { MiniCalendar, CustomCalendar },
|
components: { MiniCalendar, CustomCalendar },
|
||||||
@@ -23,7 +22,6 @@ export default {
|
|||||||
const calendarStore = useCalendarStore();
|
const calendarStore = useCalendarStore();
|
||||||
const accountStore = useAccountStore();
|
const accountStore = useAccountStore();
|
||||||
const calendarKey = ref(0);
|
const calendarKey = ref(0);
|
||||||
const route = useRoute();
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
const currentYear = new Date().getFullYear();
|
const currentYear = new Date().getFullYear();
|
||||||
@@ -31,9 +29,6 @@ export default {
|
|||||||
calendarStore.loadCalendars();
|
calendarStore.loadCalendars();
|
||||||
calendarStore.loadDictEmployees();
|
calendarStore.loadDictEmployees();
|
||||||
calendarStore.loadEmployees();
|
calendarStore.loadEmployees();
|
||||||
if (route.query.date) {
|
|
||||||
calendarStore.setSelectedDate(route.query.date);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
|
|||||||
@@ -4,7 +4,8 @@
|
|||||||
:newOrOld="isNewEvent"
|
:newOrOld="isNewEvent"
|
||||||
@postData="postData"
|
@postData="postData"
|
||||||
@closeDialog="$emit('closeDialog')"
|
@closeDialog="$emit('closeDialog')"
|
||||||
@delObject="delEvent(form.id)"
|
@delObject="delEvent(propsEvent?.event?.id)"
|
||||||
|
ref="createDialog"
|
||||||
>
|
>
|
||||||
<template v-slot:card_text>
|
<template v-slot:card_text>
|
||||||
<v-row no-gutters class="flex-column">
|
<v-row no-gutters class="flex-column">
|
||||||
@@ -19,19 +20,18 @@
|
|||||||
row-height="25"
|
row-height="25"
|
||||||
rows="1"
|
rows="1"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
v-model="form.name"
|
v-model="propsEvent.event.name"
|
||||||
:rules="rules.name"
|
:rules="rules.name"
|
||||||
></v-textarea> </v-col
|
></v-textarea> </v-col
|
||||||
></v-row>
|
></v-row>
|
||||||
|
|
||||||
<v-row no-gutters class="align-center">
|
<v-row no-gutters class="align-center">
|
||||||
<v-col class="text-body-2 text-text_grey pb-3" lg="2"> Участники </v-col>
|
<v-col class="text-body-2 text-text_grey pb-5" lg="2"> Участники </v-col>
|
||||||
<v-col>
|
<v-col>
|
||||||
<calendar-create-select
|
<calendar-create-select
|
||||||
:staff="newStaff"
|
:staff="newStaff"
|
||||||
:selectedIds="selectedIds"
|
@returnIdParticant="returnIdParticant"
|
||||||
:authorID="currentCalendarAuthorId"
|
:authorID="currentCalendarAuthorId"
|
||||||
@change="onParticipantsChange"
|
|
||||||
/> </v-col
|
/> </v-col
|
||||||
></v-row>
|
></v-row>
|
||||||
|
|
||||||
@@ -50,7 +50,7 @@
|
|||||||
class="py-3 my-select"
|
class="py-3 my-select"
|
||||||
return-object
|
return-object
|
||||||
:rules="rules.calendar"
|
:rules="rules.calendar"
|
||||||
:disabled="'id' in form"
|
:disabled="'id' in propsEvent.event"
|
||||||
auto-select-first
|
auto-select-first
|
||||||
>
|
>
|
||||||
<template v-slot:selection="{ item }">
|
<template v-slot:selection="{ item }">
|
||||||
@@ -65,37 +65,28 @@
|
|||||||
:value="item"
|
:value="item"
|
||||||
color="primary"
|
color="primary"
|
||||||
v-bind="props"
|
v-bind="props"
|
||||||
|
@click.stop="handleCalendarSelect(item.raw)"
|
||||||
:data-calendar-id="item.raw.id"
|
:data-calendar-id="item.raw.id"
|
||||||
>
|
>
|
||||||
<template v-slot:prepend>
|
<template v-slot:prepend>
|
||||||
<v-avatar class="cursor-pointer" size="8" :color="item.raw.cl_color" />
|
<v-avatar class="cursor-pointer" size="8" :color="item.raw.cl_color" />
|
||||||
</template>
|
</template>
|
||||||
|
<!-- {{ item.title }} -->
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
</template>
|
</template>
|
||||||
|
</v-autocomplete>
|
||||||
<template v-slot:append-item>
|
</v-col></v-row
|
||||||
<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-row no-gutters class="align-top">
|
||||||
<v-col class="text-body-2 text-text_grey pt-3" lg="2"> Дата и время </v-col>
|
<v-col class="text-body-2 text-text_grey pt-3" lg="2"> Дата и время </v-col>
|
||||||
<v-col class="d-flex flex-column">
|
<v-col class="d-flex flex-column">
|
||||||
<v-row no-gutters class="gap">
|
<v-row no-gutters class="gap">
|
||||||
<time-select
|
<time-select
|
||||||
:rule="selectedRule.rule ? selectedRule.rule.freq : -1"
|
:rule="selectedRule.rule ? selectedRule.rule.freq : -1"
|
||||||
:isAllDay="form.allday"
|
:isAllDay="propsEvent.event.allday"
|
||||||
:order="[2, 1]"
|
:order="[2, 1]"
|
||||||
:dateEvent="String(form.date_start)"
|
:dateEvent="String(propsEvent.event.date_start)"
|
||||||
:limitation="String(form.date_end)"
|
:limitation="String(propsEvent.event.date_end)"
|
||||||
@update:dateEvent="updateDateStart"
|
@update:dateEvent="updateDateStart"
|
||||||
@adjustEndDate="handleAutoAdjustEnd"
|
@adjustEndDate="handleAutoAdjustEnd"
|
||||||
/>
|
/>
|
||||||
@@ -104,18 +95,18 @@
|
|||||||
</v-col>
|
</v-col>
|
||||||
<time-select
|
<time-select
|
||||||
:rule="selectedRule.rule ? selectedRule.rule.freq : -1"
|
:rule="selectedRule.rule ? selectedRule.rule.freq : -1"
|
||||||
:isAllDay="form.allday"
|
:isAllDay="propsEvent.event.allday"
|
||||||
:order="[4, 5]"
|
:order="[4, 5]"
|
||||||
:dateEvent="String(form.date_end)"
|
:dateEvent="String(propsEvent.event.date_end)"
|
||||||
:limitation="String(form.date_start)"
|
:limitation="String(propsEvent.event.date_start)"
|
||||||
@update:dateEvent="updateDateEnd"
|
@update:dateEvent="updateDateEnd"
|
||||||
@adjustEndDate="handleAutoAdjustEnd"
|
@adjustEndDate="handleAutoAdjustEnd"
|
||||||
/>
|
/>
|
||||||
</v-row>
|
</v-row>
|
||||||
<v-row no-gutters>
|
<v-row no-gutters>
|
||||||
<period-events
|
<period-events
|
||||||
:dateEvent="form"
|
:dateEvent="propsEvent.event"
|
||||||
@update:dateEvent="form = $event"
|
@update:dateEvent="propsEvent.event = $event"
|
||||||
/>
|
/>
|
||||||
</v-row>
|
</v-row>
|
||||||
</v-col>
|
</v-col>
|
||||||
@@ -155,7 +146,7 @@
|
|||||||
:dateEvent="repeatEndDate ? String(repeatEndDate) : String(new Date())"
|
:dateEvent="repeatEndDate ? String(repeatEndDate) : String(new Date())"
|
||||||
@update:dateEvent="updateRepeatEndDate"
|
@update:dateEvent="updateRepeatEndDate"
|
||||||
class="wide-time-select"
|
class="wide-time-select"
|
||||||
:limitation="String(form.date_start)"
|
:limitation="String(propsEvent.event.date_start)"
|
||||||
:isEndDateEnabled="!showRepeatEnd"
|
:isEndDateEnabled="!showRepeatEnd"
|
||||||
/>
|
/>
|
||||||
</v-col>
|
</v-col>
|
||||||
@@ -171,7 +162,7 @@
|
|||||||
|
|
||||||
<uploading-file
|
<uploading-file
|
||||||
v-model:new-files="newFiles"
|
v-model:new-files="newFiles"
|
||||||
:files="form.files"
|
:files="propsEvent.event.files"
|
||||||
@update:files="handleFilesUpdate"
|
@update:files="handleFilesUpdate"
|
||||||
@postFiles="postFiles"
|
@postFiles="postFiles"
|
||||||
/>
|
/>
|
||||||
@@ -184,7 +175,7 @@
|
|||||||
rows="3"
|
rows="3"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
auto-grow
|
auto-grow
|
||||||
v-model="form.description"
|
v-model="propsEvent.event.description"
|
||||||
class="scrollable-textarea pt-3"
|
class="scrollable-textarea pt-3"
|
||||||
></v-textarea> </v-col
|
></v-textarea> </v-col
|
||||||
></v-row>
|
></v-row>
|
||||||
@@ -194,13 +185,14 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, nextTick, ref, toRaw, watch } from 'vue';
|
import { computed, nextTick, onMounted, ref, watch } from 'vue';
|
||||||
import { axiosApiInstance } from '@/utils/axios-api';
|
import { axiosApiInstance } from '@/utils/axios-api';
|
||||||
import { useAccountStore } from '@/store/AccountStore';
|
import { useAccountStore } from '@/store/AccountStore';
|
||||||
import DialogCreate from '@/components/calendar_of_events/UI_calendar/dialogCreate.vue';
|
import DialogCreate from '@/components/calendar_of_events/UI_calendar/dialogCreate.vue';
|
||||||
import calendarCreateSelect from '@/components/calendar_of_events/calendar-create-select.vue';
|
import calendarCreateSelect from '@/components/calendar_of_events/calendar-create-select.vue';
|
||||||
import TimeSelect from '@/components/calendar_of_events/UI_calendar/timeSelect.vue';
|
import TimeSelect from '@/components/calendar_of_events/UI_calendar/timeSelect.vue';
|
||||||
import UploadingFile from '@/components/UI/defaultportal/uploading-file.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 PeriodEvents from '@/components/calendar_of_events/UI_calendar/periodEvents.vue';
|
||||||
import { useAlertStore } from '@/store/UseAlertStore';
|
import { useAlertStore } from '@/store/UseAlertStore';
|
||||||
import { RRule } from 'rrule';
|
import { RRule } from 'rrule';
|
||||||
@@ -210,62 +202,107 @@ import { useCalendarStore } from '../../store/calendarStore';
|
|||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
eventCalendar: Object,
|
eventCalendar: Object,
|
||||||
allCalendars: Array,
|
allCalendars: Array,
|
||||||
|
selectedRule: Object,
|
||||||
});
|
});
|
||||||
|
|
||||||
const emit = defineEmits(['getCalendar', 'closeDialog']);
|
const emit = defineEmits(['update:eventCalendar', 'getCalendar', 'closeDialog']);
|
||||||
|
|
||||||
const accountStore = useAccountStore();
|
const accountStore = useAccountStore();
|
||||||
const calendarStore = useCalendarStore();
|
const calendarStore = useCalendarStore();
|
||||||
const alertStore = useAlertStore();
|
const createDialog = ref(null);
|
||||||
|
|
||||||
const { parseRecurrenceOptions, isRecurringEvent } = useRecurrence();
|
const { parseRecurrenceOptions, isRecurringEvent } = useRecurrence();
|
||||||
const { requestCreateCalendar } = calendarStore;
|
|
||||||
|
|
||||||
const form = ref({});
|
const propsEvent = computed({
|
||||||
const mycalendars = computed(() => props.eventCalendar?.mycalendars ?? []);
|
get: () => {
|
||||||
|
return props.eventCalendar;
|
||||||
|
},
|
||||||
|
|
||||||
const selectedIds = ref(new Set());
|
set: (value) => emit('update:eventCalendar', value),
|
||||||
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(() => {
|
const currentCalendarAuthorId = computed(() => {
|
||||||
if (isNewEvent.value) {
|
if (isNewEvent.value) {
|
||||||
|
// Для нового события - автор текущего выбранного календаря
|
||||||
return myCalendar.value?.author;
|
return myCalendar.value?.author;
|
||||||
}
|
} else {
|
||||||
const currentCalendar = mycalendars.value.find(
|
// Для существующего события - автор календаря события
|
||||||
(cal) => Number(cal.id) === Number(form.value.calendar),
|
const eventCalendarId = propsEvent.value.event.calendar;
|
||||||
|
const currentCalendar = propsEvent.value.mycalendars?.find(
|
||||||
|
(cal) => parseInt(cal.id) === parseInt(eventCalendarId),
|
||||||
);
|
);
|
||||||
return currentCalendar?.author;
|
return currentCalendar?.author;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const newStaff = computed(() => {
|
const newStaff = computed({
|
||||||
const calendarSource = isNewEvent.value
|
get() {
|
||||||
? myCalendar.value
|
let filteredStaff = [];
|
||||||
: mycalendars.value.find((cal) => Number(cal.id) === Number(form.value.calendar));
|
|
||||||
|
|
||||||
if (!calendarSource) return [];
|
if (isNewEvent.value) {
|
||||||
|
if (myCalendar.value == null) return [];
|
||||||
|
const participants = myCalendar.value.participant || [];
|
||||||
|
const calendarParticipantIds = new Set(participants.map((p) => p.participant_calendar));
|
||||||
|
|
||||||
const allowedIds = new Set(
|
// Мутируем И фильтруем для НОВОГО события
|
||||||
(calendarSource.participant ?? []).map((p) =>
|
filteredStaff = calendarStore.employees
|
||||||
isNewEvent.value ? p.participant_calendar : p.id,
|
.map((department) => {
|
||||||
),
|
// ФИЛЬТРУЕМ сотрудников - оставляем только тех, кто в календаре
|
||||||
|
const filteredEmployees = department.employees.filter((employee) =>
|
||||||
|
calendarParticipantIds.has(employee.id),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!allowedIds.size) return [];
|
// МУТАЦИЯ: устанавливаем selected=true для отфильтрованных сотрудников
|
||||||
return calendarStore.employees
|
filteredEmployees.forEach((employee) => {
|
||||||
.map((dept) => ({
|
employee.selected = true;
|
||||||
...dept,
|
|
||||||
employees: dept.employees.filter((e) => allowedIds.has(e.id)),
|
|
||||||
}))
|
|
||||||
.filter((dept) => dept.employees.length > 0);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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 = {
|
const rules = {
|
||||||
name: [
|
name: [
|
||||||
(val) => !!val || 'Поле обязательно для заполнения',
|
(val) => !!val || 'Поле обязательно для заполнения',
|
||||||
@@ -277,20 +314,28 @@ const rules = {
|
|||||||
|
|
||||||
const repeatRules = [
|
const repeatRules = [
|
||||||
{ type: 'Не повторять', rule: null, id: 1 },
|
{ type: 'Не повторять', rule: null, id: 1 },
|
||||||
{ type: 'Каждый день', rule: { freq: RRule.DAILY }, id: 2 },
|
{
|
||||||
|
type: 'Каждый день',
|
||||||
|
rule: { freq: RRule.DAILY },
|
||||||
|
id: 2,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
type: 'Каждую неделю',
|
type: 'Каждую неделю',
|
||||||
rule: { freq: RRule.WEEKLY },
|
rule: { freq: RRule.WEEKLY },
|
||||||
|
// По умолчанию - в тот же день недели, что и начальная дата
|
||||||
getRule: (startDate) => {
|
getRule: (startDate) => {
|
||||||
const day = new Date(startDate).getDay();
|
const day = new Date(startDate).getDay();
|
||||||
|
// Преобразуем день недели в формат RRule (0 — понедельник)
|
||||||
const byweekday = [day === 0 ? RRule.SU : day - 1];
|
const byweekday = [day === 0 ? RRule.SU : day - 1];
|
||||||
return { freq: RRule.WEEKLY, byweekday };
|
return { freq: RRule.WEEKLY, byweekday };
|
||||||
},
|
},
|
||||||
id: 3,
|
id: 3,
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
type: 'Каждый месяц',
|
type: 'Каждый месяц',
|
||||||
rule: { freq: RRule.MONTHLY },
|
rule: { freq: RRule.MONTHLY },
|
||||||
|
// По умолчанию - в тот же день месяца
|
||||||
getRule: (startDate) => ({
|
getRule: (startDate) => ({
|
||||||
freq: RRule.MONTHLY,
|
freq: RRule.MONTHLY,
|
||||||
bymonthday: [new Date(startDate).getDate()],
|
bymonthday: [new Date(startDate).getDate()],
|
||||||
@@ -300,16 +345,21 @@ const repeatRules = [
|
|||||||
{
|
{
|
||||||
type: 'Каждый квартал',
|
type: 'Каждый квартал',
|
||||||
rule: { freq: RRule.MONTHLY, interval: 3 },
|
rule: { freq: RRule.MONTHLY, interval: 3 },
|
||||||
getRule: (startDate) => ({
|
getRule: (startDate) => {
|
||||||
|
const date = new Date(startDate);
|
||||||
|
return {
|
||||||
freq: RRule.MONTHLY,
|
freq: RRule.MONTHLY,
|
||||||
interval: 3,
|
interval: 3, // каждые 3 месяца
|
||||||
bymonthday: [new Date(startDate).getDate()],
|
bymonthday: [date.getDate()],
|
||||||
}),
|
};
|
||||||
|
},
|
||||||
id: 6,
|
id: 6,
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
type: 'Каждый год',
|
type: 'Каждый год',
|
||||||
rule: { freq: RRule.YEARLY },
|
rule: { freq: RRule.YEARLY },
|
||||||
|
// По умолчанию - в тот же день и месяц
|
||||||
getRule: (startDate) => {
|
getRule: (startDate) => {
|
||||||
const date = new Date(startDate);
|
const date = new Date(startDate);
|
||||||
return {
|
return {
|
||||||
@@ -322,89 +372,186 @@ const repeatRules = [
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
selectedRule.value = repeatRules[0];
|
const selectedRule = ref(repeatRules[0]);
|
||||||
|
const showRepeatEnd = ref(false);
|
||||||
|
const repeatEndDate = ref(new Date());
|
||||||
|
|
||||||
const isRepeatEndDisabled = computed(() => !selectedRule.value.rule);
|
// Инициализация повторов при редактировании
|
||||||
|
const initializeRule = () => {
|
||||||
|
if (!propsEvent.value.event.period) {
|
||||||
|
selectedRule.value = repeatRules[0]; // "Не повторять"
|
||||||
|
repeatEndDate.value = propsEvent.value.event.date_end
|
||||||
|
? new Date(propsEvent.value.event.date_end)
|
||||||
|
: new Date();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
// Используем isRecurringEvent для проверки
|
||||||
|
if (isRecurringEvent(propsEvent.value.event)) {
|
||||||
|
// Парсим period с использованием parseRecurrenceOptions
|
||||||
|
const rruleOptions = parseRecurrenceOptions(
|
||||||
|
propsEvent.value.event.period,
|
||||||
|
propsEvent.value.event.date_start,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (rruleOptions) {
|
||||||
|
// ОБНОВЛЕННЫЙ ПОИСК ПРАВИЛА С ПОДДЕРЖКОЙ КВАРТАЛОВ
|
||||||
|
let foundRule;
|
||||||
|
|
||||||
|
// Для квартальных событий (MONTHLY с interval=3)
|
||||||
|
if (rruleOptions.freq === RRule.MONTHLY && rruleOptions.interval === 3) {
|
||||||
|
foundRule = repeatRules.find((rule) => rule.id === 6); // ID квартального правила
|
||||||
|
} else {
|
||||||
|
// Для остальных типов - ищем по freq
|
||||||
|
foundRule = repeatRules.find((rule) => rule.rule?.freq === rruleOptions.freq);
|
||||||
|
}
|
||||||
|
|
||||||
|
selectedRule.value = foundRule || repeatRules[0];
|
||||||
|
|
||||||
|
// ВАЖНО: инициализируем repeatEndDate и showRepeatEnd
|
||||||
|
if (rruleOptions.until) {
|
||||||
|
// Если в RRULE есть UNTIL, используем эту дату
|
||||||
|
repeatEndDate.value = new Date(rruleOptions.until);
|
||||||
|
showRepeatEnd.value = true;
|
||||||
|
} else {
|
||||||
|
// Если нет UNTIL, используем date_end события
|
||||||
|
repeatEndDate.value = propsEvent.value.event.date_end
|
||||||
|
? new Date(propsEvent.value.event.date_end)
|
||||||
|
: new Date();
|
||||||
|
showRepeatEnd.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
selectedRule.value = repeatRules[0];
|
||||||
|
showRepeatEnd.value = false;
|
||||||
|
repeatEndDate.value = propsEvent.value.event.date_end
|
||||||
|
? new Date(propsEvent.value.event.date_end)
|
||||||
|
: new Date();
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error parsing period:', error, 'Raw period:', propsEvent.value.event.period);
|
||||||
|
selectedRule.value = repeatRules[0];
|
||||||
|
showRepeatEnd.value = false;
|
||||||
|
repeatEndDate.value = propsEvent.value.event.date_end
|
||||||
|
? new Date(propsEvent.value.event.date_end)
|
||||||
|
: new Date();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const isRepeatEndDisabled = computed(() => {
|
||||||
|
return !selectedRule.value.rule; // disabled если правило null (не повторять)
|
||||||
|
});
|
||||||
|
|
||||||
|
const feedalert = useAlertStore().alert;
|
||||||
|
|
||||||
|
const titleCard = computed(() => {
|
||||||
|
if (propsEvent.value.event.hasOwnProperty('id')) {
|
||||||
|
return 'Редактирование события';
|
||||||
|
} else {
|
||||||
|
return 'Новое событие';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const isNewEvent = computed(() => !propsEvent.value.event.hasOwnProperty('id'));
|
||||||
|
|
||||||
|
const myCalendar = ref(null);
|
||||||
|
|
||||||
const safeCalendars = computed(() => {
|
const safeCalendars = computed(() => {
|
||||||
const userId = accountStore.user.is_idEmployee;
|
const userId = accountStore.user.is_idEmployee;
|
||||||
return (props.allCalendars || []).filter((calendar) => {
|
|
||||||
|
// return (props.allCalendars || []).filter((calendar) => {
|
||||||
|
// // Пользователь - автор календаря (полные права)
|
||||||
|
// if (calendar.author === userId) {
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // Пользователь - участник с правами редактора
|
||||||
|
// const participant = calendar.participant?.find((p) => p.participant_calendar === userId);
|
||||||
|
|
||||||
|
// return participant?.editor === true;
|
||||||
|
// });
|
||||||
|
|
||||||
|
let filtered = (props.allCalendars || []).filter((calendar) => {
|
||||||
if (calendar.author === userId) return true;
|
if (calendar.author === userId) return true;
|
||||||
const participant = calendar.participant?.find((p) => p.participant_calendar === userId);
|
const participant = calendar.participant?.find((p) => p.participant_calendar === userId);
|
||||||
return participant?.editor === true;
|
return participant?.editor === true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Добавляем пункт "Создать календарь"
|
||||||
|
filtered.push({
|
||||||
|
id: 'create_new',
|
||||||
|
cl_name: '➕ Создать календарь',
|
||||||
|
isFake: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
const initializeRule = () => {
|
return filtered;
|
||||||
if (!form.value.period) {
|
});
|
||||||
selectedRule.value = repeatRules[0];
|
|
||||||
repeatEndDate.value = form.value.date_end ? new Date(form.value.date_end) : new Date();
|
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;
|
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];
|
// Приоритет 2: первый доступный календарь (создание)
|
||||||
|
if (safeCalendars.value.length > 0) {
|
||||||
if (rruleOptions.until) {
|
// myCalendar.value = safeCalendars.value[0];
|
||||||
repeatEndDate.value = new Date(rruleOptions.until);
|
const firstRealCalendar = safeCalendars.value.find((cal) => cal.id !== 'create_new');
|
||||||
showRepeatEnd.value = true;
|
if (firstRealCalendar) {
|
||||||
} else {
|
myCalendar.value = firstRealCalendar;
|
||||||
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;
|
watch(
|
||||||
|
[() => safeCalendars.value.length, () => propsEvent.value],
|
||||||
|
(newCalendar) => {
|
||||||
|
initializeCalendar();
|
||||||
|
},
|
||||||
|
{ immediate: true, deep: true },
|
||||||
|
);
|
||||||
|
|
||||||
const fromEvent = form.value?.calendar
|
// Дополнительная защита - вотчер только на смену самого календаря
|
||||||
? safeCalendars.value.find((cal) => cal.id === form.value.calendar)
|
watch(eventCalendar, (newCalendar) => {
|
||||||
: null;
|
if (newCalendar && newCalendar.id !== myCalendar.value?.id) {
|
||||||
|
myCalendar.value = newCalendar;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
myCalendar.value = fromEvent ?? safeCalendars.value[0] ?? null;
|
const delEvent = (idev) => {
|
||||||
};
|
axiosApiInstance.delete(`api/calendar_of_events/my_events/?delid=${idev}`).then((result) => {
|
||||||
|
feedalert.alert = true;
|
||||||
const initForm = () => {
|
feedalert.text = result.data.mess;
|
||||||
form.value = structuredClone(toRaw(props.eventCalendar?.event ?? {}));
|
feedalert.ico = 'mdi-check';
|
||||||
newFiles.value = [];
|
feedalert.color = 'orange-accent-1';
|
||||||
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('getCalendar');
|
||||||
|
});
|
||||||
emit('closeDialog');
|
emit('closeDialog');
|
||||||
} catch (e) {
|
|
||||||
alertStore.showError('Ошибка удаления события');
|
|
||||||
console.error(e);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const newFiles = ref([]);
|
||||||
|
|
||||||
const handleFilesUpdate = (updatedExistingFiles) => {
|
const handleFilesUpdate = (updatedExistingFiles) => {
|
||||||
|
// Сохраняем новые файлы во временную переменную
|
||||||
const currentNewFiles = [...newFiles.value];
|
const currentNewFiles = [...newFiles.value];
|
||||||
form.value.files = updatedExistingFiles;
|
|
||||||
|
// Обновляем существующие файлы
|
||||||
|
propsEvent.value.event.files = updatedExistingFiles;
|
||||||
|
|
||||||
|
// Восстанавливаем новые файлы
|
||||||
newFiles.value = currentNewFiles;
|
newFiles.value = currentNewFiles;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -412,86 +559,117 @@ const postFiles = (updatedFiles) => {
|
|||||||
newFiles.value = updatedFiles;
|
newFiles.value = updatedFiles;
|
||||||
};
|
};
|
||||||
|
|
||||||
const onParticipantsChange = ({ ids, action }) => {
|
const returnIdParticant = (idPart) => {
|
||||||
const next = new Set(selectedIds.value);
|
idPart.staff.forEach((e) => {
|
||||||
ids.forEach((id) => {
|
if (e.selected == true && !propsEvent.value.event.participant.includes(e.id)) {
|
||||||
if (action === 'add') next.add(id);
|
propsEvent.value.event.participant.push(e.id);
|
||||||
else if (action === 'remove') next.delete(id);
|
} else {
|
||||||
else if (action === 'toggle') next.has(id) ? next.delete(id) : next.add(id);
|
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);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
next.add(accountStore.user.is_idEmployee);
|
|
||||||
selectedIds.value = next;
|
|
||||||
form.value.participant = Array.from(next);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const postData = async (validate) => {
|
const postData = async (validate) => {
|
||||||
if (!validate) return;
|
if (validate) {
|
||||||
if (!myCalendar.value) {
|
|
||||||
alertStore.showError('Выберите календарь');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await nextTick();
|
await nextTick();
|
||||||
|
|
||||||
updatePeriodRule(selectedRule.value);
|
updatePeriodRule(selectedRule.value);
|
||||||
form.value.calendar = myCalendar.value.id;
|
propsEvent.value.event.calendar = myCalendar.value.id;
|
||||||
|
|
||||||
const postEvent = new FormData();
|
let postEvent = new FormData();
|
||||||
postEvent.append('event', JSON.stringify({ ...form.value, files: form.value.files }));
|
|
||||||
|
|
||||||
if (newFiles.value.length) {
|
postEvent.append(
|
||||||
newFiles.value.forEach((file) => postEvent.append('files', file, file.name));
|
'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);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
axiosApiInstance.post('api/calendar_of_events/my_events/', postEvent).then((result) => {
|
||||||
const result = await axiosApiInstance.post('api/calendar_of_events/my_events/', postEvent);
|
feedalert.alert = true;
|
||||||
alertStore.showSuccess(result.data.mess);
|
feedalert.text = result.data.mess;
|
||||||
|
feedalert.ico = 'mdi-check';
|
||||||
|
feedalert.color = 'green-darken-4';
|
||||||
emit('getCalendar');
|
emit('getCalendar');
|
||||||
emit('closeDialog');
|
emit('closeDialog');
|
||||||
} catch (e) {
|
});
|
||||||
alertStore.showError('Ошибка сохранения события');
|
|
||||||
console.error(e);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleAutoAdjustEnd = (newEndDate) => {
|
const handleAutoAdjustEnd = (newEndDate) => {
|
||||||
form.value.date_end = newEndDate;
|
propsEvent.value.event.date_end = newEndDate;
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateRepeatEndDate = (date) => {
|
const updateRepeatEndDate = (date) => {
|
||||||
repeatEndDate.value = date;
|
repeatEndDate.value = date;
|
||||||
updatePeriodRule(selectedRule.value);
|
updatePeriodRule(selectedRule.value); // Пересоздаем правило с новой датой
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateDateStart = (newDate) => {
|
watch(selectedRule, (newRule) => {
|
||||||
const normalizedDate = new Date(newDate).toISOString();
|
if (!newRule.rule) {
|
||||||
form.value.date_start = normalizedDate;
|
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 startDate = new Date(normalizedDate);
|
||||||
const endDate = new Date(form.value.date_end);
|
const endDate = new Date(propsEvent.value.event.date_end);
|
||||||
|
|
||||||
if (startDate > endDate) {
|
if (startDate > endDate) {
|
||||||
const adjustedEnd = new Date(startDate);
|
const adjustedEnd = new Date(startDate);
|
||||||
adjustedEnd.setHours(startDate.getHours() + 1);
|
adjustedEnd.setHours(startDate.getHours() + 1);
|
||||||
form.value.date_end = adjustedEnd.toISOString();
|
propsEvent.value.event.date_end = adjustedEnd.toISOString(); // Тоже ISO
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectedRule.value.rule) updatePeriodRule(selectedRule.value);
|
if (selectedRule.value.rule) {
|
||||||
|
updatePeriodRule(selectedRule.value);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateDateEnd = (newDate) => {
|
const updateDateEnd = (newDate) => {
|
||||||
form.value.date_end = new Date(newDate).toISOString();
|
// Нормализуем к ISO строке
|
||||||
|
propsEvent.value.event.date_end = new Date(newDate).toISOString();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// функция обновления периода
|
||||||
const updatePeriodRule = (rule) => {
|
const updatePeriodRule = (rule) => {
|
||||||
selectedRule.value = rule;
|
selectedRule.value = rule;
|
||||||
|
|
||||||
if (!rule.rule) {
|
if (!rule.rule) {
|
||||||
showRepeatEnd.value = false;
|
propsEvent.value.event.period = null;
|
||||||
repeatEndDate.value = null;
|
|
||||||
form.value.period = null;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const dtstart = new Date(form.value.date_start);
|
const dtstart = new Date(propsEvent.value.event.date_start);
|
||||||
|
|
||||||
const localDtstart = new Date(
|
const localDtstart = new Date(
|
||||||
dtstart.getFullYear(),
|
dtstart.getFullYear(),
|
||||||
dtstart.getMonth(),
|
dtstart.getMonth(),
|
||||||
@@ -501,89 +679,87 @@ const updatePeriodRule = (rule) => {
|
|||||||
dtstart.getSeconds(),
|
dtstart.getSeconds(),
|
||||||
);
|
);
|
||||||
|
|
||||||
const base = rule.getRule ? rule.getRule(form.value.date_start) : { ...rule.rule };
|
const ruleOptions = {
|
||||||
const ruleOptions = { ...base, dtstart: localDtstart };
|
...rule.rule,
|
||||||
|
dtstart: localDtstart,
|
||||||
|
};
|
||||||
|
|
||||||
if (showRepeatEnd.value && repeatEndDate.value) {
|
if (showRepeatEnd.value && repeatEndDate.value) {
|
||||||
const u = new Date(repeatEndDate.value);
|
const untilDate = new Date(repeatEndDate.value);
|
||||||
ruleOptions.until = new Date(
|
ruleOptions.until = new Date(
|
||||||
u.getFullYear(),
|
untilDate.getFullYear(),
|
||||||
u.getMonth(),
|
untilDate.getMonth(),
|
||||||
u.getDate(),
|
untilDate.getDate(),
|
||||||
u.getHours(),
|
untilDate.getHours(),
|
||||||
u.getMinutes(),
|
untilDate.getMinutes(),
|
||||||
u.getSeconds(),
|
untilDate.getSeconds(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
form.value.period = new RRule(ruleOptions).toString();
|
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();
|
||||||
};
|
};
|
||||||
|
|
||||||
async function handleCreateCalendar() {
|
watch(
|
||||||
const idsBefore = new Set(safeCalendars.value.map((cal) => cal.id));
|
() => propsEvent.value.event?.period,
|
||||||
const created = await requestCreateCalendar();
|
(newPeriod) => {
|
||||||
if (!created) return;
|
if (newPeriod) {
|
||||||
|
initializeRule();
|
||||||
emit('getCalendar');
|
|
||||||
await waitForNewCalendar(idsBefore);
|
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{ immediate: true },
|
||||||
|
);
|
||||||
|
|
||||||
function waitForNewCalendar(idsBefore, timeoutMs = 5000) {
|
watch([safeCalendars, myCalendar], (newCalendar) => {}, { deep: true, immediate: true });
|
||||||
return new Promise((resolve) => {
|
|
||||||
const checkNow = safeCalendars.value.find((cal) => !idsBefore.has(cal.id));
|
function handleCalendarSelect(calendar) {
|
||||||
if (checkNow) {
|
if (calendar.id === 'create_new') {
|
||||||
myCalendar.value = checkNow;
|
if (window.$createCalendar) {
|
||||||
resolve(checkNow);
|
// Запоминаем максимальный ID до создания
|
||||||
return;
|
const maxIdBefore = Math.max(
|
||||||
}
|
...safeCalendars.value.filter((cal) => cal.id !== 'create_new').map((cal) => cal.id),
|
||||||
const stop = watch(
|
);
|
||||||
|
|
||||||
|
window.$createCalendar();
|
||||||
|
|
||||||
|
// Следим за появлением календаря с ID больше максимального
|
||||||
|
const unwatch = watch(
|
||||||
safeCalendars,
|
safeCalendars,
|
||||||
(list) => {
|
(newCalendars) => {
|
||||||
const fresh = list.find((cal) => !idsBefore.has(cal.id));
|
const realCalendars = newCalendars.filter((cal) => cal.id !== 'create_new');
|
||||||
if (fresh) {
|
const newCalendar = realCalendars.find((cal) => cal.id > maxIdBefore);
|
||||||
myCalendar.value = fresh;
|
|
||||||
stop();
|
if (newCalendar) {
|
||||||
clearTimeout(timer);
|
myCalendar.value = newCalendar;
|
||||||
resolve(fresh);
|
unwatch();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ deep: true },
|
{ deep: true },
|
||||||
);
|
);
|
||||||
const timer = setTimeout(() => {
|
|
||||||
stop();
|
setTimeout(() => unwatch(), 5000);
|
||||||
resolve(null);
|
|
||||||
}, timeoutMs);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
// Загрузка/переинициализация при смене редактируемого события
|
}
|
||||||
watch(() => props.eventCalendar?.event?.id, initForm, { immediate: true });
|
myCalendar.value = calendar;
|
||||||
|
|
||||||
// Участники: при смене календаря (новое событие) и при загрузке
|
|
||||||
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>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.scrollable-textarea {
|
.scrollable-textarea {
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
|
|||||||
Executable → Regular
+177
-141
@@ -1,172 +1,185 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-card class="pa-0" rounded="lg" elevation="8">
|
<v-dialog v-model="internalShow" max-width="700">
|
||||||
<!-- Акцентная полоса -->
|
<v-card class="pa-4" min-height="400">
|
||||||
<div :style="{ height: '4px', background: calendarColor }" />
|
<!-- Заголовок -->
|
||||||
|
<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-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-btn icon="mdi-close" variant="text" density="comfortable" size="small" @click="closeDialog" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<v-divider />
|
|
||||||
|
|
||||||
<!-- Контент -->
|
<!-- Контент -->
|
||||||
<v-card-text class="pa-5">
|
<v-card-text class="px-2">
|
||||||
<v-list density="comfortable" bg-color="transparent" class="pa-0">
|
<v-row no-gutters class="flex-column">
|
||||||
<!-- Дата и время -->
|
<!-- Название события -->
|
||||||
<v-list-item class="px-0">
|
<v-row no-gutters class="align-center border-bottom">
|
||||||
<template #prepend>
|
<v-col
|
||||||
<v-icon icon="mdi-clock-outline" color="medium-emphasis" class="mr-3" />
|
style="font-size: 1.1rem; line-height: 1.4"
|
||||||
</template>
|
class="text-body-1 text-text_grey font-weight-medium"
|
||||||
<v-list-item-title class="text-caption text-medium-emphasis">
|
lg="3"
|
||||||
Дата и время
|
>
|
||||||
</v-list-item-title>
|
Название
|
||||||
<v-list-item-subtitle class="text-body-2 text-high-emphasis mt-1" style="opacity: 1">
|
</v-col>
|
||||||
<span class="font-weight-medium">
|
<v-col>
|
||||||
{{ formatDateTime(eventData.event?.date_start, eventData.event?.allday) }}
|
<div class="text-body-1" style="font-size: 1.1rem; line-height: 1.4">
|
||||||
</span>
|
{{ eventData.event?.name || 'Без названия' }}
|
||||||
<v-icon icon="mdi-arrow-right" size="14" class="mx-2" />
|
</div>
|
||||||
<span class="font-weight-medium">
|
</v-col>
|
||||||
{{ formatDateTime(eventData.event?.date_end, eventData.event?.allday) }}
|
</v-row>
|
||||||
</span>
|
|
||||||
</v-list-item-subtitle>
|
|
||||||
</v-list-item>
|
|
||||||
|
|
||||||
<v-divider class="my-1" />
|
<!-- Календарь -->
|
||||||
|
<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>
|
||||||
<template v-if="eventData.event?.period">
|
<v-col>
|
||||||
<v-list-item class="px-0">
|
<div class="d-flex align-center">
|
||||||
<template #prepend>
|
<v-avatar size="20" :color="calendarColor" class="mr-3" />
|
||||||
<v-icon icon="mdi-refresh" color="medium-emphasis" class="mr-3" />
|
<span class="text-body-1">{{ calendarName }}</span>
|
||||||
</template>
|
</div>
|
||||||
<v-list-item-title class="text-caption text-medium-emphasis">Повтор</v-list-item-title>
|
</v-col>
|
||||||
<v-list-item-subtitle class="text-body-2 mt-1" style="opacity: 1">
|
</v-row>
|
||||||
{{ 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-row
|
||||||
<v-list-item class="px-0">
|
no-gutters
|
||||||
<template #prepend>
|
class="align-start pb-3 mb-3 border-bottom"
|
||||||
<v-icon icon="mdi-account-multiple-outline" color="medium-emphasis" class="mr-3" />
|
v-if="participantsList.length > 0"
|
||||||
</template>
|
|
||||||
<v-list-item-title class="text-caption text-medium-emphasis">
|
|
||||||
Участники
|
|
||||||
<v-chip size="x-small" variant="tonal" class="ml-2">{{ participantsList.length }}</v-chip>
|
|
||||||
</v-list-item-title>
|
|
||||||
<v-list-item-subtitle class="mt-2" style="opacity: 1">
|
|
||||||
<div class="d-flex flex-wrap ga-2">
|
|
||||||
<v-chip
|
|
||||||
v-for="p in participantsList"
|
|
||||||
:key="p.id"
|
|
||||||
size="small"
|
|
||||||
variant="tonal"
|
|
||||||
prepend-icon="mdi-account"
|
|
||||||
>
|
>
|
||||||
{{ p.title }}
|
<v-col class="text-body-1 text-text_grey font-weight-medium pt-1" lg="3">
|
||||||
</v-chip>
|
Участники
|
||||||
|
</v-col>
|
||||||
|
<v-col>
|
||||||
|
<div class="participants-list">
|
||||||
|
<div
|
||||||
|
v-for="participant in participantsList"
|
||||||
|
:key="participant.id"
|
||||||
|
class="text-body-1 mb-1"
|
||||||
|
>
|
||||||
|
• {{ participant.title }}
|
||||||
</div>
|
</div>
|
||||||
</v-list-item-subtitle>
|
</div>
|
||||||
</v-list-item>
|
</v-col>
|
||||||
<v-divider class="my-1" />
|
</v-row>
|
||||||
</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>
|
||||||
|
|
||||||
<!-- Файлы -->
|
<!-- Файлы -->
|
||||||
<template v-if="eventData.event?.files?.length">
|
<v-row
|
||||||
<v-list-item class="px-0">
|
no-gutters
|
||||||
<template #prepend>
|
class="align-top pb-3 mb-3 border-bottom"
|
||||||
<v-icon icon="mdi-paperclip" color="medium-emphasis" class="mr-3" />
|
v-if="eventData.event?.files?.length"
|
||||||
</template>
|
>
|
||||||
<v-list-item-title class="text-caption text-medium-emphasis">
|
<v-col class="text-body-1 text-text_grey font-weight-medium" lg="3"> Файлы </v-col>
|
||||||
Файлы
|
<v-col>
|
||||||
<v-chip size="x-small" variant="tonal" class="ml-2">
|
<div class="files-list">
|
||||||
{{ eventData.event.files.length }}
|
<div
|
||||||
</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"
|
v-for="file in eventData.event.files"
|
||||||
:key="file.id"
|
:key="file.id"
|
||||||
:prepend-icon="getFileIcon(file)"
|
class="d-flex align-center mb-2 cursor-pointer"
|
||||||
:title="truncateFileName(getFileName(file))"
|
|
||||||
append-icon="mdi-download"
|
|
||||||
rounded="md"
|
|
||||||
variant="tonal"
|
|
||||||
density="compact"
|
|
||||||
class="mb-1"
|
|
||||||
@click="downloadFile(file)"
|
@click="downloadFile(file)"
|
||||||
/>
|
>
|
||||||
</v-list>
|
<v-icon :icon="getFileIcon(file)" color="primary" class="mr-2" size="small" />
|
||||||
</v-list-item-subtitle>
|
<span class="text-body-1 text-primary text-decoration-underline">
|
||||||
</v-list-item>
|
{{ truncateFileName(getFileName(file)) }}
|
||||||
<v-divider class="my-1" />
|
</span>
|
||||||
</template>
|
</div>
|
||||||
|
</div>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
|
||||||
<!-- Описание -->
|
<!-- Описание -->
|
||||||
<v-list-item v-if="eventData.event?.description" class="px-0">
|
<v-row no-gutters class="align-top pb-3" v-if="eventData.event?.description">
|
||||||
<template #prepend>
|
<v-col class="text-body-1 text-text_grey font-weight-medium" lg="3"> Описание </v-col>
|
||||||
<v-icon icon="mdi-text" color="medium-emphasis" class="mr-3" />
|
<v-col>
|
||||||
</template>
|
<div class="text-body-1 description-text">
|
||||||
<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 }}
|
{{ eventData.event.description }}
|
||||||
</v-sheet>
|
|
||||||
</v-list-item-subtitle>
|
|
||||||
</v-list-item>
|
|
||||||
</v-list>
|
|
||||||
|
|
||||||
<!-- Пусто -->
|
|
||||||
<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>
|
</div>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
|
||||||
|
<!-- Если нет данных -->
|
||||||
|
<v-row v-if="!eventData.event?.name" class="justify-center mt-8">
|
||||||
|
<v-col class="text-center">
|
||||||
|
<v-icon size="64" color="grey-lighten-1">mdi-calendar-remove</v-icon>
|
||||||
|
<div class="text-h6 text-grey mt-2">Нет данных о событии</div>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
</v-row>
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
|
|
||||||
<v-divider />
|
|
||||||
|
|
||||||
<!-- Кнопки -->
|
<!-- Кнопки -->
|
||||||
<v-card-actions class="pa-4">
|
<v-card-actions class="justify-end pa-4 pt-0">
|
||||||
<v-spacer />
|
|
||||||
|
|
||||||
<v-btn
|
<v-btn
|
||||||
v-if="canEdit"
|
v-if="canEdit"
|
||||||
:color="calendarColor"
|
width="140"
|
||||||
|
color="btn_text"
|
||||||
variant="elevated"
|
variant="elevated"
|
||||||
prepend-icon="mdi-pencil"
|
prepend-icon="mdi-pencil"
|
||||||
|
class="text-body-1"
|
||||||
@click="onEdit"
|
@click="onEdit"
|
||||||
>
|
>
|
||||||
Редактировать
|
Редактировать
|
||||||
</v-btn>
|
</v-btn>
|
||||||
|
<v-btn
|
||||||
|
width="120"
|
||||||
|
@click="closeDialog"
|
||||||
|
color="grey-darken-1"
|
||||||
|
variant="tonal"
|
||||||
|
class="text-body-1"
|
||||||
|
>
|
||||||
|
Закрыть
|
||||||
|
</v-btn>
|
||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
</v-card>
|
</v-card>
|
||||||
|
</v-dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@@ -179,6 +192,10 @@ export default {
|
|||||||
name: 'EventCalendarShow',
|
name: 'EventCalendarShow',
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
|
show: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
eventData: {
|
eventData: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => ({}),
|
default: () => ({}),
|
||||||
@@ -193,13 +210,31 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
emits: ['close'],
|
emits: ['update:show', 'close'],
|
||||||
|
|
||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
|
const internalShow = ref(props.show);
|
||||||
const { parseRecurrenceOptions, isRecurringEvent } = useRecurrence();
|
const { parseRecurrenceOptions, isRecurringEvent } = useRecurrence();
|
||||||
const calendarStore = useCalendarStore();
|
const calendarStore = useCalendarStore();
|
||||||
|
|
||||||
const closeDialog = () => emit('close');
|
// Синхронизация с внешним состоянием
|
||||||
|
watch(
|
||||||
|
() => props.show,
|
||||||
|
(newVal) => {
|
||||||
|
internalShow.value = newVal;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
watch(internalShow, (newVal) => {
|
||||||
|
if (!newVal) {
|
||||||
|
emit('update:show', false);
|
||||||
|
emit('close');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const closeDialog = () => {
|
||||||
|
internalShow.value = false;
|
||||||
|
};
|
||||||
|
|
||||||
const calendarInfo = computed(() => {
|
const calendarInfo = computed(() => {
|
||||||
const calendarId = props.eventData.event?.calendar;
|
const calendarId = props.eventData.event?.calendar;
|
||||||
@@ -446,6 +481,7 @@ export default {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
internalShow,
|
||||||
closeDialog,
|
closeDialog,
|
||||||
calendarName,
|
calendarName,
|
||||||
calendarColor,
|
calendarColor,
|
||||||
@@ -459,7 +495,7 @@ export default {
|
|||||||
showRepeatEnd,
|
showRepeatEnd,
|
||||||
formatRepeatEndDate,
|
formatRepeatEndDate,
|
||||||
canEdit,
|
canEdit,
|
||||||
onEdit,
|
onEdit
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -10,15 +10,13 @@
|
|||||||
/>
|
/>
|
||||||
</v-dialog>
|
</v-dialog>
|
||||||
|
|
||||||
<v-dialog v-model="calendarStore.showViewDialog" max-width="700">
|
|
||||||
<event-show
|
<event-show
|
||||||
v-if="calendarStore.showViewDialog"
|
v-model:show="calendarStore.showViewDialog"
|
||||||
:event-data="calendarStore.selectedEventForView"
|
|
||||||
:all-calendars="calendarStore.calendars"
|
:all-calendars="calendarStore.calendars"
|
||||||
|
:event-data="calendarStore.selectedEventForView"
|
||||||
:employees="calendarStore.employees"
|
:employees="calendarStore.employees"
|
||||||
@close="calendarStore.closeEventView"
|
@close="calendarStore.closeEventView"
|
||||||
/>
|
/>
|
||||||
</v-dialog>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
|||||||
Executable → Regular
+330
-242
@@ -72,7 +72,8 @@
|
|||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex-grow-1 d-flex" ref="calWrap">
|
<div class="flex-grow-1 d-flex">
|
||||||
|
<!-- VCalendar -->
|
||||||
<FullCalendar
|
<FullCalendar
|
||||||
v-if="currentView !== 'listAllEvents'"
|
v-if="currentView !== 'listAllEvents'"
|
||||||
ref="calendarRef"
|
ref="calendarRef"
|
||||||
@@ -86,242 +87,60 @@
|
|||||||
</v-card>
|
</v-card>
|
||||||
</v-col>
|
</v-col>
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script>
|
||||||
import { ref, computed, watch, nextTick, onMounted, onBeforeUnmount } from 'vue';
|
import { ref, watch, nextTick, computed } from 'vue';
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
import { useRoute } from 'vue-router';
|
|
||||||
|
|
||||||
import dayGridPlugin from '@fullcalendar/daygrid';
|
import dayGridPlugin from '@fullcalendar/daygrid';
|
||||||
import timeGridPlugin from '@fullcalendar/timegrid';
|
import timeGridPlugin from '@fullcalendar/timegrid';
|
||||||
import multiMonthPlugin from '@fullcalendar/multimonth';
|
import multiMonthPlugin from '@fullcalendar/multimonth';
|
||||||
import interactionPlugin from '@fullcalendar/interaction';
|
import interactionPlugin from '@fullcalendar/interaction';
|
||||||
import listPlugin from '@fullcalendar/list';
|
import listPlugin from '@fullcalendar/list';
|
||||||
import rrulePlugin from '@fullcalendar/rrule';
|
|
||||||
import ruLocale from '@fullcalendar/core/locales/ru';
|
import ruLocale from '@fullcalendar/core/locales/ru';
|
||||||
|
import rrulePlugin from '@fullcalendar/rrule';
|
||||||
|
import { onMounted } from 'vue';
|
||||||
import { useCalendarStore } from '@/store/calendarStore';
|
import { useCalendarStore } from '@/store/calendarStore';
|
||||||
import { useAccountStore } from '@/store/AccountStore';
|
|
||||||
import { useRecurrence } from '@/components/calendar_of_events/composables/useReccurrence';
|
import { useRecurrence } from '@/components/calendar_of_events/composables/useReccurrence';
|
||||||
import { useEventListFilters } from '../composables/useEventListFilters';
|
import { useAccountStore } from '@/store/AccountStore';
|
||||||
import EventsListView from './EventsListView.vue';
|
import EventsListView from './EventsListView.vue';
|
||||||
import EventListFilters from './EventListFilters.vue';
|
import EventListFilters from './EventListFilters.vue';
|
||||||
|
import { useEventListFilters } from '../composables/useEventListFilters';
|
||||||
|
|
||||||
defineOptions({ name: 'CustomCalendar' });
|
export default {
|
||||||
|
name: 'CustomCalendar',
|
||||||
|
components: {
|
||||||
|
EventsListView,
|
||||||
|
EventListFilters,
|
||||||
|
},
|
||||||
|
|
||||||
const props = defineProps({
|
props: {
|
||||||
forHomePage: { type: Boolean, default: false },
|
forHomePage: { type: Boolean, default: false },
|
||||||
view: { type: String, default: 'dayGridMonth' },
|
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();
|
|
||||||
|
|
||||||
|
setup(props) {
|
||||||
const currentView = ref('dayGridMonth');
|
const currentView = ref('dayGridMonth');
|
||||||
const currentTitle = ref('Календарь');
|
const currentTitle = ref('Календарь');
|
||||||
const calendarRef = ref(null);
|
const calendarRef = ref(null);
|
||||||
const calWrap = ref(null);
|
const accountStore = useAccountStore();
|
||||||
|
|
||||||
const calendarApi = computed(() => calendarRef.value?.getApi?.() || null);
|
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(() => ({
|
const unwrappedFilters = computed(() => ({
|
||||||
dateRange: filters.dateRange.value,
|
dateRange: filters.dateRange.value,
|
||||||
sortOrder: filters.sortOrder.value,
|
sortOrder: filters.sortOrder.value,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const weekdayMap = {
|
const handleEventClick = (info) => {
|
||||||
воскресенье: 'воскресенье',
|
calendarStore.handleEventClick(info);
|
||||||
понедельник: 'понедельник',
|
|
||||||
вторник: 'вторник',
|
|
||||||
среда: 'среду',
|
|
||||||
четверг: 'четверг',
|
|
||||||
пятница: 'пятницу',
|
|
||||||
суббота: 'субботу',
|
|
||||||
};
|
|
||||||
|
|
||||||
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 },
|
|
||||||
},
|
|
||||||
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({
|
const calendarOptions = ref({
|
||||||
@@ -343,43 +162,297 @@ const calendarOptions = ref({
|
|||||||
aspectRatio: 1.5,
|
aspectRatio: 1.5,
|
||||||
weekNumbers: true,
|
weekNumbers: true,
|
||||||
eventDisplay: 'auto',
|
eventDisplay: 'auto',
|
||||||
eventTimeFormat: { hour: '2-digit', minute: '2-digit', hour12: false, meridiem: false },
|
eventTimeFormat: {
|
||||||
weekNumberFormat: { week: 'numeric' },
|
hour: '2-digit',
|
||||||
weekNumberCalculation: 'ISO',
|
minute: '2-digit',
|
||||||
|
hour12: false,
|
||||||
|
meridiem: false,
|
||||||
|
},
|
||||||
|
weekNumberFormat: {
|
||||||
|
week: 'numeric',
|
||||||
|
},
|
||||||
|
weekNumberCalculation: 'ISO', // ISO стандарт (понедельник - первый день)
|
||||||
selectable: true,
|
selectable: true,
|
||||||
unselectAuto: false,
|
unselectAuto: false,
|
||||||
selectMirror: false,
|
selectMirror: false,
|
||||||
dayCellClassNames: dayClassNames,
|
dayCellClassNames: (arg) => {
|
||||||
dayHeaderClassNames: dayClassNames,
|
const dayInfo = calendarStore.isNonWorkingDay(arg.date);
|
||||||
views: calendarViews,
|
const classes = [];
|
||||||
events: buildEvents,
|
if (dayInfo.isHoliday) classes.push('non-working-day');
|
||||||
|
if (dayInfo.isWeekendForStyling) classes.push('grey-background');
|
||||||
|
return classes;
|
||||||
|
},
|
||||||
|
dayHeaderClassNames: (arg) => {
|
||||||
|
const dayInfo = calendarStore.isNonWorkingDay(arg.date);
|
||||||
|
const classes = [];
|
||||||
|
if (dayInfo.isHoliday) classes.push('non-working-day');
|
||||||
|
if (dayInfo.isWeekendForStyling) classes.push('grey-background');
|
||||||
|
return classes;
|
||||||
|
},
|
||||||
|
|
||||||
|
views: {
|
||||||
|
timeGridDay: {
|
||||||
|
type: 'timeGrid',
|
||||||
|
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,
|
||||||
|
textColor: '#ffffff',
|
||||||
|
backgroundColor: eventColor,
|
||||||
|
borderColor: eventColor,
|
||||||
|
extendedProps: {
|
||||||
|
...instance.extendedProps,
|
||||||
|
_userHash: accountStore.user?.id || 'anonymous',
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
} else {
|
||||||
|
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);
|
||||||
|
},
|
||||||
eventClick: handleEventClick,
|
eventClick: handleEventClick,
|
||||||
|
|
||||||
dateClick: (info) => {
|
dateClick: (info) => {
|
||||||
calendarStore.setSelectedDateFromCalendar(info);
|
calendarStore.setSelectedDateFromCalendar(info);
|
||||||
handleDateSelection(info.dateStr);
|
handleDateSelection(info.dateStr);
|
||||||
handleCalendarDateClick(info);
|
handleCalendarDateClick(info);
|
||||||
calendarApi.value?.unselect();
|
calendarApi.value?.unselect();
|
||||||
},
|
},
|
||||||
|
|
||||||
datesSet: (info) => {
|
datesSet: (info) => {
|
||||||
if (info.view.type === 'listWeek' && selectedDate.value) {
|
if (info.view.type === 'listWeek' && selectedDate.value) {
|
||||||
currentTitle.value = formatScheduleTitle(selectedDate.value);
|
currentTitle.value = formatScheduleTitle(selectedDate.value);
|
||||||
} else if (info.view.type !== 'listWeek') {
|
} else if (info.view.type !== 'listWeek') {
|
||||||
currentTitle.value = info.view.title;
|
currentTitle.value = info.view.title;
|
||||||
}
|
}
|
||||||
if (selectedDate?.value) handleDateSelection(selectedDate.value);
|
|
||||||
|
if (selectedDate?.value) {
|
||||||
|
handleDateSelection(selectedDate.value);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
/* ──────────── Вотчеры ──────────── */
|
const handleCalendarDateClick = (info) => {
|
||||||
watch(currentView, (newView, oldView) => {
|
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;
|
||||||
|
};
|
||||||
|
|
||||||
|
const weekdayMap = {
|
||||||
|
воскресенье: 'воскресенье',
|
||||||
|
понедельник: 'понедельник',
|
||||||
|
вторник: 'вторник',
|
||||||
|
среда: 'среду',
|
||||||
|
четверг: 'четверг',
|
||||||
|
пятница: 'пятницу',
|
||||||
|
суббота: 'субботу',
|
||||||
|
};
|
||||||
|
|
||||||
|
const formatScheduleTitle = (dateValue) => {
|
||||||
|
const date = new Date(dateValue);
|
||||||
|
const weekdayRaw = date.toLocaleDateString('ru-RU', { weekday: 'long' });
|
||||||
|
const weekday = weekdayMap[weekdayRaw] || weekdayRaw;
|
||||||
|
const rest = date.toLocaleDateString('ru-RU', {
|
||||||
|
day: 'numeric',
|
||||||
|
month: 'long',
|
||||||
|
year: 'numeric',
|
||||||
|
});
|
||||||
|
return `Расписание на ${weekday}, ${rest}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
const applyView = async (newView) => {
|
||||||
|
if (newView === 'listAllEvents') {
|
||||||
|
currentTitle.value = 'Все события';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (newView === 'listWeek' && selectedDate.value) {
|
||||||
|
currentTitle.value = formatScheduleTitle(selectedDate.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
await nextTick();
|
||||||
|
if (!calendarApi.value) return;
|
||||||
|
|
||||||
|
calendarApi.value.changeView(newView);
|
||||||
|
|
||||||
|
if (newView !== 'listWeek') {
|
||||||
|
currentTitle.value = calendarApi.value.view.title;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
const currentYear = new Date().getFullYear();
|
||||||
|
calendarStore.fetchHolidays(currentYear);
|
||||||
|
// Ждем следующего тика для гарантии, что календарь инициализирован
|
||||||
|
await nextTick();
|
||||||
|
|
||||||
|
// Принудительно обновляем события после загрузки праздников
|
||||||
|
if (calendarApi.value && currentView.value !== 'listAllEvents') {
|
||||||
|
calendarApi.value.refetchEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selectedDate.value && currentView.value !== 'listAllEvents') {
|
||||||
|
handleDateSelection(selectedDate.value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(currentView, (newView) => {
|
||||||
applyView(newView);
|
applyView(newView);
|
||||||
if (oldView === 'listAllEvents' && newView !== 'listAllEvents') filters.resetFilters();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
[() => calendarStore.calendars, () => calendarStore.hiddenCalendarIds],
|
allEvents,
|
||||||
() => {
|
() => {
|
||||||
if (currentView.value !== 'listAllEvents') calendarApi.value?.refetchEvents();
|
// При изменении событий перезагружаем календарь
|
||||||
|
if (currentView.value === 'listAllEvents') return;
|
||||||
|
calendarApi.value?.refetchEvents();
|
||||||
},
|
},
|
||||||
{ deep: true },
|
{ deep: true },
|
||||||
);
|
);
|
||||||
@@ -387,7 +460,8 @@ watch(
|
|||||||
watch(
|
watch(
|
||||||
calendarColorMap,
|
calendarColorMap,
|
||||||
() => {
|
() => {
|
||||||
if (currentView.value !== 'listAllEvents') calendarApi.value?.refetchEvents();
|
if (currentView.value === 'listAllEvents') return;
|
||||||
|
calendarApi.value?.refetchEvents();
|
||||||
},
|
},
|
||||||
{ deep: true },
|
{ deep: true },
|
||||||
);
|
);
|
||||||
@@ -397,30 +471,44 @@ watch(selectedDate, (newDate) => {
|
|||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
calendarApi.value.gotoDate(newDate);
|
calendarApi.value.gotoDate(newDate);
|
||||||
handleDateSelection(newDate);
|
handleDateSelection(newDate);
|
||||||
if (route.query.date && currentView.value !== 'timeGridDay') {
|
|
||||||
currentView.value = 'timeGridDay';
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onMounted(async () => {
|
const handleFiltersUpdate = (newFilters) => {
|
||||||
ro = new ResizeObserver(scheduleUpdate);
|
Object.keys(newFilters).forEach((key) => {
|
||||||
if (calWrap.value) ro.observe(calWrap.value);
|
if (filters[key] !== undefined) {
|
||||||
|
filters[key].value = newFilters[key];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
calendarStore.fetchHolidays(new Date().getFullYear());
|
// Сброс фильтров при выходе из кастомного вида
|
||||||
await nextTick();
|
watch(currentView, (newView, oldView) => {
|
||||||
|
if (oldView === 'listAllEvents' && newView !== 'listAllEvents') {
|
||||||
if (currentView.value !== 'listAllEvents') {
|
filters.resetFilters();
|
||||||
if (calendarApi.value) calendarApi.value.refetchEvents();
|
|
||||||
if (selectedDate.value) handleDateSelection(selectedDate.value);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
return {
|
||||||
cancelAnimationFrame(rafId);
|
currentTitle,
|
||||||
ro?.disconnect();
|
calendarRef,
|
||||||
});
|
calendarApi,
|
||||||
|
currentView,
|
||||||
|
calendarOptions,
|
||||||
|
handleToday,
|
||||||
|
handleNext,
|
||||||
|
handlePrev,
|
||||||
|
handleCalendarDateClick,
|
||||||
|
handleDateSelection,
|
||||||
|
handleEventClick,
|
||||||
|
calendarStore,
|
||||||
|
filters,
|
||||||
|
handleFiltersUpdate,
|
||||||
|
unwrappedFilters,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
<style scoped>
|
<style scoped>
|
||||||
:deep(.fc-daygrid-day-number) {
|
:deep(.fc-daygrid-day-number) {
|
||||||
|
|||||||
Executable → Regular
+236
-115
@@ -1,15 +1,15 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-card elevation="2">
|
<v-card class="home-calendar-widget" elevation="2" rounded="lg">
|
||||||
<v-card-text class="pa-4">
|
<v-card-text class="pa-4">
|
||||||
<v-row no-gutters class="calendar-pair">
|
<v-row no-gutters class="calendar-pair">
|
||||||
<!-- Месячный календарь -->
|
<!-- Месячный календарь -->
|
||||||
<v-col cols="7" class="pr-2">
|
<v-col cols="7" class="pr-2">
|
||||||
<div class="calendar-header">
|
<div class="calendar-header">
|
||||||
<v-btn icon size="small" class="nav-btn" @click="prevMonth">
|
<v-btn icon size="small" @click="prevMonth" class="nav-btn">
|
||||||
<v-icon>mdi-chevron-left</v-icon>
|
<v-icon>mdi-chevron-left</v-icon>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
<span class="month-title">{{ currentMonth }}</span>
|
<span class="month-title">{{ currentMonth }}</span>
|
||||||
<v-btn icon size="small" class="nav-btn" @click="nextMonth">
|
<v-btn icon size="small" @click="nextMonth" class="nav-btn">
|
||||||
<v-icon>mdi-chevron-right</v-icon>
|
<v-icon>mdi-chevron-right</v-icon>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</div>
|
</div>
|
||||||
@@ -17,11 +17,13 @@
|
|||||||
<v-table class="month-table">
|
<v-table class="month-table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th v-for="day in WEEKDAYS" :key="day" class="weekday-header">{{ day }}</th>
|
<th v-for="day in russianWeekdays" :key="day" class="weekday-header">
|
||||||
|
{{ day }}
|
||||||
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr v-for="(week, i) in calendarWeeks" :key="i">
|
<tr v-for="(week, weekIndex) in calendarWeeks" :key="weekIndex">
|
||||||
<td
|
<td
|
||||||
v-for="day in week"
|
v-for="day in week"
|
||||||
:key="day.date"
|
:key="day.date"
|
||||||
@@ -33,8 +35,7 @@
|
|||||||
'non-working-day': day.isHoliday,
|
'non-working-day': day.isHoliday,
|
||||||
'grey-background': day.isWeekend,
|
'grey-background': day.isWeekend,
|
||||||
}"
|
}"
|
||||||
@click="selectedDate = day.date"
|
@click="onDateClick(day.date)"
|
||||||
@dblclick.stop="goToDay(day.date)"
|
|
||||||
>
|
>
|
||||||
<div class="day-content">
|
<div class="day-content">
|
||||||
<span class="day-number">{{ day.day }}</span>
|
<span class="day-number">{{ day.day }}</span>
|
||||||
@@ -44,7 +45,7 @@
|
|||||||
:key="event.id"
|
:key="event.id"
|
||||||
class="event-indicator"
|
class="event-indicator"
|
||||||
:style="{ backgroundColor: event.color }"
|
:style="{ backgroundColor: event.color }"
|
||||||
/>
|
></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
@@ -63,25 +64,29 @@
|
|||||||
|
|
||||||
<v-card variant="outlined" class="day-schedule" elevation="0">
|
<v-card variant="outlined" class="day-schedule" elevation="0">
|
||||||
<v-list density="comfortable" class="py-0">
|
<v-list density="comfortable" class="py-0">
|
||||||
<template v-if="dayEvents.length">
|
|
||||||
<v-list-item
|
<v-list-item
|
||||||
v-for="event in dayEvents"
|
v-for="event in dayEvents"
|
||||||
:key="event.id"
|
:key="event.id"
|
||||||
class="schedule-item"
|
class="schedule-item"
|
||||||
:class="{ 'current-event': isCurrentEvent(event) }"
|
:class="{ 'current-event': isCurrentEvent(event) }"
|
||||||
@click="calendarStore.handleEventClick({ event: { id: event.id } })"
|
@click="handleEventClick(event)"
|
||||||
>
|
>
|
||||||
<template #prepend>
|
<template #prepend>
|
||||||
<div class="event-color-indicator" :style="{ backgroundColor: event.color }" />
|
<div
|
||||||
</template>
|
class="event-color-indicator"
|
||||||
<v-list-item-title class="event-time">{{
|
:style="{ backgroundColor: event.color }"
|
||||||
formatTime(event.start)
|
></div>
|
||||||
}}</v-list-item-title>
|
|
||||||
<v-list-item-subtitle class="event-title">{{ event.title }}</v-list-item-subtitle>
|
|
||||||
</v-list-item>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<v-list-item v-else class="no-events">
|
<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-title class="text-grey text-center">
|
<v-list-item-title class="text-grey text-center">
|
||||||
На этот день событий нет
|
На этот день событий нет
|
||||||
</v-list-item-title>
|
</v-list-item-title>
|
||||||
@@ -94,136 +99,158 @@
|
|||||||
</v-card>
|
</v-card>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script>
|
||||||
import { ref, computed, onMounted } from 'vue';
|
import { ref, computed, onMounted, watch } from 'vue';
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
import { useRouter } from 'vue-router';
|
|
||||||
import { useCalendarStore } from '@/store/calendarStore';
|
import { useCalendarStore } from '@/store/calendarStore';
|
||||||
import { useRecurrence } from '@/components/calendar_of_events/composables/useReccurrence';
|
import { useRecurrence } from '@/components/calendar_of_events/composables/useReccurrence';
|
||||||
|
|
||||||
const WEEKDAYS = ['Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб', 'Вс'];
|
export default {
|
||||||
|
name: 'HomeCalendarWidget',
|
||||||
|
|
||||||
const toLocalDateStr = (date) => {
|
setup() {
|
||||||
const y = date.getFullYear();
|
// Реактивные данные
|
||||||
const m = String(date.getMonth() + 1).padStart(2, '0');
|
const currentDate = ref(new Date());
|
||||||
const d = String(date.getDate()).padStart(2, '0');
|
const selectedDate = ref(''); // Будет установлено в формате YYYY-MM-DD
|
||||||
return `${y}-${m}-${d}`;
|
const currentYear = new Date().getFullYear();
|
||||||
};
|
|
||||||
|
|
||||||
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 calendarStore = useCalendarStore();
|
||||||
const { allEvents, calendarColorMap } = storeToRefs(calendarStore);
|
const { allEvents, calendarColorMap } = storeToRefs(calendarStore);
|
||||||
const { generateRecurringInstances } = useRecurrence();
|
const { generateRecurringInstances, isRecurringEvent } = useRecurrence();
|
||||||
|
|
||||||
const currentDate = ref(new Date());
|
// Утилиты для работы с датами (главный источник проблем!)
|
||||||
const selectedDate = ref('');
|
const formatToLocalDate = (date) => {
|
||||||
|
const year = date.getFullYear();
|
||||||
const prevMonth = () => {
|
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||||
const d = new Date(currentDate.value);
|
const day = String(date.getDate()).padStart(2, '0');
|
||||||
d.setMonth(d.getMonth() - 1);
|
return `${year}-${month}-${day}`;
|
||||||
currentDate.value = d;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const nextMonth = () => {
|
const getStartOfDay = (date) => {
|
||||||
const d = new Date(currentDate.value);
|
const newDate = new Date(date);
|
||||||
d.setMonth(d.getMonth() + 1);
|
newDate.setHours(0, 0, 0, 0);
|
||||||
currentDate.value = d;
|
return newDate;
|
||||||
};
|
};
|
||||||
|
|
||||||
const goToDay = (date) => {
|
const areDatesEqual = (date1, date2) => {
|
||||||
calendarStore.setSelectedDate(date);
|
return getStartOfDay(date1).getTime() === getStartOfDay(date2).getTime();
|
||||||
router.push({ name: 'Calendar', query: { date, view: 'day' } });
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const expandMultiDay = (originalEvent, instance) => {
|
const events = computed(() => {
|
||||||
const start = new Date(instance.date_start || instance.start);
|
const expandedEvents = allEvents.value.flatMap((event) => {
|
||||||
const end = new Date(instance.date_end || instance.end);
|
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 days = [];
|
||||||
const cur = new Date(start);
|
const currentDay = new Date(startDate);
|
||||||
|
|
||||||
while (cur < end) {
|
while (currentDay < endDate) {
|
||||||
const dayEnd = new Date(cur);
|
const dayStart = new Date(currentDay);
|
||||||
|
const dayEnd = new Date(currentDay);
|
||||||
dayEnd.setDate(dayEnd.getDate() + 1);
|
dayEnd.setDate(dayEnd.getDate() + 1);
|
||||||
|
|
||||||
days.push({
|
days.push({
|
||||||
...originalEvent,
|
...originalEvent,
|
||||||
id: instance.id,
|
id: instance.id, // ID от экземпляра периодичности
|
||||||
date_start: new Date(cur).toISOString(),
|
date_start: dayStart.toISOString(),
|
||||||
date_end: dayEnd.toISOString(),
|
date_end: dayEnd.toISOString(),
|
||||||
allday: true,
|
allday: true,
|
||||||
isMultiDayPart: true,
|
isMultiDayPart: true,
|
||||||
isRecurringInstance: instance.isRecurringInstance || false,
|
isRecurringInstance: instance.isRecurringInstance || false,
|
||||||
|
originalStart: instance.date_start || instance.start,
|
||||||
|
originalEnd: instance.date_end || instance.end,
|
||||||
});
|
});
|
||||||
cur.setDate(cur.getDate() + 1);
|
|
||||||
|
currentDay.setDate(currentDay.getDate() + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return days;
|
return days;
|
||||||
};
|
};
|
||||||
|
|
||||||
const toWidgetEvent = (event) => ({
|
// Форматирование для виджета
|
||||||
|
const formatForWidget = (event) => {
|
||||||
|
const eventColor =
|
||||||
|
event.calendarData?.cl_color || calendarColorMap.value?.get(event.calendar) || '#1976d2';
|
||||||
|
|
||||||
|
return {
|
||||||
id: event.id,
|
id: event.id,
|
||||||
title: event.name || 'Без названия',
|
title: event.name || 'Без названия',
|
||||||
start: event.date_start,
|
start: event.date_start,
|
||||||
end: event.date_end,
|
end: event.date_end,
|
||||||
color: event.calendarData?.cl_color || calendarColorMap.value?.get(event.calendar) || '#1976d2',
|
|
||||||
description: event.description,
|
description: event.description,
|
||||||
|
color: eventColor,
|
||||||
calendar: event.calendar,
|
calendar: event.calendar,
|
||||||
|
calendarData: event.calendarData,
|
||||||
isRecurringInstance: event.isRecurringInstance || false,
|
isRecurringInstance: event.isRecurringInstance || false,
|
||||||
isMultiDayPart: event.isMultiDayPart || false,
|
isMultiDayPart: event.isMultiDayPart || false,
|
||||||
});
|
};
|
||||||
|
};
|
||||||
|
|
||||||
const events = computed(() =>
|
const russianWeekdays = ['Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб', 'Вс'];
|
||||||
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 calendarWeeks = computed(() => {
|
||||||
const year = currentDate.value.getFullYear();
|
const year = currentDate.value.getFullYear();
|
||||||
const month = currentDate.value.getMonth();
|
const month = currentDate.value.getMonth();
|
||||||
const start = new Date(year, month, 1);
|
const firstDay = new Date(year, month, 1);
|
||||||
start.setDate(start.getDate() - ((start.getDay() + 6) % 7));
|
|
||||||
|
|
||||||
const weeks = [];
|
const weeks = [];
|
||||||
let week = [];
|
let week = [];
|
||||||
|
|
||||||
|
// Находим понедельник первой недели
|
||||||
|
const startDay = new Date(firstDay);
|
||||||
|
startDay.setDate(startDay.getDate() - ((startDay.getDay() + 6) % 7));
|
||||||
|
|
||||||
|
// Генерируем 6 недель (фиксированное количество для стабильности)
|
||||||
for (let i = 0; i < 42; i++) {
|
for (let i = 0; i < 42; i++) {
|
||||||
const day = new Date(start);
|
const currentDay = new Date(startDay);
|
||||||
day.setDate(start.getDate() + i);
|
currentDay.setDate(startDay.getDate() + i);
|
||||||
const info = calendarStore.isNonWorkingDay(day);
|
|
||||||
|
const dayInfo = calendarStore.isNonWorkingDay(currentDay);
|
||||||
|
|
||||||
week.push({
|
week.push({
|
||||||
day: day.getDate(),
|
day: currentDay.getDate(),
|
||||||
date: toLocalDateStr(day),
|
date: formatToLocalDate(currentDay),
|
||||||
isCurrentMonth: day.getMonth() === month,
|
isCurrentMonth: currentDay.getMonth() === month,
|
||||||
isHoliday: info.isHoliday,
|
isHoliday: dayInfo.isHoliday,
|
||||||
isWeekend: info.isWeekendForStyling,
|
isWeekend: dayInfo.isWeekendForStyling,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (week.length === 7) {
|
if (week.length === 7) {
|
||||||
@@ -231,16 +258,23 @@ const calendarWeeks = computed(() => {
|
|||||||
week = [];
|
week = [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return weeks;
|
return weeks;
|
||||||
});
|
});
|
||||||
|
|
||||||
const currentMonth = computed(() =>
|
const currentMonth = computed(() => {
|
||||||
currentDate.value.toLocaleDateString('ru-RU', { month: 'long', year: 'numeric' }),
|
return currentDate.value.toLocaleDateString('ru-RU', {
|
||||||
);
|
month: 'long',
|
||||||
|
year: 'numeric',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
const formattedSelectedDate = computed(() => {
|
const formattedSelectedDate = computed(() => {
|
||||||
if (!selectedDate.value) return '';
|
if (!selectedDate.value) return '';
|
||||||
return new Date(`${selectedDate.value}T12:00:00`).toLocaleDateString('ru-RU', {
|
|
||||||
|
// Добавляем время для избежания смещения часовых поясов
|
||||||
|
const date = new Date(selectedDate.value + 'T12:00:00');
|
||||||
|
return date.toLocaleDateString('ru-RU', {
|
||||||
day: 'numeric',
|
day: 'numeric',
|
||||||
month: 'long',
|
month: 'long',
|
||||||
year: 'numeric',
|
year: 'numeric',
|
||||||
@@ -249,35 +283,122 @@ const formattedSelectedDate = computed(() => {
|
|||||||
|
|
||||||
const dayEvents = computed(() => {
|
const dayEvents = computed(() => {
|
||||||
if (!selectedDate.value) return [];
|
if (!selectedDate.value) return [];
|
||||||
const sel = new Date(`${selectedDate.value}T12:00:00`);
|
|
||||||
|
const selected = new Date(selectedDate.value + 'T12:00:00');
|
||||||
|
|
||||||
return events.value
|
return events.value
|
||||||
.filter((e) => datesEqual(new Date(e.start), sel))
|
.filter((event) => {
|
||||||
.sort((a, b) => new Date(a.start) - new Date(b.start));
|
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) => datesEqual(new Date(), new Date(`${date}T12:00:00`));
|
// Методы
|
||||||
const isSelected = (date) => date === selectedDate.value;
|
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 getDayEvents = (date) => {
|
||||||
const d = new Date(`${date}T12:00:00`);
|
const checkDate = new Date(date + 'T12:00:00');
|
||||||
return events.value.filter((e) => datesEqual(new Date(e.start), d));
|
|
||||||
|
return events.value.filter((event) => {
|
||||||
|
const eventDate = new Date(event.start);
|
||||||
|
return areDatesEqual(eventDate, checkDate);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const isCurrentEvent = (event) => {
|
const isCurrentEvent = (event) => {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
return now >= new Date(event.start) && now <= new Date(event.end);
|
const start = new Date(event.start);
|
||||||
|
const end = new Date(event.end);
|
||||||
|
return now >= start && now <= end;
|
||||||
};
|
};
|
||||||
|
|
||||||
const formatTime = (dateStr) =>
|
const formatTime = (dateString) => {
|
||||||
new Date(dateStr).toLocaleTimeString('ru-RU', { hour: '2-digit', minute: '2-digit' });
|
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;
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleEventClick = (event) => {
|
||||||
|
calendarStore.handleEventClick({ event: { id: event.id } });
|
||||||
|
};
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
selectedDate.value = toLocalDateStr(new Date());
|
selectedDate.value = formatToLocalDate(new Date());
|
||||||
await calendarStore.fetchHolidays(new Date().getFullYear());
|
await calendarStore.fetchHolidays(currentYear);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
// Реактивные данные
|
||||||
|
currentDate,
|
||||||
|
selectedDate,
|
||||||
|
|
||||||
|
// Вычисляемые свойства
|
||||||
|
events,
|
||||||
|
russianWeekdays,
|
||||||
|
calendarWeeks,
|
||||||
|
currentMonth,
|
||||||
|
formattedSelectedDate,
|
||||||
|
dayEvents,
|
||||||
|
isWeekendOrHoliday,
|
||||||
|
|
||||||
|
// Методы
|
||||||
|
isToday,
|
||||||
|
isSelected,
|
||||||
|
getDayEvents,
|
||||||
|
isCurrentEvent,
|
||||||
|
formatTime,
|
||||||
|
onDateClick,
|
||||||
|
prevMonth,
|
||||||
|
nextMonth,
|
||||||
|
|
||||||
|
calendarStore,
|
||||||
|
allEvents,
|
||||||
|
expandMultiDayInstance,
|
||||||
|
formatForWidget,
|
||||||
|
handleEventClick,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
.home-calendar-widget {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
font-family: 'Roboto', sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
.calendar-pair {
|
.calendar-pair {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|||||||
Executable → Regular
File mode changed.
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-card min-height="436" max-height="80%" class="pa-2" max-width="50vw">
|
<v-card min-height="436" max-height="80%" class="pa-3" max-width="50vw">
|
||||||
<v-card-title class="pr-0 pl-2 d-flex justify-space-between">
|
<v-card-title class="pr-0 pl-2 d-flex justify-space-between">
|
||||||
{{ title }}
|
{{ title }}
|
||||||
<v-icon
|
<v-icon
|
||||||
|
|||||||
Executable → Regular
File mode changed.
@@ -1,20 +1,24 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
|
<!-- -->
|
||||||
|
|
||||||
<v-autocomplete
|
<v-autocomplete
|
||||||
v-model="selectedItems"
|
v-model="selectedStaff"
|
||||||
:items="visibleDepartments"
|
:items="staffed"
|
||||||
label="Выберите из списка или найдите по ФИО"
|
label="Выберите из списка или найдите по ФИО"
|
||||||
item-title="title"
|
item-title="title"
|
||||||
item-value="id"
|
item-value="id"
|
||||||
@update:search="(val) => (searchQuery = val ?? '')"
|
:search-input.sync="filtered"
|
||||||
|
@update:search="(val) => (filtered = val)"
|
||||||
multiple
|
multiple
|
||||||
hide-details
|
hide-details
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
density="compact"
|
density="compact"
|
||||||
class="max-height-select py-3"
|
class="max-height-select py-3"
|
||||||
return-object
|
return-object
|
||||||
:custom-filter="searchInDepartment"
|
:custom-filter="customFilterFn"
|
||||||
>
|
>
|
||||||
|
<!-- :custom-filter="onFilter" -->
|
||||||
<template v-slot:selection="{ item }">
|
<template v-slot:selection="{ item }">
|
||||||
<v-chip class="me-2" color="teal-darken-3" size="small" label>
|
<v-chip class="me-2" color="teal-darken-3" size="small" label>
|
||||||
<span> {{ item.title }}</span>
|
<span> {{ item.title }}</span>
|
||||||
@@ -23,305 +27,420 @@
|
|||||||
icon="mdi-close-circle"
|
icon="mdi-close-circle"
|
||||||
size="x-small"
|
size="x-small"
|
||||||
class="ml-3"
|
class="ml-3"
|
||||||
@click.stop="selectedItems = item.raw"
|
@click.stop="selectedStaff = item.raw"
|
||||||
/>
|
/>
|
||||||
</v-chip>
|
</v-chip>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-slot:prepend-item>
|
<template v-slot:prepend-item>
|
||||||
<v-list-item
|
<v-list-item
|
||||||
:disabled="isOnlyOneEmployee"
|
:disabled="staffed.length == 1 && staffed[0].employees.length == 1"
|
||||||
class="text-body-2"
|
class="text-body-2"
|
||||||
@click.stop="toggleAllEmployees"
|
@click.stop="allUser()"
|
||||||
>
|
>
|
||||||
<span class="text-body-2"> ВСЕ СОТРУДНИКИ </span>
|
<span class="text-body-2"> ВСЕ СОТРУДНИКИ </span>
|
||||||
|
|
||||||
<template v-slot:prepend>
|
<template v-slot:prepend>
|
||||||
<v-checkbox-btn :model-value="areAllSelected" :disabled="isOnlyOneEmployee" />
|
<v-checkbox-btn
|
||||||
|
:model-value="staffed.every((e) => e[okey] == true)"
|
||||||
|
:disabled="staffed.length == 1 && staffed[0].employees.length == 1"
|
||||||
|
></v-checkbox-btn>
|
||||||
</template>
|
</template>
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
|
<!-- ВСЕ НАЧАЛЬНИКИ -->
|
||||||
<v-list-item
|
<v-list-item
|
||||||
:disabled="!hasBossesInStaff"
|
:disabled="!hasBossesInStaff"
|
||||||
class="text-body-2"
|
class="text-body-2"
|
||||||
@click.stop="toggleByPosition('boss')"
|
@click.stop="toggleByPosition('начальник')"
|
||||||
>
|
>
|
||||||
<span class="text-body-2"> ВСЕ НАЧАЛЬНИКИ </span>
|
<span class="text-body-2"> ВСЕ НАЧАЛЬНИКИ </span>
|
||||||
<template v-slot:prepend>
|
<template v-slot:prepend>
|
||||||
<v-checkbox-btn :model-value="areAllBossesSelected" :disabled="!hasBossesInStaff" />
|
<v-checkbox-btn
|
||||||
|
:model-value="hasBossesSelected"
|
||||||
|
:disabled="!hasBossesInStaff"
|
||||||
|
></v-checkbox-btn>
|
||||||
</template>
|
</template>
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
|
|
||||||
|
<!-- ВСЕ ЗАМЕСТИТЕЛИ -->
|
||||||
<v-list-item
|
<v-list-item
|
||||||
:disabled="!hasDeputiesInStaff"
|
:disabled="!hasDeputiesInStaff"
|
||||||
class="text-body-2"
|
class="text-body-2"
|
||||||
@click.stop="toggleByPosition('deputy')"
|
@click.stop="toggleByPosition('заместитель')"
|
||||||
>
|
>
|
||||||
<span class="text-body-2"> ВСЕ ЗАМЕСТИТЕЛИ </span>
|
<span class="text-body-2"> ВСЕ ЗАМЕСТИТЕЛИ </span>
|
||||||
<template v-slot:prepend>
|
<template v-slot:prepend>
|
||||||
<v-checkbox-btn :model-value="areAllDeputiesSelected" :disabled="!hasDeputiesInStaff" />
|
<v-checkbox-btn
|
||||||
|
:model-value="hasDeputiesSelected"
|
||||||
|
:disabled="!hasDeputiesInStaff"
|
||||||
|
></v-checkbox-btn>
|
||||||
</template>
|
</template>
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
|
<v-divider class="mt-2"></v-divider>
|
||||||
<v-divider class="mt-2" />
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-slot:item="{ props: itemProps, item }">
|
<template v-slot:item="{ props, item }">
|
||||||
<v-list-group v-bind="itemProps" :value="item.raw.title">
|
<v-list-group v-bind="props" :value="item.raw.title">
|
||||||
<template v-slot:activator="{ props: activatorProps }">
|
<template v-slot:activator="{ props }">
|
||||||
<v-list-item v-bind="activatorProps" density="compact" class="text-body-2" @click.stop>
|
<v-list-item v-bind="props" @click.stop="" density="compact" class="text-body-2">
|
||||||
<template v-slot:prepend>
|
<template v-slot:prepend>
|
||||||
<v-checkbox-btn
|
<v-checkbox-btn
|
||||||
color="indigo-darken-4"
|
@click.stop="selectedStaff = item.raw"
|
||||||
|
:color="'indigo-darken-4'"
|
||||||
:true-value="true"
|
:true-value="true"
|
||||||
:false-value="false"
|
:false-value="false"
|
||||||
:disabled="isDepartmentLocked(item.raw)"
|
:disabled="disable(item.raw) || isAuthor(item.raw)"
|
||||||
:indeterminate="isDepartmentIndeterminate(item.raw)"
|
:indeterminate="
|
||||||
:model-value="isSelected(item.raw)"
|
item.raw.employees.some((e) => e[okey] == true) &&
|
||||||
@click.stop="selectedItems = item.raw"
|
!item.raw.employees.every((e) => e[okey] == true)
|
||||||
/>
|
"
|
||||||
|
:model-value="item.raw[okey]"
|
||||||
|
></v-checkbox-btn>
|
||||||
</template>
|
</template>
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<v-list-item
|
<v-list-item
|
||||||
v-for="employee in filterEmployees(item.raw.employees)"
|
v-for="x in item.raw.employees.filter((e) =>
|
||||||
:key="employee.id"
|
e.title.toLowerCase().includes(filtered.toLowerCase()),
|
||||||
:value="employee.title"
|
)"
|
||||||
|
:key="x.id"
|
||||||
|
:value="x.title"
|
||||||
|
@click.stop="selectedStaff = x"
|
||||||
|
:disabled=" isAuthor(x)"
|
||||||
density="compact"
|
density="compact"
|
||||||
:disabled="isAuthor(employee)"
|
|
||||||
@click.stop="selectedItems = employee"
|
|
||||||
>
|
>
|
||||||
<template v-slot:prepend>
|
<template v-slot:prepend>
|
||||||
<v-checkbox-btn
|
<v-checkbox-btn
|
||||||
:disabled="isAuthor(employee)"
|
:disabled="isAuthor(x)"
|
||||||
color="indigo-darken-4"
|
color="indigo-darken-4"
|
||||||
:model-value="isSelected(employee)"
|
:model-value="x[okey]"
|
||||||
/>
|
></v-checkbox-btn>
|
||||||
</template>
|
</template>
|
||||||
<span class="text-body-2">{{ employee.title }}</span>
|
<span class="text-body-2"> {{ x.title }} </span>
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
</v-list-group>
|
</v-list-group>
|
||||||
</template>
|
</template>
|
||||||
</v-autocomplete>
|
</v-autocomplete>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script>
|
||||||
import { computed, ref } from 'vue';
|
import { ref, computed } from 'vue';
|
||||||
|
import { storeToRefs } from 'pinia';
|
||||||
|
import { splitname } from '@/utils/universal_functions';
|
||||||
import { useAccountStore } from '@/store/AccountStore';
|
import { useAccountStore } from '@/store/AccountStore';
|
||||||
import { useCalendarStore } from '@/store/calendarStore';
|
import { useCalendarStore } from '@/store/calendarStore';
|
||||||
|
|
||||||
const props = defineProps({
|
export default {
|
||||||
|
props: {
|
||||||
staff: {
|
staff: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: () => [],
|
default: () => [],
|
||||||
},
|
},
|
||||||
mode: {
|
okey: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'participants',
|
default: 'selected',
|
||||||
validator: (val) => ['participants', 'editors'].includes(val),
|
|
||||||
},
|
},
|
||||||
authorID: {
|
authorID: {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
selectedIds: {
|
|
||||||
type: Set,
|
|
||||||
default: null,
|
|
||||||
},
|
},
|
||||||
editorIds: {
|
|
||||||
type: Set,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const emit = defineEmits(['change']);
|
setup(props, { emit }) {
|
||||||
|
const filtered = ref('');
|
||||||
|
|
||||||
const accountStore = useAccountStore();
|
const accountStore = useAccountStore();
|
||||||
const calendarStore = useCalendarStore();
|
const calendarStore = useCalendarStore();
|
||||||
|
const { dictEmployeesLoaded } = storeToRefs(calendarStore);
|
||||||
|
|
||||||
const searchQuery = ref('');
|
const back = ref([]);
|
||||||
|
|
||||||
const isSelected = (item) => {
|
const staffed = computed({
|
||||||
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;
|
|
||||||
};
|
|
||||||
|
|
||||||
const visibleDepartments = computed(() => {
|
|
||||||
if (props.mode !== 'editors') return props.staff;
|
|
||||||
|
|
||||||
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);
|
|
||||||
});
|
|
||||||
|
|
||||||
const selectedItems = computed({
|
|
||||||
get() {
|
get() {
|
||||||
const chips = [];
|
if (props.okey == 'editor') {
|
||||||
props.staff.forEach((dept) => {
|
let ns = [];
|
||||||
if (dept.employees.length > 1 && isSelected(dept)) {
|
props.staff.forEach((e) => {
|
||||||
chips.push(dept);
|
let emp = { ...e };
|
||||||
} else if (dept.employees.length === 1) {
|
emp.employees = e.employees.filter(
|
||||||
const only = dept.employees[0];
|
(n) => n.selected == true || n.isCurrentUser == true,
|
||||||
if (isSelected(only)) chips.push(only);
|
);
|
||||||
} else {
|
if (emp.employees.length > 0) ns.push(emp);
|
||||||
chips.push(...dept.employees.filter((e) => isSelected(e)));
|
});
|
||||||
|
|
||||||
|
ns.forEach((e) => {
|
||||||
|
if (e.employees.every((w) => w.editor == true)) {
|
||||||
|
e.editor = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return chips;
|
|
||||||
|
return ns;
|
||||||
|
}
|
||||||
|
|
||||||
|
return props.staff;
|
||||||
},
|
},
|
||||||
set(value) {
|
});
|
||||||
if (!Array.isArray(value)) {
|
|
||||||
emitChange(value);
|
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 emitChange = (item) => {
|
const emitUp = (part) => {
|
||||||
// Клик по отделу
|
if ('employees' in part) {
|
||||||
if ('employees' in item) {
|
part.employees.forEach((e) => {
|
||||||
const wasSelected = isSelected(item);
|
if (e.id != accountStore.user.is_idEmployee) {
|
||||||
const action = wasSelected ? 'remove' : 'add';
|
e[props.okey] = !part[props.okey];
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
emit('returnIdParticant', {
|
||||||
const targets = allEmployees.filter((e) => e.id !== props.authorID);
|
okey: props.okey,
|
||||||
if (!targets.length) return;
|
staff: part.employees,
|
||||||
|
select: [],
|
||||||
const wasAllSelected = targets.every((e) => isSelected(e));
|
});
|
||||||
const action = wasAllSelected ? 'remove' : 'add';
|
} else if (part.length) {
|
||||||
const ids = targets.map((e) => e.id);
|
if (part[0].id != accountStore.user.is_idEmployee) {
|
||||||
|
let val = part.every((e) => e[props.okey] == true) ? false : true;
|
||||||
emit('change', { ids, action });
|
cbstaff(part, val);
|
||||||
return;
|
emit('returnIdParticant', {
|
||||||
|
okey: props.okey,
|
||||||
|
staff: back.value,
|
||||||
|
select: [],
|
||||||
|
});
|
||||||
|
back.value = [];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
part[props.okey] = !part[props.okey];
|
||||||
|
emit('returnIdParticant', {
|
||||||
|
okey: props.okey,
|
||||||
|
staff: [part],
|
||||||
|
select: [],
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Клик по отдельному сотруднику
|
|
||||||
if (item.id === props.authorID) return;
|
|
||||||
emit('change', { ids: [item.id], action: 'toggle' });
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const searchInDepartment = (_value, queryText, item) => {
|
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;
|
if (!queryText) return true;
|
||||||
const query = queryText.toLowerCase();
|
|
||||||
const target = item.raw ?? item;
|
|
||||||
|
|
||||||
const dept = visibleDepartments.value.find((d) => d.title === target.title) ?? target;
|
const searchText = queryText.toLowerCase();
|
||||||
return dept.employees?.some((e) => e.title?.toLowerCase().includes(query)) ?? false;
|
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 filterEmployees = (employees) => {
|
const disable = (department) => {
|
||||||
if (!searchQuery.value) return employees;
|
return department.id == accountStore.user.id_dict_department &&
|
||||||
const query = searchQuery.value.toLowerCase();
|
department.employees.length == 1
|
||||||
return employees.filter((e) => e.title?.toLowerCase().includes(query));
|
? true
|
||||||
|
: false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Функция проверки является ли сотрудник создателем
|
||||||
const isAuthor = (item) => {
|
const isAuthor = (item) => {
|
||||||
if (!props.authorID) return false;
|
if (!props.authorID) return false;
|
||||||
|
|
||||||
|
// Если это отдел - проверяем всех сотрудников
|
||||||
if ('employees' in item) {
|
if ('employees' in item) {
|
||||||
return item.employees.some((e) => e.id === props.authorID);
|
return item.employees.some((emp) => emp.id === props.authorID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Если это сотрудник - проверяем напрямую
|
||||||
return item.id === props.authorID;
|
return item.id === props.authorID;
|
||||||
};
|
};
|
||||||
|
|
||||||
const isDepartmentLocked = (dept) =>
|
const allUser = () => {
|
||||||
dept.id === accountStore.user.id_dict_department && dept.employees.length === 1;
|
emitUp(staffed.value);
|
||||||
|
|
||||||
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(
|
// Проверяем выбраны ли все начальники (с исключениями)
|
||||||
() =>
|
const hasBossesSelected = computed(() => {
|
||||||
visibleDepartments.value.length > 0 &&
|
const bosses = findEmployeesByPosition(['начальник', 'и.о'], ['заместитель', 'зам.']);
|
||||||
visibleDepartments.value.every((dept) => isSelected(dept)),
|
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, //
|
||||||
);
|
);
|
||||||
|
|
||||||
const areAllBossesSelected = computed(
|
if (filteredEmployees.length > 0) {
|
||||||
() => bosses.value.length > 0 && bosses.value.every((e) => isSelected(e)),
|
filteredEmployees.forEach((employee) => {
|
||||||
);
|
if (employee[props.okey] !== shouldSelect) {
|
||||||
|
selectedStaff.value = employee;
|
||||||
const areAllDeputiesSelected = computed(
|
}
|
||||||
() => deputies.value.length > 0 && deputies.value.every((e) => isSelected(e)),
|
});
|
||||||
);
|
}
|
||||||
|
}
|
||||||
const toggleAllEmployees = () => {
|
|
||||||
emitChange(visibleDepartments.value);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Все начальники / Все заместители
|
// Обновленная функция поиска с исключением
|
||||||
const findEmployeesByPosition = (includeKeywords, excludeKeywords = []) => {
|
const findEmployeesByPosition = (positionKeywords, excludeKeywords = []) => {
|
||||||
const found = [];
|
const foundEmployees = [];
|
||||||
|
|
||||||
props.staff.forEach((dept) => {
|
props.staff.forEach((department) => {
|
||||||
if (dept.id === 1) return;
|
department.employees.forEach((employee) => {
|
||||||
|
if (department.id == 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (employee.id === accountStore.user.is_idEmployee) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
dept.employees.forEach((employee) => {
|
if (props.okey === 'editor' && employee.selected !== true) {
|
||||||
if (employee.id === accountStore.user.is_idEmployee) return;
|
return;
|
||||||
if (props.mode === 'editors' && !props.selectedIds?.has(employee.id)) return;
|
}
|
||||||
|
|
||||||
const meta = calendarStore.dictEmployees.find((d) => d.id === employee.id);
|
const employeeData = calendarStore.dictEmployees.find((de) => de.id === employee.id);
|
||||||
if (!meta?.post) return;
|
|
||||||
|
|
||||||
const post = meta.post.toLowerCase();
|
if (employeeData && employeeData.post) {
|
||||||
const hasInclude = includeKeywords.some((k) => post.includes(k.toLowerCase()));
|
const post = employeeData.post.toLowerCase();
|
||||||
const hasExclude = excludeKeywords.some((k) => post.includes(k.toLowerCase()));
|
|
||||||
|
|
||||||
if (hasInclude && !hasExclude) found.push(employee);
|
// Ищем включения и исключения
|
||||||
|
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 found;
|
return foundEmployees;
|
||||||
};
|
};
|
||||||
|
// Проверяем есть ли начальники в staff
|
||||||
const bosses = computed(() =>
|
const hasBossesInStaff = computed(() => {
|
||||||
findEmployeesByPosition(['начальник', 'и.о'], ['заместитель', 'зам.']),
|
return (
|
||||||
|
findEmployeesByPosition(['начальник', 'и.о. начальника'], ['заместитель', 'зам.']).length >
|
||||||
|
0
|
||||||
);
|
);
|
||||||
const deputies = computed(() => findEmployeesByPosition(['заместитель', 'зам.'], []));
|
});
|
||||||
|
|
||||||
const hasBossesInStaff = computed(() => bosses.value.length > 0);
|
// Проверяем есть ли заместители в staff
|
||||||
const hasDeputiesInStaff = computed(() => deputies.value.length > 0);
|
const hasDeputiesInStaff = computed(() => {
|
||||||
|
return (
|
||||||
|
findEmployeesByPosition(['заместитель начальника', 'зам. начальника', 'заместитель'])
|
||||||
|
.length > 0
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
const toggleByPosition = (type) => {
|
return {
|
||||||
const list = type === 'boss' ? bosses.value : deputies.value;
|
isAuthor,
|
||||||
const targets = list.filter((e) => e.id !== props.authorID);
|
staffed,
|
||||||
if (!targets.length) return;
|
filtered,
|
||||||
|
accountStore,
|
||||||
const wasAllSelected = targets.every((e) => isSelected);
|
selectedStaff,
|
||||||
const action = wasAllSelected ? 'remove' : 'add';
|
splitname,
|
||||||
|
disable,
|
||||||
const ids = targets.map((e) => e.id);
|
allUser,
|
||||||
emit('change', { ids, action });
|
customFilterFn,
|
||||||
|
findEmployeesByPosition,
|
||||||
|
toggleByPosition,
|
||||||
|
hasBossesInStaff,
|
||||||
|
hasBossesSelected,
|
||||||
|
hasDeputiesInStaff,
|
||||||
|
hasDeputiesSelected,
|
||||||
|
dictEmployeesLoaded,
|
||||||
|
};
|
||||||
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
Executable → Regular
+117
-106
@@ -38,10 +38,9 @@
|
|||||||
<v-col class="text-body-2 text-text_grey" lg="2"> Участники </v-col>
|
<v-col class="text-body-2 text-text_grey" lg="2"> Участники </v-col>
|
||||||
<v-col>
|
<v-col>
|
||||||
<calendar-create-select
|
<calendar-create-select
|
||||||
:staff="staff"
|
:staff="newStaff"
|
||||||
:selectedIds="selectedIds"
|
@returnIdParticant="returnIdParticant"
|
||||||
:authorID="calendarAuthorId"
|
:authorID="calendarAuthorId"
|
||||||
@change="onParticipantsChange"
|
|
||||||
/> </v-col
|
/> </v-col
|
||||||
></v-row>
|
></v-row>
|
||||||
</v-col>
|
</v-col>
|
||||||
@@ -62,12 +61,10 @@
|
|||||||
<v-col class="text-body-2 text-text_grey" lg="2"> Редакторы </v-col>
|
<v-col class="text-body-2 text-text_grey" lg="2"> Редакторы </v-col>
|
||||||
<v-col>
|
<v-col>
|
||||||
<calendar-create-select
|
<calendar-create-select
|
||||||
:staff="staff"
|
:staff="newStaff"
|
||||||
mode="editors"
|
:okey="'editor'"
|
||||||
:selectedIds="selectedIds"
|
@returnIdParticant="returnIdParticant"
|
||||||
:editorIds="editorIds"
|
|
||||||
:authorID="calendarAuthorId"
|
:authorID="calendarAuthorId"
|
||||||
@change="onEditorsChange"
|
|
||||||
/>
|
/>
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col lg="1" class="text-center">
|
<v-col lg="1" class="text-center">
|
||||||
@@ -87,25 +84,26 @@
|
|||||||
</dialog-create>
|
</dialog-create>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script>
|
||||||
import { computed, ref, onMounted } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
import { axiosApiInstance } from '@/utils/axios-api';
|
import { axiosApiInstance } from '@/utils/axios-api';
|
||||||
import calendarCreateSelect from '@/components/calendar_of_events/calendar-create-select.vue';
|
import calendarCreateSelect from '@/components/calendar_of_events/calendar-create-select.vue';
|
||||||
import { useAlertStore } from '@/store/UseAlertStore';
|
import { useAlertStore } from '@/store/UseAlertStore';
|
||||||
import DialogCreate from './UI_calendar/dialogCreate.vue';
|
import DialogCreate from './UI_calendar/dialogCreate.vue';
|
||||||
import { useAccountStore } from '@/store/AccountStore';
|
import { useAccountStore } from '@/store/AccountStore';
|
||||||
|
|
||||||
const props = defineProps({
|
export default {
|
||||||
|
components: { calendarCreateSelect, DialogCreate },
|
||||||
|
|
||||||
|
props: {
|
||||||
calendar: {
|
calendar: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => ({}),
|
default: () => {},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
|
||||||
|
|
||||||
const emit = defineEmits(['update:calendar', 'getCalendar', 'closeDialog']);
|
|
||||||
|
|
||||||
|
setup(props, { emit }) {
|
||||||
const accountStore = useAccountStore();
|
const accountStore = useAccountStore();
|
||||||
const staff = ref([]);
|
|
||||||
|
|
||||||
const calendarAuthorId = computed(() => {
|
const calendarAuthorId = computed(() => {
|
||||||
// Для нового календаря - текущий пользователь
|
// Для нового календаря - текущий пользователь
|
||||||
@@ -116,88 +114,102 @@ const calendarAuthorId = computed(() => {
|
|||||||
return propsCalendar.value.author;
|
return propsCalendar.value.author;
|
||||||
});
|
});
|
||||||
|
|
||||||
const propsCalendar = computed(() => props.calendar);
|
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 alertStore = useAlertStore();
|
if (ind != -1) {
|
||||||
|
propsCalendar.value.participant.splice(ind, 1);
|
||||||
const req = (val) => {
|
}
|
||||||
return !!val || 'Поле обязательно';
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const propsCalendar = computed({
|
||||||
|
get: () => props.calendar,
|
||||||
|
set: (value) => emit('update:calendar', value),
|
||||||
|
});
|
||||||
|
|
||||||
|
const feedalert = useAlertStore().alert;
|
||||||
|
|
||||||
const rules = {
|
const rules = {
|
||||||
cl_name: [(val) => req(val)],
|
cl_name: [(val) => req(val)],
|
||||||
cl_descr: [(val) => req(val)],
|
cl_descr: [(val) => req(val)],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const isNewCalendar = computed(() => !propsCalendar.value?.id);
|
const isNewCalendar = computed(() => !propsCalendar.value?.id);
|
||||||
|
const isAuthor = computed(() => propsCalendar.value.author === accountStore.user.is_idEmployee);
|
||||||
|
|
||||||
const titleCard = computed(() =>
|
const titleCard = computed(() =>
|
||||||
isNewCalendar.value ? 'Новый календарь' : 'Редактирование календаря',
|
isNewCalendar.value ? 'Новый календарь' : 'Редактирование календаря',
|
||||||
);
|
);
|
||||||
|
|
||||||
const loadStaff = async () => {
|
const newCalendar = computed(() => (isNewCalendar.value ? true : !isAuthor.value));
|
||||||
try {
|
|
||||||
const res = await axiosApiInstance.get('api/calendar_of_events/get_employees/');
|
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);
|
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,
|
|
||||||
);
|
|
||||||
|
|
||||||
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,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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 {
|
} else {
|
||||||
propsCalendar.value.participant.splice(existingIdx, 1);
|
empl.selected = false;
|
||||||
}
|
empl.editor = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const onEditorsChange = ({ ids, action }) => {
|
return staff.value;
|
||||||
ids.forEach((id) => {
|
},
|
||||||
const existing = propsCalendar.value.participant.find((p) => p.participant_calendar === id);
|
|
||||||
if (!existing) return; // нельзя быть редактором, не будучи участником
|
|
||||||
|
|
||||||
if (action === 'add') existing.editor = true;
|
|
||||||
else if (action === 'remove') existing.editor = false;
|
|
||||||
else if (action === 'toggle') existing.editor = !existing.editor;
|
|
||||||
});
|
});
|
||||||
};
|
|
||||||
|
|
||||||
const color = [
|
const color = [
|
||||||
'#0ea5e9', // Яркий голубой
|
'#0ea5e9', // Яркий голубой
|
||||||
@@ -225,40 +237,39 @@ const colorPik = (col) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const postCalendar = async (val) => {
|
const delCalendar = (idcal) => {
|
||||||
if (!val) return;
|
axiosApiInstance
|
||||||
|
.delete(`api/calendar_of_events/my_calendars/?delid=${idcal}`)
|
||||||
try {
|
.then((result) => {
|
||||||
const result = await axiosApiInstance.post(`api/calendar_of_events/my_calendars/`, {
|
feedalert.alert = true;
|
||||||
...props.calendar,
|
feedalert.text = result.data.mess;
|
||||||
participant: propsCalendar.value.participant,
|
feedalert.ico = 'mdi-check';
|
||||||
});
|
feedalert.color = 'orange-accent-1';
|
||||||
alertStore.showSuccess(result.data.mess);
|
|
||||||
emit('getCalendar');
|
emit('getCalendar');
|
||||||
|
});
|
||||||
emit('closeDialog');
|
emit('closeDialog');
|
||||||
} catch (e) {
|
|
||||||
alertStore.showError('Ошибка сохранения календаря');
|
|
||||||
console.error(e);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const delCalendar = async (idcal) => {
|
const req = (val) => {
|
||||||
try {
|
return !!val || 'Поле обязательно';
|
||||||
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(() => {
|
return {
|
||||||
loadStaff();
|
postCalendar,
|
||||||
});
|
color,
|
||||||
|
colorPik,
|
||||||
|
returnIdParticant,
|
||||||
|
propsCalendar,
|
||||||
|
delCalendar,
|
||||||
|
rules,
|
||||||
|
titleCard,
|
||||||
|
newCalendar,
|
||||||
|
newStaff,
|
||||||
|
isNewCalendar,
|
||||||
|
calendarAuthorId,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
Executable → Regular
+24
-24
@@ -74,7 +74,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, watch } from 'vue';
|
import { onMounted, ref, watch } from 'vue';
|
||||||
import calendarCreate from '@/components/calendar_of_events/calendar-create.vue';
|
import calendarCreate from '@/components/calendar_of_events/calendar-create.vue';
|
||||||
import { useAccountStore } from '@/store/AccountStore';
|
import { useAccountStore } from '@/store/AccountStore';
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
@@ -91,18 +91,15 @@ const showDialog = ref(false);
|
|||||||
const accountStore = useAccountStore();
|
const accountStore = useAccountStore();
|
||||||
const { user } = storeToRefs(accountStore);
|
const { user } = storeToRefs(accountStore);
|
||||||
const calendarStore = useCalendarStore();
|
const calendarStore = useCalendarStore();
|
||||||
|
const { toggleCalendarVisibility, hiddenCalendarIds } = calendarStore;
|
||||||
const { hiddenCalendarIds, showCreateCalendarDialog, createCalendarInitial } =
|
|
||||||
storeToRefs(calendarStore);
|
|
||||||
|
|
||||||
const { toggleCalendarVisibility, resolveCreateCalendar } = calendarStore;
|
|
||||||
|
|
||||||
const calendar = ref(null);
|
const calendar = ref(null);
|
||||||
const openGroup = ref([0]);
|
const openGroup = ref([0]);
|
||||||
|
// const trans = ref(false);
|
||||||
const hover = ref(0);
|
const hover = ref(0);
|
||||||
|
|
||||||
const editCreatedCalendar = (cal) => {
|
const editCreatedCalendar = (cal) => {
|
||||||
if (!cal) {
|
if (cal === undefined) {
|
||||||
calendar.value = {
|
calendar.value = {
|
||||||
cl_name: '',
|
cl_name: '',
|
||||||
participant: [{ editor: true, participant_calendar: user.value.is_idEmployee }],
|
participant: [{ editor: true, participant_calendar: user.value.is_idEmployee }],
|
||||||
@@ -115,36 +112,39 @@ const editCreatedCalendar = (cal) => {
|
|||||||
showDialog.value = true;
|
showDialog.value = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCloseDialog = () => {
|
onMounted(() => {
|
||||||
const isValid = calendar.value?.cl_name?.length > 1;
|
window.$createCalendar = () => {
|
||||||
if (showCreateCalendarDialog.value) {
|
editCreatedCalendar();
|
||||||
resolveCreateCalendar(isValid ? JSON.parse(JSON.stringify(calendar.value)) : null);
|
};
|
||||||
}
|
});
|
||||||
|
|
||||||
|
const handleCloseDialog = () => {
|
||||||
|
if (calendar.value.cl_name.length > 1) {
|
||||||
|
const calendarData = JSON.parse(JSON.stringify(calendar.value));
|
||||||
|
window.dispatchEvent(
|
||||||
|
new CustomEvent('calendarCreated', {
|
||||||
|
detail: calendarData,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
showDialog.value = false;
|
showDialog.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const resetCalendar = () => {
|
||||||
|
calendar.value = {};
|
||||||
|
};
|
||||||
|
|
||||||
const toggleVisiblityEvents = (cal) => {
|
const toggleVisiblityEvents = (cal) => {
|
||||||
toggleCalendarVisibility(cal.id);
|
toggleCalendarVisibility(cal.id);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
watch(hiddenCalendarIds, (newHiddenIds) => {}, { deep: true });
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.calendars,
|
() => props.calendars,
|
||||||
(newCalendars) => {},
|
(newCalendars) => {},
|
||||||
{ deep: true },
|
{ deep: true },
|
||||||
);
|
);
|
||||||
|
|
||||||
watch(showDialog, (open) => {
|
|
||||||
if (!open && showCreateCalendarDialog.value) {
|
|
||||||
resolveCreateCalendar(null);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
watch(showCreateCalendarDialog, (open) => {
|
|
||||||
if (open && props.title === 'Мои календари') {
|
|
||||||
editCreatedCalendar(createCalendarInitial.value);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
Executable → Regular
File mode changed.
@@ -3,18 +3,19 @@
|
|||||||
<v-card-title>
|
<v-card-title>
|
||||||
<span class="text-h5">Обратная связь</span>
|
<span class="text-h5">Обратная связь</span>
|
||||||
</v-card-title>
|
</v-card-title>
|
||||||
|
|
||||||
<v-card-text class="px-2 py-0">
|
<v-card-text class="px-2 py-0">
|
||||||
<v-container>
|
<v-container>
|
||||||
<v-row>
|
<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-col>
|
||||||
<v-divider class="pb-3"/>
|
<v-divider class="pb-3"/>
|
||||||
</v-row>
|
</v-row>
|
||||||
|
<feedstar-like
|
||||||
<feedstar-like :rating="feedbackdata" @update:rating="feedbackdata.nowrating = $event" />
|
:rating=feedbackdata
|
||||||
|
@update:rating="feedbackdata.nowrating = $event"
|
||||||
|
/>
|
||||||
<v-row class="mt-6">
|
<v-row class="mt-6">
|
||||||
<v-col class="pa-0 px-3">
|
<v-col class="pa-0 px-3">
|
||||||
<v-textarea
|
<v-textarea
|
||||||
@@ -29,115 +30,149 @@
|
|||||||
</v-row>
|
</v-row>
|
||||||
</v-container>
|
</v-container>
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
|
|
||||||
<v-card-actions class="pt-0">
|
<v-card-actions class="pt-0">
|
||||||
<small v-if="average < 5 || feedbackdata.nowcomment.id !== null" class="pl-5">
|
<small v-if="average < 5 || feedbackdata.nowcomment.id!=null" class="pl-5">
|
||||||
Вы оценили сайт на <span class="font-weight-black">{{ average }}</span>
|
Вы оценили сайт на <span class="font-weight-black">{{average}}</span> {{myLabel()}}
|
||||||
{{ ratingLabel }}
|
|
||||||
</small>
|
</small>
|
||||||
<v-spacer/>
|
<v-spacer/>
|
||||||
<v-btn color="modal_btn" rounded="xl" text="Закрыть" @click="closeMenu" />
|
<v-btn
|
||||||
|
color="modal_btn"
|
||||||
|
rounded="xl"
|
||||||
|
text="Закрыть"
|
||||||
|
@click="menusCloses"
|
||||||
|
/>
|
||||||
<v-btn
|
<v-btn
|
||||||
color="modal_btn"
|
color="modal_btn"
|
||||||
variant="text"
|
variant="text"
|
||||||
:text="feedbackdata.nowcomment.id === null ? 'Отправить' : 'Обновить'"
|
:text="feedbackdata.nowcomment.id==null?'Отправить':'Обновить'"
|
||||||
@click="sendFeedback"
|
@click="feedSend"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
|
|
||||||
</v-card>
|
</v-card>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script>
|
||||||
import { ref, computed, onMounted } from 'vue';
|
import { ref, onMounted, computed } from 'vue'
|
||||||
import { axiosApiInstance } from '@/utils/axios-api';
|
import { axiosApiInstance } from '@/utils/axios-api'
|
||||||
import FeedstarLike from '@/components/UI/feedback/feedstar-like.vue';
|
|
||||||
import { useAlertStore } from '@/store/UseAlertStore';
|
|
||||||
|
|
||||||
defineProps({
|
import FeedstarLike from '@/components/UI/feedback/feedstar-like.vue'
|
||||||
LikeDialog: { type: Boolean, default: false },
|
import { useAlertStore } from '@/store/UseAlertStore'
|
||||||
});
|
|
||||||
|
|
||||||
const emit = defineEmits(['menusClose']);
|
export default {
|
||||||
|
components: { FeedstarLike },
|
||||||
|
|
||||||
const alertStore = useAlertStore();
|
props: {
|
||||||
|
LikeDialog: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
const feedbackdata = ref({
|
|
||||||
nowcomment: { comment: '', id: null },
|
|
||||||
nowrating: [],
|
|
||||||
});
|
|
||||||
|
|
||||||
const loadFeedback = async () => {
|
|
||||||
try {
|
|
||||||
const { data } = await axiosApiInstance.get('api/feedback/feedbackdata/');
|
|
||||||
feedbackdata.value = data;
|
|
||||||
|
|
||||||
if (feedbackdata.value.nowrating.length === 0) {
|
setup(props, {emit}) {
|
||||||
for (const x of feedbackdata.value.basecrit) {
|
const feedalert = useAlertStore().alert
|
||||||
feedbackdata.value.nowrating.push({
|
const feedbackdata= ref({nowcomment: {comment: '' }, nowrating: []})
|
||||||
rating: x.rating,
|
|
||||||
crit: x.id,
|
function f_feedbackdata() {
|
||||||
id: null,
|
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.nowcomment === null) {
|
if (feedbackdata.value.nowcomment === null) {
|
||||||
feedbackdata.value.nowcomment = { comment: '', id: null };
|
feedbackdata.value.nowcomment = { comment: '', id: null}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
})
|
||||||
console.error('Ошибка загрузки фидбэка:', e);
|
|
||||||
alertStore.showError('Не удалось загрузить данные обратной связи');
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
onMounted(() => {
|
||||||
|
f_feedbackdata()
|
||||||
|
})
|
||||||
|
|
||||||
const average = computed(()=> {
|
const average = computed(()=> {
|
||||||
const ratings = feedbackdata.value.nowrating;
|
const sum = feedbackdata.value.nowrating.reduce((total, obj)=> total + obj.rating, 0)
|
||||||
if (!ratings.length) return 0;
|
const sumlen = sum/feedbackdata.value.nowrating.length
|
||||||
|
const ukr = Number.isInteger(sumlen)?sumlen:sumlen.toFixed(1)
|
||||||
|
return ukr
|
||||||
|
})
|
||||||
|
|
||||||
const sum = ratings.reduce((total, obj) => total + obj.rating, 0);
|
function myLabel() {
|
||||||
const avg = sum / ratings.length;
|
let labels = ''
|
||||||
return Number.isInteger(avg) ? avg : Number(avg.toFixed(1));
|
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
|
||||||
|
}
|
||||||
|
|
||||||
const ratingLabel = computed(() => {
|
function menusCloses() {
|
||||||
const avg = average.value;
|
emit('menusClose')
|
||||||
if (avg > 0 && avg <= 3) return 'УПС-С! Мы обязательно все исправим';
|
}
|
||||||
if (avg > 2 && avg <= 4) return 'Спасибо за обратную связь, мы обратим на это внимание';
|
|
||||||
if (avg > 4 && avg < 5) return 'Класс, будем стараться до 5';
|
|
||||||
return 'Спасибо за отзыв и высокую оценку ^__^';
|
|
||||||
});
|
|
||||||
|
|
||||||
const closeMenu = () => emit('menusClose');
|
function feedSend() {
|
||||||
|
|
||||||
const sendFeedback = async () => {
|
axiosApiInstance.post(`api/feedback/feedbackdata/`, {
|
||||||
const isUpdate = feedbackdata.value.nowcomment.id !== null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
await axiosApiInstance.post('api/feedback/feedbackdata/', {
|
|
||||||
nowrating: feedbackdata.value.nowrating,
|
nowrating: feedbackdata.value.nowrating,
|
||||||
nowcomment: feedbackdata.value.nowcomment,
|
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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return {
|
||||||
|
feedbackdata,
|
||||||
|
average,
|
||||||
|
menusCloses,
|
||||||
|
myLabel,
|
||||||
|
feedSend,
|
||||||
|
feedalert
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
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>
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.custom_subtitle {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.v-selection-control__input {
|
||||||
|
width: 46%!important;
|
||||||
|
height: 46%!important;
|
||||||
|
border-radius: 0!important;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
Regular → Executable
File mode changed.
@@ -1,10 +1,12 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-row no-gutters class="gap ma-3 flex-column">
|
<v-row no-gutters class="gap ma-3 flex-column">
|
||||||
<v-col lg="2" class="w100 d-flex flex-column">
|
<v-col lg=2 class='w100 d-flex flex-column'>
|
||||||
<v-row no-gutters class="gap">
|
<v-row no-gutters class="gap">
|
||||||
<v-col lg="4">
|
<v-col lg=4>
|
||||||
<v-card class="h-100">
|
<v-card class="h-100">
|
||||||
<v-card-title> Ежедневная статистика по сотрудникам </v-card-title>
|
<v-card-title>
|
||||||
|
Ежедневная статистика по сотрудникам
|
||||||
|
</v-card-title>
|
||||||
<v-row no-gutters class="gap">
|
<v-row no-gutters class="gap">
|
||||||
<v-col class="flex-grow-0">
|
<v-col class="flex-grow-0">
|
||||||
<v-card-subtitle class="mt-2 align-self-end">
|
<v-card-subtitle class="mt-2 align-self-end">
|
||||||
@@ -12,7 +14,11 @@
|
|||||||
</v-card-subtitle>
|
</v-card-subtitle>
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col class="flex-grow-0">
|
<v-col class="flex-grow-0">
|
||||||
<v-icon icon="mdi-file-excel" color="green-darken-3" @click="excelOp('excround')" />
|
<v-icon
|
||||||
|
icon="mdi-file-excel"
|
||||||
|
color="green-darken-3"
|
||||||
|
@click="excelOp('excround')"
|
||||||
|
/>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
<v-row no-gutters class="gap mt-5">
|
<v-row no-gutters class="gap mt-5">
|
||||||
@@ -46,61 +52,67 @@
|
|||||||
</v-row>
|
</v-row>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script>
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue'
|
||||||
import { baseURL, axiosApiInstance } from '@/utils/axios-api';
|
import { baseURL } from '@/utils/axios-api'
|
||||||
import { useAlertStore } from '@/store/UseAlertStore';
|
import { axiosApiInstance } from '@/utils/axios-api'
|
||||||
|
import { useAlertStore } from '@/store/UseAlertStore'
|
||||||
|
|
||||||
const dailyfiles = ref([]);
|
export default {
|
||||||
const alertStore = useAlertStore();
|
|
||||||
|
|
||||||
const excelOp = async (ex) => {
|
setup(){
|
||||||
try {
|
|
||||||
const result = await axiosApiInstance.get(`api/general_vacation/dailyroundup/?excel=${ex}`);
|
const dailyfiles = ref([])
|
||||||
const link = document.createElement('a');
|
const feedalert = useAlertStore().alert
|
||||||
link.href = baseURL + result.data.path;
|
|
||||||
link.click();
|
const excelOp = (ex) => {
|
||||||
link.remove();
|
axiosApiInstance.get(`api/general_vacation/dailyroundup/?excel=${ex}`).then(result => {
|
||||||
} catch (e) {
|
let link = document.createElement("a")
|
||||||
alertStore.showError('Не удалось получить файл');
|
link.href = baseURL+result.data.path
|
||||||
console.error(e);
|
link.click()
|
||||||
|
link.remove()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
const onPickFile = async (ex) => {
|
const onPickFile = (ex) => {
|
||||||
const sdata = new FormData();
|
const sdata = new FormData()
|
||||||
sdata.append('dailyfiles', dailyfiles.value);
|
sdata.append('dailyfiles', dailyfiles.value)
|
||||||
|
axiosApiInstance.post(`api/general_vacation/dailyroundup/?excel=${ex}`, sdata).then(result => {
|
||||||
try {
|
textFromAlert(result.data['mess'])
|
||||||
const result = await axiosApiInstance.post(
|
})
|
||||||
`api/general_vacation/dailyroundup/?excel=${ex}`,
|
dailyfiles.value = []
|
||||||
sdata,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (result.data.mess === 'Файл загружен') {
|
|
||||||
alertStore.showSuccess('Файл загружен');
|
|
||||||
} else {
|
|
||||||
alertStore.showError(result.data.mess ?? 'Ошибка загрузки');
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
|
||||||
alertStore.showError('Ошибка загрузки');
|
|
||||||
console.error(e);
|
|
||||||
} finally {
|
|
||||||
dailyfiles.value = [];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
defineExpose({
|
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,
|
excelOp,
|
||||||
baseURL,
|
baseURL,
|
||||||
dailyfiles,
|
dailyfiles,
|
||||||
onPickFile,
|
onPickFile,
|
||||||
alertStore,
|
feedalert
|
||||||
});
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.mhight {
|
.mhight {
|
||||||
height: 150px;
|
height: 150px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
@@ -2,10 +2,23 @@
|
|||||||
<v-row class="">
|
<v-row class="">
|
||||||
<v-col class="flex-column d-flex pa-0">
|
<v-col class="flex-column d-flex pa-0">
|
||||||
<v-row class="mt-0 mx-3 h-0 overflow-auto ">
|
<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">
|
<v-col
|
||||||
|
v-for="(x, key) in newsAll"
|
||||||
|
:key="key"
|
||||||
|
class="py-1"
|
||||||
|
lg=12
|
||||||
|
md=6
|
||||||
|
sm=6
|
||||||
|
>
|
||||||
<NewsCard :news="x"/>
|
<NewsCard :news="x"/>
|
||||||
|
|
||||||
<v-dialog v-model="dialogfotoOne" width="w-100" height="900" class="flex-column">
|
|
||||||
|
<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-card class="pa-4 h-100 flex-column d-flex">
|
||||||
<v-row class="flex-grow-0 justify-end">
|
<v-row class="flex-grow-0 justify-end">
|
||||||
<v-col class="pa-0 flex-grow-0">
|
<v-col class="pa-0 flex-grow-0">
|
||||||
@@ -14,16 +27,26 @@
|
|||||||
variant="text"
|
variant="text"
|
||||||
icon="mdi-close"
|
icon="mdi-close"
|
||||||
@click="dialogfotoOne = false"
|
@click="dialogfotoOne = false"
|
||||||
|
|
||||||
|
|
||||||
/>
|
/>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
<v-row>
|
<v-row>
|
||||||
|
|
||||||
<v-col class="flex-column h_cards pa-0">
|
<v-col class="flex-column h_cards pa-0">
|
||||||
<v-img class="d-flex" :src="`${burl}${galleryimges}`" />
|
<v-img
|
||||||
|
class="d-flex"
|
||||||
|
:src="`${burl}${galleryimges}`"
|
||||||
|
/>
|
||||||
|
|
||||||
</v-col>
|
</v-col>
|
||||||
|
|
||||||
</v-row>
|
</v-row>
|
||||||
|
|
||||||
</v-card>
|
</v-card>
|
||||||
</v-dialog>
|
</v-dialog>
|
||||||
|
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
<v-divider class="mt-3"/>
|
<v-divider class="mt-3"/>
|
||||||
@@ -34,13 +57,12 @@
|
|||||||
variant="text"
|
variant="text"
|
||||||
icon="mdi-newspaper"
|
icon="mdi-newspaper"
|
||||||
color="teal-darken-4"
|
color="teal-darken-4"
|
||||||
:to="`/news`"
|
:to='`/news`'
|
||||||
/>
|
/>
|
||||||
</v-col>
|
</v-col>
|
||||||
<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">
|
||||||
class="py-0 pl-0 flex-grow-0 text-end align-self-center text-caption font-weight-bold text-no-wrap"
|
|
||||||
>
|
|
||||||
Всего новостей: {{countetnews}}
|
Всего новостей: {{countetnews}}
|
||||||
|
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
</v-col>
|
</v-col>
|
||||||
@@ -48,42 +70,43 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue'
|
||||||
import { axiosApiInstance } from '@/utils/axios-api';
|
import { axiosApiInstance } from '@/utils/axios-api'
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router'
|
||||||
import NewsCard from './UI/NewsCard.vue';
|
import NewsCard from './UI/NewsCard.vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
||||||
components: {
|
components: {
|
||||||
NewsCard,
|
NewsCard
|
||||||
},
|
},
|
||||||
|
|
||||||
setup(){
|
setup(){
|
||||||
const newsAll = ref([]);
|
|
||||||
const countetnews = ref(0);
|
const newsAll=ref([])
|
||||||
const page = ref(1);
|
const countetnews = ref(0)
|
||||||
const countpage = ref(8);
|
const page = ref(1)
|
||||||
const route = useRoute();
|
const countpage = ref(8)
|
||||||
const galleryimges = ref('');
|
const route = useRoute()
|
||||||
const dialogfotoOne = ref(false);
|
const galleryimges=ref('')
|
||||||
|
const dialogfotoOne = ref(false)
|
||||||
|
|
||||||
const loadNewsAll = () => {
|
const loadNewsAll = () => {
|
||||||
axiosApiInstance
|
axiosApiInstance.get( `api/navigation/newscrossroad/?name=${route.path}&page=${page.value-1}&countpage=${countpage.value}`).then(result => {
|
||||||
.get(
|
newsAll.value= result.data.result
|
||||||
`api/navigation/newscrossroad/?name=${route.path}&page=${page.value - 1}&countpage=${countpage.value}`,
|
countetnews.value = result.data.countpage
|
||||||
|
}
|
||||||
)
|
)
|
||||||
.then((result) => {
|
}
|
||||||
newsAll.value = result.data.result;
|
|
||||||
countetnews.value = result.data.countpage;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
loadNewsAll();
|
loadNewsAll()
|
||||||
|
|
||||||
const openOneImg = (idimg) => {
|
const openOneImg = (idimg) => {
|
||||||
dialogfotoOne.value = true;
|
dialogfotoOne.value = true
|
||||||
galleryimges.value = idimg;
|
galleryimges.value = idimg
|
||||||
};
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
newsAll,
|
newsAll,
|
||||||
@@ -93,9 +116,13 @@ export default {
|
|||||||
loadNewsAll,
|
loadNewsAll,
|
||||||
galleryimges,
|
galleryimges,
|
||||||
dialogfotoOne,
|
dialogfotoOne,
|
||||||
};
|
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style></style>
|
<style>
|
||||||
|
|
||||||
|
</style>
|
||||||
@@ -1,26 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-app>
|
<v-app>
|
||||||
<v-app-bar
|
<v-app-bar v-if="accountStore.cod2user" density="compact" color="#263f40" class="pl-4" style="box-shadow: none">
|
||||||
v-if="accountStore.cod2user"
|
<v-icon class="px-3" size="20"
|
||||||
density="compact"
|
:icon="rail ? 'mdi-chevron-right' : 'mdi-chevron-left'" @click="rail = !rail" />
|
||||||
color="#263f40"
|
<v-card class="bg-transparent" density="compact"
|
||||||
class="pl-4"
|
:prepend-avatar="imageSrc" title="Портал МИ ФНС России по ЦОД № 2" variant="text" :to="'/'" />
|
||||||
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>
|
<template v-slot:append>
|
||||||
<div class="fns-actions">
|
<div class="fns-actions">
|
||||||
<vcard-user :author="accountStore.user" />
|
<vcard-user :author="accountStore.user" />
|
||||||
@@ -79,19 +63,18 @@
|
|||||||
permanent
|
permanent
|
||||||
v-model="drawer"
|
v-model="drawer"
|
||||||
class="text-white px-2"
|
class="text-white px-2"
|
||||||
style="background-color: #335455 !important"
|
style="background-color: #335455 !important;"
|
||||||
>
|
>
|
||||||
|
|
||||||
<v-row class="my-0 h-100">
|
<v-row class="my-0 h-100">
|
||||||
<v-col class="flex-column d-flex pa-2">
|
<v-col class="flex-column d-flex pa-2">
|
||||||
<v-row>
|
<v-row>
|
||||||
<v-col>
|
<v-col>
|
||||||
<v-list nav density="compact" class="fns-nav-list">
|
<v-list nav density="compact" class="fns-nav-list">
|
||||||
<template v-for="(x, key) in navigations" :key="key">
|
<template v-for="(x, key) in navigations" :key="key">
|
||||||
|
|
||||||
<v-list-item
|
<v-list-item
|
||||||
v-if="
|
v-if="(x.path === '/portal' ? accountStore.user.is_superuser : true) && !('submenu' in x)"
|
||||||
(x.path === '/portal' ? accountStore.user.is_superuser : true) &&
|
|
||||||
!('submenu' in x)
|
|
||||||
"
|
|
||||||
:key="x.key"
|
:key="x.key"
|
||||||
:title="x.name"
|
:title="x.name"
|
||||||
:value="x.name"
|
:value="x.name"
|
||||||
@@ -105,9 +88,7 @@
|
|||||||
>
|
>
|
||||||
<template v-slot:prepend>
|
<template v-slot:prepend>
|
||||||
<v-icon :icon="x.ico" size="17" />
|
<v-icon :icon="x.ico" size="17" />
|
||||||
<v-tooltip v-if="rail" activator="parent" location="top">{{
|
<v-tooltip v-if="rail" activator="parent" location="top">{{ x.name }}</v-tooltip>
|
||||||
x.name
|
|
||||||
}}</v-tooltip>
|
|
||||||
</template>
|
</template>
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
|
|
||||||
@@ -126,9 +107,7 @@
|
|||||||
class="fns-nav-item"
|
class="fns-nav-item"
|
||||||
rounded="lg"
|
rounded="lg"
|
||||||
>
|
>
|
||||||
<v-tooltip v-if="rail" activator="parent" location="top">{{
|
<v-tooltip v-if="rail" activator="parent" location="top">{{ x.name }}</v-tooltip>
|
||||||
x.name
|
|
||||||
}}</v-tooltip>
|
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
</template>
|
</template>
|
||||||
<v-list-item
|
<v-list-item
|
||||||
@@ -143,9 +122,7 @@
|
|||||||
class="fns-nav-item fns-nav-item--child"
|
class="fns-nav-item fns-nav-item--child"
|
||||||
rounded="lg"
|
rounded="lg"
|
||||||
>
|
>
|
||||||
<v-tooltip v-if="rail" activator="parent" location="top">{{
|
<v-tooltip v-if="rail" activator="parent" location="top">{{ child.name }}</v-tooltip>
|
||||||
child.name
|
|
||||||
}}</v-tooltip>
|
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
</v-list-group>
|
</v-list-group>
|
||||||
</template>
|
</template>
|
||||||
@@ -167,9 +144,7 @@
|
|||||||
>
|
>
|
||||||
<template v-slot:prepend>
|
<template v-slot:prepend>
|
||||||
<v-icon :icon="x.imagecode" size="17" />
|
<v-icon :icon="x.imagecode" size="17" />
|
||||||
<v-tooltip v-if="rail" activator="parent" location="top">{{
|
<v-tooltip v-if="rail" activator="parent" location="top">{{ x.name }}</v-tooltip>
|
||||||
x.name
|
|
||||||
}}</v-tooltip>
|
|
||||||
</template>
|
</template>
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
</v-list>
|
</v-list>
|
||||||
@@ -193,7 +168,7 @@
|
|||||||
</v-row>
|
</v-row>
|
||||||
</v-navigation-drawer>
|
</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 />
|
<router-view />
|
||||||
<alert-default />
|
<alert-default />
|
||||||
</v-main>
|
</v-main>
|
||||||
@@ -213,6 +188,7 @@
|
|||||||
>
|
>
|
||||||
<Online-users />
|
<Online-users />
|
||||||
</v-navigation-drawer>
|
</v-navigation-drawer>
|
||||||
|
|
||||||
</v-app>
|
</v-app>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -231,10 +207,9 @@ import PageCounter from '@/components/UI/defaultportal/page-counter.vue';
|
|||||||
import AdminMenu from '@/layouts/default/AdminMenu.vue';
|
import AdminMenu from '@/layouts/default/AdminMenu.vue';
|
||||||
import { useDisplay } from 'vuetify';
|
import { useDisplay } from 'vuetify';
|
||||||
import LoginPage from '../../views/LoginPage.vue';
|
import LoginPage from '../../views/LoginPage.vue';
|
||||||
import alertDefault from './alertDefault.vue';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: { LoginPage, AuthForm, OnlineUsers, CardLike, VcardUser, PageCounter, AdminMenu, alertDefault },
|
components: { LoginPage, AuthForm, OnlineUsers, CardLike, VcardUser, PageCounter, AdminMenu },
|
||||||
mixins: [uf],
|
mixins: [uf],
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
@@ -312,6 +287,8 @@ export default {
|
|||||||
ico: 'mdi-information-variant',
|
ico: 'mdi-information-variant',
|
||||||
path: '/portal',
|
path: '/portal',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const imageSrc = computed(() => {
|
const imageSrc = computed(() => {
|
||||||
@@ -323,25 +300,9 @@ export default {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
theme,
|
theme, mainmenuStore, accountStore, drawer, drawer_right, toggleTheme,
|
||||||
mainmenuStore,
|
navigations, imageSrc, LikeDialog, scrimg, rail, showTooltip,
|
||||||
accountStore,
|
menuTruncated, alert, burl, name, closeinfo, baseURL, message,
|
||||||
drawer,
|
|
||||||
drawer_right,
|
|
||||||
toggleTheme,
|
|
||||||
navigations,
|
|
||||||
imageSrc,
|
|
||||||
LikeDialog,
|
|
||||||
scrimg,
|
|
||||||
rail,
|
|
||||||
showTooltip,
|
|
||||||
menuTruncated,
|
|
||||||
alert,
|
|
||||||
burl,
|
|
||||||
name,
|
|
||||||
closeinfo,
|
|
||||||
baseURL,
|
|
||||||
message,
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -374,7 +335,7 @@ export default {
|
|||||||
transition: background var(--fns-transition);
|
transition: background var(--fns-transition);
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background: rgba(255, 255, 255, 0.1);
|
background: rgba(255, 255, 255, 0.10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -507,7 +468,7 @@ export default {
|
|||||||
padding: 3px 8px 3px 6px;
|
padding: 3px 8px 3px 6px;
|
||||||
font-size: 10px;
|
font-size: 10px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: rgba(255, 255, 255, 0.9);
|
color: rgba(255, 255, 255, 0.90);
|
||||||
letter-spacing: 0.04em;
|
letter-spacing: 0.04em;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -609,6 +570,7 @@ export default {
|
|||||||
gap: 14px;
|
gap: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Герб */
|
/* Герб */
|
||||||
.fns-login-emblem {
|
.fns-login-emblem {
|
||||||
width: 72px;
|
width: 72px;
|
||||||
@@ -653,7 +615,7 @@ export default {
|
|||||||
|
|
||||||
.fns-login-footer {
|
.fns-login-footer {
|
||||||
font-size: 10.5px;
|
font-size: 10.5px;
|
||||||
color: rgba(255, 255, 255, 0.4);
|
color: rgba(255, 255, 255, 0.40);
|
||||||
text-align: center;
|
text-align: center;
|
||||||
letter-spacing: 0.02em;
|
letter-spacing: 0.02em;
|
||||||
margin: 4px 0 0;
|
margin: 4px 0 0;
|
||||||
|
|||||||
@@ -1,26 +1,52 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-snackbar
|
<v-snackbar
|
||||||
v-model="isOpen"
|
|
||||||
:timeout="3000"
|
:timeout="3000"
|
||||||
:color="alert.color"
|
v-model="feedalert.alert"
|
||||||
|
:color="feedalert.color"
|
||||||
|
:icon="feedalert.ico"
|
||||||
|
|
||||||
|
|
||||||
>
|
>
|
||||||
<v-icon :icon="alert.ico" />
|
<v-icon :icon="feedalert.ico" />
|
||||||
<span class="pl-2 text-body-2">{{ alert.text }}</span>
|
|
||||||
|
<span class="pl-2 text-body-2">
|
||||||
|
{{ feedalert.text }}
|
||||||
|
</span>
|
||||||
|
|
||||||
</v-snackbar>
|
</v-snackbar>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script>
|
||||||
import { computed } from 'vue';
|
import { watch } from "vue";
|
||||||
import { storeToRefs } from 'pinia';
|
import { useAlertStore } from "@/store/UseAlertStore";
|
||||||
import { useAlertStore } from '@/store/UseAlertStore';
|
|
||||||
|
|
||||||
const alertStore = useAlertStore();
|
export default {
|
||||||
const { alert } = storeToRefs(alertStore);
|
name: "AlertDefault",
|
||||||
|
setup() {
|
||||||
|
const feedalert = useAlertStore().alert;
|
||||||
|
|
||||||
const isOpen = computed({
|
watch(
|
||||||
get: () => alert.value.alert,
|
|
||||||
set: (value) => {
|
() => feedalert,
|
||||||
if (!value) alertStore.hide();
|
() => {
|
||||||
|
setTimeout(function () {
|
||||||
|
feedalert.text = "";
|
||||||
|
feedalert.ico = "";
|
||||||
|
|
||||||
|
|
||||||
|
feedalert.color = "";
|
||||||
|
feedalert.alert = false;
|
||||||
|
}, 8000);
|
||||||
},
|
},
|
||||||
});
|
{ deep: true }
|
||||||
|
);
|
||||||
|
|
||||||
|
return {
|
||||||
|
feedalert,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style></style>
|
||||||
@@ -1,17 +1,16 @@
|
|||||||
import '@mdi/font/css/materialdesignicons.css'
|
import '@mdi/font/css/materialdesignicons.css';
|
||||||
import 'vuetify/styles'
|
import 'vuetify/styles';
|
||||||
// import { VCalendar } from 'vuetify/labs/VCalendar'
|
import { VCalendar } from 'vuetify/components';
|
||||||
|
|
||||||
import { createVuetify } from 'vuetify';
|
import { createVuetify } from 'vuetify';
|
||||||
import { ru } from 'vuetify/locale';
|
import { ru } from 'vuetify/locale';
|
||||||
|
|
||||||
export default createVuetify({
|
export default createVuetify({
|
||||||
|
|
||||||
locale: {
|
locale: {
|
||||||
messages: { ru },
|
messages: { ru },
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
// VCalendar,
|
VCalendar,
|
||||||
},
|
},
|
||||||
theme: {
|
theme: {
|
||||||
defaultTheme: 'light',
|
defaultTheme: 'light',
|
||||||
|
|||||||
@@ -1,32 +1,14 @@
|
|||||||
import { defineStore } from 'pinia';
|
import { defineStore } from 'pinia'
|
||||||
import { ref } from 'vue';
|
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 show = ({ text, ico = 'mdi-information-outline', color = '' }) => {
|
const alert = ref({ "alert": false,
|
||||||
alert.value = { alert: true, text, ico, color };
|
"text": '',
|
||||||
};
|
"ico": 'mdi-plus',
|
||||||
|
"color": ''
|
||||||
|
})
|
||||||
|
|
||||||
const showSuccess = (text) => {
|
return { alert }
|
||||||
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 };
|
|
||||||
});
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
import { axiosApiInstance } from "@/utils/axios-api";
|
|
||||||
import { defineStore } from "pinia";
|
|
||||||
import { ref } from "vue";
|
|
||||||
|
|
||||||
export const useWeekendsStore = defineStore("weekends", () => {
|
|
||||||
|
|
||||||
const week = ref({});
|
|
||||||
|
|
||||||
function getWeekend(year) {
|
|
||||||
axiosApiInstance
|
|
||||||
.get(`api/calendar_of_events/exclusion_dates/?year=${year}`, {})
|
|
||||||
.then((data) => {
|
|
||||||
week.value = data.data;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return { week, getWeekend };
|
|
||||||
});
|
|
||||||
Executable → Regular
+8
-47
@@ -19,14 +19,10 @@ export const useCalendarStore = defineStore('calendarStore', () => {
|
|||||||
const employees = ref([]);
|
const employees = ref([]);
|
||||||
|
|
||||||
const selectedEvent = ref(null);
|
const selectedEvent = ref(null);
|
||||||
const selectedEventForView = ref(null);
|
|
||||||
const showEventDialog = ref(false);
|
const showEventDialog = ref(false);
|
||||||
|
const selectedEventForView = ref(null);
|
||||||
const showViewDialog = ref(false);
|
const showViewDialog = ref(false);
|
||||||
|
|
||||||
const showCreateCalendarDialog = ref(false);
|
|
||||||
const createCalendarInitial = ref(null);
|
|
||||||
let createCalendarResolver = null;
|
|
||||||
|
|
||||||
// Массив ID скрытых календарей. Загружаем из localStorage при инициализации.
|
// Массив ID скрытых календарей. Загружаем из localStorage при инициализации.
|
||||||
const hiddenCalendarIds = ref([]);
|
const hiddenCalendarIds = ref([]);
|
||||||
|
|
||||||
@@ -296,8 +292,7 @@ export const useCalendarStore = defineStore('calendarStore', () => {
|
|||||||
const { data } = await axiosApiInstance.get(
|
const { data } = await axiosApiInstance.get(
|
||||||
`api/calendar_of_events/my_events/?id=${eventId}`,
|
`api/calendar_of_events/my_events/?id=${eventId}`,
|
||||||
);
|
);
|
||||||
selectedEventForView.value = data?.event ? data : { event: data };
|
selectedEventForView.value = data;
|
||||||
|
|
||||||
showViewDialog.value = true;
|
showViewDialog.value = true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Ошибка загрузки события:', error);
|
console.error('Ошибка загрузки события:', error);
|
||||||
@@ -311,59 +306,25 @@ export const useCalendarStore = defineStore('calendarStore', () => {
|
|||||||
|
|
||||||
const handleEventClick = (info) => {
|
const handleEventClick = (info) => {
|
||||||
const id = info.event?.id ?? info.id;
|
const id = info.event?.id ?? info.id;
|
||||||
if (id) {
|
if (canEditEvent(id)) {
|
||||||
|
openEventDialog(info);
|
||||||
|
} else {
|
||||||
openEventView(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 {
|
return {
|
||||||
// State
|
// State
|
||||||
selectedDate,
|
selectedDate,
|
||||||
events,
|
events,
|
||||||
selectedEvent,
|
selectedEvent,
|
||||||
selectedEventForView,
|
|
||||||
showEventDialog,
|
showEventDialog,
|
||||||
showViewDialog,
|
|
||||||
currentView,
|
currentView,
|
||||||
calendars,
|
calendars,
|
||||||
lastUpdatedBy,
|
lastUpdatedBy,
|
||||||
hiddenCalendarIds,
|
hiddenCalendarIds,
|
||||||
holidays,
|
holidays,
|
||||||
dictEmployeesLoaded,
|
dictEmployeesLoaded,
|
||||||
showCreateCalendarDialog,
|
|
||||||
createCalendarInitial,
|
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
formattedSelectedDate,
|
formattedSelectedDate,
|
||||||
@@ -396,8 +357,8 @@ export const useCalendarStore = defineStore('calendarStore', () => {
|
|||||||
loadDictEmployees,
|
loadDictEmployees,
|
||||||
loadEmployees,
|
loadEmployees,
|
||||||
setSelectedEvent,
|
setSelectedEvent,
|
||||||
editFromView,
|
|
||||||
requestCreateCalendar,
|
getEmptyEventWrapper,
|
||||||
resolveCreateCalendar,
|
buildEventWrapper,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
Regular → Executable
+3
-3
@@ -24,7 +24,7 @@
|
|||||||
class="flex-grow-1 ma-0"
|
class="flex-grow-1 ma-0"
|
||||||
style="min-height: 0; margin: 0;"
|
style="min-height: 0; margin: 0;"
|
||||||
>
|
>
|
||||||
<v-col cols="12" md="8" lg="6" class="d-flex flex-column" style="min-height: 0;">
|
<v-col cols="12" md="8" lg="6" class="d-flex flex-column pa-1" style="min-height: 0;">
|
||||||
<div class="modern-card flex-grow-1 d-flex flex-column" style="overflow: hidden;">
|
<div class="modern-card flex-grow-1 d-flex flex-column" style="overflow: hidden;">
|
||||||
<news-home />
|
<news-home />
|
||||||
</div>
|
</div>
|
||||||
@@ -32,10 +32,10 @@
|
|||||||
|
|
||||||
<v-col
|
<v-col
|
||||||
cols="12" md="4" lg="6"
|
cols="12" md="4" lg="6"
|
||||||
class="d-flex flex-column"
|
class="d-flex flex-column pa-0"
|
||||||
style="min-height: 0; margin: 0;"
|
style="min-height: 0; margin: 0;"
|
||||||
>
|
>
|
||||||
<div class="flex-grow-1 d-flex flex-column" style="overflow: hidden;">
|
<div class="flex-grow-1" style="overflow: hidden;">
|
||||||
<HomeCalendarWidget />
|
<HomeCalendarWidget />
|
||||||
</div>
|
</div>
|
||||||
</v-col>
|
</v-col>
|
||||||
|
|||||||
@@ -1,22 +1,20 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
# Загружаем переменные окружения
|
|
||||||
source ".env.base"
|
source ".env.base"
|
||||||
if [[ -f .env.local ]]; then
|
if [[ -f .env.local ]]; then
|
||||||
source ".env.local"
|
source ".env.local"
|
||||||
fi
|
fi
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
arg='db_backup.sql.gz'
|
||||||
|
else
|
||||||
|
arg="$1" # Если аргумент передан, используем его
|
||||||
|
fi
|
||||||
|
|
||||||
# Файл бэкапа – либо первый аргумент, либо значение по умолчанию
|
echo "Ожидаю выполнения Восстановления базы данных"
|
||||||
BACKUP_FILE="${1:-db_backup.sql.gz}"
|
until docker compose -f docker-compose.yml exec db sh -c "
|
||||||
|
gunzip < /backup/$arg | mysql -u ${DB_USER} -p${DB_PASSWORD} ${DB_NAME}"
|
||||||
echo "Ожидание готовности контейнера с БД..."
|
|
||||||
until docker compose -f docker-compose.yml exec -T db sh -c "
|
|
||||||
gunzip < /backup/$BACKUP_FILE | mysql -u ${DB_USER} -p${DB_PASSWORD} ${DB_NAME} 2>/dev/null
|
|
||||||
"
|
|
||||||
do
|
do
|
||||||
echo "Контейнер ещё не готов, повтор через 2 секунды..."
|
echo "Ожидаю выполнения Дампа"
|
||||||
sleep 2
|
sleep 2
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "База данных успешно восстановлена из $BACKUP_FILE"
|
|
||||||
Reference in new issue
Block a user