[WIP] Добавил отображение времени текущей даты при замене смен, скрыл отображение выделенной ячейки при сохранении/удалении

This commit is contained in:
megavrilinvv
2023-01-25 17:03:01 +03:00
parent 082f92937d
commit 48f78626c1
5 changed files with 70 additions and 33 deletions

View File

@@ -28,6 +28,8 @@
:template="template", :template="template",
:trim-owner-name="trimOwnerName", :trim-owner-name="trimOwnerName",
:open-form="openForm", :open-form="openForm",
:active-cell="activeCell",
:set-active-cell="setActiveCell",
:change-shift="postUpdateSchedule", :change-shift="postUpdateSchedule",
@schedule-employee="createScheduleEmployee", @schedule-employee="createScheduleEmployee",
@schedules="distributeRequest" @schedules="distributeRequest"
@@ -43,11 +45,11 @@
<script> <script>
import * as moment from "moment"; import * as moment from "moment";
import BaseLoader from "@/components/Loader/BaseLoader.vue";
import { fetchWrapper } from "@/shared/fetchWrapper.js";
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 ScheduleTable from "@/pages/schedule/components/ScheduleTable.vue"; import ScheduleTable from "@/pages/schedule/components/ScheduleTable.vue";
import { fetchWrapper } from "@/shared/fetchWrapper.js";
import BaseLoader from "@/components/Loader/BaseLoader.vue";
export default { export default {
name: "TheSchedule", name: "TheSchedule",
@@ -78,6 +80,7 @@ export default {
date: null, date: null,
start_time: "", start_time: "",
end_time: "", end_time: "",
schedules: [],
}, },
buttons: [ buttons: [
{ {
@@ -110,6 +113,7 @@ export default {
showTime: false, showTime: false,
schedulesDate: {}, schedulesDate: {},
currenSchedule: null, currenSchedule: null,
activeCell: true,
}; };
}, },
computed: { computed: {
@@ -128,6 +132,7 @@ export default {
e.first_name, e.first_name,
e.patronymic e.patronymic
); );
this.replacementSheet.schedules = e.schedules;
}, },
changeShowTime() { changeShowTime() {
this.showTime = !this.showTime; this.showTime = !this.showTime;
@@ -137,6 +142,9 @@ export default {
let checkedPatronymic = patronymic !== null ? patronymic[0] + "." : ""; let checkedPatronymic = patronymic !== null ? patronymic[0] + "." : "";
return `${lastName} ${checkedFirstName}${checkedPatronymic}`; return `${lastName} ${checkedFirstName}${checkedPatronymic}`;
}, },
setActiveCell() {
this.activeCell = true;
},
clearSelect(employee) { clearSelect(employee) {
if (employee) { if (employee) {
employee.label = ""; employee.label = "";
@@ -145,6 +153,8 @@ export default {
this.selectEmployee.label = ""; this.selectEmployee.label = "";
this.selectEmployeeid = null; this.selectEmployeeid = null;
} }
if (this.buttons.find((e) => e.active))
this.buttons.find((e) => e.active).active = false;
}, },
fetchSchedules() { fetchSchedules() {
fetchWrapper fetchWrapper
@@ -217,6 +227,7 @@ export default {
this.outsideSchedules = outside; this.outsideSchedules = outside;
}, },
postCreateSchedules() { postCreateSchedules() {
this.activeCell = false;
let data = { let data = {
employee: this.schedulesDate.id, employee: this.schedulesDate.id,
active_flg: true, active_flg: true,
@@ -285,6 +296,7 @@ export default {
}; };
}, },
deleteSchedule() { deleteSchedule() {
this.activeCell = false;
let ids = ""; let ids = "";
if (this.insideSchedules?.length > 0) { if (this.insideSchedules?.length > 0) {
this.insideSchedules.forEach((e) => (ids += e.id + ",")); this.insideSchedules.forEach((e) => (ids += e.id + ","));
@@ -313,11 +325,26 @@ export default {
this.replacementSheet.start_time = localDatetime; this.replacementSheet.start_time = localDatetime;
this.replacementSheet.end_time = localDatetime; this.replacementSheet.end_time = localDatetime;
}, },
setShiftTime() {
let dateSchedule = this.replacementSheet.schedules.find(
(e) =>
e.date === moment(this.replacementSheet.date).format("YYYY-MM-DD")
);
this.replacementSheet.start_time = dateSchedule?.start_time;
this.replacementSheet.end_time = dateSchedule?.end_time;
},
}, },
watch: { watch: {
startMonth() { startMonth() {
this.fetchSchedulesEmployee(); this.fetchSchedulesEmployee();
}, },
replacementSheet: {
immediate: true,
handler(newVal) {
if (newVal) this.setShiftTime();
},
deep: true,
},
}, },
mounted() { mounted() {
this.fetchSchedules(); this.fetchSchedules();
@@ -337,14 +364,18 @@ export default {
opacity: 0 opacity: 0
transform: translateY(0px) transform: translateY(0px)
pointer-events: none pointer-events: none
.schedule-enter-active .schedule-enter-active
transition: 0.3s ease transition: 0.3s ease
.schedule-leave-to .schedule-leave-to
opacity: 0 opacity: 0
transform: translateY(0px) transform: translateY(0px)
pointer-events: none pointer-events: none
.schedule-leave-active .schedule-leave-active
transition: 0.3s ease transition: 0.3s ease
.schedule-move .schedule-move
transition: 0.3s ease transition: 0.3s ease
</style> </style>

View File

@@ -43,7 +43,7 @@
label="Сохранить", label="Сохранить",
color="primary", color="primary",
padding="8px 24px", padding="8px 24px",
no-caps no-caps,
@click="changeShift(); closeForm()" @click="changeShift(); closeForm()"
) )
</template> </template>
@@ -59,14 +59,14 @@ export default {
props: { props: {
employees: Array, employees: Array,
serialized: Array, serialized: Array,
replacementSheet: Object, modelValue: Boolean,
trimOwnerName: Function, trimOwnerName: Function,
changeShift: Function, changeShift: Function,
modelValue: Boolean, replacementSheet: Object,
}, },
computed: { computed: {
ownersList() { ownersList() {
if (this.employees) { if (this.employees || this.serialized) {
let filteredArray = []; let filteredArray = [];
this.employees.forEach((elem) => { this.employees.forEach((elem) => {
filteredArray.push({ filteredArray.push({

View File

@@ -16,6 +16,7 @@
:replacement-sheet="replacementSheet", :replacement-sheet="replacementSheet",
:employees="employees", :employees="employees",
:change-shift="changeShift" :change-shift="changeShift"
:set-active-cell="setActiveCell"
) )
schedule-table-select( schedule-table-select(
v-if="employees.length > 0", v-if="employees.length > 0",
@@ -24,7 +25,7 @@
:result="result", :result="result",
:choice-cell="choiceCell", :choice-cell="choiceCell",
:choice-state="choiceState", :choice-state="choiceState",
:trim-owner-name="trimOwnerName", :trim-owner-name="trimOwnerName"
) )
</template> </template>
@@ -47,16 +48,18 @@ export default {
scheduleList: Array, scheduleList: Array,
serialized: Array, serialized: Array,
buttons: Array, buttons: Array,
template: Object,
employees: Array, employees: Array,
showTime: Boolean, showTime: Boolean,
activeCell: Boolean,
clearSelect: Function, clearSelect: Function,
selectEmployee: Object,
startMonth: Object,
trimOwnerName: Function, trimOwnerName: Function,
openForm: Function, openForm: Function,
replacementSheet: Object,
changeShift: Function, changeShift: Function,
setActiveCell: Function,
template: Object,
selectEmployee: Object,
startMonth: Object,
replacementSheet: Object,
}, },
data() { data() {
return { return {
@@ -71,7 +74,6 @@ export default {
}, },
activeButton: null, activeButton: null,
choiceMonth: null, choiceMonth: null,
act: null,
}; };
}, },
computed: { computed: {
@@ -79,9 +81,10 @@ export default {
this.setActiveButton(); this.setActiveButton();
return { return {
"--bg-color-status": this.activeButton?.color, "--bg-color-status": this.activeButton?.color,
"--text-status": !this.template.item?.symbol "--text-status":
? this.activeButton?.text !this.template.item?.symbol && this.activeCell
: this.template.item?.symbol, ? this.activeButton?.text
: this.template.item?.symbol,
}; };
}, },
}, },
@@ -89,14 +92,14 @@ export default {
setActiveButton() { setActiveButton() {
this.activeButton = this.buttons.find((e) => e.active); this.activeButton = this.buttons.find((e) => e.active);
}, },
setActiveCell() { setActiveTemplate() {
return (this.buttons.find((e) => e.work === "WORKS").active = true); return (this.buttons.find((e) => e.work === "WORKS").active = true);
}, },
choiceCell(day, id, schedule) { choiceCell(day, id, schedule) {
if (this.showTime) return; if (this.showTime) return;
let formatTime = day.format("YYYY-MM-DD"); let formatTime = day.format("YYYY-MM-DD");
if (this.dateInterval.id !== id) { if (this.dateInterval.id !== id || !this.activeCell) {
this.dateInterval.start = ""; this.dateInterval.start = "";
this.dateInterval.end = ""; this.dateInterval.end = "";
this.dateInterval.id = ""; this.dateInterval.id = "";
@@ -150,7 +153,7 @@ export default {
this.$emit("schedules", insideSchedules, outsideSchedules); this.$emit("schedules", insideSchedules, outsideSchedules);
}, },
choiceState(day, id) { choiceState(day, id) {
let formatDay = day.format("YYYY-MM-DD"); let formatDay = day?.format("YYYY-MM-DD");
let resStart = let resStart =
this.dateInterval.start && this.dateInterval.start &&
formatDay === this.dateInterval.start && formatDay === this.dateInterval.start &&
@@ -162,16 +165,18 @@ export default {
this.dateInterval.id === id; this.dateInterval.id === id;
let resMiddle = let resMiddle =
day.isBefore(this.dateInterval.end) && day?.isBefore(this.dateInterval.end) &&
this.dateInterval.id === id && this.dateInterval.id === id &&
day.isAfter(this.dateInterval.start); day?.isAfter(this.dateInterval.start);
if (resStart || resMiddle || resEnd) if (resStart || resMiddle || resEnd) {
return { return {
"set-template": !!this.template.item?.label && this.setActiveCell(), "set-template":
status: !!this.activeButton, !!this.template.item?.label && this.setActiveTemplate(),
"set-date": !this.activeButton, status: !!this.activeButton && this.activeCell,
"set-date": !this.activeButton && this.activeCell,
}; };
}
}, },
changeDays() { changeDays() {
this.days = moment(this.choiceMonth, "YYYY-MM-DD").daysInMonth(); this.days = moment(this.choiceMonth, "YYYY-MM-DD").daysInMonth();

View File

@@ -26,7 +26,7 @@
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); clearSelect(selectEmployee)", @click="choiceCell(day, schedule.id, schedule); clearSelect(selectEmployee); setActiveCell()",
:class="choiceState(day, schedule.id)", :class="choiceState(day, schedule.id)",
:style="{backgroundColor: choiceDay(day, schedule.id) ? choiceColor(day, schedule) : '', width: `calc(100% / ${result.length})`}" :style="{backgroundColor: choiceDay(day, schedule.id) ? choiceColor(day, schedule) : '', width: `calc(100% / ${result.length})`}"
) )
@@ -43,19 +43,20 @@ export default {
components: { FormChangeShift }, components: { FormChangeShift },
props: { props: {
serialized: Array, serialized: Array,
trimOwnerName: Function,
result: Array, result: Array,
buttons: Array,
scheduleList: Array,
employees: Array,
showTime: Boolean,
trimOwnerName: Function,
choiceCell: Function, choiceCell: Function,
clearSelect: Function, clearSelect: Function,
selectEmployee: Object,
choiceState: Function, choiceState: Function,
buttons: Array,
showTime: Boolean,
scheduleList: Array,
openForm: Function, openForm: Function,
changeShift: Function, changeShift: Function,
setActiveCell: Function,
replacementSheet: Object, replacementSheet: Object,
employees: Array, selectEmployee: Object,
}, },
data() { data() {
return { return {

View File

@@ -44,12 +44,12 @@ export default {
name: "ScheduleTableSelect", name: "ScheduleTableSelect",
components: { BaseSelect }, components: { BaseSelect },
props: { props: {
selectEmployee: Object,
result: Array, result: Array,
employees: Array,
choiceCell: Function, choiceCell: Function,
choiceState: Function, choiceState: Function,
employees: Array,
trimOwnerName: Function, trimOwnerName: Function,
selectEmployee: Object,
}, },
computed: { computed: {
ownersList() { ownersList() {