fix(review-meeting): 修复专家搜索导致已选项丢失

pull/874/head
Codewoc 2026-04-02 09:13:19 +08:00
parent 0194af250d
commit 2c70c062a2
1 changed files with 18 additions and 18 deletions

View File

@ -42,12 +42,13 @@
v-if="!disabled"
ref="tableRef"
:data="filteredExperts"
row-key="id"
border
size="small"
max-height="300"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="50" align="center" />
<el-table-column type="selection" :reserve-selection="true" width="50" align="center" />
<el-table-column label="姓名" prop="nickname" width="100" />
<el-table-column label="单位" prop="deptName" show-overflow-tooltip />
<el-table-column label="职务" prop="position" width="160" show-overflow-tooltip />
@ -111,23 +112,22 @@ const selectedExperts = computed(() =>
props.experts.filter((e) => props.modelValue.includes(e.id))
)
//
watch(
() => props.modelValue,
async () => {
await nextTick()
if (!tableRef.value) return
isUpdating.value = true
tableRef.value.clearSelection()
filteredExperts.value.forEach((row) => {
if (props.modelValue.includes(row.id)) {
tableRef.value.toggleRowSelection(row, true)
}
})
isUpdating.value = false
},
{ immediate: true }
)
const syncTableSelection = async () => {
await nextTick()
if (!tableRef.value) return
isUpdating.value = true
tableRef.value.clearSelection()
filteredExperts.value.forEach((row) => {
if (props.modelValue.includes(row.id)) {
tableRef.value.toggleRowSelection(row, true)
}
})
isUpdating.value = false
}
// modelValue
watch(() => props.modelValue, syncTableSelection, { immediate: true })
watch(filteredExperts, syncTableSelection)
const handleSelectionChange = (selected: Expert[]) => {
if (isUpdating.value) return