From 90994e83decbce8c7297e2a76b81f3a49495a8ae Mon Sep 17 00:00:00 2001 From: iriska-gri <79623434+iriska-gri@users.noreply.github.com> Date: Wed, 26 Jun 2024 14:41:52 +0300 Subject: [PATCH] =?UTF-8?q?P-42=20=D0=9D=D0=B5=20=D0=B7=D0=B0=D0=B1=D1=8B?= =?UTF-8?q?=D1=82=D1=8C=20=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D1=83=20?= =?UTF-8?q?=D0=B2=D0=B0=D0=BB=D0=B8=D0=B4=D0=B0=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/back/calendar_of_events/views.py | 16 +- src/back/general_vacation/views.py | 2 +- .../open_vacancies/ResponseVacancies.vue | 16 +- .../calendar_of_events/BigCalendar.vue | 2 +- .../calendar-create-select copy.vue | 152 --------- .../calendar-create-select.vue | 11 +- .../calendar_of_events/calendar-create.vue | 318 ++++++++++-------- .../calendar_of_events/calendar-my.vue | 16 +- .../calendar_of_events/event-calendar.vue | 1 - .../calendar_of_events/event-create.vue | 10 - .../src/layouts/default/alertDefault.vue | 2 +- src/front/src/plugins/vuetify.js | 6 +- 12 files changed, 231 insertions(+), 321 deletions(-) delete mode 100644 src/front/src/components/calendar_of_events/calendar-create-select copy.vue diff --git a/src/back/calendar_of_events/views.py b/src/back/calendar_of_events/views.py index 74bd63a42..592420e81 100644 --- a/src/back/calendar_of_events/views.py +++ b/src/back/calendar_of_events/views.py @@ -39,30 +39,34 @@ class MyCalendars(APIView): ''' - print(request.data, '---------------') + try: - ob=MyCalendarPostParameters(data=request.data) + ob=MyCalendarPostParameters(data=request.data) + if ob.is_valid(): ob = ob.data participant = ob['participant'] if 'participant' in ob else False + del ob['participant'] if 'id' in ob: newcal,created = Calendar.objects.update_or_create(id=ob['id'],defaults=ob) else: newcal=Calendar.objects.create(**ob, author=DictEmployee(id=request.user.user.id)) - + if participant != False: ptspnt = [] + for x in participant: x['participant_calendar']=DictEmployee(id=x['participant_calendar']) - print(x['participant_calendar']) - CalendarParticipants.objects.update_or_create(calendar=newcal, participant_calendar=x['participant_calendar'], + + newpart, created = CalendarParticipants.objects.update_or_create(calendar=newcal, participant_calendar=x['participant_calendar'], defaults=x) + ptspnt.append(x['participant_calendar']) print(ptspnt) - CalendarParticipants.objects.exclude(calendar=newcal,participant_calendar__in=ptspnt).delete() + CalendarParticipants.objects.exclude(participant_calendar__in=ptspnt).filter(calendar=newcal).delete() else: return Response({"mess":"Ошибка валидации полей"}) except Exception as e: diff --git a/src/back/general_vacation/views.py b/src/back/general_vacation/views.py index 723a07f70..cdb75251a 100644 --- a/src/back/general_vacation/views.py +++ b/src/back/general_vacation/views.py @@ -138,7 +138,7 @@ class DailyloadAPIView(APIView): }] daily = result - print(daily,'dailydaily') + diff --git a/src/front/src/components/about_inspection/open_vacancies/ResponseVacancies.vue b/src/front/src/components/about_inspection/open_vacancies/ResponseVacancies.vue index d3465447c..5f04c06a5 100644 --- a/src/front/src/components/about_inspection/open_vacancies/ResponseVacancies.vue +++ b/src/front/src/components/about_inspection/open_vacancies/ResponseVacancies.vue @@ -7,7 +7,6 @@ - import { ref } from "vue"; -import { useAlertStore } from '@/store/useAlertStore' +import { useAlertStore } from "@/store/useAlertStore"; import { clearAxios } from "@/utils/axios-api"; - export default { props: { idVacations: { @@ -64,12 +62,11 @@ export default { }, setup(props) { const form = ref({ fio: "", email: "", tel: "", text: "" }); - const feedalert = useAlertStore().alert + const feedalert = useAlertStore().alert; const req = (val) => { - return !!val || "Поле обязательно" - } - + return !!val || "Поле обязательно"; + }; const rules = { fio: [ @@ -93,11 +90,11 @@ export default { "data", JSON.stringify({ ...form.value, vacancy_id: props.idVacations }) ); - if (file.value !==null) { + if (file.value !== null) { postFile.append("file", file.value[0]); } - + // Отправляет сообщение об отправлении при отсутсвии валидации!!!!!!!!!!!!!!!!!!!!!!!!! clearAxios .post(`api/about_inspection/postresponsevacancy/`, postFile) .then((data) => { @@ -105,7 +102,6 @@ export default { feedalert.text = data.data; feedalert.color = "teal-lighten-4"; feedalert.ico = "mdi-email-outline"; - }); }; diff --git a/src/front/src/components/calendar_of_events/BigCalendar.vue b/src/front/src/components/calendar_of_events/BigCalendar.vue index 7bcff20b0..68a908dae 100644 --- a/src/front/src/components/calendar_of_events/BigCalendar.vue +++ b/src/front/src/components/calendar_of_events/BigCalendar.vue @@ -72,7 +72,7 @@ - + {{ drawer_right }} diff --git a/src/front/src/components/calendar_of_events/calendar-create-select copy.vue b/src/front/src/components/calendar_of_events/calendar-create-select copy.vue deleted file mode 100644 index 5b392b72c..000000000 --- a/src/front/src/components/calendar_of_events/calendar-create-select copy.vue +++ /dev/null @@ -1,152 +0,0 @@ - - - - - - - - {{ item.value }} - - - - - - - ВСЕ СОТРУДНИКИ - - - - - - - - - - - - - - - - - - - - {{ x.fio }} - - - - - - - - - - diff --git a/src/front/src/components/calendar_of_events/calendar-create-select.vue b/src/front/src/components/calendar_of_events/calendar-create-select.vue index 7f0649ea4..6ca51e1c7 100644 --- a/src/front/src/components/calendar_of_events/calendar-create-select.vue +++ b/src/front/src/components/calendar_of_events/calendar-create-select.vue @@ -100,6 +100,10 @@ export default { type: Array, default: () => [], }, + editor: { + type: Boolean, + default: false, + }, }, setup(props, { emit }) { @@ -132,6 +136,7 @@ export default { }); const selectedStaff = computed(() => { + let selected = []; let idEmployees = []; @@ -139,7 +144,7 @@ export default { e.employees .filter((n) => n.selected == true) .map((res) => { - idEmployees.push({ participant_calendar: res.id }); + idEmployees.push({ participant_calendar: res.id, editor: props.editor?1:props.participant.editor }); }); if (e.employees.every((n) => n.selected == true)) { e.selected = true; @@ -149,8 +154,10 @@ export default { selected.push(...e.employees.filter((n) => n.selected == true)); } }); + emit("returnIdParticant", idEmployees); - + + // console.log(selected, accountStore.user.is_idEmployee, props.editor, selected.some(e=> e.id== accountStore.user.is_idEmployee), '222222222222222222222222222222222222') return selected; }); diff --git a/src/front/src/components/calendar_of_events/calendar-create.vue b/src/front/src/components/calendar_of_events/calendar-create.vue index 811e23bef..4e2bb0e90 100644 --- a/src/front/src/components/calendar_of_events/calendar-create.vue +++ b/src/front/src/components/calendar_of_events/calendar-create.vue @@ -1,10 +1,9 @@ - {{ calendar }} {{ - calendar.hasOwnProperty("id") + propsCalendar.hasOwnProperty("id") ? "Редактирование календаря" : "Новый календарь" }} @@ -15,110 +14,128 @@ @click="dialog_create_calendar = false" > - - - - - - Название - - - - - Цвет - - + + + + + + + Название + + + + + Цвет + + + + + Участники + + + + + + + - Участники + Редакторы - - - - - - - - Отменить - - - {{ calendar.hasOwnProperty("id") ? "Редактировать" : "Создать" }} - - - - - + + + + + + + + Участники с доступом редактирования смогут изменять поля + календаря, а также редактировать и удалять события + + + + + + + + + + Отменить + + + {{ + propsCalendar.hasOwnProperty("id") ? "Редактировать" : "Создать" + }} + + + @@ -128,6 +145,7 @@ import { computed, ref } from "vue"; import { axiosApiInstance } from "@/utils/axios-api"; import calendarCreateSelect from "@/components/calendar_of_events/calendar-create-select.vue"; import { useAlertStore } from "@/store/useAlertStore"; +import { useAccountStore } from "@/store/AccountStore"; export default { components: { calendarCreateSelect }, @@ -140,31 +158,17 @@ export default { calendar: { type: Object, - default: { - cl_name: "", - participant: [{ editor: true, participant_calendar: 0 }], - cl_color: "", - cl_descr: "", - }, + default: {}, }, }, setup(props, { emit }) { const postParticant = {}; + const accountStore = useAccountStore(); // Возможно можно сделать запись короче const returnIdParticant = (idPart) => { - console.log(props.calendar, "props.calendar"); - let g = { - participant: [{participant_calendar: 107 }], - cl_name: "проба2", - cl_color: "lime", - cl_descr: "описание", - - }; - - postParticant.value = g - // postParticant.value = { ...props.calendar, participant: idPart }; + postParticant.value = { ...props.calendar, participant: idPart }; }; const dialog_create_calendar = computed({ @@ -172,20 +176,45 @@ export default { set: (value) => emit("update:opendialog", value), }); - const feedalert = useAlertStore().alert; + const propsCalendar = computed({ + get: () => props.calendar, + set: (value) => emit("update:calendar", value), + }); + const feedalert = useAlertStore().alert; + const rules = { + cl_name: [(val) => req(val)], + cl_descr: [(val) => req(val)], + }; const postCalendar = () => { - console.log(postParticant.value, 'postParticant.valuepostParticant.value') - axiosApiInstance - .post(`api/calendar_of_events/my_calendars/`, postParticant.value) - .then((result) => { - feedalert.alert = true; - feedalert.text = result.data.mess; - feedalert.ico = "mdi-check"; - feedalert.color = "green-darken-4"; - emit("getCalendar"); - }); - dialog_create_calendar.value = false; + + if ( + postParticant.value.participant.some( + (e) => e.participant_calendar == accountStore.user.is_idEmployee + ) + ) { + axiosApiInstance + .post(`api/calendar_of_events/my_calendars/`, postParticant.value) + .then((result) => { + + feedalert.alert = true; + feedalert.text = result.data.mess; + feedalert.ico = "mdi-check"; + feedalert.color = "green-darken-4"; + emit("getCalendar"); + if (result.data.mess != "Ошибка валидации полей") { + dialog_create_calendar.value = false; + } + }); + + + + } else { + feedalert.alert = true; + feedalert.text = "Вы не можете удалить себя из редакторов"; + feedalert.color = "red-darken-2"; + feedalert.ico = "mdi-alert-outline"; + } }; const color = [ @@ -207,13 +236,33 @@ export default { ]; const colorPik = (col) => { - if (props.calendar.cl_color === col) { - props.calendar.cl_color = null; + if (propsCalendar.value.cl_color === col) { + propsCalendar.value.cl_color = null; } else { - props.calendar.cl_color = col; + propsCalendar.value.cl_color = col; } }; + const delCalendar = (idcal) => { + console.log(idcal, "idcal"); + axiosApiInstance + .delete(`api/calendar_of_events/my_calendars/?delid=${idcal}`) + .then((result) => { + feedalert.alert = true; + feedalert.text = result.data.mess; + feedalert.ico = "mdi-check"; + feedalert.color = "orange-accent-1"; + emit("getCalendar"); + }); + dialog_create_calendar.value = false; + }; + + const req = (val) => { + return !!val || "Поле обязательно"; + }; + + + return { dialog_create_calendar, @@ -221,9 +270,16 @@ export default { color, colorPik, returnIdParticant, + propsCalendar, + delCalendar, + rules, }; }, }; - + diff --git a/src/front/src/components/calendar_of_events/calendar-my.vue b/src/front/src/components/calendar_of_events/calendar-my.vue index c2edf0118..8491825fb 100644 --- a/src/front/src/components/calendar_of_events/calendar-my.vue +++ b/src/front/src/components/calendar_of_events/calendar-my.vue @@ -74,10 +74,12 @@ + @@ -110,10 +112,17 @@ export default { const trans = ref(false); const hover = ref(0); - - const editCreatedCalendar = (cal) => { - calendar.value = cal; + if (cal === undefined) { + calendar.value = { + cl_name: "", + participant: [{ editor: true, participant_calendar: accountStore.user.is_idEmployee }], + cl_color: "red", + cl_descr: "", + }; + } else { + calendar.value = cal; + } showDialog.value = true; }; @@ -136,7 +145,6 @@ export default { openGroup, trans, hover, - }; }, }; diff --git a/src/front/src/components/calendar_of_events/event-calendar.vue b/src/front/src/components/calendar_of_events/event-calendar.vue index 9f04b2858..d8d974b9d 100644 --- a/src/front/src/components/calendar_of_events/event-calendar.vue +++ b/src/front/src/components/calendar_of_events/event-calendar.vue @@ -117,7 +117,6 @@ export default { axiosApiInstance .get("api/calendar_of_events/calendarEvents/") .then((data) => { - console.log(data.data,'-vvv'); data.data.forEach((e) => { e.start = formaDashTime(e.start); e.end = e.start; diff --git a/src/front/src/components/calendar_of_events/event-create.vue b/src/front/src/components/calendar_of_events/event-create.vue index 4539fd83d..2b8c26b6b 100644 --- a/src/front/src/components/calendar_of_events/event-create.vue +++ b/src/front/src/components/calendar_of_events/event-create.vue @@ -22,16 +22,6 @@ export default { set: (value) => emit("update:opendialog", value), }); - // const confirmation = () => { - // axiosApiInstance - // .get(`api/calendar_of_events/createEvents/`) - // .then((data) => { - // console.log(data.data, "datadatadatawwwwwwwwwwww"); - // }); - // }; - - // confirmation() - return { dialog_create_event, }; diff --git a/src/front/src/layouts/default/alertDefault.vue b/src/front/src/layouts/default/alertDefault.vue index ae1410980..097e29d67 100644 --- a/src/front/src/layouts/default/alertDefault.vue +++ b/src/front/src/layouts/default/alertDefault.vue @@ -4,7 +4,7 @@ v-model="feedalert.alert" :color="feedalert.color" :icon="feedalert.ico" - variant="outlined" + > diff --git a/src/front/src/plugins/vuetify.js b/src/front/src/plugins/vuetify.js index c6509da65..01e72d880 100644 --- a/src/front/src/plugins/vuetify.js +++ b/src/front/src/plugins/vuetify.js @@ -45,7 +45,8 @@ export default createVuetify({ grey_white: '#FFFFFF', // Цвет для карточек insert_table: '#FAFAFA', btn_text: '#00897B', // фигма, текст кнопки с иконкой - select_list: '#E0EAE8' + select_list: '#E0EAE8', + btn_gray: '#E0E0E0' }, }, dark: { @@ -72,7 +73,8 @@ export default createVuetify({ grey_white: '#212121', insert_table: '#323030', btn_text: '#00897B', - select_list: '#E0EAE8' + select_list: '#E0EAE8', + btn_gray: '#E0E0E0' }, }, options: {