Fix Bug #559: 根因+修复方案摘要

This commit is contained in:
2026-05-20 11:06:24 +08:00
parent ee59fd5ea0
commit 021f7180c0

View File

@@ -1575,6 +1575,9 @@ function handleSaveGroup(orderGroupList) {
// 收集所有要添加的新行,最后统一 unshift 到数组开头(置顶显示) // 收集所有要添加的新行,最后统一 unshift 到数组开头(置顶显示)
const newRows = []; const newRows = [];
// 记录循环前的数组长度,用于清理循环中创建的临时行
const originalLength = prescriptionList.value.length;
orderGroupList.forEach((item) => { orderGroupList.forEach((item) => {
// 使用临时索引,先追加到末尾用于 setValue 填充 // 使用临时索引,先追加到末尾用于 setValue 填充
const tempIndex = prescriptionList.value.length; const tempIndex = prescriptionList.value.length;
@@ -1664,8 +1667,9 @@ function handleSaveGroup(orderGroupList) {
successCount++; successCount++;
}); });
// 统一添加到数组开头(置顶显示) // 清理循环中创建的临时行,统一添加到数组开头(置顶显示)
if (newRows.length > 0) { if (newRows.length > 0) {
prescriptionList.value.splice(originalLength); // 移除循环中追加到末尾的临时行
prescriptionList.value.unshift(...newRows); prescriptionList.value.unshift(...newRows);
proxy.$modal.msgSuccess(`成功添加 ${successCount} 个医嘱项`); proxy.$modal.msgSuccess(`成功添加 ${successCount} 个医嘱项`);
} }