hookehuyr

fix

1 <!-- 1 <!--
2 * @Date: 2023-06-21 10:23:09 2 * @Date: 2023-06-21 10:23:09
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2023-08-25 21:39:47 4 + * @LastEditTime: 2023-08-25 21:51:22
5 * @FilePath: /bieyuan/src/views/index.vue 5 * @FilePath: /bieyuan/src/views/index.vue
6 * @Description: 预约页首页 6 * @Description: 预约页首页
7 --> 7 -->
...@@ -111,10 +111,6 @@ const $route = useRoute(); ...@@ -111,10 +111,6 @@ const $route = useRoute();
111 const $router = useRouter(); 111 const $router = useRouter();
112 useTitle($route.meta.title); 112 useTitle($route.meta.title);
113 113
114 -function getDaysInMonth(year, month) {
115 - return new Date(year, month, 0).getDate();
116 -}
117 -
118 onMounted(async () => { 114 onMounted(async () => {
119 const { data } = await orderRestCountAPI(); 115 const { data } = await orderRestCountAPI();
120 // 获取三天数据 116 // 获取三天数据
...@@ -155,7 +151,7 @@ watch( ...@@ -155,7 +151,7 @@ watch(
155 ); 151 );
156 152
157 const asyncData = ref(); 153 const asyncData = ref();
158 -const showMore = async () => { 154 +const showMore = async () => { // 查看日历更多按钮操作
159 show.value = true; 155 show.value = true;
160 const { data } = await orderRestCountAPI({ start_date: dayjs().format('YYYY-MM-DD'), end_date: dayjs(maxDate.value).format('YYYY-MM-DD') }); 156 const { data } = await orderRestCountAPI({ start_date: dayjs().format('YYYY-MM-DD'), end_date: dayjs(maxDate.value).format('YYYY-MM-DD') });
161 asyncData.value = data; 157 asyncData.value = data;
...@@ -164,7 +160,7 @@ const showMore = async () => { ...@@ -164,7 +160,7 @@ const showMore = async () => {
164 }); 160 });
165 } 161 }
166 162
167 -const formatter = computed(() => { 163 +const formatter = computed(() => { // 格式化日历显示剩余数量
168 if (!asyncData.value) { 164 if (!asyncData.value) {
169 return (day) => day; 165 return (day) => day;
170 } 166 }
...@@ -193,6 +189,7 @@ const onConfirm = (dates) => { // 选择日历确定回调 ...@@ -193,6 +189,7 @@ const onConfirm = (dates) => { // 选择日历确定回调
193 dates.forEach((date) => { 189 dates.forEach((date) => {
194 selectedDates.value.push(dayjs(date).format('YYYY-MM-DD')); 190 selectedDates.value.push(dayjs(date).format('YYYY-MM-DD'));
195 }); 191 });
192 + // 缓存选中的日期
196 localStorage.setItem('save_selected_dates', JSON.stringify(selectedDates.value)); 193 localStorage.setItem('save_selected_dates', JSON.stringify(selectedDates.value));
197 clickNext(); 194 clickNext();
198 }; 195 };
...@@ -246,7 +243,7 @@ const clickNext = () => { // 点击下一步按钮 ...@@ -246,7 +243,7 @@ const clickNext = () => { // 点击下一步按钮
246 } 243 }
247 } 244 }
248 245
249 -const formatDateShow = (date) => { 246 +const formatDateShow = (date) => { // 格式化文字显示
250 if (date) { 247 if (date) {
251 const arr = date.split('-'); 248 const arr = date.split('-');
252 let month = arr[1]; 249 let month = arr[1];
......
...@@ -98,14 +98,14 @@ onMounted(async () => { ...@@ -98,14 +98,14 @@ onMounted(async () => {
98 const defaultDate = ref(null); 98 const defaultDate = ref(null);
99 const shortcut = ref([]); 99 const shortcut = ref([]);
100 100
101 -const handleCheck = (value) => { 101 +const handleCheck = (value) => { // 列表项点击操作
102 value.checked = !value.checked; 102 value.checked = !value.checked;
103 // 同步日历显示 103 // 同步日历显示
104 defaultDate.value = []; 104 defaultDate.value = [];
105 const arr = []; 105 const arr = [];
106 shortcut.value.forEach((item) => { 106 shortcut.value.forEach((item) => {
107 if (item.checked) { 107 if (item.checked) {
108 - defaultDate.value.push(dayjs(item.date).toDate()) 108 + defaultDate.value.push(dayjs(item.date).toDate()); // 修改日历显示
109 arr.push(item.date); 109 arr.push(item.date);
110 } 110 }
111 }); 111 });
...@@ -138,18 +138,13 @@ const showMore = async () => { ...@@ -138,18 +138,13 @@ const showMore = async () => {
138 }); 138 });
139 // 同步日历显示 139 // 同步日历显示
140 defaultDate.value = []; 140 defaultDate.value = [];
141 - // shortcut.value.forEach((item) => {
142 - // if (item.checked) {
143 - // defaultDate.value.push(dayjs(item.date).toDate())
144 - // }
145 - // });
146 const arr = JSON.parse(localStorage.getItem('save_selected_dates')); 141 const arr = JSON.parse(localStorage.getItem('save_selected_dates'));
147 arr.forEach((item) => { 142 arr.forEach((item) => {
148 defaultDate.value.push(dayjs(item).toDate()) 143 defaultDate.value.push(dayjs(item).toDate())
149 }); 144 });
150 } 145 }
151 146
152 -const formatter = computed(() => { 147 +const formatter = computed(() => { // 格式化日历文字显示
153 if (!asyncData.value) { 148 if (!asyncData.value) {
154 return (day) => day; 149 return (day) => day;
155 } 150 }
...@@ -169,14 +164,14 @@ const formatter = computed(() => { ...@@ -169,14 +164,14 @@ const formatter = computed(() => {
169 }; 164 };
170 }); 165 });
171 166
172 -const onConfirm = async (dates) => { 167 +const onConfirm = async (dates) => { // 日历点击确认回调
173 show.value = false; 168 show.value = false;
174 selectedDates.value = []; 169 selectedDates.value = [];
175 dates.forEach((date) => { 170 dates.forEach((date) => {
176 selectedDates.value.push(dayjs(date).format('YYYY-MM-DD')) 171 selectedDates.value.push(dayjs(date).format('YYYY-MM-DD'))
177 defaultDate.value.push(dayjs(date).toDate()) 172 defaultDate.value.push(dayjs(date).toDate())
178 }); 173 });
179 - // 后台请求数据 174 + // 后台请求数据更新日期列表
180 const { data } = await orderRestCountAPI({ dates: selectedDates.value.join(',') }); 175 const { data } = await orderRestCountAPI({ dates: selectedDates.value.join(',') });
181 shortcut.value = data; 176 shortcut.value = data;
182 shortcut.value.forEach(item => { 177 shortcut.value.forEach(item => {
......