diff --git a/src/components/teacher/ClassManagement.vue b/src/components/teacher/ClassManagement.vue index 4c67096..b186c2f 100644 --- a/src/components/teacher/ClassManagement.vue +++ b/src/components/teacher/ClassManagement.vue @@ -1665,19 +1665,22 @@ const handleTemplateDownload = (type?: string) => { // 搜索处理 const handleSearch = () => { // 搜索是实时的,通过计算属性filteredData自动过滤 - // 重置到第一页 + // 重置到第一页并清空选中状态 paginationPage.value = 1 + selectedRowKeys.value = [] // 搜索时清空选中状态 } -// 监听搜索关键词变化,重置分页 +// 监听搜索关键词变化,重置分页并清空选中状态 watch(searchKeyword, () => { paginationPage.value = 1 + selectedRowKeys.value = [] // 搜索时清空选中状态 }) // 清空搜索 const clearSearch = () => { searchKeyword.value = '' paginationPage.value = 1 + selectedRowKeys.value = [] // 清空搜索时也清空选中状态 } // 学员库相关方法 @@ -1839,9 +1842,10 @@ watch( if (newClassId !== oldClassId) { // 同步更新选择器的状态(不触发选择器的watch) selectedDepartment.value = newClassId ? String(newClassId) : '' - // 切换班级时清空搜索 + // 切换班级时清空搜索和选中状态 searchKeyword.value = '' paginationPage.value = 1 + selectedRowKeys.value = [] // 清空选中的学生 loadData(newClassId) } }, @@ -1857,9 +1861,10 @@ watch( // 如果当前props.classId存在且与选择器值一致,说明是props驱动的变化,不需要重复加载 const currentPropsClassId = props.classId ? String(props.classId) : '' if (newDepartmentId !== oldDepartmentId && newDepartmentId !== currentPropsClassId) { - // 切换班级时清空搜索 + // 切换班级时清空搜索和选中状态 searchKeyword.value = '' paginationPage.value = 1 + selectedRowKeys.value = [] // 清空选中的学生 const targetClassId = newDepartmentId || null loadData(targetClassId) }