P-42 Рабочая версия редактирования календаря

This commit is contained in:
iriska-gri committed 2024-06-25 13:33:23 +03:00
1 parent b982e01c16
commit d4ebc14212
5 files changed
+62 -67

No files matched your search

+1
View File
@@ -39,6 +39,7 @@ class MyCalendars(APIView):
''' '''
print(request.data, '---------------')
try: try:
ob=MyCalendarPostParameters(data=request.data) ob=MyCalendarPostParameters(data=request.data)
@@ -48,7 +48,6 @@
<v-col class="flex-column d-flex"> <v-col class="flex-column d-flex">
<v-row no-gutters class="h-0 overflow-auto flex-column flex-nowrap"> <v-row no-gutters class="h-0 overflow-auto flex-column flex-nowrap">
<v-col> <v-col>
<calendar-my <calendar-my
:calendars=" :calendars="
calendarForMy.filter( calendarForMy.filter(
@@ -56,10 +55,10 @@
) )
" "
title="Мои календари" title="Мои календари"
@getCalendar="getCalendar"
/> />
<calendar-my <calendar-my
:calendars=" :calendars="
calendarForMy.filter( calendarForMy.filter(
(e) => e.author != accountStore.user.is_idEmployee (e) => e.author != accountStore.user.is_idEmployee
@@ -67,12 +66,9 @@
" "
title="Подписки" title="Подписки"
/> />
</v-col> </v-col>
</v-row> </v-row>
</v-col> </v-col>
</v-row> </v-row>
</v-card> </v-card>
</v-col> </v-col>
@@ -128,17 +124,19 @@ export default {
MyYear.value = year; MyYear.value = year;
}; };
const getCalendar = () => {
axiosApiInstance axiosApiInstance
.get("api/calendar_of_events/my_calendars/") .get("api/calendar_of_events/my_calendars/")
.then((res) => { .then((res) => {
res.data.forEach( res.data.forEach(
(e) => (e) =>
(e.visible = accountStore.calendar.includes(e.id) ? false : true (e.visible = accountStore.calendar.includes(e.id) ? false : true)
)
); );
calendarForMy.value = res.data; calendarForMy.value = res.data;
console.log(calendarForMy.value, 'calendarForMy.valuecalendarForMy.valuecalendarForMy.value');
}); });
};
getCalendar();
const weekendsData = () => { const weekendsData = () => {
cal.value.$el cal.value.$el
@@ -198,6 +196,7 @@ export default {
showDialog, showDialog,
calendarForMy, calendarForMy,
accountStore, accountStore,
getCalendar,
}; };
}, },
}; };
@@ -106,10 +106,10 @@ export default {
const filtered = ref(""); const filtered = ref("");
const staff = ref([]); const staff = ref([]);
const calendarParticipant = computed({ // const calendarParticipant = computed({
get: () => props.participant, // get: () => props.participant,
set: (value) => emit("update:participant", value), // set: (value) => emit("update:participant", value),
}); // });
axiosApiInstance axiosApiInstance
.get("api/calendar_of_events/get_employees/") .get("api/calendar_of_events/get_employees/")
@@ -131,37 +131,25 @@ export default {
}); });
}); });
const selectedStaff = computed(() => { const selectedStaff = computed(() => {
let selected = []; let selected = [];
// let idEmployees = props.participant let idEmployees = [];
staff.value.forEach((e) => { staff.value.forEach((e) => {
e.employees e.employees
.filter((n) => n.selected == true) .filter((n) => n.selected == true)
.map((res) => { .map((res) => {
calendarParticipant.value.push({ participant_calendar: res.id }); idEmployees.push({ participant_calendar: res.id });
}); });
if (e.employees.every((n) => n.selected == true)) { if (e.employees.every((n) => n.selected == true)) {
e.selected = true; e.selected = true;
selected.push(e); selected.push(e);
} } else {
else {
e.selected = false; e.selected = false;
selected.push(...e.employees.filter((n) => n.selected == true)); selected.push(...e.employees.filter((n) => n.selected == true));
} }
}); });
emit("returnIdParticant", idEmployees);
// calendarParticipant.value = idEmployees
return selected; return selected;
}); });
@@ -3,8 +3,11 @@
<v-card min-height="436" class="pa-3"> <v-card min-height="436" class="pa-3">
{{ calendar }} {{ calendar }}
<v-card-title class="pr-0 pl-2 d-flex justify-space-between"> <v-card-title class="pr-0 pl-2 d-flex justify-space-between">
Новый календарь {{
calendar.hasOwnProperty("id")
? "Редактирование календаря"
: "Новый календарь"
}}
<v-icon <v-icon
icon="mdi-close cursor-pointer" icon="mdi-close cursor-pointer"
size="small" size="small"
@@ -55,10 +58,8 @@
<v-col> <v-col>
<calendar-create-select <calendar-create-select
:participant="calendar.participant" :participant="calendar.participant"
@update:participant="props.calendar.participant = $event" @returnIdParticant="returnIdParticant"
/> /> </v-col
<!-- upParticant-->
</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">
@@ -81,10 +82,10 @@
class="text-subtitle-1" class="text-subtitle-1"
elevation="0" elevation="0"
width="150" width="150"
@click="dialog_create_calendar = false"
>Отменить</v-btn >Отменить</v-btn
> >
<!-- @click="dialog_create_calendar = false" -->
<v-btn <v-btn
class="text-subtitle-1 font-weight-regular" class="text-subtitle-1 font-weight-regular"
color="btn_text" color="btn_text"
@@ -92,8 +93,9 @@
elevation="0" elevation="0"
width="150" width="150"
@click="postCalendar" @click="postCalendar"
>Создать</v-btn
> >
{{ calendar.hasOwnProperty("id") ? "Редактировать" : "Создать" }}
</v-btn>
</v-card-actions> </v-card-actions>
<!-- <v-row no-gutters class="gap flex-column"> <!-- <v-row no-gutters class="gap flex-column">
v-col* v-col*
@@ -138,34 +140,42 @@ export default {
calendar: { calendar: {
type: Object, type: Object,
default: { cl_name: "", participant: [] }, default: {
cl_name: "",
participant: [{ editor: true, participant_calendar: 0 }],
cl_color: "red",
cl_descr: "",
},
}, },
}, },
setup(props, { emit }) { setup(props, { emit }) {
console.log('-1111111111111') const postParticant = {};
// Возможно можно сделать запись короче
const returnIdParticant = (idPart) => {
console.log(props.calendar, "props.calendar");
postParticant.value = { ...props.calendar, participant: idPart };
};
const dialog_create_calendar = computed({ const dialog_create_calendar = computed({
get: () => props.opendialog, get: () => props.opendialog,
set: (value) => emit("update:opendialog", value), set: (value) => emit("update:opendialog", value),
}); });
const feedalert = useAlertStore().alert; const feedalert = useAlertStore().alert;
const postCalendar = () => { const postCalendar = () => {
axiosApiInstance axiosApiInstance
.post(`api/calendar_of_events/my_calendars/`, props.calendar) .post(`api/calendar_of_events/my_calendars/`, postParticant.value)
.then((result) => { .then((result) => {
feedalert.alert = true; feedalert.alert = true;
feedalert.text = result.data.mess; feedalert.text = result.data.mess;
feedalert.ico = "mdi-check"; feedalert.ico = "mdi-check";
feedalert.color = "green-darken-4"; feedalert.color = "green-darken-4";
emit("getCalendar");
}); });
dialog_create_calendar.value = false;
}; };
const color = [ const color = [
@@ -194,18 +204,13 @@ export default {
} }
}; };
const upParticant = () => {
console.log('hi')
props.calendar.participant = $event
}
return { return {
dialog_create_calendar, dialog_create_calendar,
postCalendar, postCalendar,
color, color,
colorPik,
upParticant returnIdParticant,
}; };
}, },
}; };
@@ -1,6 +1,12 @@
<template> <template>
<v-expansion-panels class="calendar" variant="accordion" flat tile static v-model="openGroup"> <v-expansion-panels
class="calendar"
variant="accordion"
flat
tile
static
v-model="openGroup"
>
<v-expansion-panel elevation="0" flat tile static> <v-expansion-panel elevation="0" flat tile static>
<v-expansion-panel-title flat tile static class="py-0 px-3"> <v-expansion-panel-title flat tile static class="py-0 px-3">
<div @click.stop=""> <div @click.stop="">
@@ -24,9 +30,7 @@
:value="x.cl_name" :value="x.cl_name"
@mouseenter="hover = i" @mouseenter="hover = i"
@mouseleave="hover = null" @mouseleave="hover = null"
:class="{'trasitlist': hover===i, :class="{ trasitlist: hover === i }"
}"
class="pa-0 cursor-default" class="pa-0 cursor-default"
> >
<template v-slot:prepend> <template v-slot:prepend>
@@ -47,12 +51,13 @@
<transition name="fade"> <transition name="fade">
<v-btn <v-btn
v-if=" v-if="
(x.author == accountStore.user.is_idEmployee) || x.author == accountStore.user.is_idEmployee ||
(x.participant.some( x.participant.some(
(e) => (e) =>
e.editor == true && e.editor == true &&
e.participant_calendar == accountStore.user.is_idEmployee e.participant_calendar ==
)) accountStore.user.is_idEmployee
)
" "
size="x-small" size="x-small"
icon="mdi-pen" icon="mdi-pen"
@@ -73,7 +78,7 @@
@update:opendialog="showDialog = $event" @update:opendialog="showDialog = $event"
:opendialog="showDialog" :opendialog="showDialog"
:calendar="calendar" :calendar="calendar"
@getCalendar="$emit('getCalendar')"
/> />
</v-expansion-panels> </v-expansion-panels>
</template> </template>
@@ -103,7 +108,7 @@ export default {
const calendar = ref({}); const calendar = ref({});
const openGroup = ref([0]); const openGroup = ref([0]);
const trans = ref(false); const trans = ref(false);
const hover = ref(0) const hover = ref(0);
@@ -130,7 +135,8 @@ export default {
accountStore, accountStore,
openGroup, openGroup,
trans, trans,
hover hover,
}; };
}, },
}; };
@@ -152,7 +158,6 @@ export default {
padding-right: 10px !important; padding-right: 10px !important;
} }
.trasitlist:hover .transitbtn { .trasitlist:hover .transitbtn {
animation-fill-mode: forwards; animation-fill-mode: forwards;
/* transition: opacity 0.1s; */ /* transition: opacity 0.1s; */
animation-duration: 0.5s; animation-duration: 0.5s;
@@ -178,7 +183,4 @@ export default {
/* animation-duration: 0.1s; /* animation-duration: 0.1s;
animation-name: filli; */ animation-name: filli; */
} }
</style> </style>