fix(review-meeting): 修复专家搜索导致已选项丢失
parent
0194af250d
commit
2c70c062a2
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue