Fix Bug #559: 住院医生站-临床医嘱 组套功能添加医嘱后新增医嘱置顶显示
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1579,11 +1579,21 @@ function handleSaveGroup(orderGroupList) {
|
|||||||
|
|
||||||
let successCount = 0;
|
let successCount = 0;
|
||||||
|
|
||||||
|
// 收集所有要添加的新行,最后统一 unshift 到数组开头(置顶显示)
|
||||||
|
const newRows = [];
|
||||||
|
|
||||||
orderGroupList.forEach((item) => {
|
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) {
|
if (!item) {
|
||||||
console.warn('组套中的项目为空');
|
console.warn('组套中的项目为空');
|
||||||
|
prescriptionList.value.splice(tempIndex, 1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1609,18 +1619,12 @@ function handleSaveGroup(orderGroupList) {
|
|||||||
therapyEnum: item.orderDetailInfos?.therapyEnum || '1',
|
therapyEnum: item.orderDetailInfos?.therapyEnum || '1',
|
||||||
};
|
};
|
||||||
|
|
||||||
// 预初始化空行(组套项带预填值,设为 false 让明细字段在表格中直接展示)
|
rowIndex.value = tempIndex;
|
||||||
prescriptionList.value[rowIndex.value] = {
|
|
||||||
uniqueKey: nextId.value++,
|
|
||||||
isEdit: false,
|
|
||||||
statusEnum: 1,
|
|
||||||
};
|
|
||||||
|
|
||||||
setValue(mergedDetail);
|
setValue(mergedDetail);
|
||||||
|
|
||||||
// 创建新的处方项目
|
// 创建新的处方项目
|
||||||
const newRow = {
|
const newRow = {
|
||||||
...prescriptionList.value[rowIndex.value],
|
...prescriptionList.value[tempIndex],
|
||||||
patientId: patientInfo.value.patientId,
|
patientId: patientInfo.value.patientId,
|
||||||
encounterId: patientInfo.value.encounterId,
|
encounterId: patientInfo.value.encounterId,
|
||||||
accountId: accountId.value,
|
accountId: accountId.value,
|
||||||
@@ -1639,12 +1643,12 @@ function handleSaveGroup(orderGroupList) {
|
|||||||
orgId: resolveOrgId(mergedDetail.orgId || patientInfo.value?.inHospitalOrgId) || '',
|
orgId: resolveOrgId(mergedDetail.orgId || patientInfo.value?.inHospitalOrgId) || '',
|
||||||
// 🔧 修复:同时存储 orgName,确保树匹配不到时仍有中文名称可显示
|
// 🔧 修复:同时存储 orgName,确保树匹配不到时仍有中文名称可显示
|
||||||
orgName: findOrgName(mergedDetail.orgId || patientInfo.value?.inHospitalOrgId) || mergedDetail.orgName || patientInfo.value?.inHospitalOrgName || '',
|
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,
|
conditionId: conditionId.value,
|
||||||
conditionDefinitionId: conditionDefinitionId.value,
|
conditionDefinitionId: conditionDefinitionId.value,
|
||||||
encounterDiagnosisId: encounterDiagnosisId.value,
|
encounterDiagnosisId: encounterDiagnosisId.value,
|
||||||
diagnosisName: diagnosisName.value,
|
diagnosisName: diagnosisName.value,
|
||||||
therapyEnum: prescriptionList.value[rowIndex.value]?.therapyEnum || mergedDetail.therapyEnum || '1',
|
therapyEnum: prescriptionList.value[tempIndex]?.therapyEnum || mergedDetail.therapyEnum || '1',
|
||||||
// 🔧 修复:确保组套医嘱的 categoryEnum 被正确映射,防止后端 NPE
|
// 🔧 修复:确保组套医嘱的 categoryEnum 被正确映射,防止后端 NPE
|
||||||
categoryEnum: mergedDetail?.categoryEnum || mergedDetail?.categoryCode || item?.categoryCode,
|
categoryEnum: mergedDetail?.categoryEnum || mergedDetail?.categoryCode || item?.categoryCode,
|
||||||
};
|
};
|
||||||
@@ -1663,11 +1667,13 @@ function handleSaveGroup(orderGroupList) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
newRow.contentJson = JSON.stringify(newRow);
|
newRow.contentJson = JSON.stringify(newRow);
|
||||||
prescriptionList.value[rowIndex.value] = newRow;
|
newRows.push(newRow);
|
||||||
successCount++;
|
successCount++;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (successCount > 0) {
|
// 统一添加到数组开头(置顶显示)
|
||||||
|
if (newRows.length > 0) {
|
||||||
|
prescriptionList.value.unshift(...newRows);
|
||||||
proxy.$modal.msgSuccess(`成功添加 ${successCount} 个医嘱项`);
|
proxy.$modal.msgSuccess(`成功添加 ${successCount} 个医嘱项`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user