fix [P-304]: переделка компонентов от мутаций стора, переход на Pinia для диалогов
This commit is contained in:
1 parent
1f7dc86728
commit
27a2e3680b
12 files changed
+879
-1041
No files matched your search
@@ -22,25 +22,13 @@
|
|||||||
/>
|
/>
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col>
|
<v-col>
|
||||||
<v-text-field
|
<v-text-field v-model="form.tel" :counter="7" :rules="rules.tel" label="Телефон" />
|
||||||
v-model="form.tel"
|
|
||||||
:counter="7"
|
|
||||||
:rules="rules.tel"
|
|
||||||
label="Телефон"
|
|
||||||
/>
|
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
<v-textarea
|
<v-textarea v-model="form.text" no-resize rows="4" label="Сопроводительное письмо" />
|
||||||
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 block type="submit" class="mt-4 text-none" color="btn_text"> Отправить </v-btn>
|
||||||
Отправить
|
|
||||||
</v-btn>
|
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
</v-form>
|
</v-form>
|
||||||
@@ -48,77 +36,60 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script setup>
|
||||||
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';
|
||||||
|
|
||||||
export default {
|
const props = defineProps({
|
||||||
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 req = (val) => {
|
const alertStore = useAlertStore();
|
||||||
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) => req(val),
|
(val) => !!val || 'Поле обязательно',
|
||||||
(val) =>
|
(val) => /^[а-яА-ЯЁё ]+$/.test(val) || 'Имя должно содержать русские буквы',
|
||||||
val.match(/^[а-яА-ЯЁё ]+$/) !== null || "Имя должно содержать русские буквы",
|
|
||||||
],
|
],
|
||||||
email: [(val) => req(val)],
|
email: [(val) => !!val || 'Поле обязательно'],
|
||||||
tel: [
|
tel: [
|
||||||
(val) => req(val),
|
(val) => !!val || 'Поле обязательно',
|
||||||
(val) => val.match(/^[[\d-]*\d[\d-]*$/) !== null || "Номер должен содержать цифры",
|
(val) => /^[\d-]+$/.test(val) || 'Номер должен содержать только цифры и дефисы',
|
||||||
],
|
],
|
||||||
text: "",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const file = ref(null);
|
const submit = async () => {
|
||||||
const form_vacancies = ref(null)
|
const { valid } = await form_vacancies.value.validate();
|
||||||
|
if (!valid) return;
|
||||||
const submit = () => {
|
|
||||||
|
|
||||||
if(form_vacancies.value.isValid) {
|
|
||||||
|
|
||||||
|
|
||||||
const postFile = new FormData();
|
const postFile = new FormData();
|
||||||
postFile.append(
|
postFile.append('data', JSON.stringify({ ...form.value, vacancy_id: props.idVacations }));
|
||||||
"data",
|
|
||||||
JSON.stringify({ ...form.value, vacancy_id: props.idVacations })
|
|
||||||
);
|
|
||||||
if (file.value !== null) {
|
|
||||||
|
|
||||||
postFile.append("file", file.value[0]);
|
if (file.value) {
|
||||||
|
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);
|
||||||
|
|
||||||
clearAxios
|
form.value = { fio: '', email: '', tel: '', text: '' };
|
||||||
.post(`api/about_inspection/postresponsevacancy/`, postFile)
|
file.value = null;
|
||||||
.then((data) => {
|
form_vacancies.value.resetValidation();
|
||||||
feedalert.alert = true;
|
} catch (e) {
|
||||||
feedalert.text = data.data;
|
alertStore.showError('Не удалось отправить отклик');
|
||||||
feedalert.color = "teal-lighten-4";
|
console.error(e);
|
||||||
feedalert.ico = "mdi-email-outline";
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
|
||||||
form,
|
|
||||||
file,
|
|
||||||
rules,
|
|
||||||
submit,
|
|
||||||
form_vacancies
|
|
||||||
};
|
|
||||||
},
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
@@ -5,7 +5,6 @@
|
|||||||
@postData="postData"
|
@postData="postData"
|
||||||
@closeDialog="$emit('closeDialog')"
|
@closeDialog="$emit('closeDialog')"
|
||||||
@delObject="delEvent(propsEvent?.event?.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">
|
||||||
@@ -30,8 +29,9 @@
|
|||||||
<v-col>
|
<v-col>
|
||||||
<calendar-create-select
|
<calendar-create-select
|
||||||
:staff="newStaff"
|
:staff="newStaff"
|
||||||
@returnIdParticant="returnIdParticant"
|
:selectedIds="selectedIds"
|
||||||
:authorID="currentCalendarAuthorId"
|
:authorID="currentCalendarAuthorId"
|
||||||
|
@change="onParticipantsChange"
|
||||||
/> </v-col
|
/> </v-col
|
||||||
></v-row>
|
></v-row>
|
||||||
|
|
||||||
@@ -71,12 +71,10 @@
|
|||||||
<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>
|
</v-autocomplete> </v-col
|
||||||
</v-col></v-row
|
></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">
|
||||||
@@ -185,14 +183,13 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, nextTick, onMounted, ref, watch } from 'vue';
|
import { computed, nextTick, 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';
|
||||||
@@ -209,17 +206,14 @@ const emit = defineEmits(['update:eventCalendar', 'getCalendar', 'closeDialog'])
|
|||||||
|
|
||||||
const accountStore = useAccountStore();
|
const accountStore = useAccountStore();
|
||||||
const calendarStore = useCalendarStore();
|
const calendarStore = useCalendarStore();
|
||||||
const createDialog = ref(null);
|
const alertStore = useAlertStore();
|
||||||
|
|
||||||
|
const selectedIds = ref(new Set());
|
||||||
|
|
||||||
const { parseRecurrenceOptions, isRecurringEvent } = useRecurrence();
|
const { parseRecurrenceOptions, isRecurringEvent } = useRecurrence();
|
||||||
|
const { requestCreateCalendar } = calendarStore;
|
||||||
|
|
||||||
const propsEvent = computed({
|
const propsEvent = computed(() => props.eventCalendar);
|
||||||
get: () => {
|
|
||||||
return props.eventCalendar;
|
|
||||||
},
|
|
||||||
|
|
||||||
set: (value) => emit('update:eventCalendar', value),
|
|
||||||
});
|
|
||||||
|
|
||||||
const currentCalendarAuthorId = computed(() => {
|
const currentCalendarAuthorId = computed(() => {
|
||||||
if (isNewEvent.value) {
|
if (isNewEvent.value) {
|
||||||
@@ -229,77 +223,34 @@ const currentCalendarAuthorId = computed(() => {
|
|||||||
// Для существующего события - автор календаря события
|
// Для существующего события - автор календаря события
|
||||||
const eventCalendarId = propsEvent.value.event.calendar;
|
const eventCalendarId = propsEvent.value.event.calendar;
|
||||||
const currentCalendar = propsEvent.value.mycalendars?.find(
|
const currentCalendar = propsEvent.value.mycalendars?.find(
|
||||||
(cal) => parseInt(cal.id) === parseInt(eventCalendarId),
|
(cal) => Number(cal.id) === Number(eventCalendarId),
|
||||||
);
|
);
|
||||||
return currentCalendar?.author;
|
return currentCalendar?.author;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const newStaff = computed({
|
const newStaff = computed(() => {
|
||||||
get() {
|
const calendarSource = isNewEvent.value
|
||||||
let filteredStaff = [];
|
? myCalendar.value
|
||||||
|
: propsEvent.value.mycalendars?.find(
|
||||||
if (isNewEvent.value) {
|
(cal) => Number(cal.id) === Number(propsEvent.value.event.calendar),
|
||||||
if (myCalendar.value == null) return [];
|
|
||||||
const participants = myCalendar.value.participant || [];
|
|
||||||
const calendarParticipantIds = new Set(participants.map((p) => p.participant_calendar));
|
|
||||||
|
|
||||||
// Мутируем И фильтруем для НОВОГО события
|
|
||||||
filteredStaff = calendarStore.employees
|
|
||||||
.map((department) => {
|
|
||||||
// ФИЛЬТРУЕМ сотрудников - оставляем только тех, кто в календаре
|
|
||||||
const filteredEmployees = department.employees.filter((employee) =>
|
|
||||||
calendarParticipantIds.has(employee.id),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// МУТАЦИЯ: устанавливаем selected=true для отфильтрованных сотрудников
|
if (!calendarSource) return [];
|
||||||
filteredEmployees.forEach((employee) => {
|
|
||||||
employee.selected = true;
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
const allowedIds = new Set(
|
||||||
...department,
|
(calendarSource.participant ?? []).map((p) =>
|
||||||
employees: filteredEmployees,
|
isNewEvent.value ? p.participant_calendar : p.id,
|
||||||
};
|
),
|
||||||
})
|
);
|
||||||
|
|
||||||
|
if (!allowedIds.size) return [];
|
||||||
|
return calendarStore.employees
|
||||||
|
.map((dept) => ({
|
||||||
|
...dept,
|
||||||
|
employees: dept.employees.filter((e) => allowedIds.has(e.id)),
|
||||||
|
}))
|
||||||
.filter((dept) => dept.employees.length > 0);
|
.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;
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// ВАЛИДАЦИЯ
|
// ВАЛИДАЦИЯ
|
||||||
@@ -442,35 +393,18 @@ const isRepeatEndDisabled = computed(() => {
|
|||||||
return !selectedRule.value.rule; // disabled если правило null (не повторять)
|
return !selectedRule.value.rule; // disabled если правило null (не повторять)
|
||||||
});
|
});
|
||||||
|
|
||||||
const feedalert = useAlertStore().alert;
|
|
||||||
|
|
||||||
const titleCard = computed(() => {
|
const titleCard = computed(() =>
|
||||||
if (propsEvent.value.event.hasOwnProperty('id')) {
|
'id' in propsEvent.value.event ? 'Редактирование события' : 'Новое событие',
|
||||||
return 'Редактирование события';
|
);
|
||||||
} else {
|
|
||||||
return 'Новое событие';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const isNewEvent = computed(() => !propsEvent.value.event.hasOwnProperty('id'));
|
const isNewEvent = computed(() => !('id' in propsEvent.value.event));
|
||||||
|
|
||||||
const myCalendar = ref(null);
|
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) => {
|
|
||||||
// // Пользователь - автор календаря (полные права)
|
|
||||||
// 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) => {
|
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);
|
||||||
@@ -487,74 +421,39 @@ const safeCalendars = computed(() => {
|
|||||||
return filtered;
|
return filtered;
|
||||||
});
|
});
|
||||||
|
|
||||||
const isCalendarsReady = computed(() => safeCalendars.value.length > 0);
|
|
||||||
|
|
||||||
// Computed для календаря события
|
|
||||||
const eventCalendar = computed(() => {
|
|
||||||
if (!propsEvent.value?.event?.calendar || !safeCalendars.value.length) return null;
|
|
||||||
return safeCalendars.value.find((cal) => cal.id === propsEvent.value.event.calendar);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Единоразовая инициализация при монтировании/получении данных
|
|
||||||
const initializeCalendar = () => {
|
const initializeCalendar = () => {
|
||||||
if (myCalendar.value) return; // Уже инициализирован
|
if (myCalendar.value) return;
|
||||||
|
|
||||||
// Приоритет 1: календарь из события (редактирование)
|
const fromEvent = propsEvent.value?.event?.calendar
|
||||||
if (eventCalendar.value) {
|
? safeCalendars.value.find((cal) => cal.id === propsEvent.value.event.calendar)
|
||||||
myCalendar.value = eventCalendar.value;
|
: null;
|
||||||
|
|
||||||
|
if (fromEvent) {
|
||||||
|
myCalendar.value = fromEvent;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Приоритет 2: первый доступный календарь (создание)
|
|
||||||
if (safeCalendars.value.length > 0) {
|
|
||||||
// myCalendar.value = safeCalendars.value[0];
|
|
||||||
const firstRealCalendar = safeCalendars.value.find((cal) => cal.id !== 'create_new');
|
const firstRealCalendar = safeCalendars.value.find((cal) => cal.id !== 'create_new');
|
||||||
if (firstRealCalendar) {
|
if (firstRealCalendar) myCalendar.value = firstRealCalendar;
|
||||||
myCalendar.value = firstRealCalendar;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Инициализируем когда все готово
|
|
||||||
watch(
|
|
||||||
[() => safeCalendars.value.length, () => propsEvent.value],
|
|
||||||
(newCalendar) => {
|
|
||||||
initializeCalendar();
|
|
||||||
},
|
|
||||||
{ immediate: true, deep: true },
|
|
||||||
);
|
|
||||||
|
|
||||||
// Дополнительная защита - вотчер только на смену самого календаря
|
|
||||||
watch(eventCalendar, (newCalendar) => {
|
|
||||||
if (newCalendar && newCalendar.id !== myCalendar.value?.id) {
|
|
||||||
myCalendar.value = newCalendar;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const delEvent = async (idev) => {
|
const delEvent = async (idev) => {
|
||||||
try {
|
try {
|
||||||
const result = await axiosApiInstance.delete(`api/calendar_of_events/my_events/?delid=${idev}`)
|
const result = await axiosApiInstance.delete(`api/calendar_of_events/my_events/?delid=${idev}`);
|
||||||
feedalert.alert = true
|
alertStore.showSuccess(result.data.mess)
|
||||||
feedalert.text = result.data.mess
|
emit('getCalendar');
|
||||||
feedalert.ico = 'mdi-check'
|
emit('closeDialog');
|
||||||
feedalert.color = 'orange-accent-1'
|
|
||||||
emit('getCalendar')
|
|
||||||
emit('closeDialog')
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Ошибка удаления события:', e);
|
alertStore.showError('Ошибка удаления события');
|
||||||
|
console.error(e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const newFiles = ref([]);
|
const newFiles = ref([]);
|
||||||
|
|
||||||
const handleFilesUpdate = (updatedExistingFiles) => {
|
const handleFilesUpdate = (updatedExistingFiles) => {
|
||||||
// Сохраняем новые файлы во временную переменную
|
|
||||||
const currentNewFiles = [...newFiles.value];
|
const currentNewFiles = [...newFiles.value];
|
||||||
|
|
||||||
// Обновляем существующие файлы
|
|
||||||
propsEvent.value.event.files = updatedExistingFiles;
|
propsEvent.value.event.files = updatedExistingFiles;
|
||||||
|
|
||||||
// Восстанавливаем новые файлы
|
|
||||||
newFiles.value = currentNewFiles;
|
newFiles.value = currentNewFiles;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -562,31 +461,25 @@ const postFiles = (updatedFiles) => {
|
|||||||
newFiles.value = updatedFiles;
|
newFiles.value = updatedFiles;
|
||||||
};
|
};
|
||||||
|
|
||||||
const returnIdParticant = (idPart) => {
|
const onParticipantsChange = ({ ids, action }) => {
|
||||||
idPart.staff.forEach((e) => {
|
const next = new Set(selectedIds.value);
|
||||||
if (e.selected == true && !propsEvent.value.event.participant.includes(e.id)) {
|
|
||||||
propsEvent.value.event.participant.push(e.id);
|
|
||||||
} else {
|
|
||||||
let ind = propsEvent.value.event.participant.findIndex((l) => l == e.id);
|
|
||||||
|
|
||||||
if (ind != -1) {
|
ids.forEach((id) => {
|
||||||
propsEvent.value.event.participant.splice(ind, 1);
|
if (action === 'add') {
|
||||||
}
|
next.add(id);
|
||||||
|
} else if (action === 'remove') {
|
||||||
|
next.delete(id);
|
||||||
|
} else if (action === 'toggle') {
|
||||||
|
if (next.has(id)) next.delete(id);
|
||||||
|
else next.add(id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
|
||||||
|
|
||||||
const cbSelect = (item, arr) => {
|
// Автор всегда участник
|
||||||
item.forEach((e) => {
|
next.add(accountStore.user.is_idEmployee);
|
||||||
if (!('employees' in e)) {
|
|
||||||
if (!propsEvent.value.event.participant.includes(e.id)) {
|
selectedIds.value = next;
|
||||||
propsEvent.value.event.participant.push(e.id);
|
propsEvent.value.event.participant = Array.from(next);
|
||||||
}
|
|
||||||
}
|
|
||||||
if ('employees' in e) {
|
|
||||||
cbSelect(e.employees);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const postData = async (validate) => {
|
const postData = async (validate) => {
|
||||||
@@ -610,14 +503,15 @@ const postData = async (validate) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
axiosApiInstance.post('api/calendar_of_events/my_events/', postEvent).then((result) => {
|
try {
|
||||||
feedalert.alert = true;
|
const result = await axiosApiInstance.post('api/calendar_of_events/my_events/', postEvent);
|
||||||
feedalert.text = result.data.mess;
|
console.log(alertStore)
|
||||||
feedalert.ico = 'mdi-check';
|
alertStore.showSuccess(result.data.mess);
|
||||||
feedalert.color = 'green-darken-4';
|
|
||||||
emit('getCalendar');
|
emit('getCalendar');
|
||||||
emit('closeDialog');
|
emit('closeDialog');
|
||||||
});
|
} catch (e) {
|
||||||
|
alertStore.showError('Ошибка сохранения события');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -728,39 +622,89 @@ watch(
|
|||||||
{ immediate: true },
|
{ immediate: true },
|
||||||
);
|
);
|
||||||
|
|
||||||
watch([safeCalendars, myCalendar], (newCalendar) => {}, { deep: true, immediate: true });
|
async function handleCalendarSelect(calendar) {
|
||||||
|
if (calendar.id !== 'create_new') {
|
||||||
function handleCalendarSelect(calendar) {
|
myCalendar.value = calendar;
|
||||||
if (calendar.id === 'create_new') {
|
return;
|
||||||
if (window.$createCalendar) {
|
}
|
||||||
// Запоминаем максимальный ID до создания
|
// Запоминаем id существующих календарей ДО создания
|
||||||
const maxIdBefore = Math.max(
|
const idsBefore = new Set(
|
||||||
...safeCalendars.value.filter((cal) => cal.id !== 'create_new').map((cal) => cal.id),
|
safeCalendars.value.filter((cal) => cal.id !== 'create_new').map((cal) => cal.id),
|
||||||
);
|
);
|
||||||
|
// Открываем диалог создания через store и ждём результат
|
||||||
|
const created = await requestCreateCalendar();
|
||||||
|
if (!created) return; // отменили создание
|
||||||
|
|
||||||
window.$createCalendar();
|
// Просим родителя обновить список календарей
|
||||||
|
emit('getCalendar');
|
||||||
|
// Ждём, пока allCalendars обновится и появится новый календарь
|
||||||
|
await waitForNewCalendar(idsBefore);
|
||||||
|
}
|
||||||
|
|
||||||
// Следим за появлением календаря с ID больше максимального
|
function waitForNewCalendar(idsBefore, timeoutMs = 5000) {
|
||||||
const unwatch = watch(
|
return new Promise((resolve) => {
|
||||||
|
// Вдруг уже появился (getCalendar отработал синхронно)
|
||||||
|
const checkNow = safeCalendars.value.find(
|
||||||
|
(cal) => cal.id !== 'create_new' && !idsBefore.has(cal.id),
|
||||||
|
);
|
||||||
|
if (checkNow) {
|
||||||
|
myCalendar.value = checkNow;
|
||||||
|
resolve(checkNow);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const stop = watch(
|
||||||
safeCalendars,
|
safeCalendars,
|
||||||
(newCalendars) => {
|
(list) => {
|
||||||
const realCalendars = newCalendars.filter((cal) => cal.id !== 'create_new');
|
const fresh = list.find((cal) => cal.id !== 'create_new' && !idsBefore.has(cal.id));
|
||||||
const newCalendar = realCalendars.find((cal) => cal.id > maxIdBefore);
|
if (fresh) {
|
||||||
|
myCalendar.value = fresh;
|
||||||
if (newCalendar) {
|
stop();
|
||||||
myCalendar.value = newCalendar;
|
clearTimeout(timer);
|
||||||
unwatch();
|
resolve(fresh);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ deep: true },
|
{ deep: true },
|
||||||
);
|
);
|
||||||
|
|
||||||
setTimeout(() => unwatch(), 5000);
|
const timer = setTimeout(() => {
|
||||||
|
stop();
|
||||||
|
resolve(null);
|
||||||
|
}, timeoutMs);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
watch(
|
||||||
myCalendar.value = calendar;
|
[myCalendar, () => propsEvent.value?.event?.id],
|
||||||
|
() => {
|
||||||
|
if (isNewEvent.value) {
|
||||||
|
const participantIds = (myCalendar.value?.participant ?? []).map(
|
||||||
|
(p) => p.participant_calendar,
|
||||||
|
);
|
||||||
|
|
||||||
|
const ids = new Set([accountStore.user.is_idEmployee, ...participantIds]);
|
||||||
|
|
||||||
|
selectedIds.value = ids;
|
||||||
|
propsEvent.value.event.participant = Array.from(ids);
|
||||||
|
} else {
|
||||||
|
const ids = propsEvent.value.event.participant ?? [];
|
||||||
|
selectedIds.value = new Set([accountStore.user.is_idEmployee, ...ids]);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{ immediate: true },
|
||||||
|
);
|
||||||
|
|
||||||
|
watch(
|
||||||
|
[
|
||||||
|
() => safeCalendars.value.length,
|
||||||
|
() => propsEvent.value?.event?.calendar,
|
||||||
|
() => propsEvent.value?.event?.id,
|
||||||
|
],
|
||||||
|
() => {
|
||||||
|
initializeCalendar();
|
||||||
|
},
|
||||||
|
{ immediate: true },
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
@@ -1,24 +1,20 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<!-- -->
|
|
||||||
|
|
||||||
<v-autocomplete
|
<v-autocomplete
|
||||||
v-model="selectedStaff"
|
v-model="selectedItems"
|
||||||
:items="staffed"
|
:items="visibleDepartments"
|
||||||
label="Выберите из списка или найдите по ФИО"
|
label="Выберите из списка или найдите по ФИО"
|
||||||
item-title="title"
|
item-title="title"
|
||||||
item-value="id"
|
item-value="id"
|
||||||
:search-input.sync="filtered"
|
@update:search="(val) => (searchQuery = val ?? '')"
|
||||||
@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="customFilterFn"
|
:custom-filter="searchInDepartment"
|
||||||
>
|
>
|
||||||
<!-- :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>
|
||||||
@@ -27,420 +23,305 @@
|
|||||||
icon="mdi-close-circle"
|
icon="mdi-close-circle"
|
||||||
size="x-small"
|
size="x-small"
|
||||||
class="ml-3"
|
class="ml-3"
|
||||||
@click.stop="selectedStaff = item.raw"
|
@click.stop="selectedItems = 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="staffed.length == 1 && staffed[0].employees.length == 1"
|
:disabled="isOnlyOneEmployee"
|
||||||
class="text-body-2"
|
class="text-body-2"
|
||||||
@click.stop="allUser()"
|
@click.stop="toggleAllEmployees"
|
||||||
>
|
>
|
||||||
<span class="text-body-2">ВСЕ СОТРУДНИКИ</span>
|
<span class="text-body-2">ВСЕ СОТРУДНИКИ</span>
|
||||||
|
|
||||||
<template v-slot:prepend>
|
<template v-slot:prepend>
|
||||||
<v-checkbox-btn
|
<v-checkbox-btn :model-value="areAllSelected" :disabled="isOnlyOneEmployee" />
|
||||||
: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('начальник')"
|
@click.stop="toggleByPosition('boss')"
|
||||||
>
|
>
|
||||||
<span class="text-body-2">ВСЕ НАЧАЛЬНИКИ</span>
|
<span class="text-body-2">ВСЕ НАЧАЛЬНИКИ</span>
|
||||||
<template v-slot:prepend>
|
<template v-slot:prepend>
|
||||||
<v-checkbox-btn
|
<v-checkbox-btn :model-value="areAllBossesSelected" :disabled="!hasBossesInStaff" />
|
||||||
: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('заместитель')"
|
@click.stop="toggleByPosition('deputy')"
|
||||||
>
|
>
|
||||||
<span class="text-body-2">ВСЕ ЗАМЕСТИТЕЛИ</span>
|
<span class="text-body-2">ВСЕ ЗАМЕСТИТЕЛИ</span>
|
||||||
<template v-slot:prepend>
|
<template v-slot:prepend>
|
||||||
<v-checkbox-btn
|
<v-checkbox-btn :model-value="areAllDeputiesSelected" :disabled="!hasDeputiesInStaff" />
|
||||||
: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, item }">
|
<template v-slot:item="{ props: itemProps, item }">
|
||||||
<v-list-group v-bind="props" :value="item.raw.title">
|
<v-list-group v-bind="itemProps" :value="item.raw.title">
|
||||||
<template v-slot:activator="{ props }">
|
<template v-slot:activator="{ props: activatorProps }">
|
||||||
<v-list-item v-bind="props" @click.stop="" density="compact" class="text-body-2">
|
<v-list-item v-bind="activatorProps" density="compact" class="text-body-2" @click.stop>
|
||||||
<template v-slot:prepend>
|
<template v-slot:prepend>
|
||||||
<v-checkbox-btn
|
<v-checkbox-btn
|
||||||
@click.stop="selectedStaff = item.raw"
|
color="indigo-darken-4"
|
||||||
:color="'indigo-darken-4'"
|
|
||||||
:true-value="true"
|
:true-value="true"
|
||||||
:false-value="false"
|
:false-value="false"
|
||||||
:disabled="disable(item.raw) || isAuthor(item.raw)"
|
:disabled="isDepartmentLocked(item.raw)"
|
||||||
:indeterminate="
|
:indeterminate="isDepartmentIndeterminate(item.raw)"
|
||||||
item.raw.employees.some((e) => e[okey] == true) &&
|
:model-value="isSelected(item.raw)"
|
||||||
!item.raw.employees.every((e) => e[okey] == true)
|
@click.stop="selectedItems = item.raw"
|
||||||
"
|
/>
|
||||||
: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="x in item.raw.employees.filter((e) =>
|
v-for="employee in filterEmployees(item.raw.employees)"
|
||||||
e.title.toLowerCase().includes(filtered.toLowerCase()),
|
:key="employee.id"
|
||||||
)"
|
: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(x)"
|
:disabled="isAuthor(employee)"
|
||||||
color="indigo-darken-4"
|
color="indigo-darken-4"
|
||||||
:model-value="x[okey]"
|
:model-value="isSelected(employee)"
|
||||||
></v-checkbox-btn>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<span class="text-body-2"> {{ x.title }} </span>
|
<span class="text-body-2">{{ employee.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>
|
<script setup>
|
||||||
import { ref, computed } from 'vue';
|
import { computed, ref } 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';
|
||||||
|
|
||||||
export default {
|
const props = defineProps({
|
||||||
props: {
|
|
||||||
staff: {
|
staff: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: () => [],
|
default: () => [],
|
||||||
},
|
},
|
||||||
okey: {
|
mode: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'selected',
|
default: 'participants',
|
||||||
|
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,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
setup(props, { emit }) {
|
const emit = defineEmits(['change']);
|
||||||
const filtered = ref('');
|
|
||||||
|
|
||||||
const accountStore = useAccountStore();
|
const accountStore = useAccountStore();
|
||||||
const calendarStore = useCalendarStore();
|
const calendarStore = useCalendarStore();
|
||||||
const { dictEmployeesLoaded } = storeToRefs(calendarStore);
|
|
||||||
|
|
||||||
const back = ref([]);
|
const searchQuery = ref('');
|
||||||
|
|
||||||
const staffed = computed({
|
const isSelected = (item) => {
|
||||||
get() {
|
if ('employees' in item) {
|
||||||
if (props.okey == 'editor') {
|
if (item.employees.length === 0) return false;
|
||||||
let ns = [];
|
return item.employees.every((e) => isSelected(e));
|
||||||
props.staff.forEach((e) => {
|
|
||||||
let emp = { ...e };
|
|
||||||
emp.employees = e.employees.filter(
|
|
||||||
(n) => n.selected == true || n.isCurrentUser == true,
|
|
||||||
);
|
|
||||||
if (emp.employees.length > 0) ns.push(emp);
|
|
||||||
});
|
|
||||||
|
|
||||||
ns.forEach((e) => {
|
|
||||||
if (e.employees.every((w) => w.editor == true)) {
|
|
||||||
e.editor = true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return ns;
|
|
||||||
}
|
|
||||||
|
|
||||||
return props.staff;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const selectedStaff = computed({
|
|
||||||
get() {
|
|
||||||
let selected = [];
|
|
||||||
props.staff.forEach((e) => {
|
|
||||||
if (e.employees.length != 1 && e.employees.every((n) => n[props.okey] == true)) {
|
|
||||||
e[props.okey] = true;
|
|
||||||
selected.push(e);
|
|
||||||
} else if (e.employees.length == 1) {
|
|
||||||
const singleEmployee = e.employees[0];
|
|
||||||
if (singleEmployee[props.okey] === true) {
|
|
||||||
selected.push(singleEmployee);
|
|
||||||
}
|
|
||||||
// Состояние отдела должно вычисляться на основе сотрудника
|
|
||||||
e[props.okey] = singleEmployee[props.okey] === true;
|
|
||||||
// e[props.okey] = true;
|
|
||||||
// selected.push(...e.employees.filter((n) => n[props.okey] == true));
|
|
||||||
} else {
|
|
||||||
e[props.okey] = false;
|
|
||||||
selected.push(...e.employees.filter((n) => n[props.okey] == true));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return selected;
|
|
||||||
},
|
|
||||||
|
|
||||||
set(item) {
|
|
||||||
// Если нажимать на пользователя с disable, то срабатывает
|
|
||||||
// set и отправляет данные которые не нужны, но выдает только в виде массива.
|
|
||||||
// Остальные данные передаются объектом, кроме выбора ВСЕХ ПОЛЬЗОВАТЕЛЕЙ, для него написан отдельный клик на обработку
|
|
||||||
// Таким образом предотсвращаем клик на автокомплид (хз понятно или нет)
|
|
||||||
if (!Array.isArray(item)) {
|
|
||||||
emitUp(item);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const emitUp = (part) => {
|
|
||||||
if ('employees' in part) {
|
|
||||||
part.employees.forEach((e) => {
|
|
||||||
if (e.id != accountStore.user.is_idEmployee) {
|
|
||||||
e[props.okey] = !part[props.okey];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
emit('returnIdParticant', {
|
|
||||||
okey: props.okey,
|
|
||||||
staff: part.employees,
|
|
||||||
select: [],
|
|
||||||
});
|
|
||||||
} else if (part.length) {
|
|
||||||
if (part[0].id != accountStore.user.is_idEmployee) {
|
|
||||||
let val = part.every((e) => e[props.okey] == true) ? false : true;
|
|
||||||
cbstaff(part, val);
|
|
||||||
emit('returnIdParticant', {
|
|
||||||
okey: props.okey,
|
|
||||||
staff: back.value,
|
|
||||||
select: [],
|
|
||||||
});
|
|
||||||
back.value = [];
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
part[props.okey] = !part[props.okey];
|
|
||||||
emit('returnIdParticant', {
|
|
||||||
okey: props.okey,
|
|
||||||
staff: [part],
|
|
||||||
select: [],
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
const targetSet = props.mode === 'editors' ? props.editorIds : props.selectedIds;
|
||||||
|
return targetSet?.has(item.id) ?? false;
|
||||||
};
|
};
|
||||||
|
|
||||||
const cbstaff = (item, value) => {
|
const visibleDepartments = computed(() => {
|
||||||
item.forEach((e) => {
|
if (props.mode !== 'editors') return props.staff;
|
||||||
if (e.id !== accountStore.user.is_idEmployee) {
|
|
||||||
e[props.okey] = value;
|
const isInParticipants = (employee) => props.selectedIds?.has(employee.id) ?? false;
|
||||||
}
|
return props.staff
|
||||||
if (!('employees' in e)) {
|
.map((dept) => ({
|
||||||
back.value.push(e);
|
...dept,
|
||||||
}
|
employees: dept.employees.filter(isInParticipants),
|
||||||
if ('employees' in e) {
|
}))
|
||||||
cbstaff(e.employees, value);
|
.filter((dept) => dept.employees.length > 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
const selectedItems = computed({
|
||||||
|
get() {
|
||||||
|
const chips = [];
|
||||||
|
props.staff.forEach((dept) => {
|
||||||
|
if (dept.employees.length > 1 && isSelected(dept)) {
|
||||||
|
chips.push(dept);
|
||||||
|
} else if (dept.employees.length === 1) {
|
||||||
|
const only = dept.employees[0];
|
||||||
|
if (isSelected(only)) chips.push(only);
|
||||||
|
} else {
|
||||||
|
chips.push(...dept.employees.filter((e) => isSelected(e)));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
return chips;
|
||||||
|
},
|
||||||
|
set(value) {
|
||||||
|
if (!Array.isArray(value)) {
|
||||||
|
emitChange(value);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const emitChange = (item) => {
|
||||||
|
// Клик по отделу
|
||||||
|
if ('employees' in item) {
|
||||||
|
const wasSelected = isSelected(item);
|
||||||
|
const action = wasSelected ? 'remove' : 'add';
|
||||||
|
const ids = item.employees.filter((e) => e.id !== props.authorID).map((e) => e.id);
|
||||||
|
|
||||||
|
if (ids.length) emit('change', { ids, action });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Массив (групповые операции типа "Все сотрудники")
|
||||||
|
if (Array.isArray(item)) {
|
||||||
|
if (!item.length) return;
|
||||||
|
|
||||||
|
// Собираем плоский список всех сотрудников из массива департаментов
|
||||||
|
const allEmployees = [];
|
||||||
|
item.forEach((entry) => {
|
||||||
|
if ('employees' in entry) {
|
||||||
|
allEmployees.push(...entry.employees);
|
||||||
|
} else {
|
||||||
|
allEmployees.push(entry);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const targets = allEmployees.filter((e) => e.id !== props.authorID);
|
||||||
|
if (!targets.length) return;
|
||||||
|
|
||||||
|
const wasAllSelected = targets.every((e) => isSelected(e));
|
||||||
|
const action = wasAllSelected ? 'remove' : 'add';
|
||||||
|
const ids = targets.map((e) => e.id);
|
||||||
|
|
||||||
|
emit('change', { ids, action });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Клик по отдельному сотруднику
|
||||||
|
if (item.id === props.authorID) return;
|
||||||
|
emit('change', { ids: [item.id], action: 'toggle' });
|
||||||
};
|
};
|
||||||
|
|
||||||
const customFilterFn = (item, queryText, itemText) => {
|
const searchInDepartment = (_value, queryText, item) => {
|
||||||
if (!queryText) return true;
|
if (!queryText) return true;
|
||||||
|
const query = queryText.toLowerCase();
|
||||||
|
const target = item.raw ?? item;
|
||||||
|
|
||||||
const searchText = queryText.toLowerCase();
|
const dept = visibleDepartments.value.find((d) => d.title === target.title) ?? target;
|
||||||
const target = item.raw || item;
|
return dept.employees?.some((e) => e.title?.toLowerCase().includes(query)) ?? false;
|
||||||
|
|
||||||
// Создаем Map для быстрого поиска отделов по названию
|
|
||||||
const departmentMap = new Map(staffed.value.map((dept) => [dept.title, dept]));
|
|
||||||
|
|
||||||
let department;
|
|
||||||
|
|
||||||
if (typeof target === 'string') {
|
|
||||||
// Ищем отдел по названию
|
|
||||||
department = departmentMap.get(target);
|
|
||||||
} else if (target.title) {
|
|
||||||
// Уже имеем объект отдела
|
|
||||||
department = target;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (department && department.employees) {
|
|
||||||
return department.employees.some((employee) =>
|
|
||||||
employee.title?.toLowerCase().includes(searchText),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const disable = (department) => {
|
const filterEmployees = (employees) => {
|
||||||
return department.id == accountStore.user.id_dict_department &&
|
if (!searchQuery.value) return employees;
|
||||||
department.employees.length == 1
|
const query = searchQuery.value.toLowerCase();
|
||||||
? true
|
return employees.filter((e) => e.title?.toLowerCase().includes(query));
|
||||||
: 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((emp) => emp.id === props.authorID);
|
return item.employees.some((e) => e.id === props.authorID);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Если это сотрудник - проверяем напрямую
|
|
||||||
return item.id === props.authorID;
|
return item.id === props.authorID;
|
||||||
};
|
};
|
||||||
|
|
||||||
const allUser = () => {
|
const isDepartmentLocked = (dept) =>
|
||||||
emitUp(staffed.value);
|
dept.id === accountStore.user.id_dict_department && dept.employees.length === 1;
|
||||||
|
|
||||||
|
const isOnlyOneEmployee = computed(
|
||||||
|
() => visibleDepartments.value.length === 1 && visibleDepartments.value[0].employees.length === 1,
|
||||||
|
);
|
||||||
|
|
||||||
|
const isDepartmentIndeterminate = (dept) => {
|
||||||
|
const some = dept.employees.some((e) => isSelected(e));
|
||||||
|
const all = dept.employees.every((e) => isSelected(e));
|
||||||
|
return some && !all;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Проверяем выбраны ли все начальники (с исключениями)
|
const areAllSelected = computed(
|
||||||
const hasBossesSelected = computed(() => {
|
() =>
|
||||||
const bosses = findEmployeesByPosition(['начальник', 'и.о'], ['заместитель', 'зам.']);
|
visibleDepartments.value.length > 0 &&
|
||||||
return bosses.length > 0 && bosses.every((emp) => emp[props.okey] === true);
|
visibleDepartments.value.every((dept) => isSelected(dept)),
|
||||||
});
|
|
||||||
|
|
||||||
// Проверяем выбраны ли все заместители (с исключениями)
|
|
||||||
const hasDeputiesSelected = computed(() => {
|
|
||||||
const deputies = findEmployeesByPosition(['заместитель', 'зам.'], []);
|
|
||||||
return deputies.length > 0 && deputies.every((emp) => emp[props.okey] === true);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Toggle функция с исключением
|
|
||||||
const toggleByPosition = (positionType) => {
|
|
||||||
let keywords = [];
|
|
||||||
let excludeKeywords = [];
|
|
||||||
|
|
||||||
if (positionType === 'начальник') {
|
|
||||||
keywords = ['начальник', 'и.о'];
|
|
||||||
excludeKeywords = ['заместитель', 'зам.'];
|
|
||||||
} else if (positionType === 'заместитель') {
|
|
||||||
keywords = ['заместитель', 'зам.'];
|
|
||||||
excludeKeywords = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
const employeesToToggle = findEmployeesByPosition(keywords, excludeKeywords);
|
|
||||||
const shouldSelect = !employeesToToggle.every((emp) => emp[props.okey] === true);
|
|
||||||
|
|
||||||
// if (employeesToToggle.length > 0) {
|
|
||||||
// employeesToToggle.forEach((employee) => {
|
|
||||||
// if (employee[props.okey] !== shouldSelect) {
|
|
||||||
// emitUp(employee);
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (employeesToToggle.length > 0) {
|
|
||||||
// ФИЛЬТРУЕМ - убираем создателя события из массовых операций
|
|
||||||
const filteredEmployees = employeesToToggle.filter(
|
|
||||||
(employee) => employee.id !== props.authorID, //
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (filteredEmployees.length > 0) {
|
const areAllBossesSelected = computed(
|
||||||
filteredEmployees.forEach((employee) => {
|
() => bosses.value.length > 0 && bosses.value.every((e) => isSelected(e)),
|
||||||
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 = (positionKeywords, excludeKeywords = []) => {
|
const findEmployeesByPosition = (includeKeywords, excludeKeywords = []) => {
|
||||||
const foundEmployees = [];
|
const found = [];
|
||||||
|
|
||||||
props.staff.forEach((department) => {
|
props.staff.forEach((dept) => {
|
||||||
department.employees.forEach((employee) => {
|
if (dept.id === 1) return;
|
||||||
if (department.id == 1) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (employee.id === accountStore.user.is_idEmployee) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (props.okey === 'editor' && employee.selected !== true) {
|
dept.employees.forEach((employee) => {
|
||||||
return;
|
if (employee.id === accountStore.user.is_idEmployee) return;
|
||||||
}
|
if (props.mode === 'editors' && !props.selectedIds?.has(employee.id)) return;
|
||||||
|
|
||||||
const employeeData = calendarStore.dictEmployees.find((de) => de.id === employee.id);
|
const meta = calendarStore.dictEmployees.find((d) => d.id === employee.id);
|
||||||
|
if (!meta?.post) return;
|
||||||
|
|
||||||
if (employeeData && employeeData.post) {
|
const post = meta.post.toLowerCase();
|
||||||
const post = employeeData.post.toLowerCase();
|
const hasInclude = includeKeywords.some((k) => post.includes(k.toLowerCase()));
|
||||||
|
const hasExclude = excludeKeywords.some((k) => post.includes(k.toLowerCase()));
|
||||||
|
|
||||||
// Ищем включения и исключения
|
if (hasInclude && !hasExclude) found.push(employee);
|
||||||
const hasInclude = positionKeywords.some((keyword) =>
|
|
||||||
post.includes(keyword.toLowerCase()),
|
|
||||||
);
|
|
||||||
const hasExclude = excludeKeywords.some((exclude) =>
|
|
||||||
post.includes(exclude.toLowerCase()),
|
|
||||||
);
|
|
||||||
|
|
||||||
if (hasInclude && !hasExclude) {
|
|
||||||
foundEmployees.push(employee);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
return foundEmployees;
|
return found;
|
||||||
};
|
};
|
||||||
// Проверяем есть ли начальники в staff
|
|
||||||
const hasBossesInStaff = computed(() => {
|
|
||||||
return (
|
|
||||||
findEmployeesByPosition(['начальник', 'и.о. начальника'], ['заместитель', 'зам.']).length >
|
|
||||||
0
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Проверяем есть ли заместители в staff
|
const bosses = computed(() =>
|
||||||
const hasDeputiesInStaff = computed(() => {
|
findEmployeesByPosition(['начальник', 'и.о'], ['заместитель', 'зам.']),
|
||||||
return (
|
|
||||||
findEmployeesByPosition(['заместитель начальника', 'зам. начальника', 'заместитель'])
|
|
||||||
.length > 0
|
|
||||||
);
|
);
|
||||||
});
|
const deputies = computed(() => findEmployeesByPosition(['заместитель', 'зам.'], []));
|
||||||
|
|
||||||
return {
|
const hasBossesInStaff = computed(() => bosses.value.length > 0);
|
||||||
isAuthor,
|
const hasDeputiesInStaff = computed(() => deputies.value.length > 0);
|
||||||
staffed,
|
|
||||||
filtered,
|
const toggleByPosition = (type) => {
|
||||||
accountStore,
|
const list = type === 'boss' ? bosses.value : deputies.value;
|
||||||
selectedStaff,
|
const targets = list.filter((e) => e.id !== props.authorID);
|
||||||
splitname,
|
if (!targets.length) return;
|
||||||
disable,
|
|
||||||
allUser,
|
const wasAllSelected = targets.every((e) => isSelected);
|
||||||
customFilterFn,
|
const action = wasAllSelected ? 'remove' : 'add';
|
||||||
findEmployeesByPosition,
|
|
||||||
toggleByPosition,
|
const ids = targets.map((e) => e.id);
|
||||||
hasBossesInStaff,
|
emit('change', { ids, action });
|
||||||
hasBossesSelected,
|
|
||||||
hasDeputiesInStaff,
|
|
||||||
hasDeputiesSelected,
|
|
||||||
dictEmployeesLoaded,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
@@ -38,9 +38,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="newStaff"
|
:staff="staff"
|
||||||
@returnIdParticant="returnIdParticant"
|
:selectedIds="selectedIds"
|
||||||
:authorID="calendarAuthorId"
|
:authorID="calendarAuthorId"
|
||||||
|
@change="onParticipantsChange"
|
||||||
/> </v-col
|
/> </v-col
|
||||||
></v-row>
|
></v-row>
|
||||||
</v-col>
|
</v-col>
|
||||||
@@ -61,10 +62,12 @@
|
|||||||
<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="newStaff"
|
:staff="staff"
|
||||||
:okey="'editor'"
|
mode="editors"
|
||||||
@returnIdParticant="returnIdParticant"
|
:selectedIds="selectedIds"
|
||||||
|
: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">
|
||||||
@@ -84,26 +87,25 @@
|
|||||||
</dialog-create>
|
</dialog-create>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script setup>
|
||||||
import { computed, ref } from 'vue';
|
import { computed, ref, onMounted } 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';
|
||||||
|
|
||||||
export default {
|
const props = defineProps({
|
||||||
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(() => {
|
||||||
// Для нового календаря - текущий пользователь
|
// Для нового календаря - текущий пользователь
|
||||||
@@ -114,102 +116,88 @@ export default {
|
|||||||
return propsCalendar.value.author;
|
return propsCalendar.value.author;
|
||||||
});
|
});
|
||||||
|
|
||||||
const returnIdParticant = (idPart) => {
|
const propsCalendar = computed(() => props.calendar);
|
||||||
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,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (ind != -1) {
|
const alertStore = useAlertStore();
|
||||||
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 isAuthor = computed(() => propsCalendar.value.author === accountStore.user.is_idEmployee);
|
|
||||||
|
|
||||||
|
const isNewCalendar = computed(() => !propsCalendar.value?.id);
|
||||||
const titleCard = computed(() =>
|
const titleCard = computed(() =>
|
||||||
isNewCalendar.value ? 'Новый календарь' : 'Редактирование календаря',
|
isNewCalendar.value ? 'Новый календарь' : 'Редактирование календаря',
|
||||||
);
|
);
|
||||||
|
|
||||||
const newCalendar = computed(() => (isNewCalendar.value ? true : !isAuthor.value));
|
const loadStaff = async () => {
|
||||||
|
try {
|
||||||
const postCalendar = (val) => {
|
const res = await axiosApiInstance.get('api/calendar_of_events/get_employees/');
|
||||||
if (val) {
|
staff.value = res.data.filter((e) => e.employees.length > 0);
|
||||||
axiosApiInstance
|
} catch (e) {
|
||||||
.post(`api/calendar_of_events/my_calendars/`, {
|
console.error('Ошибка загрузки сотрудников, ', e);
|
||||||
...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([]);
|
const selectedIds = computed(
|
||||||
|
() => new Set((propsCalendar.value?.participant ?? []).map((p) => p.participant_calendar)),
|
||||||
axiosApiInstance.get('api/calendar_of_events/get_employees/').then((res) => {
|
|
||||||
staff.value = res.data.filter((e) => e.employees.length > 0);
|
|
||||||
});
|
|
||||||
|
|
||||||
const newStaff = computed({
|
|
||||||
get() {
|
|
||||||
staff.value.forEach((e) => {
|
|
||||||
if (propsCalendar.value.participant.length > 0) {
|
|
||||||
e.employees.forEach((empl) => {
|
|
||||||
let ab = propsCalendar.value.participant.find(
|
|
||||||
(a) => a.participant_calendar === empl.id,
|
|
||||||
);
|
);
|
||||||
if (ab) {
|
|
||||||
empl.selected = true;
|
|
||||||
empl.editor = ab.editor;
|
|
||||||
} else {
|
|
||||||
empl.selected = false;
|
|
||||||
empl.editor = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return staff.value;
|
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,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
propsCalendar.value.participant.splice(existingIdx, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const onEditorsChange = ({ ids, action }) => {
|
||||||
|
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', // Яркий голубой
|
||||||
@@ -237,39 +225,40 @@ export default {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const delCalendar = (idcal) => {
|
const postCalendar = async (val) => {
|
||||||
axiosApiInstance
|
if (!val) return;
|
||||||
.delete(`api/calendar_of_events/my_calendars/?delid=${idcal}`)
|
|
||||||
.then((result) => {
|
try {
|
||||||
feedalert.alert = true;
|
const result = await axiosApiInstance.post(`api/calendar_of_events/my_calendars/`, {
|
||||||
feedalert.text = result.data.mess;
|
...props.calendar,
|
||||||
feedalert.ico = 'mdi-check';
|
participant: propsCalendar.value.participant,
|
||||||
feedalert.color = 'orange-accent-1';
|
|
||||||
emit('getCalendar');
|
|
||||||
});
|
});
|
||||||
|
alertStore.showSuccess(result.data.mess);
|
||||||
|
emit('getCalendar');
|
||||||
emit('closeDialog');
|
emit('closeDialog');
|
||||||
|
} catch (e) {
|
||||||
|
alertStore.showError('Ошибка сохранения календаря');
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const req = (val) => {
|
const delCalendar = async (idcal) => {
|
||||||
return !!val || 'Поле обязательно';
|
try {
|
||||||
|
const result = await axiosApiInstance.delete(
|
||||||
|
`api/calendar_of_events/my_calendars/?delid=${idcal}`,
|
||||||
|
);
|
||||||
|
alertStore.showWarning(result.data.mess);
|
||||||
|
emit('getCalendar');
|
||||||
|
emit('closeDialog');
|
||||||
|
} catch (e) {
|
||||||
|
alertStore.showError('Ошибка удаления календаря');
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
onMounted(() => {
|
||||||
postCalendar,
|
loadStaff();
|
||||||
color,
|
});
|
||||||
colorPik,
|
|
||||||
returnIdParticant,
|
|
||||||
propsCalendar,
|
|
||||||
delCalendar,
|
|
||||||
rules,
|
|
||||||
titleCard,
|
|
||||||
newCalendar,
|
|
||||||
newStaff,
|
|
||||||
isNewCalendar,
|
|
||||||
calendarAuthorId,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
@@ -74,7 +74,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { onMounted, ref, watch } from 'vue';
|
import { 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,15 +91,18 @@ 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 === undefined) {
|
if (!cal) {
|
||||||
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 }],
|
||||||
@@ -112,39 +115,36 @@ const editCreatedCalendar = (cal) => {
|
|||||||
showDialog.value = true;
|
showDialog.value = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
window.$createCalendar = () => {
|
|
||||||
editCreatedCalendar();
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
const handleCloseDialog = () => {
|
const handleCloseDialog = () => {
|
||||||
if (calendar.value.cl_name.length > 1) {
|
const isValid = calendar.value?.cl_name?.length > 1;
|
||||||
const calendarData = JSON.parse(JSON.stringify(calendar.value));
|
if (showCreateCalendarDialog.value) {
|
||||||
window.dispatchEvent(
|
resolveCreateCalendar(isValid ? JSON.parse(JSON.stringify(calendar.value)) : null);
|
||||||
new CustomEvent('calendarCreated', {
|
|
||||||
detail: calendarData,
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
showDialog.value = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
const resetCalendar = () => {
|
showDialog.value = false;
|
||||||
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>
|
||||||
|
|||||||
@@ -3,19 +3,18 @@
|
|||||||
<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
|
|
||||||
:rating=feedbackdata
|
<feedstar-like :rating="feedbackdata" @update:rating="feedbackdata.nowrating = $event" />
|
||||||
@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
|
||||||
@@ -30,149 +29,115 @@
|
|||||||
</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> {{myLabel()}}
|
Вы оценили сайт на <span class="font-weight-black">{{ average }}</span>
|
||||||
|
{{ ratingLabel }}
|
||||||
</small>
|
</small>
|
||||||
<v-spacer />
|
<v-spacer />
|
||||||
<v-btn
|
<v-btn color="modal_btn" rounded="xl" text="Закрыть" @click="closeMenu" />
|
||||||
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="feedSend"
|
@click="sendFeedback"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
|
|
||||||
</v-card>
|
</v-card>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script setup>
|
||||||
import { ref, onMounted, computed } from 'vue'
|
import { ref, computed, onMounted } 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';
|
||||||
|
|
||||||
import FeedstarLike from '@/components/UI/feedback/feedstar-like.vue'
|
defineProps({
|
||||||
import { useAlertStore } from '@/store/UseAlertStore'
|
LikeDialog: { type: Boolean, default: false },
|
||||||
|
});
|
||||||
|
|
||||||
export default {
|
const emit = defineEmits(['menusClose']);
|
||||||
components: { FeedstarLike },
|
|
||||||
|
|
||||||
props: {
|
const alertStore = useAlertStore();
|
||||||
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;
|
||||||
|
|
||||||
setup(props, {emit}) {
|
if (feedbackdata.value.nowrating.length === 0) {
|
||||||
const feedalert = useAlertStore().alert
|
for (const x of feedbackdata.value.basecrit) {
|
||||||
const feedbackdata= ref({nowcomment: {comment: '' }, nowrating: []})
|
feedbackdata.value.nowrating.push({
|
||||||
|
rating: x.rating,
|
||||||
function f_feedbackdata() {
|
crit: x.id,
|
||||||
axiosApiInstance.get('api/feedback/feedbackdata/')
|
id: null,
|
||||||
.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 sum = feedbackdata.value.nowrating.reduce((total, obj)=> total + obj.rating, 0)
|
const ratings = feedbackdata.value.nowrating;
|
||||||
const sumlen = sum/feedbackdata.value.nowrating.length
|
if (!ratings.length) return 0;
|
||||||
const ukr = Number.isInteger(sumlen)?sumlen:sumlen.toFixed(1)
|
|
||||||
return ukr
|
|
||||||
})
|
|
||||||
|
|
||||||
function myLabel() {
|
const sum = ratings.reduce((total, obj) => total + obj.rating, 0);
|
||||||
let labels = ''
|
const avg = sum / ratings.length;
|
||||||
if (average.value > 0 && average.value <= 3)
|
return Number.isInteger(avg) ? avg : Number(avg.toFixed(1));
|
||||||
labels = 'УПС-С! Мы обязательно все исправим'
|
});
|
||||||
else if (average.value > 2 && average.value <= 4)
|
|
||||||
labels = 'Спасибо за обратную связь, мы обратим на это внимание'
|
|
||||||
else if (average.value > 4 && average.value < 5)
|
|
||||||
labels = 'Класс, будем стараться до 5'
|
|
||||||
else
|
|
||||||
labels = "Спасибо за отзыв и высокую оценку ^__^"
|
|
||||||
return labels
|
|
||||||
}
|
|
||||||
|
|
||||||
function menusCloses() {
|
const ratingLabel = computed(() => {
|
||||||
emit('menusClose')
|
const avg = average.value;
|
||||||
}
|
if (avg > 0 && avg <= 3) return 'УПС-С! Мы обязательно все исправим';
|
||||||
|
if (avg > 2 && avg <= 4) return 'Спасибо за обратную связь, мы обратим на это внимание';
|
||||||
|
if (avg > 4 && avg < 5) return 'Класс, будем стараться до 5';
|
||||||
|
return 'Спасибо за отзыв и высокую оценку ^__^';
|
||||||
|
});
|
||||||
|
|
||||||
function feedSend() {
|
const closeMenu = () => emit('menusClose');
|
||||||
|
|
||||||
axiosApiInstance.post(`api/feedback/feedbackdata/`, {
|
const sendFeedback = async () => {
|
||||||
|
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',
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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>
|
|
||||||
@@ -102,7 +102,7 @@ export default {
|
|||||||
/**
|
/**
|
||||||
* Получает объект alert из хранилища alert для уведомлений.
|
* Получает объект alert из хранилища alert для уведомлений.
|
||||||
*/
|
*/
|
||||||
const feedalert = useAlertStore().alert;
|
const alertStore = useAlertStore();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Интервал переключения слайдов в миллисекундах.
|
* Интервал переключения слайдов в миллисекундах.
|
||||||
@@ -116,10 +116,8 @@ export default {
|
|||||||
const getfromserver = () => {
|
const getfromserver = () => {
|
||||||
axiosApiInstance.get('api/navigation/carousels/').then((result) => {
|
axiosApiInstance.get('api/navigation/carousels/').then((result) => {
|
||||||
if (result.data.mess !== '') {
|
if (result.data.mess !== '') {
|
||||||
feedalert.alert = true;
|
alertStore.showSuccess(result.data.mess);
|
||||||
feedalert.text = result.data.mess;
|
|
||||||
feedalert.color = 'red-darken-2';
|
|
||||||
feedalert.ico = 'mdi-alert-outline';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.data.result.length > 0) {
|
if (result.data.result.length > 0) {
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
<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">
|
||||||
@@ -14,11 +12,7 @@
|
|||||||
</v-card-subtitle>
|
</v-card-subtitle>
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col class="flex-grow-0">
|
<v-col class="flex-grow-0">
|
||||||
<v-icon
|
<v-icon icon="mdi-file-excel" color="green-darken-3" @click="excelOp('excround')" />
|
||||||
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">
|
||||||
@@ -52,67 +46,61 @@
|
|||||||
</v-row>
|
</v-row>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script setup>
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue';
|
||||||
import { baseURL } from '@/utils/axios-api'
|
import { baseURL, axiosApiInstance } from '@/utils/axios-api';
|
||||||
import { axiosApiInstance } from '@/utils/axios-api'
|
import { useAlertStore } from '@/store/UseAlertStore';
|
||||||
import { useAlertStore } from '@/store/UseAlertStore'
|
|
||||||
|
|
||||||
export default {
|
const dailyfiles = ref([]);
|
||||||
|
const alertStore = useAlertStore();
|
||||||
|
|
||||||
setup(){
|
const excelOp = async (ex) => {
|
||||||
|
try {
|
||||||
const dailyfiles = ref([])
|
const result = await axiosApiInstance.get(`api/general_vacation/dailyroundup/?excel=${ex}`);
|
||||||
const feedalert = useAlertStore().alert
|
const link = document.createElement('a');
|
||||||
|
link.href = baseURL + result.data.path;
|
||||||
const excelOp = (ex) => {
|
link.click();
|
||||||
axiosApiInstance.get(`api/general_vacation/dailyroundup/?excel=${ex}`).then(result => {
|
link.remove();
|
||||||
let link = document.createElement("a")
|
} catch (e) {
|
||||||
link.href = baseURL+result.data.path
|
alertStore.showError('Не удалось получить файл');
|
||||||
link.click()
|
console.error(e);
|
||||||
link.remove()
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const onPickFile = (ex) => {
|
const onPickFile = async (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 => {
|
|
||||||
textFromAlert(result.data['mess'])
|
|
||||||
})
|
|
||||||
dailyfiles.value = []
|
|
||||||
}
|
|
||||||
|
|
||||||
const textFromAlert = (info) => {
|
try {
|
||||||
feedalert.alert = true
|
const result = await axiosApiInstance.post(
|
||||||
if (info == "Файл загружен") {
|
`api/general_vacation/dailyroundup/?excel=${ex}`,
|
||||||
feedalert.text = "Файл загружен"
|
sdata,
|
||||||
feedalert.ico = "mdi-check"
|
);
|
||||||
feedalert.color ="green-darken-4"
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
feedalert.text = "Ошибка загрузки"
|
|
||||||
feedalert.ico = "mdi-alert-circle-outline"
|
|
||||||
feedalert.color="pink-accent-4"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
if (result.data.mess === 'Файл загружен') {
|
||||||
|
alertStore.showSuccess('Файл загружен');
|
||||||
|
} else {
|
||||||
|
alertStore.showError(result.data.mess ?? 'Ошибка загрузки');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
alertStore.showError('Ошибка загрузки');
|
||||||
|
console.error(e);
|
||||||
|
} finally {
|
||||||
|
dailyfiles.value = [];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
excelOp,
|
excelOp,
|
||||||
baseURL,
|
baseURL,
|
||||||
dailyfiles,
|
dailyfiles,
|
||||||
onPickFile,
|
onPickFile,
|
||||||
feedalert
|
alertStore,
|
||||||
}
|
});
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.mhight {
|
.mhight {
|
||||||
height: 150px;
|
height: 150px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
@@ -1,11 +1,30 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-app>
|
<v-app>
|
||||||
<v-app-bar :elevation="accountStore.cod2user ? 2 : 0" density="compact" color="app_bar" class="pl-4">
|
<v-app-bar
|
||||||
<v-icon v-if="accountStore.cod2user" class="px-3" size="20" color="black_and_white"
|
:elevation="accountStore.cod2user ? 2 : 0"
|
||||||
:icon="rail ? 'mdi-chevron-right' : 'mdi-chevron-left'" @click="rail = !rail" />
|
density="compact"
|
||||||
|
color="app_bar"
|
||||||
|
class="pl-4"
|
||||||
|
>
|
||||||
|
<v-icon
|
||||||
|
v-if="accountStore.cod2user"
|
||||||
|
class="px-3"
|
||||||
|
size="20"
|
||||||
|
color="black_and_white"
|
||||||
|
:icon="rail ? 'mdi-chevron-right' : 'mdi-chevron-left'"
|
||||||
|
@click="rail = !rail"
|
||||||
|
/>
|
||||||
|
|
||||||
<v-card v-if="accountStore.cod2user" class="bg-transparent py" color="black_and_white" density="compact"
|
<v-card
|
||||||
:prepend-avatar="imageSrc" title="Портал МИ ФНС России по ЦОД № 2" variant="text" :to="'/'" />
|
v-if="accountStore.cod2user"
|
||||||
|
class="bg-transparent py"
|
||||||
|
color="black_and_white"
|
||||||
|
density="compact"
|
||||||
|
:prepend-avatar="imageSrc"
|
||||||
|
title="Портал МИ ФНС России по ЦОД № 2"
|
||||||
|
variant="text"
|
||||||
|
:to="'/'"
|
||||||
|
/>
|
||||||
<template v-slot:image>
|
<template v-slot:image>
|
||||||
<v-img class="bggrad" />
|
<v-img class="bggrad" />
|
||||||
</template>
|
</template>
|
||||||
@@ -13,15 +32,18 @@
|
|||||||
<template v-if="accountStore.cod2user">
|
<template v-if="accountStore.cod2user">
|
||||||
<vcard-user :author="accountStore.user" />
|
<vcard-user :author="accountStore.user" />
|
||||||
<v-tooltip location="bottom">
|
<v-tooltip location="bottom">
|
||||||
|
|
||||||
|
|
||||||
<template v-slot:activator="{ props }">
|
<template v-slot:activator="{ props }">
|
||||||
<v-btn color="black_and_white" v-bind="props" dark to="/faq" icon="mdi-comment-question-outline" />
|
<v-btn
|
||||||
|
color="black_and_white"
|
||||||
|
v-bind="props"
|
||||||
|
dark
|
||||||
|
to="/faq"
|
||||||
|
icon="mdi-comment-question-outline"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
<span>F.A.Q.</span>
|
<span>F.A.Q.</span>
|
||||||
</v-tooltip>
|
</v-tooltip>
|
||||||
|
|
||||||
|
|
||||||
<v-dialog v-model="LikeDialog" persistent width="800">
|
<v-dialog v-model="LikeDialog" persistent width="800">
|
||||||
<template v-slot:activator="{ props }">
|
<template v-slot:activator="{ props }">
|
||||||
<v-btn color="black_and_white" v-bind="props" dark icon="mdi-thumb-up-outline">
|
<v-btn color="black_and_white" v-bind="props" dark icon="mdi-thumb-up-outline">
|
||||||
@@ -36,7 +58,11 @@
|
|||||||
<v-tooltip location="bottom">
|
<v-tooltip location="bottom">
|
||||||
<template v-slot:activator="{ props }">
|
<template v-slot:activator="{ props }">
|
||||||
<v-btn icon @click="toggleTheme">
|
<v-btn icon @click="toggleTheme">
|
||||||
<v-icon v-bind="props" class="mr-1" :color="theme.global.current.value.dark ? 'yellow' : 'lampa'">
|
<v-icon
|
||||||
|
v-bind="props"
|
||||||
|
class="mr-1"
|
||||||
|
:color="theme.global.current.value.dark ? 'yellow' : 'lampa'"
|
||||||
|
>
|
||||||
mdi-lightbulb-outline
|
mdi-lightbulb-outline
|
||||||
</v-icon>
|
</v-icon>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
@@ -48,20 +74,25 @@
|
|||||||
|
|
||||||
<v-tooltip location="bottom">
|
<v-tooltip location="bottom">
|
||||||
<template v-slot:activator="{ props }">
|
<template v-slot:activator="{ props }">
|
||||||
<v-btn color="black_and_white" icon="mdi-account-multiple-outline" @click="drawer_right = !drawer_right"
|
<v-btn
|
||||||
v-bind="props" />
|
color="black_and_white"
|
||||||
|
icon="mdi-account-multiple-outline"
|
||||||
|
@click="drawer_right = !drawer_right"
|
||||||
|
v-bind="props"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
<span>
|
<span>
|
||||||
{{
|
{{ drawer_right == true ? 'Скрыть пользователей' : 'Показать пользователей' }}
|
||||||
drawer_right == true
|
|
||||||
? "Скрыть пользователей"
|
|
||||||
: "Показать пользователей"
|
|
||||||
}}
|
|
||||||
</span>
|
</span>
|
||||||
</v-tooltip>
|
</v-tooltip>
|
||||||
<v-tooltip location="bottom">
|
<v-tooltip location="bottom">
|
||||||
<template v-slot:activator="{ props }">
|
<template v-slot:activator="{ props }">
|
||||||
<v-btn color="black_and_white" icon="mdi-logout" @click="accountStore.logout" v-bind="props" />
|
<v-btn
|
||||||
|
color="black_and_white"
|
||||||
|
icon="mdi-logout"
|
||||||
|
@click="accountStore.logout"
|
||||||
|
v-bind="props"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
<span> Выход </span>
|
<span> Выход </span>
|
||||||
</v-tooltip>
|
</v-tooltip>
|
||||||
@@ -74,20 +105,34 @@
|
|||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
</v-app-bar>
|
</v-app-bar>
|
||||||
<v-navigation-drawer v-if="accountStore.cod2user" :width="245" :rail="rail" permanent v-model="drawer">
|
<v-navigation-drawer
|
||||||
|
v-if="accountStore.cod2user"
|
||||||
|
:width="245"
|
||||||
|
:rail="rail"
|
||||||
|
permanent
|
||||||
|
v-model="drawer"
|
||||||
|
>
|
||||||
<v-row class="my-0 h-100">
|
<v-row class="my-0 h-100">
|
||||||
<v-col class="flex-column d-flex">
|
<v-col class="flex-column d-flex">
|
||||||
<v-row><v-col>
|
<v-row
|
||||||
|
><v-col>
|
||||||
<v-list nav density="compact">
|
<v-list nav density="compact">
|
||||||
<template v-for="(x, key) in navigations" :key="key">
|
<template v-for="(x, key) in navigations" :key="key">
|
||||||
<!-- v-if="!('submenu' in x) || (x.path== '/portal' && accountStore.user.is_staff)" -->
|
<!-- v-if="!('submenu' in x) || (x.path== '/portal' && accountStore.user.is_staff)" -->
|
||||||
<v-list-item v-if="(x.path == '/portal'? accountStore.user.is_superuser : true) && !('submenu' in x)
|
<v-list-item
|
||||||
" :key="x.key" :title="x.name" :value="x.name" :href="x.link" :disabled="x.path == ''" :to="x.path"
|
v-if="
|
||||||
|
(x.path == '/portal' ? accountStore.user.is_superuser : true) &&
|
||||||
|
!('submenu' in x)
|
||||||
|
"
|
||||||
|
:key="x.key"
|
||||||
|
:title="x.name"
|
||||||
|
:value="x.name"
|
||||||
|
:href="x.link"
|
||||||
|
:disabled="x.path == ''"
|
||||||
|
:to="x.path"
|
||||||
:target="x.link ? '_blank' : ''"
|
:target="x.link ? '_blank' : ''"
|
||||||
color="navigation"
|
color="navigation"
|
||||||
|
|
||||||
>
|
>
|
||||||
|
|
||||||
<template v-slot:prepend>
|
<template v-slot:prepend>
|
||||||
<v-icon :icon="x.ico" />
|
<v-icon :icon="x.ico" />
|
||||||
<v-tooltip v-if="rail" activator="parent" location="top">
|
<v-tooltip v-if="rail" activator="parent" location="top">
|
||||||
@@ -96,18 +141,34 @@
|
|||||||
</template>
|
</template>
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
|
|
||||||
<v-list-group v-if="x.path != '/portal' && 'submenu' in x" :class="rail ? 'railmenu' : ''" :key="key"
|
<v-list-group
|
||||||
:value="x.name">
|
v-if="x.path != '/portal' && 'submenu' in x"
|
||||||
|
:class="rail ? 'railmenu' : ''"
|
||||||
|
:key="key"
|
||||||
|
:value="x.name"
|
||||||
|
>
|
||||||
<template v-slot:activator="{ props }">
|
<template v-slot:activator="{ props }">
|
||||||
<v-list-item v-bind="props" :title="x.name" :prepend-icon="x.ico" color="navigation">
|
<v-list-item
|
||||||
|
v-bind="props"
|
||||||
|
:title="x.name"
|
||||||
|
:prepend-icon="x.ico"
|
||||||
|
color="navigation"
|
||||||
|
>
|
||||||
<v-tooltip v-if="rail" activator="parent" location="top">
|
<v-tooltip v-if="rail" activator="parent" location="top">
|
||||||
{{ x.name }}
|
{{ x.name }}
|
||||||
</v-tooltip>
|
</v-tooltip>
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
</template>
|
</template>
|
||||||
<v-list-item v-for="(child, k) in x.submenu" color="navigation" :href="child.link" :key="k"
|
<v-list-item
|
||||||
:value="child.name" :title="!rail ? child.name : menuTruncated(child.name)" :to="child.path"
|
v-for="(child, k) in x.submenu"
|
||||||
:target="child.link ? '_blank' : ''">
|
color="navigation"
|
||||||
|
:href="child.link"
|
||||||
|
:key="k"
|
||||||
|
:value="child.name"
|
||||||
|
:title="!rail ? child.name : menuTruncated(child.name)"
|
||||||
|
:to="child.path"
|
||||||
|
:target="child.link ? '_blank' : ''"
|
||||||
|
>
|
||||||
<v-tooltip v-if="rail" activator="parent" location="top">
|
<v-tooltip v-if="rail" activator="parent" location="top">
|
||||||
{{ child.name }}
|
{{ child.name }}
|
||||||
</v-tooltip>
|
</v-tooltip>
|
||||||
@@ -117,8 +178,15 @@
|
|||||||
</v-list>
|
</v-list>
|
||||||
|
|
||||||
<v-list nav density="compact">
|
<v-list nav density="compact">
|
||||||
<v-list-item v-for="x of mainmenuStore.portallinks" :key="x.name" :title="x.name" :value="x.name"
|
<v-list-item
|
||||||
:href="x.link" color="app_bar" :target="x.link ? '_blank' : ''">
|
v-for="x of mainmenuStore.portallinks"
|
||||||
|
:key="x.name"
|
||||||
|
:title="x.name"
|
||||||
|
:value="x.name"
|
||||||
|
:href="x.link"
|
||||||
|
color="app_bar"
|
||||||
|
:target="x.link ? '_blank' : ''"
|
||||||
|
>
|
||||||
<template v-slot:prepend>
|
<template v-slot:prepend>
|
||||||
<v-icon :icon="x.imagecode" />
|
<v-icon :icon="x.imagecode" />
|
||||||
<v-tooltip v-if="rail" activator="parent" location="top">
|
<v-tooltip v-if="rail" activator="parent" location="top">
|
||||||
@@ -133,7 +201,6 @@
|
|||||||
<v-row class="flex-grow-0" v-if="accountStore.user.is_staff">
|
<v-row class="flex-grow-0" v-if="accountStore.user.is_staff">
|
||||||
<v-col>
|
<v-col>
|
||||||
<AdminMenu :rail="rail" />
|
<AdminMenu :rail="rail" />
|
||||||
|
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
<v-row no-gutters class="flex-grow-0">
|
<v-row no-gutters class="flex-grow-0">
|
||||||
@@ -148,18 +215,26 @@
|
|||||||
<v-main v-if="accountStore.cod2user" class="d-flex bg-main_theme">
|
<v-main v-if="accountStore.cod2user" class="d-flex bg-main_theme">
|
||||||
<router-view />
|
<router-view />
|
||||||
|
|
||||||
|
|
||||||
<alert-default />
|
<alert-default />
|
||||||
</v-main>
|
</v-main>
|
||||||
<v-main v-else class="d-flex align-center text-h3 bg-teal-lighten-2">
|
<v-main v-else class="d-flex align-center text-h3 bg-teal-lighten-2">
|
||||||
<v-card class="h-100 w-100 d-flex justify-center rounded-0 flex-column" :image="`${burl}${scrimg}`">
|
<v-card
|
||||||
|
class="h-100 w-100 d-flex justify-center rounded-0 flex-column"
|
||||||
|
:image="`${burl}${scrimg}`"
|
||||||
|
>
|
||||||
<v-card-text
|
<v-card-text
|
||||||
class="justify-center bgCard h-100 ma-3 d-flex flex-column"
|
class="justify-center bgCard h-100 ma-3 d-flex flex-column"
|
||||||
style="background: rgba(255, 255, 255, 0.3) !important; background-color: rgba(255, 255, 255, 0.3) !important;"
|
style="
|
||||||
|
background: rgba(255, 255, 255, 0.3) !important;
|
||||||
|
background-color: rgba(255, 255, 255, 0.3) !important;
|
||||||
|
"
|
||||||
>
|
>
|
||||||
<v-row
|
<v-row
|
||||||
class="bgText flex-grow-0"
|
class="bgText flex-grow-0"
|
||||||
style="background: rgba(255, 255, 255, 0.5) !important; background-color: rgba(255, 255, 255, 0.5) !important;"
|
style="
|
||||||
|
background: rgba(255, 255, 255, 0.5) !important;
|
||||||
|
background-color: rgba(255, 255, 255, 0.5) !important;
|
||||||
|
"
|
||||||
>
|
>
|
||||||
<v-col class="text-center textcolor font-weight-black text-h3 pb-0">
|
<v-col class="text-center textcolor font-weight-black text-h3 pb-0">
|
||||||
Добро пожаловать на портал МИ ФНС России по ЦОД № 2
|
Добро пожаловать на портал МИ ФНС России по ЦОД № 2
|
||||||
@@ -167,7 +242,10 @@
|
|||||||
</v-row>
|
</v-row>
|
||||||
<v-row
|
<v-row
|
||||||
class="bgText flex-grow-0"
|
class="bgText flex-grow-0"
|
||||||
style="background: rgba(255, 255, 255, 0.5) !important; background-color: rgba(255, 255, 255, 0.5) !important;"
|
style="
|
||||||
|
background: rgba(255, 255, 255, 0.5) !important;
|
||||||
|
background-color: rgba(255, 255, 255, 0.5) !important;
|
||||||
|
"
|
||||||
>
|
>
|
||||||
<v-col class="text-subtitle-1 text-center textcolor pt-0">
|
<v-col class="text-subtitle-1 text-center textcolor pt-0">
|
||||||
Авторизуйтесь для получения доступа к контенту портала
|
Авторизуйтесь для получения доступа к контенту портала
|
||||||
@@ -178,30 +256,37 @@
|
|||||||
|
|
||||||
<alert-default />
|
<alert-default />
|
||||||
</v-main>
|
</v-main>
|
||||||
<v-navigation-drawer v-if="accountStore.cod2user" v-model="drawer_right" rail permanent location="right"
|
<v-navigation-drawer
|
||||||
@click="rail = false">
|
v-if="accountStore.cod2user"
|
||||||
|
v-model="drawer_right"
|
||||||
|
rail
|
||||||
|
permanent
|
||||||
|
location="right"
|
||||||
|
@click="rail = false"
|
||||||
|
>
|
||||||
<Online-users />
|
<Online-users />
|
||||||
</v-navigation-drawer>
|
</v-navigation-drawer>
|
||||||
</v-app>
|
</v-app>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { ref, computed } from "vue";
|
import { ref, computed } from 'vue';
|
||||||
import uf from "@/utils/universal_functions";
|
import uf from '@/utils/universal_functions';
|
||||||
import { useAccountStore } from "@/store/AccountStore";
|
import { useAccountStore } from '@/store/AccountStore';
|
||||||
import { useMainmenuStore } from "@/store/MainmenuStore";
|
import { useMainmenuStore } from '@/store/MainmenuStore';
|
||||||
import { useTheme } from "vuetify";
|
import { useTheme } from 'vuetify';
|
||||||
import AuthForm from "@/components/UI/Auth-form.vue";
|
import AuthForm from '@/components/UI/Auth-form.vue';
|
||||||
import OnlineUsers from "@/components/UI/fiousercard/onlineUsers.vue";
|
import OnlineUsers from '@/components/UI/fiousercard/onlineUsers.vue';
|
||||||
import CardLike from "@/components/cardLike.vue";
|
import CardLike from '@/components/cardLike.vue';
|
||||||
import { axiosApiInstance, clearAxios } from "@/utils/axios-api";
|
import { axiosApiInstance, clearAxios } from '@/utils/axios-api';
|
||||||
|
|
||||||
import { baseURL } from "@/utils/axios-api";
|
import { baseURL } from '@/utils/axios-api';
|
||||||
import VcardUser from "@/components/UI/fiousercard/vcardUser.vue";
|
import VcardUser from '@/components/UI/fiousercard/vcardUser.vue';
|
||||||
import PageCounter from "@/components/UI/defaultportal/page-counter.vue";
|
import PageCounter from '@/components/UI/defaultportal/page-counter.vue';
|
||||||
import AdminMenu from "@/layouts/default/AdminMenu.vue";
|
import AdminMenu from '@/layouts/default/AdminMenu.vue';
|
||||||
|
import alertDefault from './alertDefault.vue';
|
||||||
|
|
||||||
import { useDisplay } from "vuetify";
|
import { useDisplay } from 'vuetify';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
@@ -211,6 +296,7 @@ export default {
|
|||||||
VcardUser,
|
VcardUser,
|
||||||
PageCounter,
|
PageCounter,
|
||||||
AdminMenu,
|
AdminMenu,
|
||||||
|
alertDefault,
|
||||||
},
|
},
|
||||||
|
|
||||||
mixins: [uf],
|
mixins: [uf],
|
||||||
@@ -232,13 +318,12 @@ export default {
|
|||||||
|
|
||||||
const message = computed({
|
const message = computed({
|
||||||
get: () => {
|
get: () => {
|
||||||
return process.env.NODE_ENV == "development" ? true : false;
|
return process.env.NODE_ENV == 'development' ? true : false;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const screenimg = () => {
|
const screenimg = () => {
|
||||||
if (!accountStore.cod2user) {
|
if (!accountStore.cod2user) {
|
||||||
|
|
||||||
clearAxios.get(`api/navigation/screensaver/`).then((data) => {
|
clearAxios.get(`api/navigation/screensaver/`).then((data) => {
|
||||||
scrimg.value = data.data.img;
|
scrimg.value = data.data.img;
|
||||||
});
|
});
|
||||||
@@ -252,38 +337,34 @@ export default {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const toggleTheme = () => {
|
const toggleTheme = () => {
|
||||||
theme.global.name.value = theme.global.current.value.dark
|
theme.global.name.value = theme.global.current.value.dark ? 'light' : 'dark';
|
||||||
? "light"
|
|
||||||
: "dark";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
mainmenuStore.loadlinks();
|
mainmenuStore.loadlinks();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const navigations = ref([
|
const navigations = ref([
|
||||||
{
|
{
|
||||||
name: "Новости",
|
name: 'Новости',
|
||||||
ico: "mdi-newspaper",
|
ico: 'mdi-newspaper',
|
||||||
path: "/news",
|
path: '/news',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Структура",
|
name: 'Структура',
|
||||||
ico: "mdi-source-branch",
|
ico: 'mdi-source-branch',
|
||||||
submenu: [
|
submenu: [
|
||||||
{
|
{
|
||||||
name: "ОКиБ",
|
name: 'ОКиБ',
|
||||||
path: "/okib",
|
path: '/okib',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Сотрудники",
|
name: 'Сотрудники',
|
||||||
ico: "mdi-account-multiple-outline",
|
ico: 'mdi-account-multiple-outline',
|
||||||
submenu: [
|
submenu: [
|
||||||
{
|
{
|
||||||
name: "Справочник",
|
name: 'Справочник',
|
||||||
link: "http://10.252.44.33/accounting6/members.php",
|
link: 'http://10.252.44.33/accounting6/members.php',
|
||||||
},
|
},
|
||||||
|
|
||||||
// {
|
// {
|
||||||
@@ -305,34 +386,32 @@ export default {
|
|||||||
// },
|
// },
|
||||||
|
|
||||||
{
|
{
|
||||||
name: "Календарь",
|
name: 'Календарь',
|
||||||
ico: "mdi-calendar",
|
ico: 'mdi-calendar',
|
||||||
path: "/ical",
|
path: '/ical',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Голосование",
|
name: 'Голосование',
|
||||||
ico: "mdi-vote",
|
ico: 'mdi-vote',
|
||||||
path: "/vote",
|
path: '/vote',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Тестирование",
|
name: 'Тестирование',
|
||||||
ico: "mdi-book-open-blank-variant",
|
ico: 'mdi-book-open-blank-variant',
|
||||||
path: "/test",
|
path: '/test',
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
name: "Об инспекции",
|
name: 'Об инспекции',
|
||||||
ico: "mdi-city",
|
ico: 'mdi-city',
|
||||||
path: "/inspection",
|
path: '/inspection',
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
name: "О портале",
|
name: 'О портале',
|
||||||
ico: "mdi-information-variant",
|
ico: 'mdi-information-variant',
|
||||||
path: "/portal",
|
path: '/portal',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const imageSrc = computed(() => {
|
const imageSrc = computed(() => {
|
||||||
@@ -341,22 +420,21 @@ export default {
|
|||||||
|
|
||||||
const closeinfo = () => {
|
const closeinfo = () => {
|
||||||
LikeDialog.value = false;
|
LikeDialog.value = false;
|
||||||
// feedalert.value=true
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const getSafetyChapter = () => {
|
const getSafetyChapter = () => {
|
||||||
axiosApiInstance.get("api/safety/gettypes/").then((response) => {
|
axiosApiInstance.get('api/safety/gettypes/').then((response) => {
|
||||||
response.data.forEach((item) => {
|
response.data.forEach((item) => {
|
||||||
if (!item.path.startsWith("/")) {
|
if (!item.path.startsWith('/')) {
|
||||||
item.path = "/" + item.path;
|
item.path = '/' + item.path;
|
||||||
}
|
}
|
||||||
item.path = "/safety" + item.path;
|
item.path = '/safety' + item.path;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (response.data.length > 0) {
|
if (response.data.length > 0) {
|
||||||
let safetyMenu = {
|
let safetyMenu = {
|
||||||
name: "Безопасность",
|
name: 'Безопасность',
|
||||||
ico: "mdi-security",
|
ico: 'mdi-security',
|
||||||
submenu: response.data,
|
submenu: response.data,
|
||||||
};
|
};
|
||||||
navigations.value.splice(4, 0, safetyMenu);
|
navigations.value.splice(4, 0, safetyMenu);
|
||||||
|
|||||||
@@ -1,52 +1,26 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-snackbar
|
<v-snackbar
|
||||||
|
v-model="isOpen"
|
||||||
:timeout="3000"
|
:timeout="3000"
|
||||||
v-model="feedalert.alert"
|
:color="alert.color"
|
||||||
:color="feedalert.color"
|
|
||||||
:icon="feedalert.ico"
|
|
||||||
|
|
||||||
|
|
||||||
>
|
>
|
||||||
<v-icon :icon="feedalert.ico" />
|
<v-icon :icon="alert.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>
|
<script setup>
|
||||||
import { watch } from "vue";
|
import { computed } from 'vue';
|
||||||
import { useAlertStore } from "@/store/UseAlertStore";
|
import { storeToRefs } from 'pinia';
|
||||||
|
import { useAlertStore } from '@/store/UseAlertStore';
|
||||||
|
|
||||||
export default {
|
const alertStore = useAlertStore();
|
||||||
name: "AlertDefault",
|
const { alert } = storeToRefs(alertStore);
|
||||||
setup() {
|
|
||||||
const feedalert = useAlertStore().alert;
|
|
||||||
|
|
||||||
watch(
|
const isOpen = computed({
|
||||||
|
get: () => alert.value.alert,
|
||||||
() => feedalert,
|
set: (value) => {
|
||||||
() => {
|
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,14 +1,32 @@
|
|||||||
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: '' });
|
||||||
|
|
||||||
const alert = ref({ "alert": false,
|
const show = ({ text, ico = 'mdi-information-outline', color = '#475569' }) => {
|
||||||
"text": '',
|
alert.value = { alert: true, text, ico, color };
|
||||||
"ico": 'mdi-plus',
|
};
|
||||||
"color": ''
|
|
||||||
})
|
|
||||||
|
|
||||||
return { alert }
|
const showSuccess = (text) => {
|
||||||
|
show({ text, ico: 'mdi-check-circle-outline', color: '#3F6B5C' });
|
||||||
|
};
|
||||||
|
|
||||||
})
|
const showError = (text = 'Произошла ошибка') => {
|
||||||
|
show({ text, ico: 'mdi-alert-circle-outline', color: '#8B3A3A' });
|
||||||
|
};
|
||||||
|
|
||||||
|
const showWarning = (text) => {
|
||||||
|
show({ text, ico: 'mdi-alert-outline', color: '#A66B2E' });
|
||||||
|
};
|
||||||
|
|
||||||
|
const showInfo = (text) => {
|
||||||
|
show({ text, ico: 'mdi-information-outline', color: '#3F5A7A' });
|
||||||
|
};
|
||||||
|
|
||||||
|
const hide = () => {
|
||||||
|
alert.value.alert = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
return { alert, show, showSuccess, showError, showWarning, hide };
|
||||||
|
});
|
||||||
@@ -23,6 +23,10 @@ export const useCalendarStore = defineStore('calendarStore', () => {
|
|||||||
const showEventDialog = ref(false);
|
const showEventDialog = ref(false);
|
||||||
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([]);
|
||||||
|
|
||||||
@@ -320,6 +324,30 @@ export const useCalendarStore = defineStore('calendarStore', () => {
|
|||||||
showEventDialog.value = true;
|
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,
|
||||||
@@ -334,6 +362,8 @@ export const useCalendarStore = defineStore('calendarStore', () => {
|
|||||||
hiddenCalendarIds,
|
hiddenCalendarIds,
|
||||||
holidays,
|
holidays,
|
||||||
dictEmployeesLoaded,
|
dictEmployeesLoaded,
|
||||||
|
showCreateCalendarDialog,
|
||||||
|
createCalendarInitial,
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
formattedSelectedDate,
|
formattedSelectedDate,
|
||||||
@@ -367,5 +397,7 @@ export const useCalendarStore = defineStore('calendarStore', () => {
|
|||||||
loadEmployees,
|
loadEmployees,
|
||||||
setSelectedEvent,
|
setSelectedEvent,
|
||||||
editFromView,
|
editFromView,
|
||||||
|
requestCreateCalendar,
|
||||||
|
resolveCreateCalendar,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
Reference in new issue
Block a user