Добавила интервал дат в параметры

This commit is contained in:
Daria Golova
2023-08-16 23:00:36 +03:00
parent f459620040
commit 8691790a53
4 changed files with 79 additions and 10 deletions

View File

@@ -111,15 +111,18 @@ export default {
},
methods: {
previousWeek() {
this.dates.from = this.dates.from.clone().subtract(1, "week");
this.dates.to = this.dates.to.clone().subtract(1, "week");
const diff = this.dates?.to?.diff(this.dates?.from, "days") + 1;
this.dates.from = this.dates.from.clone().subtract(diff, "day");
this.dates.to = this.dates.to.clone().subtract(diff, "day");
},
nextWeek() {
this.dates.from = this.dates.from.clone().add(1, "week");
this.dates.to = this.dates.to.clone().add(1, "week");
const diff = this.dates?.to?.diff(this.dates?.from, "days") + 1;
this.dates.from = this.dates.from.clone().add(diff, "day");
this.dates.to = this.dates.to.clone().add(diff, "day");
},
...mapActions({
changeSelectedDates: "changeSelectedDates",
getEvents: "getEvents",
}),
saveDatesChange() {
this.calendarVisibility = false;
@@ -142,9 +145,17 @@ export default {
this.changeSelectedDates(val);
},
},
},
mounted() {
this.initializeDates();
selectedDates: {
deep: true,
immediate: true,
handler(val) {
if (
!val?.from.isSame(this.dates?.from) ||
!val?.to.isSame(this.dates?.to)
)
this.initializeDates();
},
},
},
};
</script>