From e4f96924f89d779b7291f5e7c72a06ed1db680e1 Mon Sep 17 00:00:00 2001 From: megavrilinvv Date: Wed, 28 Dec 2022 16:28:29 +0300 Subject: [PATCH] =?UTF-8?q?[WIP]=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=B0=D0=BF=D1=82=D0=B5=D0=B9=D0=B4=20=D0=BD=D0=B0=20?= =?UTF-8?q?=D1=80=D0=B0=D1=81=D0=BF=D0=B8=D1=81=D0=B0=D0=BD=D0=B8=D0=B5,?= =?UTF-8?q?=20=D0=BD=D0=B0=D1=81=D1=82=D1=80=D0=BE=D0=B8=D0=BB=20=D0=BE?= =?UTF-8?q?=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=B4=D0=BD=D0=B5=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/schedule/TheSchedule.vue | 69 ++++++++------ src/pages/schedule/components/ScheduleBar.vue | 6 +- .../schedule/components/ScheduleBody.vue | 95 +++++++++++-------- 3 files changed, 103 insertions(+), 67 deletions(-) diff --git a/src/pages/schedule/TheSchedule.vue b/src/pages/schedule/TheSchedule.vue index 8a607f8..1b4cf76 100644 --- a/src/pages/schedule/TheSchedule.vue +++ b/src/pages/schedule/TheSchedule.vue @@ -16,14 +16,15 @@ :start-month="startMonth", :clear-employee="clearEmployee", @new-schedule-employee="createNewScheduleEmployee", - @schedule-employee="createScheduleEmployee" + @schedule-employee="createScheduleEmployee", + @schedules="distributeRequest" ) schedule-bar( :data-schedule="dataSchedule", :buttons="buttons", :clear-employee="clearEmployee", :times="times", - :create-schedule="postCreateSchedule" + :create-schedules="postCreateSchedules" ) @@ -59,7 +60,7 @@ export default { text: "'Р'", }, { - class: "button-status", + class: "button-vacation", name: "Отпуск/больничный", work: "VACATION", active: false, @@ -140,6 +141,7 @@ export default { } }); this.serialized = serialized; + this.filterEmployee(); }, filterEmployee() { @@ -148,39 +150,52 @@ export default { this.serialized.every((item2) => item2.id !== item.id) ); }, - postCreateSchedule() { + distributeRequest(inside, outside) { + this.insideSchedules = inside; + this.outsideSchedules = outside; + }, + postCreateSchedules() { let newSchedule = null; if (this.clearEmployee.find((e) => e.schedules)) newSchedule = this.clearEmployee.find((e) => e.schedules); else newSchedule = this.serialized.find((e) => e.schedule); - - fetchWrapper - .post("accounts/schedules/create/", { - employee: newSchedule.id, - active_flg: true, + let data = { + employee: newSchedule.id, + active_flg: true, + start_time: this.times.start_time, + end_time: this.times.end_time, + status: this.buttons.find((e) => e.active).work, + }; + if (this.insideSchedules.length > 0) { + this.postUpdateSchedule(); + this.outsideSchedules.forEach((el) => { + fetchWrapper.post("accounts/schedules/create/", { + ...data, + start_date: el.start_date, + end_date: el.end_date, + }); + }); + } else { + fetchWrapper.post("accounts/schedules/create/", { + ...data, start_date: newSchedule.schedules.start_date || newSchedule.schedule.start_date, end_date: newSchedule.schedules.end_date || newSchedule.schedule.end_date, - start_time: this.times.start_time, - end_time: this.times.end_time, - status: this.buttons.find((e) => e.active).work, - }) - .then(() => this.fetchSchedules()); + }); + } }, - postUpdateSchedule(id) { - let currentEmployee = this.clearEmployee.find((e) => e.schedules); - fetchWrapper - .post(`accounts/schedules/${id}/update/`, { - employee: currentEmployee.id, - active_flg: true, - start_date: currentEmployee.schedules.start_date, - end_date: currentEmployee.schedules.end_date, - start_time: this.times.start_time, - end_time: this.times.end_time, - status: this.buttons.find((e) => e.active).work, - }) - .then(() => this.fetchSchedules()); + postUpdateSchedule() { + let ids = ""; + this.insideSchedules.forEach((e) => (ids += e.id + ",")); + ids = ids.slice(0, -1); + fetchWrapper.post(`accounts/schedules/${ids}/update/`, { + employee: this.insideSchedules[0].employeeId, + active_flg: true, + start_time: this.insideSchedules[0].start_time, + end_time: this.insideSchedules[0].end_time, + status: this.buttons.find((e) => e.active).work, + }); }, createNewScheduleEmployee(e) { let schedules = { diff --git a/src/pages/schedule/components/ScheduleBar.vue b/src/pages/schedule/components/ScheduleBar.vue index ec9d554..1b795d8 100644 --- a/src/pages/schedule/components/ScheduleBar.vue +++ b/src/pages/schedule/components/ScheduleBar.vue @@ -27,7 +27,7 @@ placeholder="Шаблоны графиков" ) .flex.justify-center - base-button.font-semibold(:size="40", @click="createSchedule") Сохранить + base-button.font-semibold(:size="40", @click="createSchedules") Сохранить