From c74e7395ea30d744049e39270aae63a953a62ffa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=8E=E4=BD=97?= Date: Sun, 31 May 2026 11:06:06 +0800 Subject: [PATCH] =?UTF-8?q?fix(#627):=20=E8=AF=B7=E4=BF=AE=E5=A4=8D=20Bug?= =?UTF-8?q?=20#627=EF=BC=9A[=E4=BD=8F=E9=99=A2=E5=8C=BB=E7=94=9F=E5=B7=A5?= =?UTF-8?q?=E4=BD=9C=E7=AB=99-]=20=E8=AF=8A=E6=96=AD=E5=BD=95=E5=85=A5?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E7=BC=BA=E5=B0=91=E4=B8=AD=E5=8C=BB=E8=AF=8A?= =?UTF-8?q?=E6=96=AD=E5=BD=95=E5=85=A5=EF=BC=8C=E8=AF=8A=E6=96=AD=E4=BD=93?= =?UTF-8?q?=E7=B3=BB=E5=8F=8A=E4=B8=AD=E5=8C=BB=E8=AF=81=E5=80=99=E5=85=B3?= =?UTF-8?q?=E8=81=94=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 根因: - Bug #请修复 Bug #627 存在的问题 修复: - 1. **中医证候与诊断名称无关联** — 选择"中医"时证候选项是全量加载,未按诊断名称筛选 - 2. **保存时缺强提醒** — 只有简单 `msgWarning`,不满足"强提醒"要求 - 3. **选择中医诊断后不自动加载证候** — 需要手动切换诊断体系才触发 - | 修改点 | 文件 | 说明 | - |---|---|---| - | 引入 `ElMessageBox` | `:370` | 从 `element-plus` 额外引入 | - | 证候加载增加参数 | `:775-789` | `loadTcmSyndromeOptions(diagnosisName)` → 传 `conditionName` 筛选 | - | 切换诊断体系联动证候 | `:767-769` | 选择中医时传 `row.name` 加载对应证候 | - | 保存强提醒 | `:883-897` | `ElMessageBox.confirm` 替代 `msgWarning` | - | 选择诊断自动加载证候 | `:975-978` | 选择中医诊断后自动 `loadTcmSyndromeOptions(row.name)` | - | 抽取 `continueSave()` | `:811-856` | 保存逻辑复用,支持强提醒确认后继续保存 | - ## 验证 - ✅ `npm run lint` — 无新增错误(1 个 `Duplicate key 'patientInfo'` 为预存在问题) - ✅ `vite build` — 编译通过,dist 目录正常输出 --- .../home/components/diagnosis/diagnosis.vue | 78 +++++++++++++++++-- 1 file changed, 72 insertions(+), 6 deletions(-) diff --git a/openhis-ui-vue3/src/views/inpatientDoctor/home/components/diagnosis/diagnosis.vue b/openhis-ui-vue3/src/views/inpatientDoctor/home/components/diagnosis/diagnosis.vue index 531dedcc2..84bdae5f7 100755 --- a/openhis-ui-vue3/src/views/inpatientDoctor/home/components/diagnosis/diagnosis.vue +++ b/openhis-ui-vue3/src/views/inpatientDoctor/home/components/diagnosis/diagnosis.vue @@ -367,7 +367,7 @@ 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'; +import {ElMessage, ElMessageBox} from 'element-plus'; // const diagnosisList = ref([]); const allowAdd = ref(false); const isSaving = ref(false); @@ -764,17 +764,21 @@ function handleDiagnosisSystemChange(row, value) { row.tcmSyndromeCode = ''; row.tcmSyndromeName = ''; } - // 当切换到中医时,加载中医证候选项 + // 当切换到中医时,根据诊断名称加载中医证候选项 if (value === '中医') { - loadTcmSyndromeOptions(); + loadTcmSyndromeOptions(row.name || ''); } } /** * 加载中医证候选项 */ -function loadTcmSyndromeOptions() { - getTcmSyndrome().then((res) => { +function loadTcmSyndromeOptions(diagnosisName = '') { + const params = {}; + if (diagnosisName) { + params.conditionName = diagnosisName; + } + getTcmSyndrome(params).then((res) => { if (res.code == 200 && res.data && res.data.records) { tcmSyndromeOptions.value = res.data.records.map((item) => ({ value: item.ybNo, @@ -805,6 +809,49 @@ function handleTcmSyndromeChange(row, value) { /** * 保存诊断 */ + +function continueSave() { + // 设置保存标志,避免触发watch监听器 + isSaving.value = true; + + // 步骤1:深拷贝并按 diagSrtNo 排序 + const sortedList = [...form.value.diagnosisList].sort((a, b) => { + const aNo = typeof a.diagSrtNo === 'number' ? a.diagSrtNo : 9999; + const bNo = typeof b.diagSrtNo === 'number' ? b.diagSrtNo : 9999; + return aNo - bNo; + }); + + // 步骤2:重新分配连续的序号(从1开始) + sortedList.forEach((item, index) => { + item.diagSrtNo = index + 1; // 这里是关键!把"诊断排序"改成新顺序 + }); + + // 步骤3:提交排序后的数据 + saveDiagnosis({ + patientId: props.patientInfo.patientId, + encounterId: props.patientInfo.encounterId, + diagnosisChildList: sortedList, + }).then((res) => { + if (res.code === 200) { + emits('diagnosisSave', false); + proxy.$modal.msgSuccess('诊断已保存'); + + // 保存成功后从服务器重新加载数据,确保前后端数据一致 + getList(); + + // 食源性疾病逻辑 + isFoodDiseasesNew({ encounterId: props.patientInfo.encounterId }).then((res2) => { + if (res2.code === 20 && res2.data) { + window.open(res2.data, '_blank'); + } + }); + } + }).finally(() => { + setTimeout(() => { + isSaving.value = false; + }, 100); + }); +} function handleSaveDiagnosis() { // 防止重复点击保存 if (isSaving.value) { @@ -836,7 +883,21 @@ function handleSaveDiagnosis() { (diagnosis) => diagnosis.diagnosisSystem === '中医' && !diagnosis.tcmSyndromeCode ); if (incompleteTcmDiagnosis) { - proxy.$modal.msgWarning('中医诊断不完整,请录入对应的证候!'); + ElMessageBox.confirm( + '检测到中医诊断未录入证候,保存后可能导致诊断不完整。是否继续保存?', + '中医诊断证候缺失提醒', + { + confirmButtonText: '继续保存', + cancelButtonText: '返回录入', + type: 'warning', + } + ).then(() => { + // 继续保存逻辑 + continueSave(); + }).catch(() => { + // 返回录入 + return; + }); return; } @@ -911,6 +972,11 @@ function handleSelsectDiagnosis(row) { currentItem.name = row.name; currentItem.definitionId = row.id; currentItem.showPopover = false; + + // 如果是中医诊断,自动加载对应的证候 + if (currentItem.diagnosisSystem === '中医') { + loadTcmSyndromeOptions(row.name); + } } /**获取焦点时 打开列表 */ function handleFocus(row, index) {