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