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" v-if="!disabled"
ref="tableRef" ref="tableRef"
:data="filteredExperts" :data="filteredExperts"
row-key="id"
border border
size="small" size="small"
max-height="300" max-height="300"
@selection-change="handleSelectionChange" @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="nickname" width="100" />
<el-table-column label="单位" prop="deptName" show-overflow-tooltip /> <el-table-column label="单位" prop="deptName" show-overflow-tooltip />
<el-table-column label="职务" prop="position" width="160" 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)) props.experts.filter((e) => props.modelValue.includes(e.id))
) )
// const syncTableSelection = async () => {
watch( await nextTick()
() => props.modelValue, if (!tableRef.value) return
async () => { isUpdating.value = true
await nextTick() tableRef.value.clearSelection()
if (!tableRef.value) return filteredExperts.value.forEach((row) => {
isUpdating.value = true if (props.modelValue.includes(row.id)) {
tableRef.value.clearSelection() tableRef.value.toggleRowSelection(row, true)
filteredExperts.value.forEach((row) => { }
if (props.modelValue.includes(row.id)) { })
tableRef.value.toggleRowSelection(row, true) isUpdating.value = false
} }
})
isUpdating.value = false // modelValue
}, watch(() => props.modelValue, syncTableSelection, { immediate: true })
{ immediate: true } watch(filteredExperts, syncTableSelection)
)
const handleSelectionChange = (selected: Expert[]) => { const handleSelectionChange = (selected: Expert[]) => {
if (isUpdating.value) return if (isUpdating.value) return