Fix Bug #455: 门诊医生站-医嘱:开立诊疗医嘱时执行科室默认获取逻辑有误且显示为原始ID
根因:setValue 中调用 findOrgNameById 时 organization 树数据尚未加载完成(异步竞态),
导致 findOrgNameById 返回空字符串,el-tree-select 无法解析 orgId 对应的名称,显示原始ID。
修复:1. 将 getOrgList 改为返回缓存的 Promise,可被 await
2. 在 setValue 的诊疗医嘱分支中 await getOrgList(),确保 org 树加载完成后再查找科室名称
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -2078,10 +2078,17 @@ function selectAdviceBase(key, row) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 🔧 Bug #455: 缓存 org 列表加载 Promise,确保 setValue 中可 await 避免竞态条件
|
||||||
|
let orgListPromise = null;
|
||||||
|
|
||||||
function getOrgList() {
|
function getOrgList() {
|
||||||
getOrgTree().then((res) => {
|
if (!orgListPromise) {
|
||||||
organization.value = res.data.records;
|
orgListPromise = getOrgTree().then((res) => {
|
||||||
});
|
organization.value = res.data.records;
|
||||||
|
return organization.value;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return orgListPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 诊疗医嘱关联检验申请时 contentJson 含 applyNo */
|
/** 诊疗医嘱关联检验申请时 contentJson 含 applyNo */
|
||||||
@@ -3453,7 +3460,9 @@ async function setValue(row) {
|
|||||||
console.log('[BugFix] setValue - prescriptionList[rowIndex].adviceType_dictText:', prescriptionList.value[rowIndex.value].adviceType_dictText);
|
console.log('[BugFix] setValue - prescriptionList[rowIndex].adviceType_dictText:', prescriptionList.value[rowIndex.value].adviceType_dictText);
|
||||||
// 🔧 Bug #455: 诊疗医嘱(adviceType=3)的执行科室默认使用患者就诊科室,
|
// 🔧 Bug #455: 诊疗医嘱(adviceType=3)的执行科室默认使用患者就诊科室,
|
||||||
// 不使用positionId(诊疗目录配置的执行科室),避免配置ID不在机构树中导致显示原始ID
|
// 不使用positionId(诊疗目录配置的执行科室),避免配置ID不在机构树中导致显示原始ID
|
||||||
|
// 关键修复:await organization 加载完成,确保 findOrgNameById 能正确查找到科室名称
|
||||||
if (Number(row.adviceType) == 3) {
|
if (Number(row.adviceType) == 3) {
|
||||||
|
await getOrgList();
|
||||||
// 覆盖 catalog 传来的 positionId/orgId,使用患者就诊科室
|
// 覆盖 catalog 传来的 positionId/orgId,使用患者就诊科室
|
||||||
prescriptionList.value[rowIndex.value].orgId = props.patientInfo?.orgId;
|
prescriptionList.value[rowIndex.value].orgId = props.patientInfo?.orgId;
|
||||||
prescriptionList.value[rowIndex.value].positionId = props.patientInfo?.orgId;
|
prescriptionList.value[rowIndex.value].positionId = props.patientInfo?.orgId;
|
||||||
|
|||||||
Reference in New Issue
Block a user