186 lines
4.8 KiB
Vue
186 lines
4.8 KiB
Vue
<template>
|
|
{{selected}}
|
|
<v-autocomplete
|
|
v-model="selectedStaff"
|
|
:items="staff"
|
|
label="Выберите из списка или найдите по ФИО"
|
|
item-title="title"
|
|
item-value="id"
|
|
:custom-filter="onFilter"
|
|
@update:search="(val) => (filtered = val)"
|
|
multiple
|
|
hide-details
|
|
variant="outlined"
|
|
density="compact"
|
|
class="max-height-select py-3"
|
|
return-object
|
|
>
|
|
<!-- -->
|
|
<template v-slot:selection="{ item }">
|
|
<v-chip>
|
|
<!-- {{item}} -->
|
|
<span> {{ item.title }}</span>
|
|
<v-icon
|
|
icon="mdi-close-circle"
|
|
size="x-small"
|
|
class="ml-3"
|
|
@click.stop="cbstaff([item.raw], false)"
|
|
/>
|
|
</v-chip>
|
|
</template>
|
|
|
|
<template v-slot:prepend-item>
|
|
<v-list-item @click="allman" class="text-body-2">
|
|
<span class="text-body-2"> ВСЕ СОТРУДНИКИ </span>
|
|
|
|
<template v-slot:prepend>
|
|
<v-checkbox-btn
|
|
:model-value="staff.every((e) => e.selected == true)"
|
|
></v-checkbox-btn>
|
|
</template>
|
|
</v-list-item>
|
|
|
|
<v-divider class="mt-2"></v-divider>
|
|
</template>
|
|
|
|
<template v-slot:item="{ props, item }">
|
|
<v-list-group v-bind="props" :value="item.raw.title">
|
|
<template v-slot:activator="{ props }">
|
|
<v-list-item
|
|
v-bind="props"
|
|
@click.stop=""
|
|
density="compact"
|
|
class="text-body-2"
|
|
>
|
|
<template v-slot:prepend>
|
|
<v-checkbox-btn
|
|
@click.stop="toggledep(item.raw)"
|
|
:color="'indigo-darken-4'"
|
|
:true-value="true"
|
|
:false-value="false"
|
|
:indeterminate="
|
|
item.raw.employees.some((e) => e.selected == true) &&
|
|
!item.raw.employees.every((e) => e.selected == true)
|
|
"
|
|
:model-value="item.raw.selected"
|
|
></v-checkbox-btn>
|
|
</template>
|
|
</v-list-item>
|
|
</template>
|
|
|
|
<v-list-item
|
|
v-for="x in item.raw.employees.filter((e) =>
|
|
e.title.toLowerCase().includes(filtered.toLowerCase())
|
|
)"
|
|
:key="x.id"
|
|
:value="x.title"
|
|
@click.stop="x.selected = !x.selected"
|
|
density="compact"
|
|
>
|
|
<template v-slot:prepend>
|
|
<v-checkbox-btn
|
|
color="indigo-darken-4"
|
|
:model-value="x.selected"
|
|
></v-checkbox-btn>
|
|
</template>
|
|
<span class="text-body-2"> {{ x.title }} </span>
|
|
</v-list-item>
|
|
</v-list-group>
|
|
</template>
|
|
</v-autocomplete>
|
|
</template>
|
|
|
|
<script>
|
|
import { ref, computed } from "vue";
|
|
import { axiosApiInstance } from "@/utils/axios-api";
|
|
import { splitname } from "@/utils/universal_functions";
|
|
|
|
|
|
export default {
|
|
props : {
|
|
participant: {
|
|
type: Array,
|
|
default: () => [],
|
|
}},
|
|
|
|
|
|
setup(props, { emit }) {
|
|
const filtered = ref("");
|
|
const staff = ref([]);
|
|
axiosApiInstance
|
|
.get("api/calendar_of_events/get_employees/")
|
|
.then((res) => {
|
|
staff.value = res.data.filter((e) => e.employees.length > 0);
|
|
console.log(staff.value, 'staff.value');
|
|
});
|
|
|
|
const selectedStaff = computed(() => {
|
|
let selected = [];
|
|
//
|
|
|
|
staff.value.forEach((e) => {
|
|
|
|
|
|
if (e.employees.every((n) => n.selected == true)) {
|
|
e.selected = true;
|
|
selected.push(e);
|
|
} else {
|
|
e.selected = false;
|
|
|
|
selected.push(...e.employees.filter((n) => {n.selected == true }));
|
|
}
|
|
});
|
|
|
|
return selected;
|
|
});
|
|
const cbstaff = (item, value) => {
|
|
item.forEach((e) => {
|
|
e.selected = value;
|
|
if ("employees" in e) {
|
|
cbstaff(e.employees, value);
|
|
}
|
|
});
|
|
};
|
|
|
|
const allman = () => {
|
|
let val = staff.value.every((e) => e.selected == true) ? false : true;
|
|
cbstaff(staff.value, val);
|
|
};
|
|
|
|
function toggledep(item) {
|
|
item.employees.forEach((e) => (e.selected = !item.selected));
|
|
item.selected = !item.selected;
|
|
}
|
|
|
|
function onFilter(item, itemText) {
|
|
return (
|
|
item.includes(filtered.value) ||
|
|
itemText.raw.employees.some((e) =>
|
|
e.title.toLowerCase().includes(filtered.value.toLowerCase())
|
|
)
|
|
);
|
|
}
|
|
|
|
return {
|
|
filtered,
|
|
staff,
|
|
selectedStaff,
|
|
allman,
|
|
cbstaff,
|
|
toggledep,
|
|
splitname,
|
|
onFilter,
|
|
};
|
|
},
|
|
};
|
|
</script>
|
|
|
|
<style>
|
|
.max-height-select .v-field__input {
|
|
max-height: 300px; /* Установите желаемую максимальную высоту */
|
|
overflow-y: auto; /* Добавьте прокрутку, если список превышает максимальную высоту */
|
|
overflow-x: hidden;
|
|
margin: 5px;
|
|
}
|
|
</style>
|