From ad90af44a214b465f74ce9b8d9d518f1e6c110b3 Mon Sep 17 00:00:00 2001 From: wangjian963 <15215920+aprilry@user.noreply.gitee.com> Date: Wed, 17 Jun 2026 16:47:29 +0800 Subject: [PATCH] =?UTF-8?q?783=20=E3=80=90=E4=BD=8F=E9=99=A2=E5=8C=BB?= =?UTF-8?q?=E7=94=9F=E5=B7=A5=E4=BD=9C=E7=AB=99-=E8=AF=8A=E6=96=AD?= =?UTF-8?q?=E5=BD=95=E5=85=A5=E3=80=91=E6=96=B0=E5=A2=9E=E8=AF=8A=E6=96=AD?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E5=8F=AF=E4=BB=A5=E4=B8=8D=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E4=B8=80=E7=9B=B4=E6=96=B0=E5=A2=9E=E8=AF=8A=E6=96=AD=EF=BC=8C?= =?UTF-8?q?=E4=B8=8D=E7=AC=A6=E5=90=88=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../home/components/diagnosis/diagnosis.vue | 39 ++++++++++++++++--- 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/healthlink-his-ui/src/views/inpatientDoctor/home/components/diagnosis/diagnosis.vue b/healthlink-his-ui/src/views/inpatientDoctor/home/components/diagnosis/diagnosis.vue index 72ae7940a..ff88469d2 100755 --- a/healthlink-his-ui/src/views/inpatientDoctor/home/components/diagnosis/diagnosis.vue +++ b/healthlink-his-ui/src/views/inpatientDoctor/home/components/diagnosis/diagnosis.vue @@ -397,7 +397,7 @@ import {deleteTcmDiagnosis} from '@/views/doctorstation/components/api.js'; import diagnosisdialog from '../diagnosis/diagnosisdialog.vue'; import AddDiagnosisDialog from './addDiagnosisDialog.vue'; import diagnosislist from '../diagnosis/diagnosislist.vue'; -import {patientInfo} from '../../store/patient.js'; + import {ElMessage} from 'element-plus'; // const diagnosisList = ref([]); const allowAdd = ref(false); @@ -472,6 +472,7 @@ function getDetail(encounterId) { if (res.code === 200) { allowAdd.value = res.data ? true : false; console.log('设置 allowAdd =', allowAdd.value, ', 病历数据:', res.data); + } else { allowAdd.value = false; console.warn('获取病历详情失败:', res.msg); } @@ -710,14 +711,40 @@ function getTree() { function handleAddDiagnosis() { console.log('点击新增诊断按钮,allowAdd:', allowAdd.value); - // 检查是否有未填写的空行(名称为空的行),防止不保存一直新增 - const hasEmptyRow = form.value.diagnosisList.some(item => !item.name); - if (hasEmptyRow) { - proxy.$modal.msgWarning('请先完善已有的诊断信息后再新增'); + // 检查当前列表是否已有未保存的诊断,阻止重复新增 + const hasUnsaved = (form.value.diagnosisList || []).some( + (item) => !item.conditionId && !item.encounterDiagnosisId + ); + if (hasUnsaved) { + proxy.$modal.msgWarning('请保存当前诊断'); return; } - addDiagnosisItem(); + // 检查表单ref是否存在 + if (!proxy.$refs.formRef) { + console.error('表单ref不存在'); + // 直接添加诊断,不经过表单验证 + addDiagnosisItem(); + return; + } + + proxy.$refs.formRef.validate((valid, fields) => { + console.log('表单验证结果:', valid, '错误字段:', fields); + if (valid) { + if (!allowAdd.value) { + proxy.$modal.msgWarning('请先填写病历'); + return; + } + addDiagnosisItem(); + } else { + console.warn('表单验证失败:', fields); + // 验证失败时也允许添加(因为是新增空行) + if (allowAdd.value) { + console.log('验证失败但允许添加,强制添加诊断'); + addDiagnosisItem(); + } + } + }); } /**