P-42 Завершено

This commit is contained in:
iriska-gri committed 2024-07-03 16:42:23 +03:00
1 parent 58ff68bcdc
commit 31fd9fbfb4
3 files changed
+76 -34

No files matched your search

@@ -15,11 +15,12 @@
</v-card-text> </v-card-text>
<v-card-actions class="justify-end"> <v-card-actions class="justify-end">
<v-btn <v-btn
v-if="!newOrOld"
icon="mdi-delete" icon="mdi-delete"
variant="tonal" variant="tonal"
rounded rounded
size="36px" size="36px"
:disabled="newOrOld"
@click="$emit('delObject')" @click="$emit('delObject')"
/> />
@@ -41,7 +42,7 @@
width="150" width="150"
type="transformation" type="transformation"
> >
{{ newOrOld ? "Создать" : "Редактировать" }} {{ title =="Новый календарь" ? "Создать" : "Редактировать" }}
</v-btn> </v-btn>
</v-card-actions> </v-card-actions>
</v-form> </v-form>
@@ -1,7 +1,7 @@
<template> <template>
<v-autocomplete <v-autocomplete
v-model="selectedStaff" v-model="selectedStaff"
:items="staff" :items="staffed"
label="Выберите из списка или найдите по ФИО" label="Выберите из списка или найдите по ФИО"
item-title="title" item-title="title"
item-value="id" item-value="id"
@@ -29,8 +29,7 @@
</template> </template>
<template v-slot:prepend-item> <template v-slot:prepend-item>
<!-- @click="staff.forEach((e) => (selectedStaff = [e, false]))" --> <v-list-item @click="selectedStaff = staffed" class="text-body-2">
<v-list-item @click="selectedStaff = staff" class="text-body-2">
<span class="text-body-2"> ВСЕ СОТРУДНИКИ </span> <span class="text-body-2"> ВСЕ СОТРУДНИКИ </span>
<template v-slot:prepend> <template v-slot:prepend>
@@ -74,6 +73,7 @@
)" )"
:key="x.id" :key="x.id"
:value="x.title" :value="x.title"
:disabled="x.id == accountStore.user.is_idEmployee"
@click.stop="selectedStaff = x" @click.stop="selectedStaff = x"
density="compact" density="compact"
> >
@@ -112,7 +112,28 @@ export default {
const filtered = ref(""); const filtered = ref("");
const accountStore = useAccountStore(); const accountStore = useAccountStore();
const back = ref([]); const back = ref([]);
const staffed = computed({
get() {
if (props.okey == "editor") {
let ns = [];
props.staff.forEach((e) => {
let emp = { ...e };
emp.employees = e.employees.filter((n) => n.selected == true);
if (emp.employees.length > 0) ns.push(emp);
});
ns.forEach((e) => {
if (e.employees.every((w) => w.editor == true)) {
e.editor = true;
}
});
return ns;
}
return props.staff;
},
});
const selectedStaff = computed({ const selectedStaff = computed({
get() { get() {
let selected = []; let selected = [];
@@ -134,7 +155,9 @@ export default {
set(item) { set(item) {
if ("employees" in item) { if ("employees" in item) {
item.employees.forEach((e) => { item.employees.forEach((e) => {
account(e); if (e.id != accountStore.user.is_idEmployee) {
e[props.okey] = !e[props.okey];
}
}); });
emit("returnIdParticant", { emit("returnIdParticant", {
@@ -143,31 +166,36 @@ export default {
}); });
} else if (item.length) { } else if (item.length) {
let val = item.every((e) => e[props.okey] == true) ? false : true; let val = item.every((e) => e[props.okey] == true) ? false : true;
// console.log(item, "GJVTYZKCZ");
cbstaff(item, val); cbstaff(item, val);
emit("returnIdParticant", { okey: props.okey, staff: back.value }); emit("returnIdParticant", { okey: props.okey, staff: back.value });
} else { } else {
account(item) // account(item)
item[props.okey] = !item[props.okey];
emit("returnIdParticant", { okey: props.okey, staff: [item] }); emit("returnIdParticant", { okey: props.okey, staff: [item] });
} }
}, },
}); });
const account = (val) => { // const account = (val) => {
if (props.okey == "selected") { // if (props.okey == "selected") {
if (val.id != accountStore.user.is_idEmployee) { // if (val.id != accountStore.user.is_idEmployee) {
val.selected = !val.selected; // val.selected = !val.selected;
} else { // } else {
val.editor = !val.editor; // val.editor = !val.editor;
} // }
} // }
}; // };
const cbstaff = (item, value) => { const cbstaff = (item, value) => {
item.forEach((e) => { item.forEach((e) => {
account(e); // account(e);
if (e.id != accountStore.user.is_idEmployee) {
e[props.okey] = value;
}
if (!("employees" in e)) { if (!("employees" in e)) {
back.value.push(e); back.value.push(e);
@@ -176,6 +204,7 @@ export default {
cbstaff(e.employees, value); cbstaff(e.employees, value);
} }
}); });
console.log(item, "item");
}; };
function onFilter(item, itemText) { function onFilter(item, itemText) {
@@ -188,6 +217,7 @@ export default {
} }
return { return {
staffed,
filtered, filtered,
accountStore, accountStore,
selectedStaff, selectedStaff,
@@ -68,7 +68,7 @@
<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-col>
<calendar-create-select <calendar-create-select
:staff="newStaff.filter(e=>e.employees.some(n=>n.selected==true))" :staff="newStaff"
:okey="'editor'" :okey="'editor'"
@returnIdParticant="returnIdParticant" @returnIdParticant="returnIdParticant"
/> />
@@ -127,18 +127,20 @@ export default {
idPart.staff.forEach((e) => { idPart.staff.forEach((e) => {
if(idPart.okey == 'editor') { if(idPart.okey == 'editor') {
let ind = propsCalendar.value.participant.findIndex( let ind = propsCalendar.value.participant.find(
(l) => l.participant_calendar == e.id (l) => l.participant_calendar == e.id
) )
if (ind >= 0) { console.log(ind);
propsCalendar.value.participant[ind].editor = e.editor ind.editor = e.editor
} // if (ind >= 0) {
else { // propsCalendar.value.participant[ind].editor = e.editor
propsCalendar.value.participant.push({ // }
editor: e.editor, // else {
participant_calendar: e.id, // propsCalendar.value.participant.push({
}); // editor: e.editor,
} // participant_calendar: e.id,
// });
// }
} }
else { else {
@@ -152,6 +154,7 @@ export default {
(l) => l.participant_calendar == e.id (l) => l.participant_calendar == e.id
); );
propsCalendar.value.participant.splice(ind, 1); propsCalendar.value.participant.splice(ind, 1);
} }
} }
}); });
@@ -175,10 +178,13 @@ export default {
const newCalendar = ref(false); const newCalendar = ref(false);
const calendarNewOrOld = () => { const calendarNewOrOld = () => {
console.log(propsCalendar.value, '------propsCalendar.valuepropsCalendar.value')
if (propsCalendar.value.hasOwnProperty("id")) { if (propsCalendar.value.hasOwnProperty("id")) {
titleCard.value = "Редактирование календаря"; titleCard.value = "Редактирование календаря";
if(propsCalendar.value.author!=accountStore.user.is_idEmployee ) newCalendar.value = true
} else { } else {
titleCard.value = "Новый календарь"; titleCard.value = "Новый календарь";
newCalendar.value = true; newCalendar.value = true;
} }
}; };
@@ -224,25 +230,30 @@ export default {
const newStaff = computed({ const newStaff = computed({
get() { get() {
staff.value.forEach((e) => { staff.value.forEach((e) => {
if (propsCalendar.value.participant.length > 0) { if (propsCalendar.value.participant.length > 0) {
e.employees.forEach((empl) => { e.employees.forEach((empl) => {
let a =
let ab =
propsCalendar.value.participant.find( propsCalendar.value.participant.find(
(a) => a.participant_calendar === empl.id (a) => a.participant_calendar === empl.id
) )
if ( if (ab) {
a
) {
empl.selected = true; empl.selected = true;
empl.editor = a.editor empl.editor = ab.editor
} }
else {
empl.selected = false;
empl.editor = false
}
}); });
} }
}); });
// console.log(staff.value);
return staff.value; return staff.value;
}, },
}); });