Fix Bug #433: 门诊手术安排编辑弹窗麻醉方法回显为代码且外请专家姓名未加载修复
根因:setupAnesDataWatch 的 watch({ immediate: true }) 在字典未加载时触发,
因合并条件判断同时检查字典长度和pendingAnesData,导致字典未加载时不进入
处理逻辑但也不清理watch。当handleEdit设置pendingAnesData后,watch仍活跃
但后续字典加载时pendingAnesData可能已被handleEdit的直接转换路径处理过。
修复:
1. setupAnesDataWatch: 将合并条件拆分为早期返回(字典未加载时跳过)和
pendingAnesData处理两步,确保字典加载后watch仍活跃
2. handleEdit/handleView: 显式赋值externalExpertName确保响应式更新
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1144,13 +1144,17 @@ const {
|
||||
const pendingAnesData = ref(null)
|
||||
|
||||
// 监听麻醉字典加载,完成后立即设置表单值
|
||||
// Bug #433: watch 回调中优先判断字典是否已加载,未加载时跳过(不处理也不清理)
|
||||
// 确保字典加载完成时 watch 仍然活跃并能处理 pendingAnesData
|
||||
let anesDataUnwatch = null
|
||||
function setupAnesDataWatch() {
|
||||
if (anesDataUnwatch) return // 防止重复设置
|
||||
anesDataUnwatch = watch(
|
||||
anesthesiaList,
|
||||
(newList) => {
|
||||
if (newList && newList.length > 0 && pendingAnesData.value) {
|
||||
// Bug #433: 字典未加载时跳过,不清理 watch,等待下次触发
|
||||
if (!newList || newList.length === 0) return
|
||||
if (pendingAnesData.value) {
|
||||
const data = pendingAnesData.value
|
||||
if (data.anesMethod != null) form.anesMethod = Number(data.anesMethod)
|
||||
if (data.incisionLevel != null) form.incisionType = Number(data.incisionLevel)
|
||||
@@ -1349,7 +1353,8 @@ function handleEdit(row) {
|
||||
if (res.code === 200) {
|
||||
const data = res.data
|
||||
Object.assign(form, data)
|
||||
// Bug #433: 如果字典已加载则立即转换,否则存入pending等待字典加载完成
|
||||
// Bug #433: 先存 pending 再调 watch 函数,确保 watch immediate 回调能看到 pendingAnesData
|
||||
// 修复时序问题:watch({ immediate: true }) 同步触发时 pendingAnesData.value 已被设置
|
||||
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)
|
||||
@@ -1359,6 +1364,8 @@ function handleEdit(row) {
|
||||
pendingAnesData.value = data
|
||||
setupAnesDataWatch()
|
||||
}
|
||||
// Bug #433: 显式赋值确保响应式更新
|
||||
if (data.externalExpertName != null) form.externalExpertName = data.externalExpertName
|
||||
} else {
|
||||
proxy.$modal.msgError('获取手术安排详情失败')
|
||||
}
|
||||
@@ -1378,7 +1385,8 @@ function handleView(row) {
|
||||
if (res.code === 200) {
|
||||
const data = res.data
|
||||
Object.assign(form, data)
|
||||
// Bug #433: 如果字典已加载则立即转换,否则存入pending等待字典加载完成
|
||||
// Bug #433: 先存 pending 再调 watch 函数,确保 watch immediate 回调能看到 pendingAnesData
|
||||
// 修复时序问题:watch({ immediate: true }) 同步触发时 pendingAnesData.value 已被设置
|
||||
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)
|
||||
@@ -1388,6 +1396,8 @@ function handleView(row) {
|
||||
pendingAnesData.value = data
|
||||
setupAnesDataWatch()
|
||||
}
|
||||
// Bug #433: 显式赋值确保响应式更新
|
||||
if (data.externalExpertName != null) form.externalExpertName = data.externalExpertName
|
||||
} else {
|
||||
proxy.$modal.msgError('获取手术安排详情失败')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user