Fix Bug #559: 住院医生站-临床医嘱 组套功能添加医嘱后新增医嘱置顶显示

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-20 10:15:13 +08:00
parent c7da7440f6
commit 2db79e3ac9

View File

@@ -1579,11 +1579,21 @@ function handleSaveGroup(orderGroupList) {
let successCount = 0;
// 收集所有要添加的新行,最后统一 unshift 到数组开头(置顶显示)
const newRows = [];
orderGroupList.forEach((item) => {
rowIndex.value = prescriptionList.value.length;
// 使用临时索引,先追加到末尾用于 setValue 填充
const tempIndex = prescriptionList.value.length;
prescriptionList.value[tempIndex] = {
uniqueKey: nextId.value++,
isEdit: false,
statusEnum: 1,
};
if (!item) {
console.warn('组套中的项目为空');
prescriptionList.value.splice(tempIndex, 1);
return;
}
@@ -1609,18 +1619,12 @@ function handleSaveGroup(orderGroupList) {
therapyEnum: item.orderDetailInfos?.therapyEnum || '1',
};
// 预初始化空行(组套项带预填值,设为 false 让明细字段在表格中直接展示)
prescriptionList.value[rowIndex.value] = {
uniqueKey: nextId.value++,
isEdit: false,
statusEnum: 1,
};
rowIndex.value = tempIndex;
setValue(mergedDetail);
// 创建新的处方项目
const newRow = {
...prescriptionList.value[rowIndex.value],
...prescriptionList.value[tempIndex],
patientId: patientInfo.value.patientId,
encounterId: patientInfo.value.encounterId,
accountId: accountId.value,
@@ -1639,12 +1643,12 @@ function handleSaveGroup(orderGroupList) {
orgId: resolveOrgId(mergedDetail.orgId || patientInfo.value?.inHospitalOrgId) || '',
// 🔧 修复:同时存储 orgName确保树匹配不到时仍有中文名称可显示
orgName: findOrgName(mergedDetail.orgId || patientInfo.value?.inHospitalOrgId) || mergedDetail.orgName || patientInfo.value?.inHospitalOrgName || '',
dbOpType: prescriptionList.value[rowIndex.value].requestId ? '2' : '1',
dbOpType: prescriptionList.value[tempIndex].requestId ? '2' : '1',
conditionId: conditionId.value,
conditionDefinitionId: conditionDefinitionId.value,
encounterDiagnosisId: encounterDiagnosisId.value,
diagnosisName: diagnosisName.value,
therapyEnum: prescriptionList.value[rowIndex.value]?.therapyEnum || mergedDetail.therapyEnum || '1',
therapyEnum: prescriptionList.value[tempIndex]?.therapyEnum || mergedDetail.therapyEnum || '1',
// 🔧 修复:确保组套医嘱的 categoryEnum 被正确映射,防止后端 NPE
categoryEnum: mergedDetail?.categoryEnum || mergedDetail?.categoryCode || item?.categoryCode,
};
@@ -1663,11 +1667,13 @@ function handleSaveGroup(orderGroupList) {
}
newRow.contentJson = JSON.stringify(newRow);
prescriptionList.value[rowIndex.value] = newRow;
newRows.push(newRow);
successCount++;
});
if (successCount > 0) {
// 统一添加到数组开头(置顶显示)
if (newRows.length > 0) {
prescriptionList.value.unshift(...newRows);
proxy.$modal.msgSuccess(`成功添加 ${successCount} 个医嘱项`);
}
}