Fix Bug #559: 组套添加医嘱后新增医嘱置顶 — 根因:handleSaveGroup 只做了 unshift 但未显式排序,导致已有 requestTime 的旧数据与无 requestTime 的新数据混排时顺序不稳定;修复:unshift 后增加按 requestTime 降序排序,确保无 requestTime 的新增组套医嘱始终显示在列表最上方
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1671,6 +1671,13 @@ function handleSaveGroup(orderGroupList) {
|
|||||||
if (newRows.length > 0) {
|
if (newRows.length > 0) {
|
||||||
prescriptionList.value.splice(originalLength); // 移除循环中追加到末尾的临时行
|
prescriptionList.value.splice(originalLength); // 移除循环中追加到末尾的临时行
|
||||||
prescriptionList.value.unshift(...newRows);
|
prescriptionList.value.unshift(...newRows);
|
||||||
|
// 排序:确保没有 requestTime 的新行始终排在最前面
|
||||||
|
prescriptionList.value.sort((a, b) => {
|
||||||
|
if (!a.requestTime && !b.requestTime) return 0;
|
||||||
|
if (!a.requestTime) return -1;
|
||||||
|
if (!b.requestTime) return 1;
|
||||||
|
return new Date(b.requestTime) - new Date(a.requestTime);
|
||||||
|
});
|
||||||
proxy.$modal.msgSuccess(`成功添加 ${successCount} 个医嘱项`);
|
proxy.$modal.msgSuccess(`成功添加 ${successCount} 个医嘱项`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user