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) {