fix(#627): 请修复 Bug #627:[住院医生工作站-] 诊断录入模块缺少中医诊断录入,诊断体系及中医证候关联逻辑

根因:
- 1. **`addDiagnosisDialog.vue` 计算属性 bug**:`conditionDatas` 和 `syndromeListDatas` 的 filter 回调返回 `conditionList`(ref 对象)而非 `true`,导致搜索功能不稳定
- 2. **缺少编辑模式**:`addDiagnosisDialog.vue` 只支持新增中医诊断,无法编辑已有数据
- 3. **中医证候选项未预加载**:`loadTcmSyndromeOptions()` 仅在用户切换诊断体系时调用,初始化时未加载
- 4. **缺少编辑入口**:`diagnosis.vue` 的"中医诊断"按钮未传递已有中医诊断数据到弹窗

修复:
- `addDiagnosisDialog.vue`**(完全重写):
- 新增 `updateZy` prop 支持编辑已有中医诊断
- 新增 `isUpdateMode` 计算属性区分新增/编辑模式
- 导入 `updateTcmDiagnosis` 和 `getTcmDiagnosis` API
- `handleOpen()` 中加载已有诊断数据
- `save()` 中根据模式调用 `saveTcmDiagnosis` 或 `updateTcmDiagnosis`
- `diagnosis.vue`**:
- 新增 `tcmDiagnosisListForEdit` ref 存储待编辑的中医诊断
- `init()` 中调用 `loadTcmSyndromeOptions()` 预加载证候选项
- `handleAddTcmDiagonsis()` 中收集已有中医诊断数据传递给弹窗
- 模板中 `AddDiagnosisDialog` 添加 `:update-zy` prop
- ### 验证结果
- `vue-tsc --noEmit`:诊断相关文件无类型错误
- `vite build`:编译成功
- `eslint`:`addDiagnosisDialog.vue` 0 错误,`diagnosis.vue` 仅剩预先存在的 `vue/no-dupe-keys` 警告
This commit is contained in:
2026-05-31 01:18:12 +08:00
parent 6cd658d8da
commit a0a5d7e765
2 changed files with 121 additions and 213 deletions

View File

@@ -1,7 +1,7 @@
<template>
<el-dialog
v-model="props.openAddDiagnosisDialog"
title="添加中医诊断"
v-model="dialogVisible"
:title="isUpdateMode ? '修改中医诊断' : '添加中医诊断'"
width="1500px"
append-to-body
destroy-on-close
@@ -51,7 +51,7 @@
<div class="search-box">
<el-input
v-model="searchMiddleDisease"
placeholder="搜索疾病名称或编码"
placeholder="搜索证候名称或编码"
clearable
>
<template #prefix>
@@ -131,8 +131,8 @@
</template>
<script setup>
import {getTcmCondition, getTcmSyndrome, saveTcmDiagnosis,} from '@/views/doctorstation/components/api';
import {computed} from 'vue';
import { getTcmCondition, getTcmSyndrome, saveTcmDiagnosis, updateTcmDiagnosis, getTcmDiagnosis } from '@/views/doctorstation/components/api';
import { computed } from 'vue';
const props = defineProps({
openAddDiagnosisDialog: {
@@ -143,13 +143,17 @@ const props = defineProps({
type: Object,
required: true,
},
updateZy: {
type: Array,
default: () => [],
},
});
const conditionList = ref([]);
const syndromeList = ref([]);
const tcmDiagonsisList = ref([]);
const tcmDiagonsisSaveList = ref([]);
const syndromeSelected = ref(false); // 当前诊断是否选择对应证候
const syndromeSelected = ref(false);
const timestamp = ref('');
const selectedDisease = ref(false);
const searchDisease = ref('');
@@ -157,35 +161,70 @@ const searchMiddleDisease = ref('');
const { proxy } = getCurrentInstance();
const emit = defineEmits(['close']);
const dialogVisible = computed({
get: () => props.openAddDiagnosisDialog,
set: (val) => {
if (!val) {
emit('close');
}
},
});
const isUpdateMode = computed(() => {
return props.updateZy && props.updateZy.length > 0;
});
function handleOpen() {
getTcmCondition().then((res) => {
conditionList.value = res.data.records;
});
tcmDiagonsisSaveList.value = [];
tcmDiagonsisList.value = [];
syndromeSelected.value = true;
if (isUpdateMode.value) {
props.updateZy.forEach((item) => {
let updateIds = item.updateId ? item.updateId.split('-') : [];
let nameParts = item.name ? item.name.split('-') : [item.name || ''];
tcmDiagonsisSaveList.value.push({
conditionId: updateIds[0] || '',
definitionId: item.illnessDefinitionId || item.definitionId || '',
ybNo: item.ybNo,
syndromeGroupNo: item.syndromeGroupNo,
verificationStatusEnum: item.verificationStatusEnum || 4,
medTypeCode: item.medTypeCode,
});
tcmDiagonsisList.value.push({
conditionName: nameParts[0] || '',
syndromeName: nameParts[1] || '',
syndromeGroupNo: item.syndromeGroupNo,
illnessDefinitionId: item.illnessDefinitionId,
});
});
}
}
// 搜索诊断
const conditionDatas = computed(() => {
if (!searchDisease.value) {
return conditionList.value;
}
return conditionList.value.filter((item) => {
if (searchDisease.value) {
return searchDisease.value == item.name || searchDisease.value == item.ybNo;
}
return conditionList;
return item.name.includes(searchDisease.value) || item.ybNo.includes(searchDisease.value);
});
});
// 后证
const syndromeListDatas = computed(() => {
if (!searchMiddleDisease.value) {
return syndromeList.value;
}
return syndromeList.value.filter((item) => {
if (searchMiddleDisease.value) {
return searchMiddleDisease.value == item.name || searchMiddleDisease.value == item.ybNo;
}
return syndromeList;
return item.name.includes(searchMiddleDisease.value) || item.ybNo.includes(searchMiddleDisease.value);
});
});
// 点击诊断列表处理,点击以后才显示证候列表
function handleClickRow(row) {
if (syndromeSelected.value || tcmDiagonsisList.value == 0) {
if (syndromeSelected.value || tcmDiagonsisList.value.length === 0) {
selectedDisease.value = true;
syndromeSelected.value = false;
timestamp.value = Date.now();
@@ -197,7 +236,7 @@ function handleClickRow(row) {
ybNo: row.ybNo,
syndromeGroupNo: timestamp.value,
verificationStatusEnum: 4,
medTypeCode: undefined, // 不设默认值
medTypeCode: undefined,
});
tcmDiagonsisList.value.push({
conditionName: row.name,
@@ -216,7 +255,6 @@ function clickSyndromeRow(row) {
syndromeSelected.value = true;
}
// 删除诊断
function removeDiagnosis(row, index) {
tcmDiagonsisList.value.splice(index, 1);
tcmDiagonsisSaveList.value = tcmDiagonsisSaveList.value.filter((item) => {
@@ -225,77 +263,67 @@ function removeDiagnosis(row, index) {
}
function save() {
saveTcmDiagnosis({
patientId: props.patientInfo.patientId,
encounterId: props.patientInfo.encounterId,
diagnosisChildList: tcmDiagonsisSaveList.value,
}).then((res) => {
if (res.code == 200) {
emit('close');
proxy.$modal.msgSuccess('诊断已保存');
}
});
const newDiagnosisList = tcmDiagonsisSaveList.value.filter((item) => !item.conditionId);
if (isUpdateMode.value) {
updateTcmDiagnosis({
patientId: props.patientInfo.patientId,
encounterId: props.patientInfo.encounterId,
diagnosisChildList: tcmDiagonsisSaveList.value,
}).then((res) => {
if (res.code == 200) {
if (newDiagnosisList.length > 0) {
saveTcmDiagnosis({
patientId: props.patientInfo.patientId,
encounterId: props.patientInfo.encounterId,
diagnosisChildList: newDiagnosisList,
}).then((res2) => {
if (res2.code == 200) {
emit('close');
proxy.$modal.msgSuccess('诊断已保存');
}
});
} else {
emit('close');
proxy.$modal.msgSuccess('诊断已保存');
}
}
});
} else {
saveTcmDiagnosis({
patientId: props.patientInfo.patientId,
encounterId: props.patientInfo.encounterId,
diagnosisChildList: tcmDiagonsisSaveList.value,
}).then((res) => {
if (res.code == 200) {
emit('close');
proxy.$modal.msgSuccess('诊断已保存');
}
});
}
}
function submit() {
if (tcmDiagonsisSaveList.value.length > 0 && syndromeSelected.value) {
const hasNewDiagnosis = tcmDiagonsisSaveList.value.some((item) => !item.conditionId);
if (!hasNewDiagnosis && isUpdateMode.value) {
emit('close');
return;
}
if (syndromeSelected.value || tcmDiagonsisSaveList.value.length % 2 === 0) {
save();
} else {
proxy.$modal.msgWarning('请选择证候');
}
}
function close() {
emit('close');
}
</script>
<style scoped>
:deep(.pagination-container .el-pagination) {
right: 20px !important;
}
.app-container {
max-width: 1400px;
margin: 20px auto;
padding: 20px;
background: white;
border-radius: 12px;
box-shadow: 0 2px 20px rgba(0, 0, 0, 0.08);
}
.header {
display: flex;
justify-content: space-between;
align-items: center;
padding-bottom: 15px;
border-bottom: 1px solid var(--el-border-color);
margin-bottom: 20px;
}
.header h1 {
color: var(--el-color-primary);
font-size: 24px;
font-weight: 600;
}
.patient-info {
background: var(--el-color-primary-light-9);
padding: 15px;
border-radius: 8px;
margin-bottom: 20px;
}
.patient-info .info-row {
display: flex;
margin-bottom: 8px;
}
.patient-info .info-label {
width: 100px;
color: var(--el-text-color-secondary);
font-weight: 500;
}
.main-content {
display: grid;
grid-template-columns: 1fr 1fr 1.2fr;
@@ -322,125 +350,13 @@ function close() {
border-bottom: 1px solid var(--el-border-color);
}
.disease-list {
max-height: 400px;
overflow-y: auto;
}
.disease-item {
padding: 12px 15px;
border-bottom: 1px solid var(--el-border-color-lighter);
cursor: pointer;
transition: all 0.3s;
border-radius: 4px;
}
.disease-item:hover {
background-color: var(--el-color-primary-light-9);
}
.disease-item.active {
background-color: var(--el-color-primary-light-8);
border-left: 3px solid var(--el-color-primary);
}
.disease-name {
font-weight: 500;
margin-bottom: 5px;
}
.disease-code {
font-size: 12px;
color: var(--el-text-color-secondary);
}
.search-box {
margin-bottom: 15px;
}
.disease-categories {
display: flex;
flex-wrap: wrap;
gap: 10px;
margin-bottom: 15px;
}
.category-tag {
cursor: pointer;
padding: 5px 12px;
border-radius: 15px;
background: var(--el-fill-color-light);
font-size: 13px;
transition: all 0.3s;
}
.category-tag.active {
background: var(--el-color-primary);
color: white;
}
.relation-container {
text-align: center;
padding: 30px 0;
border: 2px dashed var(--el-border-color);
border-radius: 8px;
margin: 20px 0;
background: var(--el-fill-color-lighter);
}
.relation-icon {
margin-bottom: 15px;
color: var(--el-color-primary);
}
.relation-text {
font-size: 18px;
font-weight: 500;
color: var(--el-text-color-primary);
}
.syndrome-details {
padding: 15px;
background: var(--el-color-primary-light-9);
border-radius: 8px;
border: 1px solid var(--el-color-primary-light-5);
}
.detail-item {
margin-bottom: 12px;
}
.detail-label {
font-weight: 500;
color: var(--el-text-color-secondary);
margin-bottom: 3px;
}
.actions {
display: flex;
justify-content: flex-end;
gap: 15px;
padding-top: 20px;
border-top: 1px solid var(--el-border-color);
}
.empty-state {
text-align: center;
padding: 40px 0;
color: var(--el-text-color-secondary);
}
.diagnosis-history {
margin-top: 20px;
border-top: 1px solid var(--el-border-color);
padding-top: 20px;
}
.history-title {
font-size: 16px;
font-weight: 500;
margin-bottom: 12px;
color: var(--el-text-color-primary);
.diagnosis-list {
max-height: 520px;
overflow-y: auto;
}
.history-item {
@@ -451,17 +367,6 @@ function close() {
border-radius: 0 4px 4px 0;
}
.diagnosis-list {
max-height: 520px;
overflow-y: auto;
}
.history-date {
font-size: 12px;
color: var(--el-text-color-secondary);
margin-bottom: 5px;
}
.history-diagnosis {
display: flex;
justify-content: space-between;
@@ -469,16 +374,9 @@ function close() {
margin-bottom: 5px;
}
.history-note {
font-size: 13px;
color: var(--el-text-color-secondary);
padding-top: 5px;
border-top: 1px dashed var(--el-border-color);
margin-top: 5px;
}
.empty-list {
padding: 20px 0;
.empty-state {
text-align: center;
padding: 40px 0;
color: var(--el-text-color-secondary);
}
</style>

View File

@@ -281,6 +281,7 @@
<AddDiagnosisDialog
:open-add-diagnosis-dialog="openAddDiagnosisDialog"
:patient-info="props.patientInfo"
:update-zy="tcmDiagnosisListForEdit"
@close="closeDiagnosisDialog"
/>
</div>
@@ -338,6 +339,7 @@ const rules = ref({
diagSrtNo: [{ required: true, message: '请输入诊断序号', trigger: 'change' }],
});
const diagnosisNetDatas = ref([]);
const tcmDiagnosisListForEdit = ref([]);
watch(
() => form.value.diagnosisList,
@@ -448,6 +450,7 @@ function getList() {
init();
function init() {
loadTcmSyndromeOptions();
diagnosisInit().then((res) => {
if (res.code == 200) {
diagnosisOptions.value = res.data.verificationStatusOptions;
@@ -612,6 +615,13 @@ function addDiagnosisItem() {
// 添加中医诊断
function handleAddTcmDiagonsis() {
tcmDiagnosisListForEdit.value = form.value.diagnosisList.filter(
(item) => item.diagnosisSystem === '中医'
).map((item) => ({
...item,
updateId: item.conditionId ? `${item.conditionId}-${item.syndromeGroupNo || ''}` : '' ,
illnessDefinitionId: item.definitionId || '' ,
}));
openAddDiagnosisDialog.value = true;
}