feat(打卡): 重构计数打卡功能,支持表单数据复用
- 修改计数对象为列表项,增加确认模式 - 重构动态表单字段处理逻辑 - 更新API接口参数为gratitude_form_list - 优化计数打卡的提交逻辑
Showing
6 changed files
with
29 additions
and
20 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-12-16 11:52:53 | 4 | + * @LastEditTime: 2025-12-16 17:54:43 |
| 5 | * @FilePath: /mlaj/src/api/checkin.js | 5 | * @FilePath: /mlaj/src/api/checkin.js |
| 6 | * @Description: 签到模块相关接口 | 6 | * @Description: 签到模块相关接口 |
| 7 | */ | 7 | */ |
| ... | @@ -22,6 +22,7 @@ const Api = { | ... | @@ -22,6 +22,7 @@ const Api = { |
| 22 | CHECKIN_TEACHER_LIST: '/srv/?a=checkin&t=teacher_list', | 22 | CHECKIN_TEACHER_LIST: '/srv/?a=checkin&t=teacher_list', |
| 23 | CHECKIN_TEACHER_REVIEW: '/srv/?a=checkin&t=teacher_review', | 23 | CHECKIN_TEACHER_REVIEW: '/srv/?a=checkin&t=teacher_review', |
| 24 | CHECKIN_TEACHER_CHECKED_DATES: '/srv/?a=checkin&t=teacher_checked_dates', | 24 | CHECKIN_TEACHER_CHECKED_DATES: '/srv/?a=checkin&t=teacher_checked_dates', |
| 25 | + CHECKIN_TEACHER_REUSE_GRATITUDE_FORM: '/srv/?a=checkin&t=reuse_gratitude_form', | ||
| 25 | } | 26 | } |
| 26 | 27 | ||
| 27 | /** | 28 | /** |
| ... | @@ -75,7 +76,7 @@ export const checkinTaskAPI = (params) => fn(fetch.post(Api.TASK_CHECKIN, param | ... | @@ -75,7 +76,7 @@ export const checkinTaskAPI = (params) => fn(fetch.post(Api.TASK_CHECKIN, param |
| 75 | * @param file_type 上传附件的类型 image=上传图片,video=视频,audio=音频 | 76 | * @param file_type 上传附件的类型 image=上传图片,video=视频,audio=音频 |
| 76 | * @param makeup_time 补卡时间 | 77 | * @param makeup_time 补卡时间 |
| 77 | * @param gratitude_count 感恩次数 | 78 | * @param gratitude_count 感恩次数 |
| 78 | - * @param gratitude_people_ids 感恩对象ID数组 [id1,id2,id3] | 79 | + * @param gratitude_form_list 感恩表单数据 [{id,name,city,unit,其他信息字段}] |
| 79 | * @returns | 80 | * @returns |
| 80 | */ | 81 | */ |
| 81 | export const addUploadTaskAPI = (params) => fn(fetch.post(Api.TASK_UPLOAD_ADD, params)) | 82 | export const addUploadTaskAPI = (params) => fn(fetch.post(Api.TASK_UPLOAD_ADD, params)) |
| ... | @@ -106,7 +107,7 @@ export const getUploadTaskListAPI = (params) => fn(fetch.post(Api.TASK_UPLOAD_L | ... | @@ -106,7 +107,7 @@ export const getUploadTaskListAPI = (params) => fn(fetch.post(Api.TASK_UPLOAD_L |
| 106 | * avatar 打卡人头像, created_time 打卡时间, created_time_desc 打卡时间描述, note 打卡内容, files[{meta_id,name,value,extension}] 附件列表, | 107 | * avatar 打卡人头像, created_time 打卡时间, created_time_desc 打卡时间描述, note 打卡内容, files[{meta_id,name,value,extension}] 附件列表, |
| 107 | * file_type 上传附件的类型 image=上传图片,video=视频,audio=音频, like_count 点赞数, is_my 是不是我的打卡, is_like 我是否已经点赞, is_makeup 是否补卡 | 108 | * file_type 上传附件的类型 image=上传图片,video=视频,audio=音频, like_count 点赞数, is_my 是不是我的打卡, is_like 我是否已经点赞, is_makeup 是否补卡 |
| 108 | * gratitude_count 感恩次数 | 109 | * gratitude_count 感恩次数 |
| 109 | - * gratitude_people 感恩对象列表 [{id,name,city,unit}] | 110 | + * gratitude_form_list 感恩表单数据 [{id,name,city,unit,其他信息字段}] |
| 110 | * } | 111 | * } |
| 111 | */ | 112 | */ |
| 112 | export const getUploadTaskInfoAPI = (params) => fn(fetch.get(Api.TASK_UPLOAD_INFO, params)) | 113 | export const getUploadTaskInfoAPI = (params) => fn(fetch.get(Api.TASK_UPLOAD_INFO, params)) |
| ... | @@ -118,7 +119,7 @@ export const getUploadTaskInfoAPI = (params) => fn(fetch.get(Api.TASK_UPLOAD_IN | ... | @@ -118,7 +119,7 @@ export const getUploadTaskInfoAPI = (params) => fn(fetch.get(Api.TASK_UPLOAD_IN |
| 118 | * @param meta_id[] 附件ID列表 | 119 | * @param meta_id[] 附件ID列表 |
| 119 | * @param file_type 上传附件的类型 image=上传图片,video=视频,audio=音频 | 120 | * @param file_type 上传附件的类型 image=上传图片,video=视频,audio=音频 |
| 120 | * @param gratitude_count 感恩次数 | 121 | * @param gratitude_count 感恩次数 |
| 121 | - * @param gratitude_people_ids 感恩对象ID数组 [id1,id2,id3] | 122 | + * @param gratitude_form_list 感恩表单数据 [{id,name,city,unit,其他信息字段}] |
| 122 | * @returns | 123 | * @returns |
| 123 | */ | 124 | */ |
| 124 | export const editUploadTaskInfoAPI = (params) => fn(fetch.get(Api.TASK_UPLOAD_EDIT, params)) | 125 | export const editUploadTaskInfoAPI = (params) => fn(fetch.get(Api.TASK_UPLOAD_EDIT, params)) |
| ... | @@ -183,3 +184,10 @@ export const checkinTaskReviewAPI = (params) => fn(fetch.post(Api.CHECKIN_TEACH | ... | @@ -183,3 +184,10 @@ export const checkinTaskReviewAPI = (params) => fn(fetch.post(Api.CHECKIN_TEACH |
| 183 | * @returns data: { my_checkin_dates 已打卡日期列表 } | 184 | * @returns data: { my_checkin_dates 已打卡日期列表 } |
| 184 | */ | 185 | */ |
| 185 | export const getCheckinTeacherCheckedDatesAPI = (params) => fn(fetch.get(Api.CHECKIN_TEACHER_CHECKED_DATES, params)) | 186 | export const getCheckinTeacherCheckedDatesAPI = (params) => fn(fetch.get(Api.CHECKIN_TEACHER_CHECKED_DATES, params)) |
| 187 | + | ||
| 188 | +/** | ||
| 189 | + * @description: 复用感恩表单数据 | ||
| 190 | + * @param subtask_id 小作业ID | ||
| 191 | + * @returns | ||
| 192 | + */ | ||
| 193 | +export const reuseGratitudeFormAPI = (params) => fn(fetch.post(Api.CHECKIN_TEACHER_REUSE_GRATITUDE_FORM, params)) | ... | ... |
| 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-12-16 13:59:55 | 4 | + * @LastEditTime: 2025-12-16 17:52:19 |
| 5 | * @FilePath: /mlaj/src/api/gratitude.js | 5 | * @FilePath: /mlaj/src/api/gratitude.js |
| 6 | * @Description: 计数模块相关接口 | 6 | * @Description: 计数模块相关接口 |
| 7 | */ | 7 | */ | ... | ... |
| ... | @@ -12,7 +12,7 @@ | ... | @@ -12,7 +12,7 @@ |
| 12 | <div v-for="field in localFields" :key="field.id"> | 12 | <div v-for="field in localFields" :key="field.id"> |
| 13 | <van-field | 13 | <van-field |
| 14 | v-model="field.value" | 14 | v-model="field.value" |
| 15 | - label-width="4rem" | 15 | + label-width="5rem" |
| 16 | :label="field.label" | 16 | :label="field.label" |
| 17 | :placeholder="'请输入' + field.label" | 17 | :placeholder="'请输入' + field.label" |
| 18 | :type="field.type === 'textarea' ? 'textarea' : 'text'" | 18 | :type="field.type === 'textarea' ? 'textarea' : 'text'" |
| ... | @@ -43,7 +43,7 @@ const props = defineProps({ | ... | @@ -43,7 +43,7 @@ const props = defineProps({ |
| 43 | */ | 43 | */ |
| 44 | title: { | 44 | title: { |
| 45 | type: String, | 45 | type: String, |
| 46 | - default: '添加对象' | 46 | + default: '添加列表项' |
| 47 | }, | 47 | }, |
| 48 | /** | 48 | /** |
| 49 | * 表单字段配置 | 49 | * 表单字段配置 |
| ... | @@ -101,14 +101,8 @@ const onBeforeClose = (action) => { | ... | @@ -101,14 +101,8 @@ const onBeforeClose = (action) => { |
| 101 | } | 101 | } |
| 102 | } | 102 | } |
| 103 | 103 | ||
| 104 | - // 收集表单数据 | 104 | + // 触发确认事件,传递表单数据 (保持与 fields 结构一致) |
| 105 | - const formData = localFields.value.reduce((acc, field) => { | 105 | + emit('confirm', localFields.value) |
| 106 | - acc[field.id] = field.value | ||
| 107 | - return acc | ||
| 108 | - }, {}) | ||
| 109 | - | ||
| 110 | - // 触发确认事件,传递表单数据 | ||
| 111 | - emit('confirm', formData) | ||
| 112 | return true // 允许关闭 | 106 | return true // 允许关闭 |
| 113 | } | 107 | } |
| 114 | return true // 取消时允许关闭 | 108 | return true // 取消时允许关闭 | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2025-12-16 11:44:27 | 2 | * @Date: 2025-12-16 11:44:27 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-12-16 14:17:38 | 4 | + * @LastEditTime: 2025-12-16 17:59:29 |
| 5 | * @FilePath: /mlaj/src/components/count/CheckinTargetList.vue | 5 | * @FilePath: /mlaj/src/components/count/CheckinTargetList.vue |
| 6 | * @Description: 打卡动态对象列表组件 | 6 | * @Description: 打卡动态对象列表组件 |
| 7 | --> | 7 | --> |
| ... | @@ -9,7 +9,7 @@ | ... | @@ -9,7 +9,7 @@ |
| 9 | <div class="mb-4"> | 9 | <div class="mb-4"> |
| 10 | <div class="flex justify-between items-center mb-2 mx-2"> | 10 | <div class="flex justify-between items-center mb-2 mx-2"> |
| 11 | <div class="flex items-center gap-2"> | 11 | <div class="flex items-center gap-2"> |
| 12 | - <div class="text-sm font-bold text-gray-700">{{ dynamicFieldText }}对象</div> | 12 | + <div class="text-sm font-bold text-gray-700">{{ dynamicFieldText }}列表</div> |
| 13 | <div class="text-xs text-gray-400 font-normal scale-90 origin-left">(长按可编辑/删除)</div> | 13 | <div class="text-xs text-gray-400 font-normal scale-90 origin-left">(长按可编辑/删除)</div> |
| 14 | </div> | 14 | </div> |
| 15 | <van-button size="small" type="primary" plain icon="plus" @click="onAdd" class="!h-7">添加</van-button> | 15 | <van-button size="small" type="primary" plain icon="plus" @click="onAdd" class="!h-7">添加</van-button> |
| ... | @@ -49,7 +49,7 @@ | ... | @@ -49,7 +49,7 @@ |
| 49 | </div> | 49 | </div> |
| 50 | </template> | 50 | </template> |
| 51 | <div v-else class="w-full text-center py-4 text-gray-400 text-sm"> | 51 | <div v-else class="w-full text-center py-4 text-gray-400 text-sm"> |
| 52 | - 暂无{{ dynamicFieldText }}对象,请点击上方添加按钮 | 52 | + 暂无{{ dynamicFieldText }}列表,请点击上方添加按钮 |
| 53 | </div> | 53 | </div> |
| 54 | </div> | 54 | </div> |
| 55 | </div> | 55 | </div> | ... | ... |
| ... | @@ -307,13 +307,20 @@ export function useCheckin() { | ... | @@ -307,13 +307,20 @@ export function useCheckin() { |
| 307 | let result | 307 | let result |
| 308 | if (route.query.status === 'edit') { | 308 | if (route.query.status === 'edit') { |
| 309 | // 编辑打卡 | 309 | // 编辑打卡 |
| 310 | - result = await editUploadTaskInfoAPI({ | 310 | + const editData = { |
| 311 | i: route.query.post_id, | 311 | i: route.query.post_id, |
| 312 | subtask_id: submitData.subtask_id || route.query.subtask_id, | 312 | subtask_id: submitData.subtask_id || route.query.subtask_id, |
| 313 | note: submitData.note, | 313 | note: submitData.note, |
| 314 | meta_id: submitData.meta_id, | 314 | meta_id: submitData.meta_id, |
| 315 | file_type: submitData.file_type, | 315 | file_type: submitData.file_type, |
| 316 | - }) | 316 | + } |
| 317 | + | ||
| 318 | + // 如果有计数对象列表,也需要传递 | ||
| 319 | + if (submitData.gratitude_form_list) { | ||
| 320 | + editData.gratitude_form_list = submitData.gratitude_form_list | ||
| 321 | + } | ||
| 322 | + | ||
| 323 | + result = await editUploadTaskInfoAPI(editData) | ||
| 317 | } else { | 324 | } else { |
| 318 | // 新增打卡 | 325 | // 新增打卡 |
| 319 | result = await addUploadTaskAPI(submitData) | 326 | result = await addUploadTaskAPI(submitData) | ... | ... |
This diff is collapsed. Click to expand it.
-
Please register or login to post a comment