[WIP] Добавил отображение текста при выборе даты и выбор employee
This commit is contained in:
@@ -13,9 +13,11 @@
|
|||||||
:serialized="serialized",
|
:serialized="serialized",
|
||||||
:data-schedule="dataSchedule",
|
:data-schedule="dataSchedule",
|
||||||
:buttons="buttons",
|
:buttons="buttons",
|
||||||
:start-month="startMonth"
|
:start-month="startMonth",
|
||||||
|
:clear-employee="clearEmployee",
|
||||||
|
@new-date="createNewDate"
|
||||||
)
|
)
|
||||||
schedule-bar(:data-schedule="dataSchedule", :select-work="selectWork", :buttons="buttons")
|
schedule-bar(:data-schedule="dataSchedule", :buttons="buttons")
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@@ -31,6 +33,7 @@ export default {
|
|||||||
return {
|
return {
|
||||||
employeeList: [],
|
employeeList: [],
|
||||||
scheduleList: [],
|
scheduleList: [],
|
||||||
|
clearEmployee: [],
|
||||||
serialized: [],
|
serialized: [],
|
||||||
dataSchedule: {
|
dataSchedule: {
|
||||||
status: "",
|
status: "",
|
||||||
@@ -45,7 +48,7 @@ export default {
|
|||||||
work: "WORKS",
|
work: "WORKS",
|
||||||
active: false,
|
active: false,
|
||||||
color: "#55CD76",
|
color: "#55CD76",
|
||||||
text: "Р",
|
text: "'Р'",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
class: "button-status",
|
class: "button-status",
|
||||||
@@ -53,7 +56,7 @@ export default {
|
|||||||
work: "VACATION",
|
work: "VACATION",
|
||||||
active: false,
|
active: false,
|
||||||
color: "#D7D9FF",
|
color: "#D7D9FF",
|
||||||
text: "О",
|
text: "'О'",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
class: "button-free",
|
class: "button-free",
|
||||||
@@ -61,7 +64,7 @@ export default {
|
|||||||
work: "DAY_OFF",
|
work: "DAY_OFF",
|
||||||
active: false,
|
active: false,
|
||||||
color: "#9294A7",
|
color: "#9294A7",
|
||||||
text: "В",
|
text: "'В'",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
startMonth: moment().startOf("month"),
|
startMonth: moment().startOf("month"),
|
||||||
@@ -94,6 +97,14 @@ export default {
|
|||||||
)
|
)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
this.scheduleList.push(...data.results);
|
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());
|
.then(() => this.filterScheduleEmployee());
|
||||||
});
|
});
|
||||||
@@ -134,8 +145,29 @@ export default {
|
|||||||
});
|
});
|
||||||
this.serialized = serialized;
|
this.serialized = serialized;
|
||||||
},
|
},
|
||||||
selectWork(work) {
|
postCreateSchedule() {
|
||||||
this.dataSchedule.status = work;
|
fetchWrapper
|
||||||
|
.post("accounts/schedules/create/", {
|
||||||
|
employee: "582b6557-33f4-480f-b578-984bbca0a925",
|
||||||
|
active_flg: true,
|
||||||
|
start_date: "2019-08-24",
|
||||||
|
end_date: "2019-08-24",
|
||||||
|
title: "string",
|
||||||
|
name: "string",
|
||||||
|
start_time: "string",
|
||||||
|
end_time: "string",
|
||||||
|
status: "string",
|
||||||
|
work_template: 0,
|
||||||
|
holiday_template: 0,
|
||||||
|
})
|
||||||
|
.then(() => this.fetchSchedules());
|
||||||
|
},
|
||||||
|
createNewDate(e) {
|
||||||
|
let res = this.clearEmployee.find((elem) => elem.id === e.id);
|
||||||
|
res.schedules.push({
|
||||||
|
start_date: e.start,
|
||||||
|
end_date: e.end,
|
||||||
|
});
|
||||||
},
|
},
|
||||||
switchPreviousMonth() {
|
switchPreviousMonth() {
|
||||||
this.startMonth = this.startMonth.clone().subtract(1, "M");
|
this.startMonth = this.startMonth.clone().subtract(1, "M");
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template lang="pug">
|
<template lang="pug">
|
||||||
.wrapper-bar.flex.flex-col.gap-y-4
|
.wrapper-bar.flex.flex-col.gap-y-4
|
||||||
.flex.px-5.py-5.w-full.justify-around
|
.flex.px-5.py-5.w-full.justify-around.gap-x-4
|
||||||
.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 Начало
|
||||||
@@ -38,7 +38,7 @@ 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, selectWork: Function, buttons: Array },
|
props: { dataSchedule: Object, buttons: Array },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
scheduleList: [
|
scheduleList: [
|
||||||
@@ -90,7 +90,7 @@ export default {
|
|||||||
color: var(--font-grey-color)
|
color: var(--font-grey-color)
|
||||||
|
|
||||||
.status-wrapper
|
.status-wrapper
|
||||||
width: 690px
|
min-width: 690px
|
||||||
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
|
||||||
|
|||||||
@@ -16,11 +16,11 @@
|
|||||||
:style="{opacity: changeOpacity(day)}"
|
:style="{opacity: changeOpacity(day)}"
|
||||||
) {{day.format("ddd")}}
|
) {{day.format("ddd")}}
|
||||||
.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-9.w-9
|
.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(@click="openSelect(schedule)")
|
||||||
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.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",
|
||||||
:key="day",
|
:key="day",
|
||||||
:id="schedule.id + day",
|
:id="schedule.id + day",
|
||||||
@@ -29,9 +29,9 @@
|
|||||||
:style="{backgroundColor: day.format('YYYY-MM-DD') === choiceDay(day, schedule.id) ? choiceColor(day) : ''}"
|
:style="{backgroundColor: day.format('YYYY-MM-DD') === choiceDay(day, schedule.id) ? choiceColor(day) : ''}"
|
||||||
)
|
)
|
||||||
.flex {{day.format("YYYY-MM-DD") === choiceDay(day, schedule.id) ? choiceWorks(day) : ''}}
|
.flex {{day.format("YYYY-MM-DD") === choiceDay(day, schedule.id) ? choiceWorks(day) : ''}}
|
||||||
//- .schedule-body.flex.w-full
|
.schedule-body.flex.w-full(v-if="clearEmployee")
|
||||||
//- .edit.flex.items-center.justify-center.h-9.w-9
|
.edit.flex.items-center.justify-center.h-11.w-11(:style="{borderBottom: 'none'}")
|
||||||
//- .flex.items-center.gap-x-8
|
.flex.icon-edit(v-if="currentEmployee.label")
|
||||||
//- base-button(
|
//- base-button(
|
||||||
//- confirm,
|
//- confirm,
|
||||||
//- rounded,
|
//- rounded,
|
||||||
@@ -41,18 +41,28 @@
|
|||||||
//- 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(
|
.name.flex.justify-center.items-center.cursor-pointer(
|
||||||
//- v-if="currentEmployee.label",
|
v-if="currentEmployee.label",
|
||||||
//- @click="openSelect"
|
@click="openSelect"
|
||||||
//- )
|
|
||||||
//- span {{currentEmployee.label}}
|
|
||||||
//- .name.flex(v-if="!currentEmployee.label")
|
|
||||||
//- base-custom-select(
|
|
||||||
//- :items="ownersList",
|
|
||||||
//- v-model="currentEmployee",
|
|
||||||
//- placeholder="Добавить сотрудника",
|
|
||||||
//- :style="{border: 'none'}"
|
|
||||||
)
|
)
|
||||||
|
span {{currentEmployee.label}}
|
||||||
|
.name.flex(v-if="!currentEmployee.label")
|
||||||
|
base-custom-select(
|
||||||
|
:items="ownersList",
|
||||||
|
v-model="currentEmployee",
|
||||||
|
placeholder="Добавить сотрудника",
|
||||||
|
:style="{border: 'none'}"
|
||||||
|
)
|
||||||
|
.cell.flex.flex-col.items-center.justify-center.w-11.h-11.cursor-pointer(
|
||||||
|
v-if="currentEmployee.label",
|
||||||
|
v-for="day in result",
|
||||||
|
:key="day",
|
||||||
|
:id="currentEmployee.id + day",
|
||||||
|
@click="choiceCell(day, currentEmployee.id)",
|
||||||
|
:class="selectTime(day, currentEmployee.id)",
|
||||||
|
:style="{backgroundColor: day.format('YYYY-MM-DD') === choiceDay(day, currentEmployee.id) ? choiceColor(day) : '', borderBottom: 'none'}"
|
||||||
|
)
|
||||||
|
.flex {{day.format("YYYY-MM-DD") === choiceDay(day, currentEmployee.id) ? choiceWorks(day) : ''}}
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@@ -76,6 +86,7 @@ export default {
|
|||||||
dataSchedule: Object,
|
dataSchedule: Object,
|
||||||
buttons: Array,
|
buttons: Array,
|
||||||
startMonth: Object,
|
startMonth: Object,
|
||||||
|
clearEmployee: Array,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -99,9 +110,9 @@ export default {
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
ownersList() {
|
ownersList() {
|
||||||
if (this.employeeList) {
|
if (this.clearEmployee) {
|
||||||
let filteredArray = [];
|
let filteredArray = [];
|
||||||
this.employeeList.forEach((elem) => {
|
this.clearEmployee.forEach((elem) => {
|
||||||
filteredArray.push({
|
filteredArray.push({
|
||||||
id: elem.id,
|
id: elem.id,
|
||||||
label: this.trimOwnerName(
|
label: this.trimOwnerName(
|
||||||
@@ -119,6 +130,7 @@ export default {
|
|||||||
this.setActiveButton();
|
this.setActiveButton();
|
||||||
return {
|
return {
|
||||||
"--bg-color-status": this.activeButton?.color,
|
"--bg-color-status": this.activeButton?.color,
|
||||||
|
"--text-status": this.activeButton?.text,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -142,6 +154,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;
|
||||||
|
this.$emit("new-date", this.dateInterval);
|
||||||
} else this.dateInterval.start = formatTime;
|
} else this.dateInterval.start = formatTime;
|
||||||
},
|
},
|
||||||
selectTime(day, id) {
|
selectTime(day, id) {
|
||||||
@@ -175,7 +188,7 @@ 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 a = this.scheduleList.find((e) => e.date === currentDay).status;
|
||||||
return this.buttons.find((e) => e.work === a).text;
|
return this.buttons.find((e) => e.work === a).text[1];
|
||||||
},
|
},
|
||||||
choiceColor(day) {
|
choiceColor(day) {
|
||||||
let currentDay = day.format("YYYY-MM-DD");
|
let currentDay = day.format("YYYY-MM-DD");
|
||||||
@@ -203,11 +216,12 @@ export default {
|
|||||||
// }
|
// }
|
||||||
// },
|
// },
|
||||||
choiceDay(day, employee) {
|
choiceDay(day, employee) {
|
||||||
let currentDay = day.format("YYYY-MM-DD");
|
let current = day.format("YYYY-MM-DD");
|
||||||
return this.scheduleList.find(
|
return this.scheduleList.find(
|
||||||
(e) => currentDay === e.date && e.employee.id === employee
|
(e) => current === e.date && e.employee.id === employee
|
||||||
)?.date;
|
)?.date;
|
||||||
},
|
},
|
||||||
|
|
||||||
changeOpacity(day) {
|
changeOpacity(day) {
|
||||||
return day.format("ddd") === "сб" || day.format("ddd") === "вс"
|
return day.format("ddd") === "сб" || day.format("ddd") === "вс"
|
||||||
? "0.6"
|
? "0.6"
|
||||||
@@ -233,6 +247,7 @@ export default {
|
|||||||
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
|
||||||
min-height: 87px
|
min-height: 87px
|
||||||
|
width: fit-content
|
||||||
|
|
||||||
.schedule-body
|
.schedule-body
|
||||||
&:hover
|
&:hover
|
||||||
@@ -256,14 +271,14 @@ 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: 255px
|
min-width: 247px
|
||||||
max-width: 255px
|
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: 255px
|
min-width: 247px
|
||||||
max-width: 255px
|
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)
|
||||||
@@ -281,6 +296,9 @@ export default {
|
|||||||
.status
|
.status
|
||||||
background-color: var(--bg-color-status)
|
background-color: var(--bg-color-status)
|
||||||
|
|
||||||
|
.status::before
|
||||||
|
content: var(--text-status)
|
||||||
|
|
||||||
.from-date
|
.from-date
|
||||||
background: limegreen
|
background: limegreen
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user