WIP Добавила даты в стор

This commit is contained in:
Daria Golova
2023-06-08 17:02:26 +03:00
parent b3d0bd77bb
commit cbc4ed5b51
5 changed files with 133 additions and 32 deletions

View File

@@ -63,8 +63,9 @@
<script>
import BaseInput from "@/components/base/BaseInput";
import * as moment from "moment/moment";
//import * as moment from "moment/moment";
import BaseCalendar from "@/components/base/BaseCalendar";
import { mapState, mapActions } from "vuex";
export default {
name: "CalendarHeader",
components: { BaseInput, BaseCalendar },
@@ -82,8 +83,8 @@ export default {
},
],
date: {
from: moment(),
to: moment().clone().add(6, "day"),
from: null,
to: null,
},
calendarVisibility: false,
};
@@ -94,6 +95,12 @@ export default {
"D MMMM YYYY"
)} - ${this.date?.to?.format("D MMMM YYYY")}`;
},
...mapState({
selectedDates: (state) => state.calendar.selectedDates,
}),
...mapActions({
changeSelectedDates: "changeSelectedDates",
}),
},
methods: {
previousWeek() {
@@ -105,6 +112,32 @@ export default {
this.date.to = this.date.to.clone().add(1, "week");
},
},
/*watch: {
selectedDates: {
immediate: true,
deep: true,
handler(val) {
console.log("в сторе", val);
},
},
date: {
immediate: true,
deep: true,
handler(val) {
console.log("в компоненте", val);
},
},
calendarVisibility(val) {
console.log(val, this.changeSelectedDates);
if (val === false) this.changeSelectedDates(this.date);
},
},*/
mounted() {
this.date = {
from: this.selectedDates.from.clone(),
to: this.selectedDates.to.clone(),
};
},
};
</script>