191 lines
5.0 KiB
Vue
191 lines
5.0 KiB
Vue
<template>
|
|
<!-- <div>
|
|
{{staff}}
|
|
</div> -->
|
|
|
|
<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>
|
|
<span> {{ item.title }}</span>
|
|
|
|
<v-icon
|
|
v-if="item.value != accountStore.user.is_idEmployee"
|
|
icon="mdi-close-circle"
|
|
size="x-small"
|
|
class="ml-3"
|
|
@click.stop="selectedStaff = item.raw"
|
|
/>
|
|
</v-chip>
|
|
</template>
|
|
|
|
<template v-slot:prepend-item>
|
|
<v-list-item
|
|
@click="staff.forEach((e) => (selectedStaff = e))"
|
|
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="selectedStaff = 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="selectedStaff = x"
|
|
density="compact"
|
|
>
|
|
<template v-slot:prepend>
|
|
<v-checkbox-btn
|
|
color="indigo-darken-4"
|
|
:model-value="x.selected"
|
|
:disabled="x.id == accountStore.user.is_idEmployee"
|
|
></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 { splitname } from "@/utils/universal_functions";
|
|
import { useAccountStore } from "@/store/AccountStore";
|
|
|
|
export default {
|
|
props: {
|
|
staff: {
|
|
type: Array,
|
|
default: () => [],
|
|
},
|
|
},
|
|
|
|
setup(props, { emit }) {
|
|
const filtered = ref("");
|
|
const accountStore = useAccountStore();
|
|
|
|
const selectedStaff = computed({
|
|
get() {
|
|
let selected = [];
|
|
let idEmployees = [];
|
|
|
|
props.staff.forEach((e) => {
|
|
e.employees
|
|
.filter((n) => n.selected == true)
|
|
.forEach((res) => {
|
|
idEmployees.push({
|
|
participant_calendar: res.id,
|
|
});
|
|
});
|
|
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;
|
|
},
|
|
|
|
set(item) {
|
|
|
|
if ("employees" in item) {
|
|
console.log(item)
|
|
|
|
item.employees.forEach((e) => {
|
|
if (e.id != accountStore.user.is_idEmployee) {
|
|
|
|
e.selected = !e.selected;
|
|
|
|
|
|
}
|
|
});
|
|
emit("returnIdParticant", item.employees);
|
|
} else {
|
|
item.selected = !item.selected;
|
|
|
|
emit("returnIdParticant", [item]);
|
|
}
|
|
},
|
|
});
|
|
|
|
function onFilter(item, itemText) {
|
|
return (
|
|
item.includes(filtered.value) ||
|
|
itemText.raw.employees.some((e) =>
|
|
e.title.toLowerCase().includes(filtered.value.toLowerCase())
|
|
)
|
|
);
|
|
}
|
|
|
|
return {
|
|
filtered,
|
|
accountStore,
|
|
selectedStaff,
|
|
splitname,
|
|
onFilter,
|
|
};
|
|
},
|
|
};
|
|
</script>
|
|
|
|
<style>
|
|
.max-height-select .v-field__input {
|
|
max-height: 300px; /* Установите желаемую максимальную высоту */
|
|
overflow-y: auto; /* Добавьте прокрутку, если список превышает максимальную высоту */
|
|
overflow-x: hidden;
|
|
margin: 5px;
|
|
}
|
|
</style>
|