修复西药处方单bug

This commit is contained in:
2025-11-25 13:49:38 +08:00
parent 250d7dde34
commit 50ef9e6743

View File

@@ -1604,7 +1604,15 @@ function selectAdviceBase(key, row) {
let targetIndex = -1; let targetIndex = -1;
let targetRow = null; let targetRow = null;
// 遍历所有处方找到对应的行 // 1. 首先在当前处方的prescriptionList中查找
const currentIndex = prescriptionList.value.findIndex((item) => item.uniqueKey === key);
if (currentIndex !== -1) {
// 在当前处方中找到匹配的行
targetPrescriptionId = currentPrescriptionId.value;
targetIndex = currentIndex;
targetRow = prescriptionList.value[currentIndex];
} else {
// 2. 如果当前处方中找不到,遍历所有处方找到对应的行
for (const prescription of westernPrescriptions.value) { for (const prescription of westernPrescriptions.value) {
const prescriptionData = allPrescriptionsData.value[prescription.id] || []; const prescriptionData = allPrescriptionsData.value[prescription.id] || [];
const index = prescriptionData.findIndex((item) => item.uniqueKey === key); const index = prescriptionData.findIndex((item) => item.uniqueKey === key);
@@ -1615,6 +1623,7 @@ function selectAdviceBase(key, row) {
break; break;
} }
} }
}
if (targetIndex === -1) { if (targetIndex === -1) {
console.error('找不到对应的行数据, uniqueKey:', key); console.error('找不到对应的行数据, uniqueKey:', key);
@@ -2285,6 +2294,13 @@ function handleSaveBatch(prescriptionId) {
return item.statusEnum == 1 && !item.isSaved; return item.statusEnum == 1 && !item.isSaved;
}) })
.map((item) => { .map((item) => {
// 为每个医嘱项设置minUnitQuantity值避免后端null值异常
if (item.adviceType == 1 || item.adviceType == 2) {
item.minUnitQuantity = item.minUnitCode == item.unitCode ? item.quantity : item.quantity * item.partPercent;
} else {
item.minUnitQuantity = item.quantity;
}
// 将前端的耗材类型4转换为后端需要的类型2 // 将前端的耗材类型4转换为后端需要的类型2
const saveAdviceType = item.adviceType == 4 ? 2 : item.adviceType; const saveAdviceType = item.adviceType == 4 ? 2 : item.adviceType;