diff --git a/openhis-ui-vue3/src/views/surgicalschedule/index.vue b/openhis-ui-vue3/src/views/surgicalschedule/index.vue index 1ab934c24..fa9e59e7a 100755 --- a/openhis-ui-vue3/src/views/surgicalschedule/index.vue +++ b/openhis-ui-vue3/src/views/surgicalschedule/index.vue @@ -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('获取手术安排详情失败') }