[WIP] Добавил отображение текста на расписании, добавил create
This commit is contained in:
@@ -17,7 +17,13 @@
|
||||
:clear-employee="clearEmployee",
|
||||
@new-date="createNewDate"
|
||||
)
|
||||
schedule-bar(:data-schedule="dataSchedule", :buttons="buttons")
|
||||
schedule-bar(
|
||||
:data-schedule="dataSchedule",
|
||||
:buttons="buttons",
|
||||
:clear-employee="clearEmployee",
|
||||
:times="times",
|
||||
:create-schedule="postCreateSchedule"
|
||||
)
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@@ -41,6 +47,7 @@ export default {
|
||||
startTime: "",
|
||||
endTime: "",
|
||||
},
|
||||
times: { start_time: "", end_time: "" },
|
||||
buttons: [
|
||||
{
|
||||
class: "button-work",
|
||||
@@ -60,7 +67,7 @@ export default {
|
||||
},
|
||||
{
|
||||
class: "button-free",
|
||||
name: "Статусы",
|
||||
name: "Выходной",
|
||||
work: "DAY_OFF",
|
||||
active: false,
|
||||
color: "#9294A7",
|
||||
@@ -86,28 +93,16 @@ export default {
|
||||
},
|
||||
fetchSchedulesEmployee() {
|
||||
this.scheduleList = [];
|
||||
this.employeeList.forEach((e) => {
|
||||
fetchWrapper
|
||||
.get(
|
||||
`accounts/schedules/?employee=${
|
||||
e.id
|
||||
}&date_after=${this.startMonth.format(
|
||||
"YYYY-MM-DD"
|
||||
)}&date_before=${this.endMonth.format("YYYY-MM-DD")}`
|
||||
)
|
||||
.then((data) => {
|
||||
this.scheduleList.push(...data.results);
|
||||
if (!data.count)
|
||||
this.clearEmployee.push({
|
||||
first_name: e.first_name,
|
||||
id: e.id,
|
||||
last_name: e.last_name,
|
||||
patronymic: e.patronymic,
|
||||
schedules: [],
|
||||
});
|
||||
})
|
||||
.then(() => this.filterScheduleEmployee());
|
||||
});
|
||||
fetchWrapper
|
||||
.get(
|
||||
`accounts/schedules/?date_after=${this.startMonth.format(
|
||||
"YYYY-MM-DD"
|
||||
)}&date_before=${this.endMonth.format("YYYY-MM-DD")}`
|
||||
)
|
||||
.then((data) => {
|
||||
this.scheduleList.push(...data.results);
|
||||
})
|
||||
.then(() => this.filterScheduleEmployee());
|
||||
},
|
||||
filterScheduleEmployee() {
|
||||
let serialized = [];
|
||||
@@ -144,30 +139,35 @@ export default {
|
||||
}
|
||||
});
|
||||
this.serialized = serialized;
|
||||
this.filterEmployee();
|
||||
},
|
||||
filterEmployee() {
|
||||
this.clearEmployee = [];
|
||||
this.clearEmployee = this.employeeList.filter((item) =>
|
||||
this.serialized.every((item2) => item2.id !== item.id)
|
||||
);
|
||||
},
|
||||
postCreateSchedule() {
|
||||
fetchWrapper
|
||||
.post("accounts/schedules/create/", {
|
||||
employee: "582b6557-33f4-480f-b578-984bbca0a925",
|
||||
employee: this.clearEmployee.find((e) => e.schedules).id,
|
||||
active_flg: true,
|
||||
start_date: "2019-08-24",
|
||||
end_date: "2019-08-24",
|
||||
title: "string",
|
||||
name: "string",
|
||||
start_time: "string",
|
||||
end_time: "string",
|
||||
status: "string",
|
||||
work_template: 0,
|
||||
holiday_template: 0,
|
||||
start_date: this.clearEmployee.find((e) => e.schedules).schedules
|
||||
.start_date,
|
||||
end_date: this.clearEmployee.find((e) => e.schedules).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());
|
||||
},
|
||||
createNewDate(e) {
|
||||
let res = this.clearEmployee.find((elem) => elem.id === e.id);
|
||||
res.schedules.push({
|
||||
let schedules = {
|
||||
start_date: e.start,
|
||||
end_date: e.end,
|
||||
});
|
||||
};
|
||||
this.clearEmployee.find((elem) => elem.id === e.id).schedules = schedules;
|
||||
},
|
||||
switchPreviousMonth() {
|
||||
this.startMonth = this.startMonth.clone().subtract(1, "M");
|
||||
|
||||
Reference in New Issue
Block a user