P-42 Старая логика работает с запросом
This commit is contained in:
1 parent
3ba272b11b
commit
e3aace6f9d
5 files changed
+70
-39
No files matched your search
@@ -79,7 +79,7 @@ import { ref, onMounted, watch } from "vue";
|
||||
import { useWeekendsStore } from "@/store/WeekendsStore";
|
||||
import EventCreate from "@/components/calendar_of_events/event-create.vue";
|
||||
import CalendarMy from "@/components/calendar_of_events/calendar-my.vue";
|
||||
|
||||
import { axiosApiInstance } from "@/utils/axios-api";
|
||||
export default {
|
||||
components: { EventCreate, CalendarMy },
|
||||
|
||||
@@ -144,6 +144,11 @@ export default {
|
||||
week.getWeekend(MyYear.value);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return {
|
||||
drawer_right,
|
||||
selectdate,
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
v-model="selectedStaff"
|
||||
:items="staff"
|
||||
label="Выберите из списка или найдите по ФИО"
|
||||
item-title="department"
|
||||
item-value="department"
|
||||
item-title="name"
|
||||
item-value="name"
|
||||
multiple
|
||||
hide-details
|
||||
variant="outlined"
|
||||
@@ -12,7 +12,7 @@
|
||||
class="max-height-select"
|
||||
return-object
|
||||
>
|
||||
<template v-slot:selection="{ item, index }">
|
||||
<template v-slot:selection="{ item }">
|
||||
<v-chip>
|
||||
<span> {{ item.title }}</span>
|
||||
</v-chip>
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
<template v-slot:prepend-item>
|
||||
<v-list-item @click="toggle" class="text-body-2">
|
||||
|
||||
<span class="text-body-2"> ВСЕ СОТРУДНИКИ </span>
|
||||
|
||||
<template v-slot:prepend>
|
||||
@@ -35,7 +36,7 @@
|
||||
</template>
|
||||
|
||||
<template v-slot:item="{ props, item }">
|
||||
<v-list-group v-bind="props" :value="item.raw.department">
|
||||
<v-list-group v-bind="props" :value="item.raw.name">
|
||||
<template v-slot:activator="{ props }">
|
||||
<v-list-item
|
||||
v-bind="props"
|
||||
@@ -47,7 +48,7 @@
|
||||
</template>
|
||||
|
||||
<v-list-item
|
||||
v-for="(x, i) in item.raw.staff"
|
||||
v-for="(x, i) in item.raw.employees"
|
||||
:key="i"
|
||||
:value="x.fio"
|
||||
@click.stop="selectFIO(x, item.raw.id)"
|
||||
@@ -62,35 +63,46 @@
|
||||
|
||||
<script>
|
||||
import { ref, computed } from "vue";
|
||||
|
||||
import { axiosApiInstance } from "@/utils/axios-api";
|
||||
export default {
|
||||
setup() {
|
||||
const staff = ref([
|
||||
{
|
||||
department: "ОКТП",
|
||||
id: 1,
|
||||
staff: [
|
||||
{ fio: "ГИС", id: 1 },
|
||||
{ fio: "СВВ", id: 2 },
|
||||
{ fio: "ФА", id: 3 },
|
||||
{ fio: "АА", id: 4 },
|
||||
],
|
||||
},
|
||||
{
|
||||
department: "ОВТП",
|
||||
id: 2,
|
||||
staff: [
|
||||
{ fio: "ЩВ", id: 1 },
|
||||
{ fio: "ДК", id: 2 },
|
||||
],
|
||||
},
|
||||
]);
|
||||
|
||||
const staff = ref([])
|
||||
axiosApiInstance.get("api/calendar_of_events/get_employees/").then((res) => {
|
||||
staff.value = res.data
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
// const staff = ref([
|
||||
// {
|
||||
// department: "ОКТП",
|
||||
// id: 1,
|
||||
// staff: [
|
||||
// { fio: "ГИС", id: 1 },
|
||||
// { fio: "СВВ", id: 2 },
|
||||
// { fio: "ФА", id: 3 },
|
||||
// { fio: "АА", id: 4 },
|
||||
// ],
|
||||
// },
|
||||
// {
|
||||
// department: "ОВТП",
|
||||
// id: 2,
|
||||
// staff: [
|
||||
// { fio: "ЩВ", id: 1 },
|
||||
// { fio: "ДК", id: 2 },
|
||||
// ],
|
||||
// },
|
||||
// ]);
|
||||
|
||||
|
||||
|
||||
const selectedStaff = ref([]);
|
||||
const selectDepartnment = ref({});
|
||||
|
||||
|
||||
|
||||
const allStaff = computed(
|
||||
() => {
|
||||
let summSelectDep = 0
|
||||
@@ -103,27 +115,32 @@ export default {
|
||||
|
||||
const onePlusStaff = computed(() => selectedStaff.value.length > 0);
|
||||
|
||||
|
||||
|
||||
|
||||
function toggle() {
|
||||
|
||||
|
||||
staff.value.forEach((e) => {
|
||||
|
||||
if (!selectDepartnment.value[e.id]) {
|
||||
selectDepartnment.value[e.id] = [];
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
console.log(allStaff.value, '1111111111111111111')
|
||||
|
||||
if (allStaff.value) {
|
||||
selectDepartnment.value = [];
|
||||
selectedStaff.value = []
|
||||
} else {
|
||||
|
||||
Object.keys(staff.value).map((el) => {
|
||||
staff.value[el].staff.map((fio) =>
|
||||
// console.log(fio.fio)
|
||||
|
||||
staff.value[el].employees.map((fio) =>
|
||||
|
||||
selectDepartnment.value[staff.value[el].id].push(fio.fio)
|
||||
);
|
||||
selectedStaff.value.push(staff.value[el].department)
|
||||
selectedStaff.value.push(staff.value[el].name)
|
||||
}
|
||||
|
||||
);
|
||||
@@ -134,18 +151,25 @@ export default {
|
||||
}
|
||||
|
||||
function selectFIO(user, dep) {
|
||||
|
||||
staff.value.forEach((e) => {
|
||||
|
||||
if (!selectDepartnment.value[e.id]) {
|
||||
selectDepartnment.value[e.id] = [];
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if (selectedStaff.value.includes(user.fio)) {
|
||||
let index = selectedStaff.value.indexOf(user.fio);
|
||||
selectedStaff.value.splice(index, 1);
|
||||
}
|
||||
let ob = staff.value.find((el) => el.id == dep);
|
||||
|
||||
console.log(selectDepartnment.value, 'selectDepartnment.value1111111111111111111')
|
||||
console.log(selectedStaff.value, 'selectedStaff.value1111111111111111111')
|
||||
|
||||
|
||||
let ob = staff.value.find((el) => el.id == dep);
|
||||
console.log(ob, 'eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee')
|
||||
if (selectDepartnment.value[dep].includes(user.fio)) {
|
||||
let inddep = selectDepartnment.value[dep].indexOf(user.fio);
|
||||
selectDepartnment.value[dep].splice(inddep, 1);
|
||||
@@ -153,14 +177,14 @@ export default {
|
||||
selectDepartnment.value[dep].push(user.fio);
|
||||
}
|
||||
|
||||
if (selectDepartnment.value[dep].length == ob.staff.length) {
|
||||
if (selectDepartnment.value[dep].length == ob.employees.length) {
|
||||
selectedStaff.value = selectedStaff.value.filter(
|
||||
(el) => !~selectDepartnment.value[dep].indexOf(el)
|
||||
);
|
||||
selectedStaff.value.push(ob.department);
|
||||
selectedStaff.value.push(ob.name);
|
||||
} else {
|
||||
selectedStaff.value = selectedStaff.value.filter(
|
||||
(el) => el != ob.department
|
||||
(el) => el != ob.name
|
||||
);
|
||||
|
||||
selectDepartnment.value[dep].filter((el) => {
|
||||
|
||||
@@ -474,7 +474,7 @@ export default {
|
||||
});
|
||||
};
|
||||
|
||||
// getSafetyChapter();
|
||||
getSafetyChapter();
|
||||
|
||||
return {
|
||||
theme,
|
||||
|
||||
Reference in new issue
Block a user