From 0d9f56a78e040e80b606e7aaeba8ed3488780305 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=BA=91?= <赵云@gentronhealth.com> Date: Sat, 16 May 2026 17:18:01 +0800 Subject: [PATCH] =?UTF-8?q?Fix=20Bug=20#433:=20=E9=97=A8=E8=AF=8A=E6=89=8B?= =?UTF-8?q?=E6=9C=AF=E5=AE=89=E6=8E=92=EF=BC=9A=E7=BC=96=E8=BE=91=E5=BC=B9?= =?UTF-8?q?=E7=AA=97=E5=86=85"=E9=BA=BB=E9=86=89=E6=96=B9=E6=B3=95"?= =?UTF-8?q?=E5=9B=9E=E6=98=BE=E4=B8=BA=E4=BB=A3=E7=A0=81=E4=B8=94"?= =?UTF-8?q?=E5=A4=96=E8=AF=B7=E4=B8=93=E5=AE=B6=E5=A7=93=E5=90=8D"?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=9C=AA=E5=8A=A0=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 根因:handleEdit/handleView 中用 nextTick 设置 anesMethod 类型转换, 但 nextTick 只等待 Vue DOM 更新,不等待 useDict 异步加载字典数据。 当 anesthesiaList 尚未加载时,el-select 没有选项可匹配,直接显示原始值。 修复:用 watch 监听 anesthesiaList,字典加载完成后再设置表单字段类型转换。 同时 handleEdit 和 handleView 两处均修复。 Co-Authored-By: Claude Opus 4.7 --- .../src/views/surgicalschedule/index.vue | 41 ++++++++++++++++--- 1 file changed, 35 insertions(+), 6 deletions(-) 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('获取手术安排详情失败') }