Fix Bug #402: 住院医生站诊断录入:点击保存诊断后,列表出现重复记录且部分条目元数据缺失

根因分析:
1. 前端保存按钮无防重复点击保护,连续点击会发送多个请求
2. 保存成功后前端使用本地排序数据更新,未从服务器重新加载,导致前后端数据不一致
3. 后端 saveDoctorDiagnosis 保存后未回写 encounterDiagnosisId,后续保存无法正确更新已有记录

修复方案:
- 前端:在 handleSaveDiagnosis 入口增加 isSaving 守卫,防止重复提交
- 前端:保存成功后调用 getList() 从服务器重新加载数据,确保前后端一致
- 后端:saveOrUpdate 后回写 encounterDiagnosisId 到返回参数,前端可跟踪记录ID

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
赵云
2026-05-14 09:10:21 +08:00
parent 74e0d7f440
commit 7448adae3a
2 changed files with 12 additions and 5 deletions

View File

@@ -261,8 +261,10 @@ public class DoctorStationDiagnosisAppServiceImpl implements IDoctorStationDiagn
// 设置创建时间,避免数据库约束错误
encounterDiagnosis.setCreateTime(new Date());
iEncounterDiagnosisService.saveOrUpdate(encounterDiagnosis);
// 回写就诊诊断ID供前端后续更新使用
saveDiagnosisChildParam.setEncounterDiagnosisId(encounterDiagnosis.getId());
}
return R.ok(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00002, new Object[] {"诊断"}));
return R.ok(saveDiagnosisParam, MessageUtils.createMessage(PromptMsgConstant.Common.M00002, new Object[] {"诊断"}));
}

View File

@@ -568,6 +568,11 @@ function handleMaindise(value, index) {
* 保存诊断
*/
function handleSaveDiagnosis() {
// 防止重复点击保存
if (isSaving.value) {
return;
}
for (let index = 0; index < (form.value.diagnosisList || []).length; index++) {
const item = form.value.diagnosisList[index];
if (!item.diagSrtNo) {
@@ -600,7 +605,7 @@ function handleSaveDiagnosis() {
// 步骤2重新分配连续的序号从1开始
sortedList.forEach((item, index) => {
item.diagSrtNo = index + 1; // 这里是关键!把诊断排序”改成新顺序
item.diagSrtNo = index + 1; // 这里是关键!把诊断排序”改成新顺序
});
// 步骤3提交排序后的数据
@@ -610,12 +615,12 @@ function handleSaveDiagnosis() {
diagnosisChildList: sortedList,
}).then((res) => {
if (res.code === 200) {
// 步骤4更新本地数据使用全新对象防止响应式问题
form.value.diagnosisList = sortedList.map(item => ({ ...item }));
emits('diagnosisSave', false);
proxy.$modal.msgSuccess('诊断已保存');
// 保存成功后从服务器重新加载数据,确保前后端数据一致
getList();
// 食源性疾病逻辑
isFoodDiseasesNew({ encounterId: props.patientInfo.encounterId }).then((res2) => {
if (res2.code === 20 && res2.data) {