This commit is contained in:
iriska-gri committed 2024-06-04 15:40:59 +03:00
1 parent 4356a5600d
commit 7ab0353833
2 files changed
+73 -63

No files matched your search

@@ -6,20 +6,25 @@
label="Выберите из списка или найдите по ФИО" label="Выберите из списка или найдите по ФИО"
item-title="title" item-title="title"
item-value="id" item-value="id"
:custom-filter="onFilter"
multiple multiple
hide-details hide-details
variant="outlined" variant="outlined"
density="compact" density="compact"
class="max-height-select" 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}} -->
<span> {{ item.title }}</span> <span> {{ item.title }}</span>
<v-btn <v-icon
@click.stop="cbstaff([item.raw],false)" icon="mdi-close-circle"
>x</v-btn> size="x-small"
class="ml-3"
@click.stop="cbstaff([item.raw], false)"
/>
</v-chip> </v-chip>
</template> </template>
@@ -29,7 +34,7 @@
<template v-slot:prepend> <template v-slot:prepend>
<v-checkbox-btn <v-checkbox-btn
:model-value="staff.every(e=>e.selected==true)" :model-value="staff.every((e) => e.selected == true)"
></v-checkbox-btn> ></v-checkbox-btn>
</template> </template>
</v-list-item> </v-list-item>
@@ -38,13 +43,11 @@
</template> </template>
<template v-slot:item="{ props, item }"> <template v-slot:item="{ props, item }">
<v-list-group <v-list-group
v-bind="props" v-bind="props"
:value="item.raw.title" :value="item.raw.title"
v-if="item.raw.id != 0" v-if="item.raw.id != 0"
> >
<template v-slot:activator="{ props }"> <template v-slot:activator="{ props }">
<v-list-item <v-list-item
v-bind="props" v-bind="props"
@@ -52,21 +55,19 @@
density="compact" density="compact"
class="text-body-2" class="text-body-2"
> >
<template v-slot:prepend> <template v-slot:prepend>
{{ item.raw.selected }} <v-checkbox-btn
<v-checkbox-btn @click.stop="toggledep(item.raw)"
@click.stop="toggledep(item.raw)" :color="'indigo-darken-4'"
:color="'indigo-darken-4'" :true-value="true"
:true-value="true" :false-value="false"
:false-value="false" :indeterminate="
:indeterminate="item.raw.employees.some(e=>e.selected==true) && !item.raw.employees.every(e=>e.selected==true)" item.raw.employees.some((e) => e.selected == true) &&
:model-value="item.raw.selected" !item.raw.employees.every((e) => e.selected == true)
></v-checkbox-btn> "
</template> :model-value="item.raw.selected"
></v-checkbox-btn>
</template>
</v-list-item> </v-list-item>
</template> </template>
@@ -74,12 +75,12 @@
v-for="x in item.raw.employees" v-for="x in item.raw.employees"
:key="x.id" :key="x.id"
:value="x.title" :value="x.title"
@click.stop="x.selected=!x.selected" @click.stop="x.selected = !x.selected"
density="compact" density="compact"
> >
<template v-slot:prepend> <template v-slot:prepend>
<v-checkbox-btn <v-checkbox-btn
color="indigo-darken-4" color="indigo-darken-4"
:model-value="x.selected" :model-value="x.selected"
></v-checkbox-btn> ></v-checkbox-btn>
</template> </template>
@@ -93,55 +94,62 @@
<script> <script>
import { ref, computed } from "vue"; import { ref, computed } from "vue";
import { axiosApiInstance } from "@/utils/axios-api"; import { axiosApiInstance } from "@/utils/axios-api";
import { splitname } from "@/utils/universal_functions";
export default { export default {
setup() { setup() {
const staff = ref([]); const staff = ref([]);
axiosApiInstance axiosApiInstance
.get("api/calendar_of_events/get_employees/") .get("api/calendar_of_events/get_employees/")
.then((res) => { .then((res) => {
staff.value = res.data; staff.value = res.data.filter((e) => e.employees.length > 0);
}); });
const selectedStaff =computed(() => { const selectedStaff = computed(() => {
let selected = [] let selected = [];
staff.value.forEach((e)=>{ staff.value.forEach((e) => {
if (e.employees.every(n=>n.selected==true)){ if (e.employees.every((n) => n.selected == true)) {
e.selected=true e.selected = true;
selected.push(e) selected.push(e);
} else {
}else{ e.selected = false;
selected.push(...e.employees.filter((n) => n.selected == true));
e.selected=false
selected.push(...e.employees.filter(n=>n.selected==true))}
}
)
return selected
}
)
const cbstaff=(item, value)=>{
console.log(item);
item.forEach((e)=>{
e.selected=value
if('employees' in e){
cbstaff(e.employees, value)
} }
}) });
}
const allman =()=>{ return selected;
let val = staff.value.every(e=>e.selected==true)?false:true });
cbstaff(staff.value, val) const cbstaff = (item, value) => {
} console.log(item);
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) { function toggledep(item) {
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 onFilter(item, queryText, itemText){
console.log(item, 'item')
console.log(queryText, 'queryText,')
console.log(itemText.raw.employees, 'itemText,')
// let fio = itemText.raw.employees.map(e =>e.title.includes(queryText))
// console.log (itemText.raw.employees.map(e =>e.title.includes(queryText)))
// console.log(item.includes(queryText));
return itemText.raw.employees.map(e =>e.title.includes(queryText))
// return item.title.includes(queryText)
// || item.Value.toLocaleLowerCase().includes(queryText.toLocaleLowerCase())
}
return { return {
staff, staff,
@@ -149,6 +157,8 @@ export default {
allman, allman,
cbstaff, cbstaff,
toggledep, toggledep,
splitname,
onFilter
}; };
}, },
}; };
@@ -156,7 +166,7 @@ export default {
<style> <style>
.max-height-select .v-field__input { .max-height-select .v-field__input {
max-height: 60px; /* Установите желаемую максимальную высоту */ max-height: 300px; /* Установите желаемую максимальную высоту */
overflow-y: auto; /* Добавьте прокрутку, если список превышает максимальную высоту */ overflow-y: auto; /* Добавьте прокрутку, если список превышает максимальную высоту */
overflow-x: hidden; overflow-x: hidden;
margin: 5px; margin: 5px;
@@ -1,6 +1,6 @@
<template> <template>
<v-dialog v-model="dialog_create_calendar" max-width="636"> <v-dialog v-model="dialog_create_calendar" min-width="636" max-width="800">
<v-card height="436" class="pa-3"> <v-card min-height="436" class="pa-3">
<v-card-title class="pr-0 pl-2 d-flex justify-space-between"> <v-card-title class="pr-0 pl-2 d-flex justify-space-between">
Новый календарь Новый календарь
<v-icon <v-icon
@@ -27,7 +27,7 @@
hide-details hide-details
></v-textarea></v-col ></v-textarea></v-col
></v-row> ></v-row>
<v-row no-gutters class="align-center"> <v-row no-gutters class="align-center pt-3">
<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-for="(x, key) in color" :key="key"> <v-col v-for="(x, key) in color" :key="key">
<v-avatar <v-avatar