fix: 修复班级切换时选中状态保持问题
This commit is contained in:
parent
8297d62258
commit
41cccd9f7a
@ -1665,19 +1665,22 @@ const handleTemplateDownload = (type?: string) => {
|
|||||||
// 搜索处理
|
// 搜索处理
|
||||||
const handleSearch = () => {
|
const handleSearch = () => {
|
||||||
// 搜索是实时的,通过计算属性filteredData自动过滤
|
// 搜索是实时的,通过计算属性filteredData自动过滤
|
||||||
// 重置到第一页
|
// 重置到第一页并清空选中状态
|
||||||
paginationPage.value = 1
|
paginationPage.value = 1
|
||||||
|
selectedRowKeys.value = [] // 搜索时清空选中状态
|
||||||
}
|
}
|
||||||
|
|
||||||
// 监听搜索关键词变化,重置分页
|
// 监听搜索关键词变化,重置分页并清空选中状态
|
||||||
watch(searchKeyword, () => {
|
watch(searchKeyword, () => {
|
||||||
paginationPage.value = 1
|
paginationPage.value = 1
|
||||||
|
selectedRowKeys.value = [] // 搜索时清空选中状态
|
||||||
})
|
})
|
||||||
|
|
||||||
// 清空搜索
|
// 清空搜索
|
||||||
const clearSearch = () => {
|
const clearSearch = () => {
|
||||||
searchKeyword.value = ''
|
searchKeyword.value = ''
|
||||||
paginationPage.value = 1
|
paginationPage.value = 1
|
||||||
|
selectedRowKeys.value = [] // 清空搜索时也清空选中状态
|
||||||
}
|
}
|
||||||
|
|
||||||
// 学员库相关方法
|
// 学员库相关方法
|
||||||
@ -1839,9 +1842,10 @@ watch(
|
|||||||
if (newClassId !== oldClassId) {
|
if (newClassId !== oldClassId) {
|
||||||
// 同步更新选择器的状态(不触发选择器的watch)
|
// 同步更新选择器的状态(不触发选择器的watch)
|
||||||
selectedDepartment.value = newClassId ? String(newClassId) : ''
|
selectedDepartment.value = newClassId ? String(newClassId) : ''
|
||||||
// 切换班级时清空搜索
|
// 切换班级时清空搜索和选中状态
|
||||||
searchKeyword.value = ''
|
searchKeyword.value = ''
|
||||||
paginationPage.value = 1
|
paginationPage.value = 1
|
||||||
|
selectedRowKeys.value = [] // 清空选中的学生
|
||||||
loadData(newClassId)
|
loadData(newClassId)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -1857,9 +1861,10 @@ watch(
|
|||||||
// 如果当前props.classId存在且与选择器值一致,说明是props驱动的变化,不需要重复加载
|
// 如果当前props.classId存在且与选择器值一致,说明是props驱动的变化,不需要重复加载
|
||||||
const currentPropsClassId = props.classId ? String(props.classId) : ''
|
const currentPropsClassId = props.classId ? String(props.classId) : ''
|
||||||
if (newDepartmentId !== oldDepartmentId && newDepartmentId !== currentPropsClassId) {
|
if (newDepartmentId !== oldDepartmentId && newDepartmentId !== currentPropsClassId) {
|
||||||
// 切换班级时清空搜索
|
// 切换班级时清空搜索和选中状态
|
||||||
searchKeyword.value = ''
|
searchKeyword.value = ''
|
||||||
paginationPage.value = 1
|
paginationPage.value = 1
|
||||||
|
selectedRowKeys.value = [] // 清空选中的学生
|
||||||
const targetClassId = newDepartmentId || null
|
const targetClassId = newDepartmentId || null
|
||||||
loadData(targetClassId)
|
loadData(targetClassId)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user