[WIP] Добавил delete, возможность создания события на 1 день, поправил стили, отображение дней при изменении месяца

This commit is contained in:
megavrilinvv
2023-01-09 17:20:20 +03:00
parent e2cf5525ae
commit 2604d22471
3 changed files with 87 additions and 66 deletions

View File

@@ -17,6 +17,8 @@
:start-month="startMonth",
:clear-employee="clearEmployee",
:show-time="showTime",
:clear-select="clearSelect",
:select-employee="selectEmployee",
@schedule-employee="createScheduleEmployee",
@schedules="distributeRequest"
)
@@ -24,6 +26,7 @@
:buttons="buttons",
:times="times",
:create-schedules="postCreateSchedules",
:delete-schedule="deleteSchedule"
)
</template>
@@ -43,6 +46,10 @@ export default {
scheduleList: [],
clearEmployee: [],
serialized: [],
selectEmployee: {
label: "",
id: null,
},
times: { start_time: "", end_time: "" },
timesShift: { start_time: "", end_time: "" },
buttons: [
@@ -59,7 +66,7 @@ export default {
name: "Отпуск/больничный",
work: "VACATION",
active: false,
color: "#D7D9FF",
color: "var(--btn-blue-color-2)",
text: "'О'",
},
{
@@ -73,7 +80,6 @@ export default {
],
startMonth: moment().startOf("month"),
showTime: false,
currentEmployee: {},
schedulesDate: {},
};
},
@@ -86,6 +92,15 @@ export default {
changeShowTime() {
this.showTime = !this.showTime;
},
clearSelect(employee) {
if (employee) {
employee.label = "";
employee.id = null;
} else {
this.selectEmployee.label = "";
this.selectEmployeeid = null;
}
},
fetchSchedules() {
fetchWrapper
.get("general/employee/")
@@ -96,6 +111,7 @@ export default {
},
fetchSchedulesEmployee() {
this.scheduleList = [];
this.clearSelect();
fetchWrapper
.get(
`accounts/schedules/?date_after=${this.startMonth.format(
@@ -150,10 +166,9 @@ export default {
this.serialized.every((el) => el.id !== item.id)
);
},
distributeRequest(inside, outside, currentEmployee) {
distributeRequest(inside, outside) {
this.insideSchedules = inside;
this.outsideSchedules = outside;
this.currentEmployee = currentEmployee;
},
postCreateSchedules() {
let data = {
@@ -198,16 +213,21 @@ export default {
.then(() => this.fetchSchedules());
},
createScheduleEmployee(e, id) {
let schedules = {
start_date: e.start,
end_date: e.end,
};
this.schedulesDate = {
start_date: e.start,
end_date: e.end,
end_date: e.end ? e.end : e.start,
id: id,
};
this.serialized.find((elem) => elem.id === e.id).schedule = schedules;
},
deleteSchedule() {
let ids = "";
if (this.insideSchedules.length > 0) {
this.insideSchedules.forEach((e) => (ids += e.id + ","));
ids = ids.slice(0, -1);
fetchWrapper
.del(`accounts/schedules/${ids}/delete/`)
.then(() => this.fetchSchedules());
}
},
switchPreviousMonth() {
this.startMonth = this.startMonth.clone().subtract(1, "M");