This commit is contained in:
iriska-gri committed 2024-06-04 16:50:49 +03:00
1 parent e1039cbf46
commit 133696de50
1 file changed
+16 -20
@@ -1,13 +1,12 @@
<template> <template>
<v-autocomplete <v-autocomplete
v-model="selectedStaff" v-model="selectedStaff"
:items="staff" :items="staff"
label="Выберите из списка или найдите по ФИО" label="Выберите из списка или найдите по ФИО"
item-title="title" item-title="title"
item-value="id" item-value="id"
:custom-filter="onFilter" :custom-filter="onFilter"
@update:search="filchange" @update:search="(val) => (filtered = val)"
multiple multiple
hide-details hide-details
variant="outlined" variant="outlined"
@@ -15,7 +14,7 @@
class="max-height-select py-3" class="max-height-select py-3"
return-object return-object
> >
<!-- --> <!-- -->
<template v-slot:selection="{ item }"> <template v-slot:selection="{ item }">
<v-chip> <v-chip>
<!-- {{item}} --> <!-- {{item}} -->
@@ -73,7 +72,9 @@
</template> </template>
<v-list-item <v-list-item
v-for="x in item.raw.employees.filter(e=>e.title.toLowerCase().includes(filtered.toLowerCase()))" v-for="x in item.raw.employees.filter((e) =>
e.title.toLowerCase().includes(filtered.toLowerCase())
)"
:key="x.id" :key="x.id"
:value="x.title" :value="x.title"
@click.stop="x.selected = !x.selected" @click.stop="x.selected = !x.selected"
@@ -98,7 +99,7 @@ import { axiosApiInstance } from "@/utils/axios-api";
import { splitname } from "@/utils/universal_functions"; import { splitname } from "@/utils/universal_functions";
export default { export default {
setup() { setup() {
const filtered= ref("") const filtered = ref("");
const staff = ref([]); const staff = ref([]);
axiosApiInstance axiosApiInstance
.get("api/calendar_of_events/get_employees/") .get("api/calendar_of_events/get_employees/")
@@ -121,7 +122,6 @@ export default {
return selected; return selected;
}); });
const cbstaff = (item, value) => { const cbstaff = (item, value) => {
console.log(item);
item.forEach((e) => { item.forEach((e) => {
e.selected = value; e.selected = value;
if ("employees" in e) { if ("employees" in e) {
@@ -139,21 +139,17 @@ export default {
item.employees.forEach((e) => (e.selected = !item.selected)); item.employees.forEach((e) => (e.selected = !item.selected));
item.selected = !item.selected; item.selected = !item.selected;
} }
function filchange(search){
if(search.length==0){ function onFilter(item, itemText) {
filtered.value='' return (
} item.includes(filtered.value) ||
itemText.raw.employees.some((e) =>
e.title.toLowerCase().includes(filtered.value.toLowerCase())
)
);
} }
function onFilter(item, queryText, itemText){
filtered.value=queryText===null?"":queryText
return item.includes(filtered.value) || itemText.raw.employees.some(e =>e.title.toLowerCase().includes(filtered.value.toLowerCase()))
}
return { return {
filchange,
filtered, filtered,
staff, staff,
selectedStaff, selectedStaff,
@@ -161,7 +157,7 @@ export default {
cbstaff, cbstaff,
toggledep, toggledep,
splitname, splitname,
onFilter onFilter,
}; };
}, },
}; };