P-47 Перенос запроса

This commit is contained in:
iriska-gri committed 2024-07-04 10:38:26 +03:00
1 parent 31fd9fbfb4
commit f001cc75fe
4 files changed
+141 -182

No files matched your search

@@ -88,12 +88,12 @@
rail rail
> >
</v-navigation-drawer> </v-navigation-drawer>
{{ showDialog }} <v-dialog v-model="showDialog" max-width="700">
<event-create <event-create
@update:opendialog="showDialog = $event" @closeDialog = "showDialog = false"
:opendialog="showDialog"
:eventCalendar="eventFromCalendar" :eventCalendar="eventFromCalendar"
/> />
</v-dialog>
</v-row> </v-row>
</template> </template>
@@ -151,7 +151,7 @@ export default {
.then((res) => { .then((res) => {
eventFromCalendar.value = res.data eventFromCalendar.value = res.data
if (idEvent.value==null) { if (idEvent.value==null) {
eventFromCalendar.value.event = {name:'', participant: [], files: [], date_start: "", date_end: "", period: null, description: ''} eventFromCalendar.value.event = {name:'', participant: [], files: [], date_start: "", date_end: "", period: null, description: '', calendar: null}
} }
// res.data.forEach( // res.data.forEach(
@@ -17,7 +17,7 @@
<template v-slot:selection="{ item }"> <template v-slot:selection="{ item }">
<v-chip> <v-chip>
<span> {{ item.title }}</span> <span> {{ item.title }}</span>
{{ item }}
<v-icon <v-icon
v-if="item.value != accountStore.user.is_idEmployee" v-if="item.value != accountStore.user.is_idEmployee"
icon="mdi-close-circle" icon="mdi-close-circle"
@@ -27,14 +27,19 @@
/> />
</v-chip> </v-chip>
</template> </template>
<!--
посчитать количество что я тут один и добавить условие -->
<template v-slot:prepend-item> <template v-slot:prepend-item>
<v-list-item @click="selectedStaff = staffed" class="text-body-2"> <v-list-item
@click="selectedStaff = staffed"
:disabled="staffed.length == 1 && staffed[0][okey] == true"
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
:model-value="staff.every((e) => e[okey] == true)" :model-value="staffed.every((e) => e[okey] == true)"
></v-checkbox-btn> ></v-checkbox-btn>
</template> </template>
</v-list-item> </v-list-item>
@@ -50,6 +55,7 @@
@click.stop="" @click.stop=""
density="compact" density="compact"
class="text-body-2" class="text-body-2"
:disabled="staffed.length == 1 && staffed[0][okey] == true"
> >
<template v-slot:prepend> <template v-slot:prepend>
<v-checkbox-btn <v-checkbox-btn
@@ -61,7 +67,11 @@
item.raw.employees.some((e) => e[okey] == true) && item.raw.employees.some((e) => e[okey] == true) &&
!item.raw.employees.every((e) => e[okey] == true) !item.raw.employees.every((e) => e[okey] == true)
" "
:model-value="item.raw[okey]" :model-value="
staffed.length == 1 && staffed[0][okey] == true
? true
: item.raw[okey]
"
></v-checkbox-btn> ></v-checkbox-btn>
</template> </template>
</v-list-item> </v-list-item>
@@ -139,8 +149,6 @@ export default {
let selected = []; let selected = [];
props.staff.forEach((e) => { props.staff.forEach((e) => {
// e.employees.filter(n => n[props.okey] == true)
if (e.employees.every((n) => n[props.okey] == true)) { if (e.employees.every((n) => n[props.okey] == true)) {
e[props.okey] = true; e[props.okey] = true;
selected.push(e); selected.push(e);
@@ -166,12 +174,10 @@ 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)
item[props.okey] = !item[props.okey]; item[props.okey] = !item[props.okey];
@@ -72,13 +72,6 @@
:okey="'editor'" :okey="'editor'"
@returnIdParticant="returnIdParticant" @returnIdParticant="returnIdParticant"
/> />
<!-- <calendar-create-select
:editor="true"
:participant="
propsCalendar.participant.filter((e) => e.editor == 1)
"
@returnIdParticant="returnIdParticant"
/> -->
</v-col> </v-col>
<v-col lg="1" class="text-center"> <v-col lg="1" class="text-center">
<v-tooltip location="top"> <v-tooltip location="top">
@@ -116,50 +109,30 @@ export default {
}, },
setup(props, { emit }) { setup(props, { emit }) {
const form_calendar = ref(null);
const for_editor = ref([]);
const accountStore = useAccountStore(); const accountStore = useAccountStore();
const returnIdParticant = (idPart) => { const returnIdParticant = (idPart) => {
idPart.staff.forEach((e) => { idPart.staff.forEach((e) => {
if(idPart.okey == 'editor') { if (idPart.okey == "editor") {
let ind = propsCalendar.value.participant.find( let ind = propsCalendar.value.participant.find(
(l) => l.participant_calendar == e.id (l) => l.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 {
if (e.selected == true) {
propsCalendar.value.participant.push({
editor: false,
participant_calendar: e.id,
});
} else {
let ind = propsCalendar.value.participant.findIndex(
(l) => l.participant_calendar == e.id
); );
propsCalendar.value.participant.splice(ind, 1);
ind.editor = e.editor;
} else {
if (e.selected == true) {
propsCalendar.value.participant.push({
editor: false,
participant_calendar: e.id,
});
} else {
let ind = propsCalendar.value.participant.findIndex(
(l) => l.participant_calendar == e.id
);
propsCalendar.value.participant.splice(ind, 1);
}
} }
}
}); });
}; };
const propsCalendar = computed({ const propsCalendar = computed({
@@ -178,10 +151,10 @@ 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 if (propsCalendar.value.author != accountStore.user.is_idEmployee)
newCalendar.value = true;
} else { } else {
titleCard.value = "Новый календарь"; titleCard.value = "Новый календарь";
@@ -214,46 +187,28 @@ export default {
axiosApiInstance axiosApiInstance
.get("api/calendar_of_events/get_employees/") .get("api/calendar_of_events/get_employees/")
.then((res) => { .then((res) => {
// console.log(res.data, "res.data");
staff.value = res.data.filter((e) => e.employees.length > 0); staff.value = res.data.filter((e) => e.employees.length > 0);
}); });
const editorStaff = computed({
get() {
// console.log(staff.value, '111111111111111111')
// console.log(propsCalendar.value.participant, 'propsCalendar.value.participantpropsCalendar.value.participant')
// let r= staff.value.filter(e=> e.selected ==true)
// return r
}
})
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 ab = propsCalendar.value.participant.find(
let ab = (a) => a.participant_calendar === empl.id
propsCalendar.value.participant.find( );
(a) => a.participant_calendar === empl.id
)
if (ab) { if (ab) {
empl.selected = true; empl.selected = true;
empl.editor = ab.editor empl.editor = ab.editor;
} else {
}
else {
empl.selected = false; empl.selected = false;
empl.editor = false empl.editor = false;
} }
}); });
} }
}); });
// console.log(staff.value);
return staff.value; return staff.value;
}, },
}); });
@@ -309,12 +264,9 @@ export default {
propsCalendar, propsCalendar,
delCalendar, delCalendar,
rules, rules,
form_calendar,
titleCard, titleCard,
newCalendar, newCalendar,
staff, newStaff
newStaff,
editorStaff
}; };
}, },
}; };
@@ -1,63 +1,76 @@
<template> <template>
<v-dialog v-model="dialog_create_event" max-width="700"> <dialog-create
<dialog-create :title="titleCard"
:title="titleCard" :newOrOld="newEvent"
:newOrOld="newEvent" @closeDialog="$emit('closeDialog')"
@closeDialog="dialog_create_calendar = false" >
> <template v-slot:card_text>
<template v-slot:card_text> <v-row no-gutters class="flex-column">
<v-row no-gutters class="flex-column"> <v-col class="d-flex flex-column">
<v-col class="d-flex flex-column"> <v-row no-gutters class="align-center">
<v-row no-gutters class="align-center"> <my-helper :pretext="propsEvent" />
<v-col class="text-body-2 text-text_grey pb-5" lg="2">
Название <v-col class="text-body-2 text-text_grey pb-5" lg="2">
</v-col> Название
<v-col> </v-col>
{{ propsEvent }} <v-col>
<v-textarea <v-textarea
density="compact" density="compact"
label="Добавить название" label="Добавить название"
row-height="25" row-height="25"
rows="1" rows="1"
variant="outlined" variant="outlined"
v-model="propsEvent.event.name" v-model="propsEvent.event.name"
></v-textarea> </v-col ></v-textarea> </v-col
></v-row> ></v-row>
<v-row no-gutters class="align-center pb-3"> <v-row no-gutters class="align-center pb-3">
<v-col class="text-body-2 text-text_grey" lg="2"> <v-col class="text-body-2 text-text_grey" lg="2"> Календарь</v-col>
Календарь</v-col <v-col>
<v-autocomplete
v-model="calendar"
:items="propsEvent.mycalendars"
label="Выберите календарь или найдите по названию"
item-title="cl_name"
item-value="id"
hide-details
variant="outlined"
density="compact"
class="py-3"
return-object
> >
<v-col> <template v-slot:selection="{ item }">
<v-avatar
class="cursor-pointer"
size="8"
:color="item.raw.cl_color"
/>
<span class="pl-2">
{{ item.title }}
</span>
</template>
<template v-slot:item="{ props, item }">
<v-list-item
:key="item.title"
:value="item"
color="primary"
@click.stop="calendar = item"
>
<template v-slot:prepend>
<v-avatar
class="cursor-pointer"
size="8"
:color="item.raw.cl_color"
/>
</template>
{{ item.title }}
<!-- {{ item}} -->
</v-list-item>
</template>
</v-autocomplete>
</v-col></v-row
>
<v-autocomplete <!-- <v-row no-gutters class="align-center pb-3">
v-model="nameCalendar"
:items="propsEvent.mycalendars"
label="Выберите календарь или найдите по названию"
item-title="cl_name"
item-value="id"
hide-details
variant="outlined"
density="compact"
class="py-3"
return-object
>
<template v-slot:chip="{ item }">
<v-avatar
class="cursor-pointer"
size="8"
:color="item.raw.cl_color"
/>
<span class="pl-2">
{{ item.title }}
</span>
</template>
</v-autocomplete>
</v-col></v-row
>
<!-- <v-row no-gutters class="align-center pb-3">
<v-col class="text-body-2 text-text_grey" lg="2"> <v-col class="text-body-2 text-text_grey" lg="2">
Участники Участники
</v-col> </v-col>
@@ -67,8 +80,8 @@
@returnIdParticant="returnIdParticant" @returnIdParticant="returnIdParticant"
/> </v-col /> </v-col
></v-row> --> ></v-row> -->
</v-col> </v-col>
<!-- <v-col class="d-flex flex-grow-0"> <!-- <v-col class="d-flex flex-grow-0">
<v-textarea <v-textarea
density="compact" density="compact"
label="Описание" label="Описание"
@@ -81,7 +94,7 @@
v-model="propsCalendar.cl_descr" v-model="propsCalendar.cl_descr"
></v-textarea> ></v-textarea>
</v-col> --> </v-col> -->
<!-- <v-row no-gutters class="align-center"> <!-- <v-row no-gutters class="align-center">
<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
@@ -94,13 +107,12 @@
</v-col> </v-col>
</v-row> --> </v-row> -->
</v-row> </v-row>
<!-- {{propsEvent}} --> <!-- {{propsEvent}} -->
</template> </template>
</dialog-create> </dialog-create>
<!-- @delObject="delCalendar(propsCalendar.id)" <!-- @delObject="delCalendar(propsCalendar.id)"
@postData="postCalendar" --> @postData="postCalendar" -->
</v-dialog>
</template> </template>
<script> <script>
@@ -112,11 +124,6 @@ export default {
components: { DialogCreate }, components: { DialogCreate },
props: { props: {
opendialog: {
type: Boolean,
default: false,
},
eventCalendar: { eventCalendar: {
type: Object, type: Object,
default: () => {}, default: () => {},
@@ -129,44 +136,38 @@ export default {
set: (value) => emit("update:eventCalendar", value), set: (value) => emit("update:eventCalendar", value),
}); });
const dialog_create_event = computed({ const calendar = computed({
get: () => props.opendialog, get() {
set: (value) => emit("update:opendialog", value), let selected = [];
if (propsEvent.value.event.calendar) {
let ind = propsEvent.value.mycalendars.findIndex(
(e) => e.id == propsEvent.value.event.calendar
);
selected.push({
cl_name: propsEvent.value.mycalendars[ind].cl_name,
cl_color: propsEvent.value.mycalendars[ind].cl_color,
});
}
return selected;
},
set(newValue) {
propsEvent.value.event.calendar = newValue.value;
},
}); });
const titleCard = ref(""); const titleCard = ref("");
const newEvent = ref(false); const newEvent = ref(false);
const eventNewOrOld = () => {
// propsCalendar.value.hasOwnProperty("id")
// if (true) {
titleCard.value = "Новое события";
// } else {
// titleCard.value = "Новое событие";
// newEvent.value = true;
// }
};
const nameCalendar = ref([]); const nameCalendar = ref([]);
watch(
() => dialog_create_event,
(newValue, oldValue) => {
if (newValue) {
eventNewOrOld();
}
},
{ deep: true }
);
return { return {
dialog_create_event,
titleCard, titleCard,
newEvent, newEvent,
propsEvent, propsEvent,
nameCalendar, nameCalendar,
calendar,
}; };
}, },
}; };