feat(教师打卡): 添加教师查看已打卡日期功能
在日历组件中添加月份切换事件处理,当年级、班级或课程选择变化时重新获取对应月份的打卡日期数据
Showing
2 changed files
with
45 additions
and
5 deletions
| 1 | /* | 1 | /* |
| 2 | * @Date: 2025-06-06 09:26:16 | 2 | * @Date: 2025-06-06 09:26:16 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-06-25 11:41:56 | 4 | + * @LastEditTime: 2025-10-27 15:51:02 |
| 5 | * @FilePath: /mlaj/src/api/checkin.js | 5 | * @FilePath: /mlaj/src/api/checkin.js |
| 6 | * @Description: 签到模块相关接口 | 6 | * @Description: 签到模块相关接口 |
| 7 | */ | 7 | */ |
| ... | @@ -20,6 +20,7 @@ const Api = { | ... | @@ -20,6 +20,7 @@ const Api = { |
| 20 | TASK_UPLOAD_DISLIKE: '/srv/?a=checkin&t=dislike', | 20 | TASK_UPLOAD_DISLIKE: '/srv/?a=checkin&t=dislike', |
| 21 | CHECKIN_TEACHER_LIST: '/srv/?a=checkin&t=teacher_list', | 21 | CHECKIN_TEACHER_LIST: '/srv/?a=checkin&t=teacher_list', |
| 22 | CHECKIN_TEACHER_REVIEW: '/srv/?a=checkin&t=teacher_review', | 22 | CHECKIN_TEACHER_REVIEW: '/srv/?a=checkin&t=teacher_review', |
| 23 | + CHECKIN_TEACHER_CHECKED_DATES: '/srv/?a=checkin&t=teacher_checked_dates', | ||
| 23 | } | 24 | } |
| 24 | 25 | ||
| 25 | /** | 26 | /** |
| ... | @@ -126,3 +127,14 @@ export const getCheckinTeacherListAPI = (params) => fn(fetch.get(Api.CHECKIN_TE | ... | @@ -126,3 +127,14 @@ export const getCheckinTeacherListAPI = (params) => fn(fetch.get(Api.CHECKIN_TE |
| 126 | * @returns | 127 | * @returns |
| 127 | */ | 128 | */ |
| 128 | export const checkinTaskReviewAPI = (params) => fn(fetch.post(Api.CHECKIN_TEACHER_REVIEW, params)) | 129 | export const checkinTaskReviewAPI = (params) => fn(fetch.post(Api.CHECKIN_TEACHER_REVIEW, params)) |
| 130 | + | ||
| 131 | +/** | ||
| 132 | + * @description: 老师查看已打卡日期 | ||
| 133 | + * @param grade_id 年级ID | ||
| 134 | + * @param class_id 班级ID | ||
| 135 | + * @param group_id 课程ID | ||
| 136 | + * @param month 月份 | ||
| 137 | + * @param keyword 搜索 | ||
| 138 | + * @returns data: { my_checkin_dates 已打卡日期列表 } | ||
| 139 | + */ | ||
| 140 | +export const getCheckinTeacherCheckedDatesAPI = (params) => fn(fetch.get(Api.CHECKIN_TEACHER_CHECKED_DATES, params)) | ... | ... |
| 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-10-15 15:39:00 | 4 | + * @LastEditTime: 2025-10-27 16:21:16 |
| 5 | * @FilePath: /mlaj/src/views/teacher/checkinPage.vue | 5 | * @FilePath: /mlaj/src/views/teacher/checkinPage.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| ... | @@ -19,6 +19,7 @@ | ... | @@ -19,6 +19,7 @@ |
| 19 | <van-calendar ref="myRefCalendar" :show-title="false" :poppable="false" :show-confirm="false" :style="{ height: calendarHeight }" | 19 | <van-calendar ref="myRefCalendar" :show-title="false" :poppable="false" :show-confirm="false" :style="{ height: calendarHeight }" |
| 20 | switch-mode="year-month" color="#4caf50" :formatter="formatter" row-height="50" :show-mark="false" | 20 | switch-mode="year-month" color="#4caf50" :formatter="formatter" row-height="50" :show-mark="false" |
| 21 | @select="onSelectDay" | 21 | @select="onSelectDay" |
| 22 | + @panel-change="onPanelChange" | ||
| 22 | @click-subtitle="onClickSubtitle"> | 23 | @click-subtitle="onClickSubtitle"> |
| 23 | </van-calendar> | 24 | </van-calendar> |
| 24 | <div style="padding: 0 1rem; margin-top: 1rem;"> | 25 | <div style="padding: 0 1rem; margin-top: 1rem;"> |
| ... | @@ -193,7 +194,7 @@ import AudioPlayer from "@/components/ui/AudioPlayer.vue"; | ... | @@ -193,7 +194,7 @@ import AudioPlayer from "@/components/ui/AudioPlayer.vue"; |
| 193 | import { useTitle } from '@vueuse/core'; | 194 | import { useTitle } from '@vueuse/core'; |
| 194 | import dayjs from 'dayjs'; | 195 | import dayjs from 'dayjs'; |
| 195 | 196 | ||
| 196 | -import { getTaskDetailAPI, getCheckinTeacherListAPI, checkinTaskReviewAPI, likeUploadTaskInfoAPI, dislikeUploadTaskInfoAPI } from "@/api/checkin"; | 197 | +import { getTaskDetailAPI, getCheckinTeacherListAPI, checkinTaskReviewAPI, likeUploadTaskInfoAPI, dislikeUploadTaskInfoAPI,getCheckinTeacherCheckedDatesAPI } from "@/api/checkin"; |
| 197 | import { getTeacherGradeClassListAPI } from "@/api/teacher"; | 198 | import { getTeacherGradeClassListAPI } from "@/api/teacher"; |
| 198 | 199 | ||
| 199 | const route = useRoute() | 200 | const route = useRoute() |
| ... | @@ -211,12 +212,16 @@ const gradeOption = ref([]); | ... | @@ -211,12 +212,16 @@ const gradeOption = ref([]); |
| 211 | const classOption = ref([]); | 212 | const classOption = ref([]); |
| 212 | const courseOption = ref([]); | 213 | const courseOption = ref([]); |
| 213 | 214 | ||
| 215 | +const currentMonth = ref(dayjs().format('YYYY-MM')); | ||
| 216 | + | ||
| 214 | const handleGradeChange = async (val) => { | 217 | const handleGradeChange = async (val) => { |
| 215 | console.log('val', val); | 218 | console.log('val', val); |
| 216 | selectGradeValue.value = val; | 219 | selectGradeValue.value = val; |
| 217 | selectCourseValue.value = null; | 220 | selectCourseValue.value = null; |
| 218 | // 根据年级ID 更新过滤列表 | 221 | // 根据年级ID 更新过滤列表 |
| 219 | getFilterList(val); | 222 | getFilterList(val); |
| 223 | + // 重新获取打卡日期 | ||
| 224 | + getCheckedDates(currentMonth.value); | ||
| 220 | // 重置分页参数 | 225 | // 重置分页参数 |
| 221 | page.value = 0 | 226 | page.value = 0 |
| 222 | checkinDataList.value = [] | 227 | checkinDataList.value = [] |
| ... | @@ -231,6 +236,8 @@ const handleClassChange = (val) => { | ... | @@ -231,6 +236,8 @@ const handleClassChange = (val) => { |
| 231 | selectCourseValue.value = null; | 236 | selectCourseValue.value = null; |
| 232 | // 根据年级ID和班级ID 更新过滤列表 | 237 | // 根据年级ID和班级ID 更新过滤列表 |
| 233 | getFilterList(selectGradeValue.value, val); | 238 | getFilterList(selectGradeValue.value, val); |
| 239 | + // 重新获取打卡日期 | ||
| 240 | + getCheckedDates(currentMonth.value); | ||
| 234 | // 重置分页参数 | 241 | // 重置分页参数 |
| 235 | page.value = 0 | 242 | page.value = 0 |
| 236 | checkinDataList.value = [] | 243 | checkinDataList.value = [] |
| ... | @@ -242,6 +249,8 @@ const handleClassChange = (val) => { | ... | @@ -242,6 +249,8 @@ const handleClassChange = (val) => { |
| 242 | const handleCourseChange = (val) => { | 249 | const handleCourseChange = (val) => { |
| 243 | console.log('val', val); | 250 | console.log('val', val); |
| 244 | selectCourseValue.value = val; | 251 | selectCourseValue.value = val; |
| 252 | + // 重新获取打卡日期 | ||
| 253 | + getCheckedDates(currentMonth.value); | ||
| 245 | // 重置分页参数 | 254 | // 重置分页参数 |
| 246 | page.value = 0 | 255 | page.value = 0 |
| 247 | checkinDataList.value = [] | 256 | checkinDataList.value = [] |
| ... | @@ -569,6 +578,12 @@ const onClickSubtitle = (evt) => { | ... | @@ -569,6 +578,12 @@ const onClickSubtitle = (evt) => { |
| 569 | console.warn('点击了日期标题'); | 578 | console.warn('点击了日期标题'); |
| 570 | } | 579 | } |
| 571 | 580 | ||
| 581 | +// 切换月份时触发 | ||
| 582 | +const onPanelChange = ({ date }) => { | ||
| 583 | + currentMonth.value = dayjs(date).format('YYYY-MM'); | ||
| 584 | + getCheckedDates(currentMonth.value); | ||
| 585 | +} | ||
| 586 | + | ||
| 572 | const handLike = async (post) => { | 587 | const handLike = async (post) => { |
| 573 | if (!post.is_liked) { | 588 | if (!post.is_liked) { |
| 574 | const { code, data } = await likeUploadTaskInfoAPI({ checkin_id: post.id, }) | 589 | const { code, data } = await likeUploadTaskInfoAPI({ checkin_id: post.id, }) |
| ... | @@ -677,8 +692,19 @@ const getTaskDetail = async (month) => { | ... | @@ -677,8 +692,19 @@ const getTaskDetail = async (month) => { |
| 677 | progress1.value = ((data.checkin_number/data.target_number)*100).toFixed(1); // 计算进度条百分比 | 692 | progress1.value = ((data.checkin_number/data.target_number)*100).toFixed(1); // 计算进度条百分比 |
| 678 | showProgress.value = !isNaN(progress1.value); // 如果是NaN,就不显示进度条 | 693 | showProgress.value = !isNaN(progress1.value); // 如果是NaN,就不显示进度条 |
| 679 | teamAvatars.value = data.checkin_avatars; | 694 | teamAvatars.value = data.checkin_avatars; |
| 680 | - // 获取当前用户的打卡日期 | 695 | + } |
| 681 | - myCheckinDates.value = data.my_checkin_dates; | 696 | +} |
| 697 | + | ||
| 698 | +// 获取用户打卡日期的函数 | ||
| 699 | +const getCheckedDates = async (month) => { | ||
| 700 | + const checkedDatesResult = await getCheckinTeacherCheckedDatesAPI({ | ||
| 701 | + grade_id: selectGradeValue.value, | ||
| 702 | + class_id: selectClassValue.value, | ||
| 703 | + group_id: selectCourseValue.value, | ||
| 704 | + month | ||
| 705 | + }); | ||
| 706 | + if (checkedDatesResult.code) { | ||
| 707 | + myCheckinDates.value = checkedDatesResult.data.my_checkin_dates; | ||
| 682 | // 把['2025-06-06'] 转化为 [6] 只取日期去掉0 | 708 | // 把['2025-06-06'] 转化为 [6] 只取日期去掉0 |
| 683 | // myCheckinDates.value = myCheckinDates.value.map(date => { | 709 | // myCheckinDates.value = myCheckinDates.value.map(date => { |
| 684 | // return dayjs(date).date(); | 710 | // return dayjs(date).date(); |
| ... | @@ -757,10 +783,12 @@ onMounted(async () => { | ... | @@ -757,10 +783,12 @@ onMounted(async () => { |
| 757 | const current_date = route.query.date; | 783 | const current_date = route.query.date; |
| 758 | if (current_date) { | 784 | if (current_date) { |
| 759 | getTaskDetail(dayjs(current_date).format('YYYY-MM')); | 785 | getTaskDetail(dayjs(current_date).format('YYYY-MM')); |
| 786 | + getCheckedDates(dayjs(current_date).format('YYYY-MM')); | ||
| 760 | myRefCalendar.value?.reset(new Date(current_date)); | 787 | myRefCalendar.value?.reset(new Date(current_date)); |
| 761 | onLoad(current_date); | 788 | onLoad(current_date); |
| 762 | } else { | 789 | } else { |
| 763 | getTaskDetail(dayjs().format('YYYY-MM')); | 790 | getTaskDetail(dayjs().format('YYYY-MM')); |
| 791 | + getCheckedDates(dayjs().format('YYYY-MM')); | ||
| 764 | onLoad(dayjs().format('YYYY-MM-DD')); | 792 | onLoad(dayjs().format('YYYY-MM-DD')); |
| 765 | } | 793 | } |
| 766 | // 获取老师的年级、班级、课程列表信息 | 794 | // 获取老师的年级、班级、课程列表信息 | ... | ... |
-
Please register or login to post a comment