hookehuyr

feat(teacher/checkinPage): 添加日期选择器并优化日历组件

在教师签到页面添加日期选择触发区域,优化日历组件为弹窗模式
更新日期选择逻辑,添加当前日期显示和格式化功能
调整日历弹窗高度样式,提升用户体验
1 <!-- 1 <!--
2 * @Date: 2025-05-29 15:34:17 2 * @Date: 2025-05-29 15:34:17
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2025-12-11 20:54:50 4 + * @LastEditTime: 2025-12-11 22:03:52
5 * @FilePath: /mlaj/src/views/teacher/checkinPage.vue 5 * @FilePath: /mlaj/src/views/teacher/checkinPage.vue
6 * @Description: 文件描述 6 * @Description: 文件描述
7 --> 7 -->
...@@ -16,14 +16,22 @@ ...@@ -16,14 +16,22 @@
16 </van-dropdown-menu> --> 16 </van-dropdown-menu> -->
17 <!-- 课程, 大分组, 小分组 筛选 --> 17 <!-- 课程, 大分组, 小分组 筛选 -->
18 <CourseGroupCascader @change="on_cascade_change" /> 18 <CourseGroupCascader @change="on_cascade_change" />
19 +
20 + <!-- 日期选择触发区域 -->
21 + <div class="date-trigger" @click="showCalendar = true">
22 + <div class="current-date">{{ formattedSelectedDate }}</div>
23 + <div class="date-hint">点击切换日期</div>
24 + </div>
19 </van-sticky> 25 </van-sticky>
20 26
21 - <van-calendar ref="myRefCalendar" :show-title="false" :poppable="false" :show-confirm="false" 27 + <van-config-provider :theme-vars="themeVars">
22 - switch-mode="year-month" color="#4caf50" :formatter="formatter" row-height="50" :show-mark="false" 28 + <van-calendar ref="myRefCalendar" v-model:show="showCalendar" :poppable="true" :show-confirm="false"
29 + switch-mode="year-month" color="#4caf50" :formatter="formatter" row-height="50" :show-mark="false" title="选择日期"
23 @select="onSelectDay" 30 @select="onSelectDay"
24 @panel-change="onPanelChange" 31 @panel-change="onPanelChange"
25 @click-subtitle="onClickSubtitle"> 32 @click-subtitle="onClickSubtitle">
26 </van-calendar> 33 </van-calendar>
34 + </van-config-provider>
27 35
28 <!-- <div style="padding: 0 1rem; margin-top: 1rem;"> 36 <!-- <div style="padding: 0 1rem; margin-top: 1rem;">
29 <van-row gutter="15"> 37 <van-row gutter="15">
...@@ -150,7 +158,13 @@ const gradeOption = ref([]); ...@@ -150,7 +158,13 @@ const gradeOption = ref([]);
150 const classOption = ref([]); 158 const classOption = ref([]);
151 const courseOption = ref([]); 159 const courseOption = ref([]);
152 160
161 +const showCalendar = ref(false);
153 const currentMonth = ref(dayjs().format('YYYY-MM')); 162 const currentMonth = ref(dayjs().format('YYYY-MM'));
163 +const selectedDate = ref(dayjs().format('YYYY-MM-DD'));
164 +
165 +const formattedSelectedDate = computed(() => {
166 + return dayjs(selectedDate.value).format('YYYY年MM月DD日');
167 +});
154 168
155 /** 169 /**
156 * 重置分页参数并重新加载数据 170 * 重置分页参数并重新加载数据
...@@ -335,6 +349,7 @@ const themeVars = reactive({ ...@@ -335,6 +349,7 @@ const themeVars = reactive({
335 calendarHeaderShadow: 'rgba(0, 0, 0, 0.1)', 349 calendarHeaderShadow: 'rgba(0, 0, 0, 0.1)',
336 calendarInfoLineHeight: '0.3rem', 350 calendarInfoLineHeight: '0.3rem',
337 buttonNormalFontSize: '1rem', 351 buttonNormalFontSize: '1rem',
352 + calendarPopupHeight: '25rem',
338 }) 353 })
339 354
340 const progress1 = ref(0); 355 const progress1 = ref(0);
...@@ -380,8 +395,6 @@ const formatter = (day) => { ...@@ -380,8 +395,6 @@ const formatter = (day) => {
380 return day; 395 return day;
381 } 396 }
382 397
383 -// 添加一个响应式变量来存储当前选中的日期
384 -const selectedDate = ref('');
385 398
386 const onSelectDay = (day) => { 399 const onSelectDay = (day) => {
387 getTaskDetail(dayjs(day).format('YYYY-MM')); 400 getTaskDetail(dayjs(day).format('YYYY-MM'));
...@@ -389,6 +402,7 @@ const onSelectDay = (day) => { ...@@ -389,6 +402,7 @@ const onSelectDay = (day) => {
389 // 更新当前选中的日期 402 // 更新当前选中的日期
390 const currentSelectedDate = dayjs(day).format('YYYY-MM-DD'); 403 const currentSelectedDate = dayjs(day).format('YYYY-MM-DD');
391 selectedDate.value = currentSelectedDate; 404 selectedDate.value = currentSelectedDate;
405 + showCalendar.value = false;
392 406
393 // 修改浏览器地址把当前的date加入地址栏, 页面不刷新 407 // 修改浏览器地址把当前的date加入地址栏, 页面不刷新
394 // 使用replace替代push,避免在浏览器历史记录中添加多个条目 408 // 使用replace替代push,避免在浏览器历史记录中添加多个条目
...@@ -622,11 +636,13 @@ const getFilterList = async (grade_id=null, class_id=null) => { ...@@ -622,11 +636,13 @@ const getFilterList = async (grade_id=null, class_id=null) => {
622 onMounted(async () => { 636 onMounted(async () => {
623 const current_date = route.query.date; 637 const current_date = route.query.date;
624 if (current_date) { 638 if (current_date) {
639 + selectedDate.value = current_date;
625 getTaskDetail(dayjs(current_date).format('YYYY-MM')); 640 getTaskDetail(dayjs(current_date).format('YYYY-MM'));
626 getCheckedDates(dayjs(current_date).format('YYYY-MM')); 641 getCheckedDates(dayjs(current_date).format('YYYY-MM'));
627 myRefCalendar.value?.reset(new Date(current_date)); 642 myRefCalendar.value?.reset(new Date(current_date));
628 onLoad(current_date); 643 onLoad(current_date);
629 } else { 644 } else {
645 + selectedDate.value = dayjs().format('YYYY-MM-DD');
630 getTaskDetail(dayjs().format('YYYY-MM')); 646 getTaskDetail(dayjs().format('YYYY-MM'));
631 getCheckedDates(dayjs().format('YYYY-MM')); 647 getCheckedDates(dayjs().format('YYYY-MM'));
632 onLoad(dayjs().format('YYYY-MM-DD')); 648 onLoad(dayjs().format('YYYY-MM-DD'));
...@@ -703,6 +719,32 @@ const handleAdd = (type) => { ...@@ -703,6 +719,32 @@ const handleAdd = (type) => {
703 .van-back-top { 719 .van-back-top {
704 background-color: #4caf50; 720 background-color: #4caf50;
705 } 721 }
722 +
723 +.date-trigger {
724 + background-color: #fff;
725 + padding: 1rem;
726 + text-align: center;
727 + cursor: pointer;
728 + border-bottom: 1px solid #eee;
729 + display: flex;
730 + align-items: center;
731 + justify-content: center;
732 + gap: 0.5rem;
733 + flex-direction: column;
734 +
735 + .current-date {
736 + font-size: 1rem;
737 + font-weight: bold;
738 + color: #333;
739 + margin-bottom: 0;
740 + }
741 +
742 + .date-hint {
743 + font-size: 0.8rem;
744 + color: #999;
745 + }
746 +}
747 +
706 /* 下拉菜单选项文字单行显示 */ 748 /* 下拉菜单选项文字单行显示 */
707 .van-dropdown-item { 749 .van-dropdown-item {
708 .van-cell__title { 750 .van-cell__title {
......