[WIP] Добавил аптейд на расписание, настроил отображение дней

This commit is contained in:
megavrilinvv
2022-12-28 16:28:29 +03:00
parent 7a1bfd45c4
commit e4f96924f8
3 changed files with 103 additions and 67 deletions

View File

@@ -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"
)
</template>
@@ -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 = {