P-42 Взрыв мозга, но работает. Остаток - чек бокс на отделы

This commit is contained in:
iriska-gri committed 2024-05-31 13:15:59 +03:00
1 parent 2b0481817c
commit 2aab352319
1 file changed
+33 -12
@@ -21,7 +21,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>
<v-checkbox-btn
:color="onePlusStaff ? 'indigo-darken-4' : undefined"
@@ -86,30 +86,51 @@ export default {
},
]);
const selectedStaff = ref([]);
const selectDepartnment = ref({});
const allStaff = computed(
() => selectedStaff.value.length === staff.value.length
() => {
let summSelectDep = 0
Object.keys(selectDepartnment.value).map((el) => { summSelectDep += selectDepartnment.value[el].length})
return summSelectDep === 6
}
);
const onePlusStaff = computed(() => selectedStaff.value.length > 0);
function toggle() {
let summStaff = 0
let summSelectDep = 0
staff.value.map((el)=> {summStaff += el.staff.length} )
// selectDepartnment.value.map((el)=> {summSelectDep += el.length} )
console.log(summStaff,summSelectDep, 'summStaff')
console.log(selectedStaff.value, 'selectedStaff');
console.log(selectDepartnment.value, 'selectedStaff');
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 {
// selectedStaff.value = staff.value.slice();
// staff.value.map((el)=> {selectedStaff.value.push(el)})
// console.log(selectDepartnment.value)
Object.keys(staff.value).map((el) => {
staff.value[el].staff.map((fio) =>
// console.log(fio.fio)
selectDepartnment.value[staff.value[el].id].push(fio.fio)
);
selectedStaff.value.push(staff.value[el].department)
}
);
}
}
function selectFIO(user, dep) {