WIP Доделала календарь
This commit is contained in:
@@ -23,12 +23,12 @@
|
|||||||
)
|
)
|
||||||
.week.py-4.px-5.grid.grid-rows-1.grid-cols-7
|
.week.py-4.px-5.grid.grid-rows-1.grid-cols-7
|
||||||
.flex.items-center.justify-center.week-item.text-xsx.py-1(v-for="day of week", :key="day") {{ day }}
|
.flex.items-center.justify-center.week-item.text-xsx.py-1(v-for="day of week", :key="day") {{ day }}
|
||||||
.body.pb-5.px-5
|
.body.pb-7.px-5
|
||||||
.flex.items-center.justify-center.cursor-pointer.w-full.h-full(
|
.flex.items-center.justify-center.cursor-pointer.w-full.h-full(
|
||||||
v-for="date of internalDatesList",
|
v-for="date of internalDatesList",
|
||||||
@click="selectDate(date)",
|
@click="selectDate(date)",
|
||||||
:key="date",
|
:key="date",
|
||||||
:style="calculateRangeStyle(date)"
|
:style="calculateRangeStyle(date)",
|
||||||
)
|
)
|
||||||
.flex.items-center.justify-center.rounded-full.w-full.h-full(
|
.flex.items-center.justify-center.rounded-full.w-full.h-full(
|
||||||
:class="calculateCellClasses(date)",
|
:class="calculateCellClasses(date)",
|
||||||
@@ -92,10 +92,6 @@ export default {
|
|||||||
this.internalDate = this.internalDate.clone().add(1, "month");
|
this.internalDate = this.internalDate.clone().add(1, "month");
|
||||||
},
|
},
|
||||||
calculateCellClasses(date) {
|
calculateCellClasses(date) {
|
||||||
if (date.isSame(this.today, "day"))
|
|
||||||
return {
|
|
||||||
"date-today": true,
|
|
||||||
};
|
|
||||||
if (this.defineDateRange(date))
|
if (this.defineDateRange(date))
|
||||||
return {
|
return {
|
||||||
"date-active": true,
|
"date-active": true,
|
||||||
@@ -106,6 +102,11 @@ export default {
|
|||||||
)
|
)
|
||||||
return {
|
return {
|
||||||
"text-white": true,
|
"text-white": true,
|
||||||
|
"date-range": true,
|
||||||
|
};
|
||||||
|
if (date.isSame(this.today, "day"))
|
||||||
|
return {
|
||||||
|
"date-today": true,
|
||||||
};
|
};
|
||||||
if (date.isSame(this.internalDate, "month"))
|
if (date.isSame(this.internalDate, "month"))
|
||||||
return {
|
return {
|
||||||
@@ -116,7 +117,12 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
calculateRangeStyle(date) {
|
calculateRangeStyle(date) {
|
||||||
if (this.range && this.value?.from && this.value?.to) {
|
if (
|
||||||
|
this.range &&
|
||||||
|
this.value?.from &&
|
||||||
|
this.value?.to &&
|
||||||
|
!this.value?.from.isSame(this.value?.to?.format("YYYY-MM-DD"))
|
||||||
|
) {
|
||||||
if (date.isSame(this.value?.from?.format("YYYY-MM-DD")))
|
if (date.isSame(this.value?.from?.format("YYYY-MM-DD")))
|
||||||
return {
|
return {
|
||||||
"border-top-left-radius": "9999px",
|
"border-top-left-radius": "9999px",
|
||||||
@@ -167,21 +173,7 @@ export default {
|
|||||||
date.isSame(this.value?.to?.format("YYYY-MM-DD"))
|
date.isSame(this.value?.to?.format("YYYY-MM-DD"))
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
calculateRange(start, end, count) {
|
|
||||||
let internalCount = count ? count : end.diff(start, "days");
|
|
||||||
return [...Array(internalCount - 2)].map(() =>
|
|
||||||
start.add(1, "day").clone()
|
|
||||||
);
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
// watch: {
|
|
||||||
// modelValue: {
|
|
||||||
// deep: true,
|
|
||||||
// handler(value) {
|
|
||||||
// console.log(value);
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
mounted() {
|
mounted() {
|
||||||
if (this.value) {
|
if (this.value) {
|
||||||
if (this.range) {
|
if (this.range) {
|
||||||
@@ -210,8 +202,10 @@ export default {
|
|||||||
color: var(--font-grey-color)
|
color: var(--font-grey-color)
|
||||||
.date-month
|
.date-month
|
||||||
color: var(--font-black-color)
|
color: var(--font-black-color)
|
||||||
.date-other:hover, .date-month:hover, .date-today:hover
|
.date-other:hover, .date-month:hover
|
||||||
background-color: var(--border-light-grey-color)
|
background-color: var(--border-light-grey-color)
|
||||||
|
.date-today:hover, .date-range:hover
|
||||||
|
background-color: var(--btn-blue-color-2)
|
||||||
.date-today
|
.date-today
|
||||||
border: 1px dashed var(--btn-blue-color)
|
border: 1px dashed var(--btn-blue-color)
|
||||||
color: var(--btn-blue-color)
|
color: var(--btn-blue-color)
|
||||||
|
|||||||
@@ -17,7 +17,8 @@
|
|||||||
dense,
|
dense,
|
||||||
icon="arrow_back_ios_new",
|
icon="arrow_back_ios_new",
|
||||||
text-color="primary",
|
text-color="primary",
|
||||||
padding="2px 11px 2px 8px"
|
padding="2px 11px 2px 8px",
|
||||||
|
@click="previousWeek"
|
||||||
)
|
)
|
||||||
base-input(
|
base-input(
|
||||||
outlined,
|
outlined,
|
||||||
@@ -25,40 +26,30 @@
|
|||||||
fontSize="16px",
|
fontSize="16px",
|
||||||
lineHeight="19px",
|
lineHeight="19px",
|
||||||
iconRight,
|
iconRight,
|
||||||
id="calendarIcon"
|
v-model="currentWeek",
|
||||||
|
readonly
|
||||||
)
|
)
|
||||||
q-icon.text(name="app:calendar", size="20px", ref="calendarIcon", @click="changeCalendarVisibility(false)")
|
.h-5.w-5.flex.items-center.justify-center
|
||||||
//q-popup-proxy(
|
q-icon.text.cursor-pointer(:name="calendarVisibility ? 'app:cancel' : 'app:calendar'",
|
||||||
cover,
|
:size="calendarVisibility ? '10px' : '16px'"
|
||||||
transition-show="scale",
|
)
|
||||||
transition-hide="scale"
|
q-menu(
|
||||||
anchor="bottom middle", self="top middle"
|
:style="{'margin-top': '4px !important'}"
|
||||||
//)
|
v-model="calendarVisibility",
|
||||||
//q-date(v-model="date", minimal, range)
|
transition-show="scale",
|
||||||
.flex.items-center.justify-end
|
transition-hide="scale"
|
||||||
q-btn(
|
self="top middle",
|
||||||
v-close-popup,
|
:offset="[118, 14]"
|
||||||
label="Закрыть",
|
)
|
||||||
color="primary",
|
base-calendar(v-model="date", range, :range-count="7")
|
||||||
flat
|
|
||||||
)
|
|
||||||
q-menu(
|
|
||||||
:style="{'margin-top': '4px !important'}"
|
|
||||||
target="#calendarIcon"
|
|
||||||
v-model="calendarVisibility",
|
|
||||||
transition-show="scale",
|
|
||||||
transition-hide="scale"
|
|
||||||
anchor="bottom middle",
|
|
||||||
self="top middle"
|
|
||||||
)
|
|
||||||
base-calendar(v-model="date", range)
|
|
||||||
q-btn(
|
q-btn(
|
||||||
color="secondary",
|
color="secondary",
|
||||||
icon="arrow_forward_ios",
|
icon="arrow_forward_ios",
|
||||||
round,
|
round,
|
||||||
size="14px",
|
size="14px",
|
||||||
text-color="primary",
|
text-color="primary",
|
||||||
dense
|
dense,
|
||||||
|
@click="nextWeek"
|
||||||
)
|
)
|
||||||
.h-10.p-1.flex.items-center.justify-between.bg-secondary.rounded.text-grey-color.ml-52
|
.h-10.p-1.flex.items-center.justify-between.bg-secondary.rounded.text-grey-color.ml-52
|
||||||
q-btn-toggle(
|
q-btn-toggle(
|
||||||
@@ -91,18 +82,29 @@ export default {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
date: {
|
date: {
|
||||||
from: moment().clone().add(1, "month"),
|
from: moment(),
|
||||||
to: moment().clone().add(2, "month"),
|
to: moment().clone().add(6, "day"),
|
||||||
},
|
},
|
||||||
calendarVisibility: false,
|
calendarVisibility: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
computed: {
|
||||||
changeCalendarVisibility(value) {
|
currentWeek() {
|
||||||
this.calendarVisibility = value;
|
return `${this.date?.from?.format(
|
||||||
|
"D MMMM YYYY"
|
||||||
|
)} - ${this.date?.to?.format("D MMMM YYYY")}`;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
previousWeek() {
|
||||||
|
this.date.from = this.date.from.clone().subtract(1, "week");
|
||||||
|
this.date.to = this.date.to.clone().subtract(1, "week");
|
||||||
|
},
|
||||||
|
nextWeek() {
|
||||||
|
this.date.from = this.date.from.clone().add(1, "week");
|
||||||
|
this.date.to = this.date.to.clone().add(1, "week");
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
watch: {},
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -134,3 +136,7 @@ export default {
|
|||||||
.q-btn-group :deep(.q-btn-item)
|
.q-btn-group :deep(.q-btn-item)
|
||||||
border-radius: 4px !important
|
border-radius: 4px !important
|
||||||
</style>
|
</style>
|
||||||
|
<style lang="sass">
|
||||||
|
.q-field--outlined.q-field--readonly .q-field__control:before
|
||||||
|
border-style: solid !important
|
||||||
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user