[WIP] Добавил отображение текста на расписании, добавил create

This commit is contained in:
megavrilinvv
2022-12-26 19:56:07 +03:00
parent 1dd0c79360
commit 82f1eaf2e8
4 changed files with 61 additions and 72 deletions

View File

@@ -37,7 +37,7 @@
.flex.flex-col.gap-y-6 .flex.flex-col.gap-y-6
.flex.flex-col.gap-y-2 .flex.flex-col.gap-y-2
.font-bold Услуги .font-bold Услуги
.counter.text-smm Выберите подходищие из списка .counter.text-smm Выберите подходящие из списка
.services-wrapper.flex.flex-col.pt-4.px-4 .services-wrapper.flex.flex-col.pt-4.px-4
.flex.gap-x-2 .flex.gap-x-2
base-input( base-input(

View File

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

View File

@@ -4,10 +4,10 @@
.time-wrapper.flex.justify-between .time-wrapper.flex.justify-between
.flex.flex-col.items-center.py-14px.px-4.gap-y-14px .flex.flex-col.items-center.py-14px.px-4.gap-y-14px
.text.text-smm Начало .text.text-smm Начало
base-input-date.select(v-model:value="dataSchedule.endTime") base-input-time.select(v-model:value="times.start_time")
.flex.flex-col.items-center.py-14px.px-4.gap-y-14px .flex.flex-col.items-center.py-14px.px-4.gap-y-14px
.text.span.text-smm Конец .text.span.text-smm Конец
base-input-date.select(v-model:value="dataSchedule.startTime") base-input-time.select(v-model:value="times.end_time")
.status-wrapper.flex.flex-col .status-wrapper.flex.flex-col
.flex.justify-center.items-center.h-10 .flex.justify-center.items-center.h-10
span.font-semibold Статусы span.font-semibold Статусы
@@ -27,7 +27,7 @@
placeholder="Шаблоны графиков" placeholder="Шаблоны графиков"
) )
.flex.justify-center .flex.justify-center
base-button.font-semibold(:size="40") Сохранить base-button.font-semibold(:size="40", @click="createSchedule") Сохранить
</template> </template>
<script> <script>
@@ -38,7 +38,13 @@ import BaseInputDate from "@/components/base/BaseInputDate.vue";
export default { export default {
name: "ScheduleBar", name: "ScheduleBar",
components: { BaseButton, BaseCustomSelect, BaseInputTime, BaseInputDate }, components: { BaseButton, BaseCustomSelect, BaseInputTime, BaseInputDate },
props: { dataSchedule: Object, buttons: Array }, props: {
dataSchedule: Object,
buttons: Array,
clearEmployee: Array,
times: Object,
createSchedule: Function,
},
data() { data() {
return { return {
scheduleList: [ scheduleList: [
@@ -66,7 +72,6 @@ export default {
border-radius: 4px border-radius: 4px
.time-wrapper .time-wrapper
width: 420px
height: 102px height: 102px
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

View File

@@ -1,7 +1,7 @@
<template lang="pug"> <template lang="pug">
.schedule.flex-col(:style="themeCell") .schedule.flex-col(:style="themeCell")
.table-header.flex.w-full .table-header.flex.w-full
.flex.items-center(:style="{padding: '16px 102px'}") .flex.items-center.justify-center.pl-11(:style="{width: 'calc(25% + 44px)'}")
.text.font-bold Сотрудник .text.font-bold Сотрудник
.column-wrapper.flex .column-wrapper.flex
.schedule-column.flex.flex-col.items-center.justify-center.w-11( .schedule-column.flex.flex-col.items-center.justify-center.w-11(
@@ -9,7 +9,6 @@
:style="{backgroundColor: day.format('ddd') === 'сб' || day.format('ddd') === 'вс' ? 'var(--bg-white-color-1)' : ''}" :style="{backgroundColor: day.format('ddd') === 'сб' || day.format('ddd') === 'вс' ? 'var(--bg-white-color-1)' : ''}"
) )
.text.flex.font-bold( .text.flex.font-bold(
@click="selectDay(day.format('D'))"
:style="{opacity: changeOpacity(day)}" :style="{opacity: changeOpacity(day)}"
) {{day.format("D")}} ) {{day.format("D")}}
.text.flex.font-bold( .text.flex.font-bold(
@@ -18,7 +17,7 @@
.schedule-body.flex.w-full(v-for="schedule in serialized", :key="schedule.id") .schedule-body.flex.w-full(v-for="schedule in serialized", :key="schedule.id")
.edit.flex.items-center.justify-center.h-11.w-11 .edit.flex.items-center.justify-center.h-11.w-11
.flex.icon-edit .flex.icon-edit
.name-employee.flex.justify-center.items-center.cursor-pointer(@click="openSelect(schedule)") .name-employee.flex.justify-center.items-center.cursor-pointer
span {{trimOwnerName(schedule.last_name, schedule.first_name, schedule.patronymic)}} span {{trimOwnerName(schedule.last_name, schedule.first_name, schedule.patronymic)}}
.cell.flex.flex-col.items-center.justify-center.w-11.h-11.cursor-pointer( .cell.flex.flex-col.items-center.justify-center.w-11.h-11.cursor-pointer(
v-for="day in result", v-for="day in result",
@@ -42,8 +41,7 @@
//- ) //- )
//- .icon-ok.text-xsm(class="pt-[3px]") //- .icon-ok.text-xsm(class="pt-[3px]")
.name.flex.justify-center.items-center.cursor-pointer( .name.flex.justify-center.items-center.cursor-pointer(
v-if="currentEmployee.label", v-if="currentEmployee.label"
@click="openSelect"
) )
span {{currentEmployee.label}} span {{currentEmployee.label}}
.name.flex(v-if="!currentEmployee.label") .name.flex(v-if="!currentEmployee.label")
@@ -51,7 +49,7 @@
:items="ownersList", :items="ownersList",
v-model="currentEmployee", v-model="currentEmployee",
placeholder="Добавить сотрудника", placeholder="Добавить сотрудника",
:style="{border: 'none'}" :style="{border: 'none', justifyContent: 'center'}"
) )
.cell.flex.flex-col.items-center.justify-center.w-11.h-11.cursor-pointer( .cell.flex.flex-col.items-center.justify-center.w-11.h-11.cursor-pointer(
v-if="currentEmployee.label", v-if="currentEmployee.label",
@@ -60,9 +58,8 @@
:id="currentEmployee.id + day", :id="currentEmployee.id + day",
@click="choiceCell(day, currentEmployee.id)", @click="choiceCell(day, currentEmployee.id)",
:class="selectTime(day, currentEmployee.id)", :class="selectTime(day, currentEmployee.id)",
:style="{backgroundColor: day.format('YYYY-MM-DD') === choiceDay(day, currentEmployee.id) ? choiceColor(day) : '', borderBottom: 'none'}" :style="{borderBottom: 'none'}"
) )
.flex {{day.format("YYYY-MM-DD") === choiceDay(day, currentEmployee.id) ? choiceWorks(day) : ''}}
</template> </template>
<script> <script>
@@ -187,13 +184,13 @@ export default {
}, },
choiceWorks(day) { choiceWorks(day) {
let currentDay = day.format("YYYY-MM-DD"); let currentDay = day.format("YYYY-MM-DD");
let a = this.scheduleList.find((e) => e.date === currentDay).status; let res = this.scheduleList.find((e) => e.date === currentDay).status;
return this.buttons.find((e) => e.work === a).text[1]; return this.buttons.find((e) => e.work === res).text[1];
}, },
choiceColor(day) { choiceColor(day) {
let currentDay = day.format("YYYY-MM-DD"); let currentDay = day.format("YYYY-MM-DD");
let a = this.scheduleList.find((e) => e.date === currentDay).status; let res = this.scheduleList.find((e) => e.date === currentDay).status;
return this.buttons.find((e) => e.work === a).color; return this.buttons.find((e) => e.work === res).color;
}, },
changeDays() { changeDays() {
this.days = moment().daysInMonth(); this.days = moment().daysInMonth();
@@ -209,12 +206,6 @@ export default {
let checkedPatronymic = patronymic !== null ? patronymic[0] + "." : ""; let checkedPatronymic = patronymic !== null ? patronymic[0] + "." : "";
return `${lastName} ${checkedFirstName}${checkedPatronymic}`; return `${lastName} ${checkedFirstName}${checkedPatronymic}`;
}, },
// openSelect() {
// this.showSelect = true;
// for (let index = 0; index < this.employeeList.length; index++) {
// this.employee.push(this.employeeList[index]);
// }
// },
choiceDay(day, employee) { choiceDay(day, employee) {
let current = day.format("YYYY-MM-DD"); let current = day.format("YYYY-MM-DD");
return this.scheduleList.find( return this.scheduleList.find(
@@ -227,12 +218,6 @@ export default {
? "0.6" ? "0.6"
: "1"; : "1";
}, },
openSelect(schedule) {
console.log(schedule);
},
selectDay(day) {
console.log(day);
},
}, },
mounted() { mounted() {
@@ -246,8 +231,9 @@ export default {
.schedule .schedule
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
border-right: none
min-height: 87px min-height: 87px
width: fit-content width: calc(100vw - 144px)
.schedule-body .schedule-body
&:hover &:hover
@@ -271,14 +257,12 @@ export default {
border-bottom: 1.5px solid var(--border-light-grey-color-1) border-bottom: 1.5px solid var(--border-light-grey-color-1)
.name .name
min-width: 247px width: 25%
max-width: 247px
border-right: 1.5px solid var(--border-light-grey-color-1) border-right: 1.5px solid var(--border-light-grey-color-1)
color: var(--btn-blue-color) color: var(--btn-blue-color)
.name-employee .name-employee
min-width: 247px width: 25%
max-width: 247px
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)
color: var(--btn-blue-color) color: var(--btn-blue-color)