P-47 Редактировать отображение выбранных календарей

This commit is contained in:
iriska-gri committed 2024-07-01 17:00:49 +03:00
1 parent 6a5d5d642c
commit d83c260e59
5 files changed
+173 -146

No files matched your search

@@ -26,6 +26,7 @@
@click="showDialog = true"
>Создать событие</v-btn
>
<!-- {{eventFromCalendar}} -->
</v-col>
<v-col class="w100" lg="3">
<v-locale-provider locale="ru">
@@ -91,6 +92,7 @@
<event-create
@update:opendialog="showDialog = $event"
:opendialog="showDialog"
:eventCalendar="eventFromCalendar"
/>
</v-row>
</template>
@@ -116,6 +118,8 @@ export default {
const MyYear = ref(selectdate.value.getFullYear());
const MyMonth = ref(selectdate.value.getMonth() + 1);
const calendarForMy = ref([]);
const eventFromCalendar = ref({})
const idEvent = ref(null)
const getMonth = (month) => {
MyMonth.value = month + 1;
@@ -126,7 +130,7 @@ export default {
const getCalendar = () => {
axiosApiInstance
.get("api/calendar_of_events/my_calendars/")
.get(`api/calendar_of_events/my_calendars/`)
.then((res) => {
res.data.forEach(
(e) =>
@@ -138,6 +142,28 @@ export default {
getCalendar();
const getEvents = () => {
axiosApiInstance
.get(`api/calendar_of_events/my_events/${idEvent.value==null?'':`?id=${idEvent.value}`}`)
.then((res) => {
eventFromCalendar.value = res.data
if (idEvent.value==null) {
eventFromCalendar.value.event = {name:'', participant: [], files: [], date_start: "", date_end: "", period: null, description: ''}
}
// res.data.forEach(
// (e) =>
// (e.visible = accountStore.calendar.includes(e.id) ? false : true)
// );
// calendarForMy.value = res.data;
});
};
getEvents();
const weekendsData = () => {
cal.value.$el
.querySelectorAll(".v-date-picker-month__day")
@@ -197,6 +223,7 @@ export default {
calendarForMy,
accountStore,
getCalendar,
eventFromCalendar
};
},
};
@@ -119,7 +119,7 @@ export default {
.get("api/calendar_of_events/get_employees/")
.then((res) => {
staff.value = res.data.filter((e) => e.employees.length > 0);
console.log(staff.value, 'staff.valuestaff.value')
staff.value.forEach((e) => {
if (props.participant.length > 0) {
e.employees.forEach((empl) => {
@@ -1,142 +1,5 @@
<template>
<v-dialog v-model="dialog_create_calendar" min-width="636" max-width="800">
<!-- <v-card min-height="436" class="pa-3">
<v-card-title class="pr-0 pl-2 d-flex justify-space-between">
{{
propsCalendar.hasOwnProperty("id")
? "Редактирование календаря"
: "Новый календарь"
}}
<v-icon
icon="mdi-close cursor-pointer"
size="small"
color="grey"
@click="dialog_create_calendar = false"
></v-icon>
</v-card-title>
<v-form ref="form_calendar" @submit.prevent="postCalendar">
<v-card-text class="d-flex px-3">
<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" lg="2">
Название
</v-col>
<v-col>
<v-textarea
density="compact"
label="Описание"
row-height="25"
rows="1"
variant="outlined"
v-model="propsCalendar.cl_name"
:rules="rules.cl_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-for="(x, key) in color" :key="key">
<v-avatar
class="cursor-pointer"
@click="colorPik(x, key)"
size="x-small"
:color="x"
:variant="
propsCalendar.cl_color === null
? 'flat'
: propsCalendar.cl_color === x
? 'flat'
: 'tonal'
"
/> </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>
<calendar-create-select
:participant="propsCalendar.participant"
@returnIdParticant="returnIdParticant"
/> </v-col
></v-row>
</v-col>
<v-col class="d-flex flex-grow-0">
<v-textarea
density="compact"
label="Описание"
row-height="25"
rows="4"
variant="outlined"
shaped
no-resize
:rules="rules.cl_descr"
v-model="propsCalendar.cl_descr"
></v-textarea>
</v-col>
<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
: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">
<template v-slot:activator="{ props }">
<v-icon v-bind="props" icon="mdi-help-circle-outline" />
</template>
<div class="custom-tooltip">
Участники с доступом редактирования смогут изменять поля
календаря, а также редактировать и удалять события
</div>
</v-tooltip>
</v-col>
</v-row>
</v-row>
</v-card-text>
<v-card-actions class="justify-end">
<v-btn
icon="mdi-delete"
variant="tonal"
rounded
size="36px"
:disabled="!propsCalendar.hasOwnProperty('id')"
@click="delCalendar(propsCalendar.id)"
/>
<v-btn
class="text-subtitle-1"
elevation="0"
width="150"
@click="dialog_create_calendar = false"
color="btn_gray"
variant="flat"
>Отменить</v-btn
>
<v-btn
class="text-subtitle-1 font-weight-regular"
color="btn_text"
variant="flat"
elevation="0"
width="150"
type="postCalendar"
>
{{
propsCalendar.hasOwnProperty("id") ? "Редактировать" : "Создать"
}}
</v-btn>
</v-card-actions>
</v-form>
</v-card> -->
<dialog-create
:title="titleCard"
:newOrOld="newCalendar"
@@ -148,7 +11,7 @@
<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" lg="2">
<v-col class="text-body-2 text-text_grey pb-5" lg="2">
Название
</v-col>
<v-col>
@@ -285,7 +148,7 @@ export default {
const titleCard = ref("");
const newCalendar = ref(false);
const calendarOrEvents = () => {
const calendarNewOrOld = () => {
if (propsCalendar.value.hasOwnProperty("id")) {
titleCard.value = "Редактирование календаря";
} else {
@@ -298,7 +161,7 @@ export default {
() => dialog_create_calendar,
(newValue, oldValue) => {
if (newValue) {
calendarOrEvents();
calendarNewOrOld();
}
},
{ deep: true }
@@ -1,29 +1,167 @@
<template>
<v-dialog v-model="dialog_create_event" max-width="700">
<v-card height="400"> hello </v-card>
<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>
{{nameCalendar}}
<v-autocomplete
v-model="nameCalendar"
:items="propsEvent.mycalendars"
label="Выберите календарь или найдите по названию"
item-title="cl_name"
item-value="id"
hide-details
variant="outlined"
density="compact"
class="max-height-select py-3"
return-object
>
</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>
<v-col>
<calendar-create-select
:participant="propsCalendar.participant"
@returnIdParticant="returnIdParticant"
/> </v-col
></v-row> -->
</v-col>
<!-- <v-col class="d-flex flex-grow-0">
<v-textarea
density="compact"
label="Описание"
row-height="25"
rows="4"
variant="outlined"
shaped
no-resize
:rules="rules.cl_descr"
v-model="propsCalendar.cl_descr"
></v-textarea>
</v-col> -->
<!-- <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
:editor="true"
:participant="
propsCalendar.participant.filter((e) => e.editor == 1)
"
@returnIdParticant="returnIdParticant"
/>
</v-col>
</v-row> -->
</v-row>
<!-- {{propsEvent}} -->
</template>
</dialog-create>
<!-- @delObject="delCalendar(propsCalendar.id)"
@postData="postCalendar" -->
</v-dialog>
</template>
<script>
import { computed, ref } from "vue";
import { computed, ref, watch } from "vue";
import { axiosApiInstance } from "@/utils/axios-api";
import DialogCreate from "./UI_calendar/dialogCreate.vue";
export default {
components: { DialogCreate },
props: {
opendialog: {
type: Boolean,
default: false,
},
eventCalendar: {
type: Object,
default: () => {},
},
},
setup(props, { emit }) {
const propsEvent = computed({
get: () => props.eventCalendar,
set: (value) => emit("update:eventCalendar", value),
});
const dialog_create_event = computed({
get: () => props.opendialog,
set: (value) => emit("update:opendialog", 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
};
},
};