[WIP] Добавил создание расписания и доработка выбора дат для апдейта

This commit is contained in:
megavrilinvv
2022-12-27 18:42:00 +03:00
parent 687a56defb
commit ae721f2327
2 changed files with 61 additions and 11 deletions

View File

@@ -15,7 +15,8 @@
:buttons="buttons",
:start-month="startMonth",
:clear-employee="clearEmployee",
@new-date="createNewDate"
@new-schedule-employee="createNewScheduleEmployee",
@schedule-employee="createScheduleEmployee"
)
schedule-bar(
:data-schedule="dataSchedule",
@@ -148,13 +149,19 @@ export default {
);
},
postCreateSchedule() {
let currentEmployee = this.clearEmployee.find((e) => e.schedules);
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: currentEmployee.id,
employee: newSchedule.id,
active_flg: true,
start_date: currentEmployee.schedules.start_date,
end_date: currentEmployee.schedules.end_date,
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,
@@ -175,13 +182,20 @@ export default {
})
.then(() => this.fetchSchedules());
},
createNewDate(e) {
createNewScheduleEmployee(e) {
let schedules = {
start_date: e.start,
end_date: e.end,
};
this.clearEmployee.find((elem) => elem.id === e.id).schedules = schedules;
},
createScheduleEmployee(e) {
let schedules = {
start_date: e.start,
end_date: e.end,
};
this.serialized.find((elem) => elem.id === e.id).schedule = schedules;
},
switchPreviousMonth() {
this.startMonth = this.startMonth.clone().subtract(1, "M");
},