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
+131 -136

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)
@@ -44,35 +44,31 @@
</v-date-picker> </v-date-picker>
</v-locale-provider> </v-locale-provider>
</v-col> </v-col>
<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( (e) => e.author == accountStore.user.is_idEmployee
(e) => e.author == accountStore.user.is_idEmployee )
) "
" 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 )
) "
" 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;
}; };
axiosApiInstance const getCalendar = () => {
.get("api/calendar_of_events/my_calendars/") axiosApiInstance
.then((res) => { .get("api/calendar_of_events/my_calendars/")
res.data.forEach( .then((res) => {
(e) => res.data.forEach(
(e.visible = accountStore.calendar.includes(e.id) ? false : true (e) =>
) (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,16 +106,16 @@ 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/")
.then((res) => { .then((res) => {
staff.value = res.data.filter((e) => e.employees.length > 0); staff.value = res.data.filter((e) => e.employees.length > 0);
staff.value.forEach((e) => { staff.value.forEach((e) => {
if (props.participant.length > 0) { if (props.participant.length > 0) {
e.employees.forEach((empl) => { e.employees.forEach((empl) => {
@@ -131,38 +131,26 @@ 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="">
@@ -18,54 +24,53 @@
</v-expansion-panel-title> </v-expansion-panel-title>
<v-expansion-panel-text flat tile static> <v-expansion-panel-text flat tile static>
<template v-if="Object.keys(calendars).length > 0"> <template v-if="Object.keys(calendars).length > 0">
<v-list-item <v-list-item
v-for="(x, i) in calendars" v-for="(x, i) in calendars"
:key="i" :key="i"
: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>
> <v-checkbox-btn
<template v-slot:prepend> class="text-caption"
<v-checkbox-btn :class="`text-${x.cl_color}`"
class="text-caption" v-model="x.visible"
:class="`text-${x.cl_color}`" :color="x.cl_color"
v-model="x.visible" @update:modelValue="chekUpdate(x)"
:color="x.cl_color" ></v-checkbox-btn>
@update:modelValue="chekUpdate(x)" </template>
></v-checkbox-btn> <template v-slot:title>
</template> <span class="text-body-2"> {{ x.cl_name }} </span>
<template v-slot:title> </template>
<span class="text-body-2"> {{ x.cl_name }} </span>
</template>
<template v-slot:append> <template v-slot:append>
<!-- <my-helper :pretext = x /> --> <!-- <my-helper :pretext = x /> -->
<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" "
icon="mdi-pen" size="x-small"
variant="text" icon="mdi-pen"
class="transitbtn" variant="text"
@click.stop="editCreatedCalendar(x)" class="transitbtn"
></v-btn> @click.stop="editCreatedCalendar(x)"
</transition> ></v-btn>
</template> </transition>
</v-list-item> </template>
</v-list-item>
</template> </template>
<template v-else> <template v-else>
<div class="text-caption text-grey text-center">Календарей нет</div> <div class="text-caption text-grey text-center">Календарей нет</div>
</template> </template>
</v-expansion-panel-text> </v-expansion-panel-text>
</v-expansion-panel> </v-expansion-panel>
@@ -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,
}; };
}, },
}; };
@@ -148,11 +154,10 @@ export default {
} }
.calendar .v-expansion-panel-text__wrapper { .calendar .v-expansion-panel-text__wrapper {
padding: 0!important; padding: 0 !important;
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;
@@ -173,12 +178,9 @@ export default {
.transitbtn { .transitbtn {
opacity: 0; opacity: 0;
/* animation-direction: reverse; */ /* animation-direction: reverse; */
/* animation-duration: 0.1s; /* animation-duration: 0.1s;
animation-name: filli; */ animation-name: filli; */
} }
</style> </style>