WIP EmployeesList подтягивается из Schedules
This commit is contained in:
@@ -2,14 +2,14 @@
|
|||||||
.calendar-container.flex
|
.calendar-container.flex
|
||||||
calendar-sidebar(
|
calendar-sidebar(
|
||||||
:url="url",
|
:url="url",
|
||||||
:team-data="employeesData",
|
:schedules-data="schedulesData",
|
||||||
:open-form-create="openFormCreateEvent",
|
:open-form-create="openFormCreateEvent",
|
||||||
:event-statuses="eventStatuses",
|
:event-statuses="eventStatuses",
|
||||||
@width="changeWidth",
|
@width="changeWidth",
|
||||||
)
|
)
|
||||||
calendar-schedule(
|
calendar-schedule(
|
||||||
:url="url",
|
:url="url",
|
||||||
:owners-data="employeesData",
|
:schedules-data="schedulesData",
|
||||||
:current-date="currentDate",
|
:current-date="currentDate",
|
||||||
:time-information="timeInformation",
|
:time-information="timeInformation",
|
||||||
:events-data="eventsData",
|
:events-data="eventsData",
|
||||||
@@ -31,6 +31,7 @@
|
|||||||
:selected-event-data="selectedEvent",
|
:selected-event-data="selectedEvent",
|
||||||
:event-statuses="eventStatuses",
|
:event-statuses="eventStatuses",
|
||||||
:time-information="timeInformation",
|
:time-information="timeInformation",
|
||||||
|
:current-date="currentDate",
|
||||||
@clear-selected-event-data="clearSelectedEvent",
|
@clear-selected-event-data="clearSelectedEvent",
|
||||||
@close-change-form="setChangeFormState"
|
@close-change-form="setChangeFormState"
|
||||||
)
|
)
|
||||||
@@ -78,8 +79,9 @@ export default {
|
|||||||
dayEndTime: "22:00",
|
dayEndTime: "22:00",
|
||||||
},
|
},
|
||||||
eventsData: [],
|
eventsData: [],
|
||||||
employeesData: [],
|
schedulesData: [],
|
||||||
isOpenForm: false,
|
isOpenForm: false,
|
||||||
|
WORKING_STATUS: "WORKS",
|
||||||
changeFormWasClosed: false,
|
changeFormWasClosed: false,
|
||||||
eventStatuses: [
|
eventStatuses: [
|
||||||
{
|
{
|
||||||
@@ -140,13 +142,28 @@ export default {
|
|||||||
saveEventsData(res) {
|
saveEventsData(res) {
|
||||||
this.eventsData = res.results;
|
this.eventsData = res.results;
|
||||||
},
|
},
|
||||||
saveEmployeesData(res) {
|
saveSchedulesData(res) {
|
||||||
this.employeesData = res.results;
|
if (res.results.length === 0) {
|
||||||
|
this.schedulesData = [];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let filteredEmployees = res.results.filter(
|
||||||
|
(elem) => elem.status === this.WORKING_STATUS
|
||||||
|
);
|
||||||
|
if (filteredEmployees.length === 0) {
|
||||||
|
this.schedulesData = [];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.schedulesData = filteredEmployees;
|
||||||
},
|
},
|
||||||
fetchEmployeesData() {
|
fetchSchedulesData() {
|
||||||
fetchWrapper
|
fetchWrapper
|
||||||
.get(`general/employee/?date=${this.currentDate.format("YYYY-MM-DD")}`)
|
.get(
|
||||||
.then((res) => this.saveEmployeesData(res));
|
`accounts/schedules/?date_after=${this.currentDate.format(
|
||||||
|
"YYYY-MM-DD"
|
||||||
|
)}&date_before=${this.currentDate.format("YYYY-MM-DD")}`
|
||||||
|
)
|
||||||
|
.then((res) => this.saveSchedulesData(res));
|
||||||
},
|
},
|
||||||
fetchEventsData() {
|
fetchEventsData() {
|
||||||
fetchWrapper
|
fetchWrapper
|
||||||
@@ -192,11 +209,11 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
currentDate() {
|
currentDate() {
|
||||||
this.fetchEmployeesData();
|
this.fetchSchedulesData();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.fetchEmployeesData();
|
this.fetchSchedulesData();
|
||||||
this.fetchEventsData();
|
this.fetchEventsData();
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -70,20 +70,9 @@ export default {
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
workingShift() {
|
workingShift() {
|
||||||
console.log(this.ownerData);
|
|
||||||
if (!this.ownerData.id) return null;
|
if (!this.ownerData.id) return null;
|
||||||
let foundedSchedule = this.ownerData.schedule.find(
|
let start = this.ownerData.start_time;
|
||||||
(elem) => elem.date === this.currentDate.format("YYYY-MM-DD")
|
let end = this.ownerData.end_time;
|
||||||
);
|
|
||||||
if (!foundedSchedule) return null;
|
|
||||||
let start = foundedSchedule.start_time.slice(
|
|
||||||
0,
|
|
||||||
foundedSchedule.start_time.length - 3
|
|
||||||
);
|
|
||||||
let end = foundedSchedule.end_time.slice(
|
|
||||||
0,
|
|
||||||
foundedSchedule.end_time.length - 3
|
|
||||||
);
|
|
||||||
return {
|
return {
|
||||||
start: start.split(":"),
|
start: start.split(":"),
|
||||||
end: end.split(":"),
|
end: end.split(":"),
|
||||||
@@ -269,6 +258,6 @@ export default {
|
|||||||
|
|
||||||
.nonworking-time
|
.nonworking-time
|
||||||
width: 100%
|
width: 100%
|
||||||
background-color: var(--font-dark-blue-color)
|
background-color: var(--btn-blue-sec-color)
|
||||||
opacity: 0.05
|
opacity: 0.3
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -113,6 +113,12 @@ export default {
|
|||||||
return {};
|
return {};
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
currentDate: {
|
||||||
|
type: Object,
|
||||||
|
default() {
|
||||||
|
return {};
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -130,6 +136,7 @@ export default {
|
|||||||
ifClearedForm: true,
|
ifClearedForm: true,
|
||||||
membersData: [],
|
membersData: [],
|
||||||
ownersData: [],
|
ownersData: [],
|
||||||
|
WORKING_STATUS: "WORKS",
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -298,10 +305,27 @@ export default {
|
|||||||
},
|
},
|
||||||
checkTime() {
|
checkTime() {
|
||||||
let counter = 0;
|
let counter = 0;
|
||||||
|
let foundedSchedule = {};
|
||||||
|
let foundedEmployee = this.ownersData.find(
|
||||||
|
(elem) => elem.id === this.employees.employee.id
|
||||||
|
);
|
||||||
|
if (foundedEmployee)
|
||||||
|
foundedSchedule = foundedEmployee.schedules.find(
|
||||||
|
(elem) =>
|
||||||
|
elem.date === this.eventDate && elem.status === this.WORKING_STATUS
|
||||||
|
);
|
||||||
|
if (!foundedSchedule) {
|
||||||
|
this.addErrorNotification(
|
||||||
|
"Некорректная дата события",
|
||||||
|
`В данный день ${this.employees.employee.label} не работает`
|
||||||
|
);
|
||||||
|
counter += 1;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (
|
if (
|
||||||
this.checkTimeLimits(
|
this.checkTimeLimits(
|
||||||
this.startTime,
|
this.startTime,
|
||||||
this.timeInformation.dayStartTime,
|
foundedSchedule.start_time,
|
||||||
"start"
|
"start"
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
@@ -311,13 +335,7 @@ export default {
|
|||||||
);
|
);
|
||||||
counter += 1;
|
counter += 1;
|
||||||
}
|
}
|
||||||
if (
|
if (this.checkTimeLimits(this.endTime, foundedSchedule.end_time, "end")) {
|
||||||
this.checkTimeLimits(
|
|
||||||
this.endTime,
|
|
||||||
this.timeInformation.dayEndTime,
|
|
||||||
"end"
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
this.addErrorNotification(
|
this.addErrorNotification(
|
||||||
"Некорректное время окончания события",
|
"Некорректное время окончания события",
|
||||||
"Время окончания события позже окончания рабочего дня"
|
"Время окончания события позже окончания рабочего дня"
|
||||||
@@ -325,11 +343,7 @@ export default {
|
|||||||
counter += 1;
|
counter += 1;
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
this.checkTimeLimits(
|
this.checkTimeLimits(this.endTime, foundedSchedule.start_time, "start")
|
||||||
this.endTime,
|
|
||||||
this.timeInformation.dayStartTime,
|
|
||||||
"start"
|
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
this.addErrorNotification(
|
this.addErrorNotification(
|
||||||
"Некорректное время окончания события",
|
"Некорректное время окончания события",
|
||||||
@@ -338,11 +352,7 @@ export default {
|
|||||||
counter += 1;
|
counter += 1;
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
this.checkTimeLimits(
|
this.checkTimeLimits(this.startTime, foundedSchedule.end_time, "end")
|
||||||
this.startTime,
|
|
||||||
this.timeInformation.dayEndTime,
|
|
||||||
"end"
|
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
this.addErrorNotification(
|
this.addErrorNotification(
|
||||||
"Некорректное время начала события",
|
"Некорректное время начала события",
|
||||||
@@ -485,11 +495,58 @@ export default {
|
|||||||
},
|
},
|
||||||
fetchOwnersData() {
|
fetchOwnersData() {
|
||||||
fetchWrapper
|
fetchWrapper
|
||||||
.get("general/employee/")
|
.get(
|
||||||
|
`accounts/schedules/?date_after=${this.currentDate
|
||||||
|
.clone()
|
||||||
|
.subtract(1, "month")
|
||||||
|
.format("YYYY-MM-DD")}&date_before=${this.currentDate
|
||||||
|
.clone()
|
||||||
|
.add(1, "month")
|
||||||
|
.format("YYYY-MM-DD")}`
|
||||||
|
)
|
||||||
.then((res) => this.saveOwnersData(res));
|
.then((res) => this.saveOwnersData(res));
|
||||||
},
|
},
|
||||||
saveOwnersData(res) {
|
saveOwnersData(res) {
|
||||||
this.ownersData = res.results;
|
let serializedList = [];
|
||||||
|
if (res.results.length === 0) {
|
||||||
|
this.ownersData = [];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
res.results.forEach((elem) => {
|
||||||
|
let foundedElem = serializedList.find(
|
||||||
|
(item) => item.id === elem.employee.id
|
||||||
|
);
|
||||||
|
if (!foundedElem) {
|
||||||
|
serializedList.push({
|
||||||
|
id: elem.employee.id,
|
||||||
|
last_name: elem.employee.last_name,
|
||||||
|
first_name: elem.employee.first_name,
|
||||||
|
patronymic: elem.employee.patronymic,
|
||||||
|
color: elem.employee.color,
|
||||||
|
schedules: [
|
||||||
|
{
|
||||||
|
date: elem.date,
|
||||||
|
end_time: elem.end_time.slice(0, elem.end_time.length - 3),
|
||||||
|
start_time: elem.start_time.slice(
|
||||||
|
0,
|
||||||
|
elem.start_time.length - 3
|
||||||
|
),
|
||||||
|
status: elem.status,
|
||||||
|
id: elem.id,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
foundedElem.schedules.push({
|
||||||
|
date: elem.date,
|
||||||
|
end_time: elem.end_time.slice(0, elem.end_time.length - 3),
|
||||||
|
start_time: elem.start_time.slice(0, elem.start_time.length - 3),
|
||||||
|
status: elem.status,
|
||||||
|
id: elem.id,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.ownersData = serializedList;
|
||||||
},
|
},
|
||||||
saveMembersData(res) {
|
saveMembersData(res) {
|
||||||
this.membersData = res.results;
|
this.membersData = res.results;
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
sidebarWidth: String,
|
sidebarWidth: String,
|
||||||
ownersData: {
|
schedulesData: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default() {
|
default() {
|
||||||
return [];
|
return [];
|
||||||
@@ -168,15 +168,16 @@ export default {
|
|||||||
},
|
},
|
||||||
filteredOwners() {
|
filteredOwners() {
|
||||||
let filteredArray = [];
|
let filteredArray = [];
|
||||||
this.ownersData.forEach((elem) => {
|
this.schedulesData.forEach((elem) => {
|
||||||
filteredArray.push({
|
filteredArray.push({
|
||||||
id: elem.id,
|
id: elem.employee.id,
|
||||||
last_name: elem.last_name,
|
last_name: elem.employee.last_name,
|
||||||
first_name: elem.first_name,
|
first_name: elem.employee.first_name,
|
||||||
patronymic: elem.patronymic,
|
patronymic: elem.employee.patronymic,
|
||||||
color: elem.color,
|
color: elem.employee.color,
|
||||||
photo: elem.photo,
|
photo: elem.employee.photo,
|
||||||
schedule: elem.schedule,
|
end_time: elem.end_time.slice(0, elem.end_time.length - 3),
|
||||||
|
start_time: elem.start_time.slice(0, elem.start_time.length - 3),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return filteredArray;
|
return filteredArray;
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ export default {
|
|||||||
CalendarSidebarTeammate,
|
CalendarSidebarTeammate,
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
teamData: Array,
|
schedulesData: Array,
|
||||||
openFormCreate: Function,
|
openFormCreate: Function,
|
||||||
eventStatuses: Array,
|
eventStatuses: Array,
|
||||||
url: String,
|
url: String,
|
||||||
@@ -74,6 +74,10 @@ export default {
|
|||||||
width: this.widthSidebarClose,
|
width: this.widthSidebarClose,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
teamData() {
|
||||||
|
if (this.schedulesData.length === 0) return [];
|
||||||
|
return this.schedulesData.map((elem) => elem.employee);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
changeSize() {
|
changeSize() {
|
||||||
|
|||||||
Reference in New Issue
Block a user