Merge branch 'UC-202' into 'master'
Resolve UC-202 See merge request andrusyakka/urban-couscous!237
This commit is contained in:
@@ -4,17 +4,19 @@
|
|||||||
schedule-header(
|
schedule-header(
|
||||||
:start-month="startMonth",
|
:start-month="startMonth",
|
||||||
:times-shift="timesShift",
|
:times-shift="timesShift",
|
||||||
|
:change-show-time="changeShowTime",
|
||||||
|
:show-time="showTime"
|
||||||
@switch-previous-month="switchPreviousMonth",
|
@switch-previous-month="switchPreviousMonth",
|
||||||
@switch-next-month="switchNextMonth"
|
@switch-next-month="switchNextMonth"
|
||||||
)
|
)
|
||||||
schedule-body(
|
schedule-table(
|
||||||
:schedules-employee="fetchSchedulesEmployee",
|
:schedules-employee="fetchSchedulesEmployee",
|
||||||
:schedule-list="scheduleList",
|
:schedule-list="scheduleList",
|
||||||
:serialized="serialized",
|
:serialized="serialized",
|
||||||
:buttons="buttons",
|
:buttons="buttons",
|
||||||
:start-month="startMonth",
|
:start-month="startMonth",
|
||||||
:clear-employee="clearEmployee",
|
:clear-employee="clearEmployee",
|
||||||
@new-schedule-employee="createNewScheduleEmployee",
|
:show-time="showTime",
|
||||||
@schedule-employee="createScheduleEmployee",
|
@schedule-employee="createScheduleEmployee",
|
||||||
@schedules="distributeRequest"
|
@schedules="distributeRequest"
|
||||||
)
|
)
|
||||||
@@ -29,11 +31,12 @@
|
|||||||
import * as moment from "moment";
|
import * as moment from "moment";
|
||||||
import ScheduleHeader from "@/pages/schedule/components/ScheduleHeader.vue";
|
import ScheduleHeader from "@/pages/schedule/components/ScheduleHeader.vue";
|
||||||
import ScheduleBar from "@/pages/schedule/components/ScheduleBar.vue";
|
import ScheduleBar from "@/pages/schedule/components/ScheduleBar.vue";
|
||||||
import ScheduleBody from "@/pages/schedule/components/ScheduleBody.vue";
|
import ScheduleTable from "@/pages/schedule/components/ScheduleTable.vue";
|
||||||
import { fetchWrapper } from "@/shared/fetchWrapper.js";
|
import { fetchWrapper } from "@/shared/fetchWrapper.js";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "TheSchedule",
|
name: "TheSchedule",
|
||||||
components: { ScheduleHeader, ScheduleBar, ScheduleBody },
|
components: { ScheduleHeader, ScheduleBar, ScheduleTable },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
employeeList: [],
|
employeeList: [],
|
||||||
@@ -69,6 +72,9 @@ export default {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
startMonth: moment().startOf("month"),
|
startMonth: moment().startOf("month"),
|
||||||
|
showTime: false,
|
||||||
|
currentEmployee: {},
|
||||||
|
schedulesDate: {},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -77,6 +83,9 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
changeShowTime() {
|
||||||
|
this.showTime = !this.showTime;
|
||||||
|
},
|
||||||
fetchSchedules() {
|
fetchSchedules() {
|
||||||
fetchWrapper
|
fetchWrapper
|
||||||
.get("general/employee/")
|
.get("general/employee/")
|
||||||
@@ -111,8 +120,8 @@ export default {
|
|||||||
schedules: [
|
schedules: [
|
||||||
{
|
{
|
||||||
date: e.date,
|
date: e.date,
|
||||||
end_time: e.end_time,
|
end_time: e.end_time ? e.end_time.slice(0, -3) : "",
|
||||||
start_time: e.start_time,
|
start_time: e.start_time ? e.start_time.slice(0, -3) : "",
|
||||||
status: e.status,
|
status: e.status,
|
||||||
id: e.id,
|
id: e.id,
|
||||||
title: e.title,
|
title: e.title,
|
||||||
@@ -123,8 +132,8 @@ export default {
|
|||||||
} else {
|
} else {
|
||||||
foundedElem.schedules.push({
|
foundedElem.schedules.push({
|
||||||
date: e.date,
|
date: e.date,
|
||||||
end_time: e.end_time,
|
end_time: e.end_time ? e.end_time.slice(0, -3) : "",
|
||||||
start_time: e.start_time,
|
start_time: e.start_time ? e.start_time.slice(0, -3) : "",
|
||||||
status: e.status,
|
status: e.status,
|
||||||
id: e.id,
|
id: e.id,
|
||||||
title: e.title,
|
title: e.title,
|
||||||
@@ -138,27 +147,25 @@ export default {
|
|||||||
filterEmployee() {
|
filterEmployee() {
|
||||||
this.clearEmployee = [];
|
this.clearEmployee = [];
|
||||||
this.clearEmployee = this.employeeList.filter((item) =>
|
this.clearEmployee = this.employeeList.filter((item) =>
|
||||||
this.serialized.every((item2) => item2.id !== item.id)
|
this.serialized.every((el) => el.id !== item.id)
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
distributeRequest(inside, outside) {
|
distributeRequest(inside, outside, currentEmployee) {
|
||||||
this.insideSchedules = inside;
|
this.insideSchedules = inside;
|
||||||
this.outsideSchedules = outside;
|
this.outsideSchedules = outside;
|
||||||
|
this.currentEmployee = currentEmployee;
|
||||||
},
|
},
|
||||||
postCreateSchedules() {
|
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);
|
|
||||||
let data = {
|
let data = {
|
||||||
employee: newSchedule.id,
|
employee: this.schedulesDate.id,
|
||||||
active_flg: true,
|
active_flg: true,
|
||||||
start_time: this.times.start_time,
|
start_time: this.times.start_time,
|
||||||
end_time: this.times.end_time,
|
end_time: this.times.end_time,
|
||||||
status: this.buttons.find((e) => e.active).work,
|
status: this.buttons.find((e) => e.active).work,
|
||||||
};
|
};
|
||||||
if (this.insideSchedules.length > 0) {
|
if (this.insideSchedules?.length > 0) {
|
||||||
this.postUpdateSchedule();
|
this.postUpdateSchedule();
|
||||||
|
if (this.outsideSchedules)
|
||||||
this.outsideSchedules.forEach((el) => {
|
this.outsideSchedules.forEach((el) => {
|
||||||
fetchWrapper.post("accounts/schedules/create/", {
|
fetchWrapper.post("accounts/schedules/create/", {
|
||||||
...data,
|
...data,
|
||||||
@@ -167,38 +174,38 @@ export default {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
fetchWrapper.post("accounts/schedules/create/", {
|
fetchWrapper
|
||||||
|
.post("accounts/schedules/create/", {
|
||||||
...data,
|
...data,
|
||||||
start_date:
|
start_date: this.schedulesDate.start_date,
|
||||||
newSchedule.schedules.start_date || newSchedule.schedule.start_date,
|
end_date: this.schedulesDate.end_date,
|
||||||
end_date:
|
})
|
||||||
newSchedule.schedules.end_date || newSchedule.schedule.end_date,
|
.then(() => this.fetchSchedules());
|
||||||
});
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
postUpdateSchedule() {
|
postUpdateSchedule() {
|
||||||
let ids = "";
|
let ids = "";
|
||||||
this.insideSchedules.forEach((e) => (ids += e.id + ","));
|
this.insideSchedules.forEach((e) => (ids += e.id + ","));
|
||||||
ids = ids.slice(0, -1);
|
ids = ids.slice(0, -1);
|
||||||
fetchWrapper.post(`accounts/schedules/${ids}/update/`, {
|
fetchWrapper
|
||||||
|
.post(`accounts/schedules/${ids}/update/`, {
|
||||||
employee: this.insideSchedules[0].employeeId,
|
employee: this.insideSchedules[0].employeeId,
|
||||||
active_flg: true,
|
active_flg: true,
|
||||||
start_time: this.insideSchedules[0].start_time,
|
start_time: this.times.start_time,
|
||||||
end_time: this.insideSchedules[0].end_time,
|
end_time: this.times.end_time,
|
||||||
status: this.buttons.find((e) => e.active).work,
|
status: this.buttons.find((e) => e.active).work,
|
||||||
});
|
})
|
||||||
|
.then(() => this.fetchSchedules());
|
||||||
},
|
},
|
||||||
createNewScheduleEmployee(e) {
|
createScheduleEmployee(e, id) {
|
||||||
let schedules = {
|
let schedules = {
|
||||||
start_date: e.start,
|
start_date: e.start,
|
||||||
end_date: e.end,
|
end_date: e.end,
|
||||||
};
|
};
|
||||||
this.clearEmployee.find((elem) => elem.id === e.id).schedules = schedules;
|
this.schedulesDate = {
|
||||||
},
|
|
||||||
createScheduleEmployee(e) {
|
|
||||||
let schedules = {
|
|
||||||
start_date: e.start,
|
start_date: e.start,
|
||||||
end_date: e.end,
|
end_date: e.end,
|
||||||
|
id: id,
|
||||||
};
|
};
|
||||||
this.serialized.find((elem) => elem.id === e.id).schedule = schedules;
|
this.serialized.find((elem) => elem.id === e.id).schedule = schedules;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -29,6 +29,12 @@
|
|||||||
.text.flex.items-center
|
.text.flex.items-center
|
||||||
.text.font-medium.text-base {{ dateString }}
|
.text.font-medium.text-base {{ dateString }}
|
||||||
.opacity-50.font-bold.text-xxs.ml-2(v-if="isCurrentMonth") Текущий
|
.opacity-50.font-bold.text-xxs.ml-2(v-if="isCurrentMonth") Текущий
|
||||||
|
.flex.gap-x-4
|
||||||
|
base-button.font-semibold(
|
||||||
|
:size="40",
|
||||||
|
:style="{minWidth: '176px'}",
|
||||||
|
@click="changeShowTime"
|
||||||
|
) {{textButton}}
|
||||||
base-button.font-semibold(:size="40", @click="openForm") Замена смен
|
base-button.font-semibold(:size="40", @click="openForm") Замена смен
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -43,6 +49,8 @@ export default {
|
|||||||
props: {
|
props: {
|
||||||
startMonth: Object,
|
startMonth: Object,
|
||||||
timesShift: Object,
|
timesShift: Object,
|
||||||
|
changeShowTime: Function,
|
||||||
|
showTime: Boolean,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -61,6 +69,9 @@ export default {
|
|||||||
})
|
})
|
||||||
.join(" ");
|
.join(" ");
|
||||||
},
|
},
|
||||||
|
textButton() {
|
||||||
|
return this.showTime ? "Скрыть время" : "Показать время";
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
openForm() {
|
openForm() {
|
||||||
|
|||||||
@@ -26,13 +26,14 @@
|
|||||||
v-for="day in result",
|
v-for="day in result",
|
||||||
:key="day",
|
:key="day",
|
||||||
:id="schedule.id + day",
|
:id="schedule.id + day",
|
||||||
@click="choiceCell(day, schedule.id, schedule); saveEmployee()",
|
@click="choiceCell(day, schedule.id, schedule); clearData()",
|
||||||
:class="choiceState(day, schedule.id)",
|
:class="choiceState(day, schedule.id)",
|
||||||
:style="{backgroundColor: choiceDay(day, schedule.id) ? choiceColor(day, schedule) : ''}"
|
:style="{backgroundColor: choiceDay(day, schedule.id) ? choiceColor(day, schedule) : ''}"
|
||||||
)
|
)
|
||||||
.flex(
|
.flex(
|
||||||
:class="{'cell-work': choiceState(day, schedule.id).status}"
|
:class="{'cell-work': choiceState(day, schedule.id).status, 'show-time': showTime}"
|
||||||
) {{choiceDay(day, schedule.id) ? choiceWorks(day, schedule) : ''}}
|
) {{choiceDay(day, schedule.id) ? choiceWorks(day, schedule) : ''}}
|
||||||
|
|
||||||
.schedule-select.flex.w-full.pr-2(v-if="clearEmployee")
|
.schedule-select.flex.w-full.pr-2(v-if="clearEmployee")
|
||||||
.edit.flex.items-center.justify-center.h-11.w-11(v-if="currentEmployee.label")
|
.edit.flex.items-center.justify-center.h-11.w-11(v-if="currentEmployee.label")
|
||||||
.flex.icon-edit(v-if="currentEmployee.label")
|
.flex.icon-edit(v-if="currentEmployee.label")
|
||||||
@@ -45,7 +46,7 @@
|
|||||||
//- v-if="currentEmployee.label"
|
//- v-if="currentEmployee.label"
|
||||||
//- )
|
//- )
|
||||||
//- .icon-ok.text-xsm(class="pt-[3px]")
|
//- .icon-ok.text-xsm(class="pt-[3px]")
|
||||||
.name.flex.justify-center.items-center.cursor-pointer(:class="{'select-name': currentEmployee.label}")
|
.text.flex.justify-center.items-center.cursor-pointer(:class="{'select-name': currentEmployee.label}")
|
||||||
base-custom-select(
|
base-custom-select(
|
||||||
v-if="!currentEmployee.label",
|
v-if="!currentEmployee.label",
|
||||||
:items="ownersList",
|
:items="ownersList",
|
||||||
@@ -71,7 +72,7 @@ import BaseButton from "@/components/base/BaseButton.vue";
|
|||||||
import BaseCustomSelect from "@/components/base/BaseCustomSelect.vue";
|
import BaseCustomSelect from "@/components/base/BaseCustomSelect.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "ScheduleBody",
|
name: "ScheduleTable",
|
||||||
components: { BaseModal, BaseButton, BaseCustomSelect },
|
components: { BaseModal, BaseButton, BaseCustomSelect },
|
||||||
props: {
|
props: {
|
||||||
scheduleList: Array,
|
scheduleList: Array,
|
||||||
@@ -79,6 +80,7 @@ export default {
|
|||||||
buttons: Array,
|
buttons: Array,
|
||||||
startMonth: Object,
|
startMonth: Object,
|
||||||
clearEmployee: Array,
|
clearEmployee: Array,
|
||||||
|
showTime: Boolean,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -125,6 +127,14 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
choiceTime(schedule, day) {
|
||||||
|
let currentDay = day.format("YYYY-MM-DD");
|
||||||
|
let start = schedule.schedules.find(
|
||||||
|
(e) => e.date === currentDay
|
||||||
|
)?.start_time;
|
||||||
|
let end = schedule.schedules.find((e) => e.date === currentDay)?.end_time;
|
||||||
|
return `${start} ${end}`;
|
||||||
|
},
|
||||||
changelColumnColor(day) {
|
changelColumnColor(day) {
|
||||||
return day.format("ddd") === "сб" || day.format("ddd") === "вс"
|
return day.format("ddd") === "сб" || day.format("ddd") === "вс"
|
||||||
? true
|
? true
|
||||||
@@ -134,6 +144,7 @@ export default {
|
|||||||
this.activeButton = this.buttons.find((e) => e.active);
|
this.activeButton = this.buttons.find((e) => e.active);
|
||||||
},
|
},
|
||||||
choiceCell(time, id, schedule) {
|
choiceCell(time, id, schedule) {
|
||||||
|
if (this.showTime) return;
|
||||||
let formatTime = time.format("YYYY-MM-DD");
|
let formatTime = time.format("YYYY-MM-DD");
|
||||||
let insideSchedules = schedule?.schedules.filter(
|
let insideSchedules = schedule?.schedules.filter(
|
||||||
(el) =>
|
(el) =>
|
||||||
@@ -158,9 +169,7 @@ export default {
|
|||||||
this.dateInterval.id = id;
|
this.dateInterval.id = id;
|
||||||
} else if (time.isAfter(this.dateInterval.start)) {
|
} else if (time.isAfter(this.dateInterval.start)) {
|
||||||
this.dateInterval.end = formatTime;
|
this.dateInterval.end = formatTime;
|
||||||
if (this.currentEmployee.label) {
|
this.$emit("schedule-employee", this.dateInterval, id);
|
||||||
this.$emit("new-schedule-employee", this.dateInterval);
|
|
||||||
} else this.$emit("schedule-employee", this.dateInterval);
|
|
||||||
} else this.dateInterval.start = formatTime;
|
} else this.dateInterval.start = formatTime;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
@@ -197,7 +206,12 @@ export default {
|
|||||||
start_date: moment(lastDate).add(1, "d").format("YYYY-MM-DD"),
|
start_date: moment(lastDate).add(1, "d").format("YYYY-MM-DD"),
|
||||||
end_date: this.dateInterval.end,
|
end_date: this.dateInterval.end,
|
||||||
});
|
});
|
||||||
this.$emit("schedules", insideSchedules, outsideSchedules);
|
this.$emit(
|
||||||
|
"schedules",
|
||||||
|
insideSchedules,
|
||||||
|
outsideSchedules,
|
||||||
|
this.currentEmployee
|
||||||
|
);
|
||||||
},
|
},
|
||||||
choiceState(day, id) {
|
choiceState(day, id) {
|
||||||
let formatDay = day.format("YYYY-MM-DD");
|
let formatDay = day.format("YYYY-MM-DD");
|
||||||
@@ -218,16 +232,20 @@ export default {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
status: (resStart || resMiddle || resEnd) && !!this.activeButton,
|
status: (resStart || resMiddle || resEnd) && !!this.activeButton,
|
||||||
|
"set-time": this.showTime,
|
||||||
"from-date": !!resStart && !this.activeButton,
|
"from-date": !!resStart && !this.activeButton,
|
||||||
"to-date": !!resEnd && !this.activeButton,
|
"to-date": !!resEnd && !this.activeButton,
|
||||||
"middle-dates": !!resMiddle && !this.activeButton,
|
"middle-dates": !!resMiddle && !this.activeButton,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
saveEmployee() {
|
clearData() {
|
||||||
this.currentEmployee.label = "";
|
this.currentEmployee.label = "";
|
||||||
this.currentEmployee.id = null;
|
this.currentEmployee.id = null;
|
||||||
},
|
},
|
||||||
choiceWorks(day, employee) {
|
choiceWorks(day, employee) {
|
||||||
|
if (this.showTime) {
|
||||||
|
return this.choiceTime(employee, day);
|
||||||
|
}
|
||||||
let currentDay = day.format("YYYY-MM-DD");
|
let currentDay = day.format("YYYY-MM-DD");
|
||||||
let res = employee.schedules.find((e) => e.date === currentDay)?.status;
|
let res = employee.schedules.find((e) => e.date === currentDay)?.status;
|
||||||
return this.buttons.find((e) => e.work === res)?.text[1];
|
return this.buttons.find((e) => e.work === res)?.text[1];
|
||||||
@@ -235,6 +253,9 @@ export default {
|
|||||||
choiceColor(day, employee) {
|
choiceColor(day, employee) {
|
||||||
let currentDay = day.format("YYYY-MM-DD");
|
let currentDay = day.format("YYYY-MM-DD");
|
||||||
let res = employee.schedules.find((e) => e.date === currentDay)?.status;
|
let res = employee.schedules.find((e) => e.date === currentDay)?.status;
|
||||||
|
if (res !== "WORKS" && this.showTime) {
|
||||||
|
return "var(--default-white)";
|
||||||
|
}
|
||||||
return this.buttons.find((e) => e.work === res)?.color;
|
return this.buttons.find((e) => e.work === res)?.color;
|
||||||
},
|
},
|
||||||
changeDays() {
|
changeDays() {
|
||||||
@@ -315,11 +336,6 @@ export default {
|
|||||||
border-right: 1.5px solid var(--border-light-grey-color-1)
|
border-right: 1.5px solid var(--border-light-grey-color-1)
|
||||||
border-bottom: 1.5px solid var(--border-light-grey-color-1)
|
border-bottom: 1.5px solid var(--border-light-grey-color-1)
|
||||||
|
|
||||||
.name
|
|
||||||
color: var(--btn-blue-color)
|
|
||||||
border-bottom: 1.5px solid var(--border-light-grey-color-1)
|
|
||||||
border-right: 1.5px solid var(--border-light-grey-color-1)
|
|
||||||
|
|
||||||
.select-name
|
.select-name
|
||||||
width: 25%
|
width: 25%
|
||||||
border-right: 1.5px solid var(--border-light-grey-color-1)
|
border-right: 1.5px solid var(--border-light-grey-color-1)
|
||||||
@@ -334,6 +350,10 @@ export default {
|
|||||||
border-right: 1.5px solid var(--border-light-grey-color-1)
|
border-right: 1.5px solid var(--border-light-grey-color-1)
|
||||||
border-bottom: 1.5px solid var(--border-light-grey-color-1)
|
border-bottom: 1.5px solid var(--border-light-grey-color-1)
|
||||||
|
|
||||||
|
.show-time
|
||||||
|
text-align: center
|
||||||
|
font-size: 12px
|
||||||
|
|
||||||
.modal-wrapper
|
.modal-wrapper
|
||||||
border: 1.5px solid var(--border-light-grey-color-1)
|
border: 1.5px solid var(--border-light-grey-color-1)
|
||||||
border-radius: 4px
|
border-radius: 4px
|
||||||
Reference in New Issue
Block a user