P-42 Рабочая версия редактирования календаря
This commit is contained in:
1 parent
b982e01c16
commit
d4ebc14212
5 files changed
+126
-131
No files matched your search
@@ -39,6 +39,7 @@ class MyCalendars(APIView):
|
|||||||
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
print(request.data, '---------------')
|
||||||
try:
|
try:
|
||||||
|
|
||||||
ob=MyCalendarPostParameters(data=request.data)
|
ob=MyCalendarPostParameters(data=request.data)
|
||||||
|
|||||||
@@ -48,31 +48,27 @@
|
|||||||
<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
|
||||||
|
:calendars="
|
||||||
|
calendarForMy.filter(
|
||||||
|
(e) => e.author == accountStore.user.is_idEmployee
|
||||||
|
)
|
||||||
|
"
|
||||||
|
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="Подписки"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<calendar-my
|
|
||||||
|
|
||||||
:calendars="
|
|
||||||
calendarForMy.filter(
|
|
||||||
(e) => e.author != accountStore.user.is_idEmployee
|
|
||||||
)
|
|
||||||
"
|
|
||||||
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,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="">
|
||||||
@@ -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"
|
||||||
|
>
|
||||||
|
<template v-slot:prepend>
|
||||||
|
<v-checkbox-btn
|
||||||
|
class="text-caption"
|
||||||
|
:class="`text-${x.cl_color}`"
|
||||||
|
v-model="x.visible"
|
||||||
|
:color="x.cl_color"
|
||||||
|
@update:modelValue="chekUpdate(x)"
|
||||||
|
></v-checkbox-btn>
|
||||||
|
</template>
|
||||||
|
<template v-slot:title>
|
||||||
|
<span class="text-body-2"> {{ x.cl_name }} </span>
|
||||||
|
</template>
|
||||||
|
|
||||||
}"
|
<template v-slot:append>
|
||||||
class="pa-0 cursor-default"
|
<!-- <my-helper :pretext = x /> -->
|
||||||
>
|
<transition name="fade">
|
||||||
<template v-slot:prepend>
|
<v-btn
|
||||||
<v-checkbox-btn
|
v-if="
|
||||||
class="text-caption"
|
x.author == accountStore.user.is_idEmployee ||
|
||||||
:class="`text-${x.cl_color}`"
|
x.participant.some(
|
||||||
v-model="x.visible"
|
(e) =>
|
||||||
:color="x.cl_color"
|
e.editor == true &&
|
||||||
@update:modelValue="chekUpdate(x)"
|
e.participant_calendar ==
|
||||||
></v-checkbox-btn>
|
accountStore.user.is_idEmployee
|
||||||
</template>
|
)
|
||||||
<template v-slot:title>
|
"
|
||||||
<span class="text-body-2"> {{ x.cl_name }} </span>
|
size="x-small"
|
||||||
</template>
|
icon="mdi-pen"
|
||||||
|
variant="text"
|
||||||
<template v-slot:append>
|
class="transitbtn"
|
||||||
<!-- <my-helper :pretext = x /> -->
|
@click.stop="editCreatedCalendar(x)"
|
||||||
<transition name="fade">
|
></v-btn>
|
||||||
<v-btn
|
</transition>
|
||||||
v-if="
|
</template>
|
||||||
(x.author == accountStore.user.is_idEmployee) ||
|
</v-list-item>
|
||||||
(x.participant.some(
|
|
||||||
(e) =>
|
|
||||||
e.editor == true &&
|
|
||||||
e.participant_calendar == accountStore.user.is_idEmployee
|
|
||||||
))
|
|
||||||
"
|
|
||||||
size="x-small"
|
|
||||||
icon="mdi-pen"
|
|
||||||
variant="text"
|
|
||||||
class="transitbtn"
|
|
||||||
@click.stop="editCreatedCalendar(x)"
|
|
||||||
></v-btn>
|
|
||||||
</transition>
|
|
||||||
</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;
|
||||||
@@ -178,7 +183,4 @@ export default {
|
|||||||
/* animation-duration: 0.1s;
|
/* animation-duration: 0.1s;
|
||||||
animation-name: filli; */
|
animation-name: filli; */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
Reference in new issue
Block a user