fix(teacher): 修复任务主页条件渲染和打卡类型处理
添加任务类型判断逻辑,修复日期和附件类型的条件渲染 防止打卡类型任务跳转作业记录页
Showing
1 changed file
with
13 additions
and
7 deletions
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2025-11-19 21:00:00 | 2 | * @Date: 2025-11-19 21:00:00 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-12-05 22:31:03 | 4 | + * @LastEditTime: 2025-12-10 11:32:08 |
| 5 | * @FilePath: /mlaj/src/views/teacher/taskHomePage.vue | 5 | * @FilePath: /mlaj/src/views/teacher/taskHomePage.vue |
| 6 | * @Description: 教师端作业主页(头部介绍、统计、日历与学生完成情况;数据Mock) | 6 | * @Description: 教师端作业主页(头部介绍、统计、日历与学生完成情况;数据Mock) |
| 7 | --> | 7 | --> |
| ... | @@ -19,9 +19,10 @@ | ... | @@ -19,9 +19,10 @@ |
| 19 | <div class="details text-sm text-gray-600"> | 19 | <div class="details text-sm text-gray-600"> |
| 20 | <div class="detailItem">周期:{{ task_details.cycle }}</div> | 20 | <div class="detailItem">周期:{{ task_details.cycle }}</div> |
| 21 | <div class="detailItem">频次:{{ task_details.frequency }}</div> | 21 | <div class="detailItem">频次:{{ task_details.frequency }}</div> |
| 22 | - <div class="detailItem">开始时间:{{ task_details.begin_date }}</div> | 22 | + <div v-if="task_details.begin_date" class="detailItem">开始时间:{{ task_details.begin_date }}</div> |
| 23 | - <div class="detailItem">截止时间:{{ task_details.end_date }}</div> | 23 | + <div v-if="task_details.end_date" class="detailItem">截止时间:{{ task_details.end_date }}</div> |
| 24 | - <div class="detailItem">附件类型:{{ task_details.attachment_type }}</div> | 24 | + <div v-if="task_details.attachment_type.length" class="detailItem">附件类型:{{ task_details.attachment_type }}</div> |
| 25 | + <div v-if="task_type === 'checkin'" class="detailItem">类型:打卡签到</div> | ||
| 25 | </div> | 26 | </div> |
| 26 | </div> | 27 | </div> |
| 27 | 28 | ||
| ... | @@ -90,7 +91,7 @@ | ... | @@ -90,7 +91,7 @@ |
| 90 | <div class="text-base font-semibold text-gray-800">完成情况({{ completed_count }}/{{ user_list.length }}) | 91 | <div class="text-base font-semibold text-gray-800">完成情况({{ completed_count }}/{{ user_list.length }}) |
| 91 | </div> | 92 | </div> |
| 92 | <!-- <div class="text-xs text-gray-500">当前日期:{{ current_date_text }}</div> --> | 93 | <!-- <div class="text-xs text-gray-500">当前日期:{{ current_date_text }}</div> --> |
| 93 | - <div class="text-xs text-gray-500">点击查看作业记录</div> | 94 | + <div v-if="task_type !== 'checkin'" class="text-xs text-gray-500">点击查看作业记录</div> |
| 94 | </div> | 95 | </div> |
| 95 | <div class="grid grid-cols-5 gap-3 StudentsGrid"> | 96 | <div class="grid grid-cols-5 gap-3 StudentsGrid"> |
| 96 | <div v-for="(stu, idx) in students_status" :key="stu.id" | 97 | <div v-for="(stu, idx) in students_status" :key="stu.id" |
| ... | @@ -223,6 +224,7 @@ const upload_text = computed(() => `${upload_count.value}%`) | ... | @@ -223,6 +224,7 @@ const upload_text = computed(() => `${upload_count.value}%`) |
| 223 | const today = new Date() | 224 | const today = new Date() |
| 224 | const selected_date = ref(format_date(today)) | 225 | const selected_date = ref(format_date(today)) |
| 225 | const user_list = ref([]) | 226 | const user_list = ref([]) |
| 227 | +const task_type = ref('') | ||
| 226 | 228 | ||
| 227 | /** | 229 | /** |
| 228 | * 获取作业详情和学生完成情况 | 230 | * 获取作业详情和学生完成情况 |
| ... | @@ -237,6 +239,7 @@ async function fetchData() { | ... | @@ -237,6 +239,7 @@ async function fetchData() { |
| 237 | if (res.code) { | 239 | if (res.code) { |
| 238 | task_title.value = res.data.title | 240 | task_title.value = res.data.title |
| 239 | task_intro.value = res.data.note | 241 | task_intro.value = res.data.note |
| 242 | + task_type.value = res.data.task_type || '' | ||
| 240 | 243 | ||
| 241 | // 格式化周期显示 | 244 | // 格式化周期显示 |
| 242 | const cycleMap = { | 245 | const cycleMap = { |
| ... | @@ -265,8 +268,8 @@ async function fetchData() { | ... | @@ -265,8 +268,8 @@ async function fetchData() { |
| 265 | task_details.value = { | 268 | task_details.value = { |
| 266 | cycle: cycleText, | 269 | cycle: cycleText, |
| 267 | frequency: `每周期${res.data.frequency || 1}次`, | 270 | frequency: `每周期${res.data.frequency || 1}次`, |
| 268 | - begin_date: dayjs(res.data.begin_date).format('YYYY-MM-DD'), | 271 | + begin_date: res.data.begin_date ? dayjs(res.data.begin_date).format('YYYY-MM-DD') : '', |
| 269 | - end_date: dayjs(res.data.end_date).format('YYYY-MM-DD'), | 272 | + end_date: res.data.end_date ? dayjs(res.data.end_date).format('YYYY-MM-DD') : '', |
| 270 | // time_range: `${res.data.begin_date || '00:00'} ~ ${res.data.end_date || '23:59'}`, // 注意:API返回的begin_date/end_date可能是日期也可能是时间,这里暂且直接展示 | 273 | // time_range: `${res.data.begin_date || '00:00'} ~ ${res.data.end_date || '23:59'}`, // 注意:API返回的begin_date/end_date可能是日期也可能是时间,这里暂且直接展示 |
| 271 | attachment_type: attachmentText | 274 | attachment_type: attachmentText |
| 272 | } | 275 | } |
| ... | @@ -375,6 +378,9 @@ const current_date_text = computed(() => selected_date.value) | ... | @@ -375,6 +378,9 @@ const current_date_text = computed(() => selected_date.value) |
| 375 | * @returns {void} | 378 | * @returns {void} |
| 376 | */ | 379 | */ |
| 377 | function go_student_record(stu) { | 380 | function go_student_record(stu) { |
| 381 | + if (task_type.value === 'checkin') { | ||
| 382 | + return | ||
| 383 | + } | ||
| 378 | // 跳转到固定ID的作业记录页面,当前版本不使用传入ID | 384 | // 跳转到固定ID的作业记录页面,当前版本不使用传入ID |
| 379 | $router.push({ name: 'StudentRecord', query: { created_by: stu.id, date: selected_date.value } }) | 385 | $router.push({ name: 'StudentRecord', query: { created_by: stu.id, date: selected_date.value } }) |
| 380 | } | 386 | } | ... | ... |
-
Please register or login to post a comment