Fix Bug #433: 门诊手术安排:编辑弹窗内"麻醉方法"回显为代码且"外请专家姓名"数据未加载
根因:handleEdit/handleView 中用 nextTick 设置 anesMethod 类型转换, 但 nextTick 只等待 Vue DOM 更新,不等待 useDict 异步加载字典数据。 当 anesthesiaList 尚未加载时,el-select 没有选项可匹配,直接显示原始值。 修复:用 watch 监听 anesthesiaList,字典加载完成后再设置表单字段类型转换。 同时 handleEdit 和 handleView 两处均修复。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1140,6 +1140,29 @@ const {
|
||||
method_code
|
||||
} = useDict('surgical_site', 'anesthesia_type', 'incision_level', 'isolation_type', 'surgery_type', 'surgery_level', 'surgery_nature', 'method_code')
|
||||
|
||||
// Bug #433: 存储待转换的数据,等待字典加载后再设置类型
|
||||
const pendingAnesData = ref(null)
|
||||
|
||||
// 监听麻醉字典加载,完成后立即设置表单值
|
||||
let anesDataUnwatch = null
|
||||
function setupAnesDataWatch() {
|
||||
if (anesDataUnwatch) return // 防止重复设置
|
||||
anesDataUnwatch = watch(
|
||||
anesthesiaList,
|
||||
(newList) => {
|
||||
if (newList && newList.length > 0 && pendingAnesData.value) {
|
||||
const data = pendingAnesData.value
|
||||
if (data.anesMethod != null) form.anesMethod = Number(data.anesMethod)
|
||||
if (data.incisionLevel != null) form.incisionType = Number(data.incisionLevel)
|
||||
if (data.isExternalExpert != null) form.isExternalExpert = Number(data.isExternalExpert)
|
||||
pendingAnesData.value = null
|
||||
if (anesDataUnwatch) { anesDataUnwatch(); anesDataUnwatch = null }
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
}
|
||||
|
||||
// 加载数据
|
||||
onMounted(() => {
|
||||
const anesthesiaType = sessionStorage.getItem('anesthesiaType')
|
||||
@@ -1325,13 +1348,16 @@ function handleEdit(row) {
|
||||
if (res.code === 200) {
|
||||
const data = res.data
|
||||
Object.assign(form, data)
|
||||
// 使用nextTick确保在Vue响应式更新后再赋值,避免el-select无法匹配选项
|
||||
nextTick(() => {
|
||||
// Bug #433: 如果字典已加载则立即转换,否则存入pending等待字典加载完成
|
||||
if (anesthesiaList.value && anesthesiaList.value.length > 0) {
|
||||
if (data.anesMethod != null) form.anesMethod = Number(data.anesMethod)
|
||||
if (data.incisionLevel != null) form.incisionType = Number(data.incisionLevel)
|
||||
if (data.feeType != null) form.feeType = data.feeType
|
||||
if (data.isExternalExpert != null) form.isExternalExpert = Number(data.isExternalExpert)
|
||||
})
|
||||
} else {
|
||||
pendingAnesData.value = data
|
||||
setupAnesDataWatch()
|
||||
}
|
||||
} else {
|
||||
proxy.$modal.msgError('获取手术安排详情失败')
|
||||
}
|
||||
@@ -1351,13 +1377,16 @@ function handleView(row) {
|
||||
if (res.code === 200) {
|
||||
const data = res.data
|
||||
Object.assign(form, data)
|
||||
// 使用nextTick确保在Vue响应式更新后再赋值,避免el-select无法匹配选项
|
||||
nextTick(() => {
|
||||
// Bug #433: 如果字典已加载则立即转换,否则存入pending等待字典加载完成
|
||||
if (anesthesiaList.value && anesthesiaList.value.length > 0) {
|
||||
if (data.anesMethod != null) form.anesMethod = Number(data.anesMethod)
|
||||
if (data.incisionLevel != null) form.incisionType = Number(data.incisionLevel)
|
||||
if (data.feeType != null) form.feeType = data.feeType
|
||||
if (data.isExternalExpert != null) form.isExternalExpert = Number(data.isExternalExpert)
|
||||
})
|
||||
} else {
|
||||
pendingAnesData.value = data
|
||||
setupAnesDataWatch()
|
||||
}
|
||||
} else {
|
||||
proxy.$modal.msgError('获取手术安排详情失败')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user