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> <template v-slot:prepend-item>
<v-list-item @click="toggle" class="text-body-2"> <v-list-item @click="toggle" class="text-body-2">
<span class="text-body-2"> ВСЕ СОТРУДНИКИ </span> <span class="text-body-2"> ВСЕ СОТРУДНИКИ </span>
<template v-slot:prepend> <template v-slot:prepend>
<v-checkbox-btn <v-checkbox-btn
:color="onePlusStaff ? 'indigo-darken-4' : undefined" :color="onePlusStaff ? 'indigo-darken-4' : undefined"
@@ -86,30 +86,51 @@ export default {
}, },
]); ]);
const selectedStaff = ref([]); const selectedStaff = ref([]);
const selectDepartnment = ref({}); const selectDepartnment = ref({});
const allStaff = computed( 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); const onePlusStaff = computed(() => selectedStaff.value.length > 0);
function toggle() { function toggle() {
let summStaff = 0
let summSelectDep = 0 staff.value.forEach((e) => {
staff.value.map((el)=> {summStaff += el.staff.length} ) if (!selectDepartnment.value[e.id]) {
// selectDepartnment.value.map((el)=> {summSelectDep += el.length} ) selectDepartnment.value[e.id] = [];
console.log(summStaff,summSelectDep, 'summStaff') }
console.log(selectedStaff.value, 'selectedStaff'); });
console.log(selectDepartnment.value, 'selectedStaff');
console.log(allStaff.value, '1111111111111111111')
if (allStaff.value) { if (allStaff.value) {
selectDepartnment.value = []; selectDepartnment.value = [];
selectedStaff.value = []
} else { } else {
// selectedStaff.value = staff.value.slice();
// staff.value.map((el)=> {selectedStaff.value.push(el)}) Object.keys(staff.value).map((el) => {
// console.log(selectDepartnment.value) 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) { function selectFIO(user, dep) {