This commit is contained in:
parent
2335488836
commit
7c60847f46
|
|
@ -535,6 +535,9 @@ const managerDialog = reactive({
|
|||
type: 'plan', // 'plan', 'actual', 'highAltitude', 'ground', 'actual_highAltitude', 'actual_ground'
|
||||
})
|
||||
|
||||
// 标志:是否正在同步表格选中状态(防止同步时触发 selection-change 事件导致选中状态丢失)
|
||||
const isSyncingSelection = ref(false)
|
||||
|
||||
// 将公共人员列表转换为表格展示需要的字段结构
|
||||
const personList = computed(() => {
|
||||
return (personnelCommonOptions.value || []).map((item) => ({
|
||||
|
|
@ -593,6 +596,7 @@ const selectedManagerNames = computed(() => {
|
|||
// 同步表格选中状态:根据 managerDialog.selected 设置表格的选中状态
|
||||
const syncTableSelection = () => {
|
||||
if (!personTableRef.value || !managerDialogConfig.outerVisible) return
|
||||
isSyncingSelection.value = true
|
||||
nextTick(() => {
|
||||
// 清空当前表格选中状态
|
||||
personTableRef.value.clearSelection()
|
||||
|
|
@ -603,6 +607,10 @@ const syncTableSelection = () => {
|
|||
personTableRef.value.toggleRowSelection(row, true)
|
||||
}
|
||||
})
|
||||
// 同步完成后,延迟清除标志,确保所有 selection-change 事件都已处理
|
||||
nextTick(() => {
|
||||
isSyncingSelection.value = false
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -649,6 +657,9 @@ const onOpenPersonPicker = async (type = 'plan', subType = null) => {
|
|||
}
|
||||
|
||||
const onManagerSelectionChange = (rows) => {
|
||||
// 如果正在同步选中状态,直接返回,避免错误地更新选中状态
|
||||
if (isSyncingSelection.value) return
|
||||
|
||||
// 获取当前过滤结果中所有行的 ID
|
||||
const currentFilteredIds = new Set(filteredPersons.value.map((row) => row.id))
|
||||
|
||||
|
|
@ -667,14 +678,29 @@ const onManagerSelectionChange = (rows) => {
|
|||
const onRemoveManager = (item) => {
|
||||
managerDialog.selected = managerDialog.selected.filter((row) => row.id !== item.id)
|
||||
if (personTableRef.value) {
|
||||
const target = personList.value.find((row) => row.id === item.id)
|
||||
if (target) personTableRef.value.toggleRowSelection(target, false)
|
||||
// 优先在过滤后的列表中查找,如果找不到再在全量列表中查找
|
||||
const target =
|
||||
filteredPersons.value.find((row) => row.id === item.id) ||
|
||||
personList.value.find((row) => row.id === item.id)
|
||||
if (target) {
|
||||
isSyncingSelection.value = true
|
||||
personTableRef.value.toggleRowSelection(target, false)
|
||||
nextTick(() => {
|
||||
isSyncingSelection.value = false
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const onClearManagers = () => {
|
||||
managerDialog.selected = []
|
||||
if (personTableRef.value) personTableRef.value.clearSelection()
|
||||
if (personTableRef.value) {
|
||||
isSyncingSelection.value = true
|
||||
personTableRef.value.clearSelection()
|
||||
nextTick(() => {
|
||||
isSyncingSelection.value = false
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const onConfirmManager = () => {
|
||||
|
|
@ -944,6 +970,14 @@ watch(
|
|||
{ immediate: true },
|
||||
)
|
||||
|
||||
watch(
|
||||
() => managerDialogConfig.outerVisible,
|
||||
(newVisible) => {
|
||||
if (!newVisible) {
|
||||
managerDialog.keyword = ''
|
||||
}
|
||||
},
|
||||
)
|
||||
// onMounted(() => {
|
||||
// if (route.query.id) {
|
||||
// getDetail()
|
||||
|
|
|
|||
|
|
@ -567,7 +567,7 @@
|
|||
</el-col>
|
||||
</el-row>
|
||||
<el-row class="common-btn-row fixed-bottom">
|
||||
<ComButton plain type="info" @click="managerDialog.visible = false">
|
||||
<ComButton plain type="info" @click="onCloseDialogOuter(false)">
|
||||
取消
|
||||
</ComButton>
|
||||
<ComButton type="primary" @click="onConfirmManager">确定</ComButton>
|
||||
|
|
@ -849,6 +849,9 @@ const managerDialog = reactive({
|
|||
selected: [],
|
||||
})
|
||||
|
||||
// 标志:是否正在同步表格选中状态(防止同步时触发 selection-change 事件导致选中状态丢失)
|
||||
const isSyncingSelection = ref(false)
|
||||
|
||||
// 将公共人员列表转换为表格展示需要的字段结构
|
||||
const personList = computed(() => {
|
||||
return (personnelCommonOptions.value || []).map((item) => ({
|
||||
|
|
@ -880,6 +883,7 @@ const selectedManagerNames = computed(() =>
|
|||
// 同步表格选中状态:根据 managerDialog.selected 设置表格的选中状态
|
||||
const syncTableSelection = () => {
|
||||
if (!personTableRef.value || !managerDialog.visible) return
|
||||
isSyncingSelection.value = true
|
||||
nextTick(() => {
|
||||
// 清空当前表格选中状态
|
||||
personTableRef.value.clearSelection()
|
||||
|
|
@ -890,6 +894,10 @@ const syncTableSelection = () => {
|
|||
personTableRef.value.toggleRowSelection(row, true)
|
||||
}
|
||||
})
|
||||
// 同步完成后,延迟清除标志,确保所有 selection-change 事件都已处理
|
||||
nextTick(() => {
|
||||
isSyncingSelection.value = false
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -912,6 +920,9 @@ const onOpenPersonPicker = async () => {
|
|||
}
|
||||
|
||||
const onManagerSelectionChange = (rows) => {
|
||||
// 如果正在同步选中状态,直接返回,避免错误地更新选中状态
|
||||
if (isSyncingSelection.value) return
|
||||
|
||||
// 获取当前过滤结果中所有行的 ID
|
||||
const currentFilteredIds = new Set(filteredPersons.value.map((row) => row.id))
|
||||
|
||||
|
|
@ -930,14 +941,29 @@ const onManagerSelectionChange = (rows) => {
|
|||
const onRemoveManager = (item) => {
|
||||
managerDialog.selected = managerDialog.selected.filter((row) => row.id !== item.id)
|
||||
if (personTableRef.value) {
|
||||
const target = personList.value.find((row) => row.id === item.id)
|
||||
if (target) personTableRef.value.toggleRowSelection(target, false)
|
||||
// 优先在过滤后的列表中查找,如果找不到再在全量列表中查找
|
||||
const target =
|
||||
filteredPersons.value.find((row) => row.id === item.id) ||
|
||||
personList.value.find((row) => row.id === item.id)
|
||||
if (target) {
|
||||
isSyncingSelection.value = true
|
||||
personTableRef.value.toggleRowSelection(target, false)
|
||||
nextTick(() => {
|
||||
isSyncingSelection.value = false
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const onClearManagers = () => {
|
||||
managerDialog.selected = []
|
||||
if (personTableRef.value) personTableRef.value.clearSelection()
|
||||
if (personTableRef.value) {
|
||||
isSyncingSelection.value = true
|
||||
personTableRef.value.clearSelection()
|
||||
nextTick(() => {
|
||||
isSyncingSelection.value = false
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const onConfirmManager = () => {
|
||||
|
|
@ -1130,6 +1156,16 @@ watch(
|
|||
{ immediate: true },
|
||||
)
|
||||
|
||||
watch(
|
||||
() => managerDialogConfig.outerVisible,
|
||||
(newVisible) => {
|
||||
if (!newVisible) {
|
||||
managerDialog.keyword = ''
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
)
|
||||
|
||||
// onMounted(() => {
|
||||
// getDetail()
|
||||
// })
|
||||
|
|
|
|||
Loading…
Reference in New Issue