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
+144 -185

No files matched your search

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