From 861647e87be23be6d67c6f21c3a7cade1ba210c3 Mon Sep 17 00:00:00 2001 From: iriska-gri <79623434+iriska-gri@users.noreply.github.com> Date: Thu, 30 May 2024 16:56:58 +0300 Subject: [PATCH] =?UTF-8?q?P-42=20=D0=9C=D0=B5=D0=B3=D0=B0=D0=BB=D0=BE?= =?UTF-8?q?=D0=B3=D0=B8=D0=BA=D0=B0=20=20=D0=B2=D1=8B=D0=B1=D0=BE=D1=80?= =?UTF-8?q?=D0=BE=D0=BC=20=D1=81=D0=BE=D1=82=D1=80=D1=83=D0=B4=D0=BD=D0=B8?= =?UTF-8?q?=D0=BA=D0=BE=D0=B2=20=D0=B8=20=D0=BE=D1=82=D0=B4=D0=B5=D0=BB?= =?UTF-8?q?=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Продолжить писать функцию --- .../calendar-create-select copy.vue | 152 ++++++++++++++++++ .../calendar-create-select.vue | 148 +++++++++++------ 2 files changed, 254 insertions(+), 46 deletions(-) create mode 100644 src/front/src/components/calendar_of_events/calendar-create-select copy.vue diff --git a/src/front/src/components/calendar_of_events/calendar-create-select copy.vue b/src/front/src/components/calendar_of_events/calendar-create-select copy.vue new file mode 100644 index 000000000..263ee45e0 --- /dev/null +++ b/src/front/src/components/calendar_of_events/calendar-create-select copy.vue @@ -0,0 +1,152 @@ + + + + + diff --git a/src/front/src/components/calendar_of_events/calendar-create-select.vue b/src/front/src/components/calendar_of_events/calendar-create-select.vue index 9d81693fd..f45be7143 100644 --- a/src/front/src/components/calendar_of_events/calendar-create-select.vue +++ b/src/front/src/components/calendar_of_events/calendar-create-select.vue @@ -12,39 +12,23 @@ class="max-height-select" return-object > - - @@ -87,18 +61,29 @@ import { ref, onMounted, computed } from "vue"; export default { setup() { - - const staff = ref([ { department: "ОКТП", id: 1, - staff: [{ fio: "ГИС", id: 1 }, { fio: "СВВ", id: 2 }, { fio: "ФА", id: 3 }, { fio: "АА", id: 4 }], + staff: [ + { fio: "ГИС", id: 1 }, + { fio: "СВВ", id: 2 }, + { fio: "ФА", id: 3 }, + { fio: "АА", id: 4 }, + ], + }, + { + department: "ОВТП", + id: 2, + staff: [ + { fio: "ЩВ", id: 1 }, + { fio: "ДК", id: 2 }, + ], }, - { department: "ОВТП", id: 2, staff: [{ fio: "ЩВ", id: 1 }, { fio: "ДК", id: 2 }] }, ]); const selectedStaff = ref([]); + const selectDepartnment = ref({}); const allStaff = computed( () => selectedStaff.value.length === staff.value.length @@ -115,16 +100,89 @@ export default { } function selectFIO(user, dep) { - let ob = staff.value.find(el => el.id == dep) + staff.value.forEach((e) => { + if (!selectDepartnment.value[e.id]) { + selectDepartnment.value[e.id] = []; + } + }); + // selectDepartnment.forEach((e) => { - ob['chek'] = false - let indx = selectedStaff.value.findIndex((i) => i.id == dep) - if (indx ==-1) { - selectedStaff.value.push(ob) - } - - - console.log(ob, 'ki') + // if (!ob[e.author.id]) { + // ob[e.author.id] = 0 + // } + // ob[e.author.id] += 1 + // }) + + let ob = staff.value.find((el) => el.id == dep); + + if(selectDepartnment.value[dep].includes(user.fio)) { + let inddep = selectDepartnment.value[dep].indexOf(user.fio) + selectDepartnment.value[dep].splice(inddep, 1); + } + else { + selectDepartnment.value[dep].push(user.fio) + + // if(selectDepartnment.value[dep].length == ob.staff.length){ + // selectDepartnment.value[dep]['dep'] = ob.department + // } + // else { + // selectDepartnment.value[dep]['dep'] = '' + // } + + } + + if (selectedStaff.value.includes(user.fio)) { + let index = selectedStaff.value.indexOf(user.fio); + selectedStaff.value.splice(index, 1); + } + else { + if (selectDepartnment.value[dep].length == ob.staff.length) { + selectedStaff.value.filter( ( el ) => !~selectDepartnment.value[dep].indexOf( el ) ) + selectedStaff.value.push(ob.department) + + } + else { + selectedStaff.value.push(user.fio); + } + // + } + // selectedStaff.value = selectDepartnment.value[dep] + // console.log(selectedStaff.value, '------------'); + // selectedStaff.value.push(selectDepartnment.value[dep]) + + // if (selectedStaff.value.includes(user.fio)) { + + // let index = selectedStaff.value.indexOf(user.fio); + // selectedStaff.value.splice(index, 1); + + // let inddep = selectDepartnment.value[dep].indexOf(user.fio) + // selectDepartnment.value[dep].splice(inddep, 1); + + + // } else { + // selectDepartnment.value[dep].push(user.fio); + // if (selectDepartnment.value[dep].length == ob.staff.length) { + // selectDepartnment.value[dep] = [] + // selectedStaff.value.push(ob.department); + + // } else { + // selectedStaff.value.push(user.fio); + // } + // } + console.log(selectedStaff.value, 'selectedStaff.valueselectedStaff.value') + console.log(selectDepartnment.value, selectDepartnment.value[dep].length == ob.staff.length, "11111111111111111"); + // + // userDep.department = ob.department + // userDep.staff = user + + // ob['chek'] = false + // let indx = selectedStaff.value.findIndex((i) => i.id == dep) + // if (indx ==-1) { + + // selectedStaff.value.push(ob) + // } + + // console.log(userDep, 'ki') } return { @@ -133,10 +191,8 @@ export default { allStaff, onePlusStaff, selectFIO, - + selectDepartnment, toggle, - - }; }, };