hookehuyr

fix

<!--
* @Date: 2023-06-21 10:23:09
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2023-08-25 21:39:47
* @LastEditTime: 2023-08-25 21:51:22
* @FilePath: /bieyuan/src/views/index.vue
* @Description: 预约页首页
-->
......@@ -111,10 +111,6 @@ const $route = useRoute();
const $router = useRouter();
useTitle($route.meta.title);
function getDaysInMonth(year, month) {
return new Date(year, month, 0).getDate();
}
onMounted(async () => {
const { data } = await orderRestCountAPI();
// 获取三天数据
......@@ -155,7 +151,7 @@ watch(
);
const asyncData = ref();
const showMore = async () => {
const showMore = async () => { // 查看日历更多按钮操作
show.value = true;
const { data } = await orderRestCountAPI({ start_date: dayjs().format('YYYY-MM-DD'), end_date: dayjs(maxDate.value).format('YYYY-MM-DD') });
asyncData.value = data;
......@@ -164,7 +160,7 @@ const showMore = async () => {
});
}
const formatter = computed(() => {
const formatter = computed(() => { // 格式化日历显示剩余数量
if (!asyncData.value) {
return (day) => day;
}
......@@ -193,6 +189,7 @@ const onConfirm = (dates) => { // 选择日历确定回调
dates.forEach((date) => {
selectedDates.value.push(dayjs(date).format('YYYY-MM-DD'));
});
// 缓存选中的日期
localStorage.setItem('save_selected_dates', JSON.stringify(selectedDates.value));
clickNext();
};
......@@ -246,7 +243,7 @@ const clickNext = () => { // 点击下一步按钮
}
}
const formatDateShow = (date) => {
const formatDateShow = (date) => { // 格式化文字显示
if (date) {
const arr = date.split('-');
let month = arr[1];
......
......@@ -98,14 +98,14 @@ onMounted(async () => {
const defaultDate = ref(null);
const shortcut = ref([]);
const handleCheck = (value) => {
const handleCheck = (value) => { // 列表项点击操作
value.checked = !value.checked;
// 同步日历显示
defaultDate.value = [];
const arr = [];
shortcut.value.forEach((item) => {
if (item.checked) {
defaultDate.value.push(dayjs(item.date).toDate())
defaultDate.value.push(dayjs(item.date).toDate()); // 修改日历显示
arr.push(item.date);
}
});
......@@ -138,18 +138,13 @@ const showMore = async () => {
});
// 同步日历显示
defaultDate.value = [];
// shortcut.value.forEach((item) => {
// if (item.checked) {
// defaultDate.value.push(dayjs(item.date).toDate())
// }
// });
const arr = JSON.parse(localStorage.getItem('save_selected_dates'));
arr.forEach((item) => {
defaultDate.value.push(dayjs(item).toDate())
});
}
const formatter = computed(() => {
const formatter = computed(() => { // 格式化日历文字显示
if (!asyncData.value) {
return (day) => day;
}
......@@ -169,14 +164,14 @@ const formatter = computed(() => {
};
});
const onConfirm = async (dates) => {
const onConfirm = async (dates) => { // 日历点击确认回调
show.value = false;
selectedDates.value = [];
dates.forEach((date) => {
selectedDates.value.push(dayjs(date).format('YYYY-MM-DD'))
defaultDate.value.push(dayjs(date).toDate())
});
// 后台请求数据
// 后台请求数据更新日期列表
const { data } = await orderRestCountAPI({ dates: selectedDates.value.join(',') });
shortcut.value = data;
shortcut.value.forEach(item => {
......