首页页面进行了初步优化
This commit is contained in:
@@ -2,19 +2,17 @@
|
||||
<div>
|
||||
<el-row :gutter="24">
|
||||
<el-col :span="4" :xs="24">
|
||||
<div style="height: 44px; display: flex; align-items: center; flex: none">
|
||||
<el-input
|
||||
v-model="diagnosis"
|
||||
placeholder="诊断名称"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
@keyup.enter="queryDiagnosisUse"
|
||||
>
|
||||
<template #append>
|
||||
<el-button icon="Search" @click="queryDiagnosisUse" />
|
||||
</template>
|
||||
</el-input>
|
||||
</div>
|
||||
<el-input
|
||||
v-model="diagnosis"
|
||||
placeholder="诊断名称"
|
||||
clearable
|
||||
style="width: 100%; margin-bottom: 10px"
|
||||
@keyup.enter="queryDiagnosisUse"
|
||||
>
|
||||
<template #append>
|
||||
<el-button icon="Search" @click="queryDiagnosisUse" />
|
||||
</template>
|
||||
</el-input>
|
||||
<el-tree
|
||||
ref="treeRef"
|
||||
:data="tree"
|
||||
@@ -68,16 +66,21 @@
|
||||
</el-tree>
|
||||
</el-col>
|
||||
<el-col :span="20" :xs="24">
|
||||
<div style="height: 44px; display: flex; align-items: center; flex: none">
|
||||
<div style="margin-bottom: 10px">
|
||||
<el-button type="primary" plain @click="handleAddDiagnosis()"> 新增诊断 </el-button>
|
||||
<el-button type="primary" plain @click="handleSaveDiagnosis()"> 保存诊断 </el-button>
|
||||
<el-button type="primary" plain @click="handleAddTcmDiagonsis()"> 中医诊断 </el-button>
|
||||
<el-button type="primary" plain @click="handleImport()"> 导入慢性病诊断 </el-button>
|
||||
</div>
|
||||
|
||||
<el-form :model="form" :rules="rules" ref="formRef">
|
||||
<el-table ref="diagnosisTableRef" :data="form.diagnosisList" height="650">
|
||||
<el-table-column label="序号" type="index" width="50" />
|
||||
<el-table-column label="诊断排序" align="center" prop="diagSrtNo" width="180">
|
||||
<el-table-column label="序号" width="50" >
|
||||
<template #default="scope">
|
||||
{{ scope.$index + 1 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="诊断排序" align="center" prop="diagSrtNo" width="120">
|
||||
<template #default="scope">
|
||||
<el-form-item
|
||||
:prop="`diagnosisList.${scope.$index}.diagSrtNo`"
|
||||
@@ -136,9 +139,13 @@
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="医保码" align="center" prop="ybNo" width="180" />
|
||||
<el-table-column label="诊断类型" align="center" prop="maindiseFlag">
|
||||
|
||||
<el-table-column label="诊断医生" align="center" prop="diagnosisDoctor" width="120" />
|
||||
<el-table-column label="诊断时间" align="center" prop="diagnosisTime" width="150" />
|
||||
<el-table-column label="诊断代码" align="center" prop="ybNo" width="180" />
|
||||
<el-table-column label="诊断类型" align="center" prop="maindiseFlag" width="120">
|
||||
<template #default="scope">
|
||||
<div style="display:flex;flex-direction:column;align-items:center;gap:5px;">
|
||||
<el-checkbox
|
||||
label="主诊断"
|
||||
:trueLabel="1"
|
||||
@@ -151,7 +158,7 @@
|
||||
<el-select
|
||||
v-model="scope.row.verificationStatusEnum"
|
||||
placeholder=" "
|
||||
style="width: 40%; padding-bottom: 5px; padding-left: 10px"
|
||||
style="width: 100%; padding-bottom: 5px; padding-left: 10px"
|
||||
size="small"
|
||||
>
|
||||
<el-option
|
||||
@@ -161,6 +168,7 @@
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" width="130">
|
||||
@@ -185,28 +193,30 @@
|
||||
/>
|
||||
<AddDiagnosisDialog
|
||||
:openAddDiagnosisDialog="openAddDiagnosisDialog"
|
||||
:patientInfo="patientInfo"
|
||||
:patientInfo="props.patientInfo"
|
||||
@close="closeDiagnosisDialog"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { getCurrentInstance } from 'vue';
|
||||
import { getCurrentInstance, nextTick } from 'vue'; // 添加 nextTick 导入
|
||||
import useUserStore from '@/store/modules/user';
|
||||
import {
|
||||
getConditionDefinitionInfo,
|
||||
saveDiagnosis,
|
||||
diagnosisInit,
|
||||
deleteDiagnosisBind,
|
||||
getEncounterDiagnosis,
|
||||
getEmrDetail,
|
||||
getChronicDisease,
|
||||
getTcmDiagnosis,
|
||||
delEncounterDiagnosis,
|
||||
isFoodDiseasesNew,
|
||||
} from '../api';
|
||||
import diagnosisdialog from '../diagnosis/diagnosisdialog.vue';
|
||||
import AddDiagnosisDialog from './addDiagnosisDialog.vue';
|
||||
import diagnosislist from '../diagnosis/diagnosislist.vue';
|
||||
import { patientInfo } from '../../store/patient.js';
|
||||
// const diagnosisList = ref([]);
|
||||
const allowAdd = ref(false);
|
||||
const tree = ref([]);
|
||||
@@ -228,50 +238,93 @@ const props = defineProps({
|
||||
});
|
||||
const emits = defineEmits(['diagnosisSave']);
|
||||
const { proxy } = getCurrentInstance();
|
||||
const userStore = useUserStore();
|
||||
const { med_type } = proxy.useDict('med_type');
|
||||
const rules = ref({
|
||||
name: [{ required: true, message: '请选择诊断', trigger: 'change' }],
|
||||
medTypeCode: [{ required: true, message: '请选择诊断类型', trigger: 'change' }],
|
||||
diagSrtNo: [{ required: true, message: '请输入诊断序号', trigger: 'change' }],
|
||||
});
|
||||
|
||||
const isSaving = ref(false);
|
||||
watch(
|
||||
() => form.value.diagnosisList,
|
||||
() => {
|
||||
emits('diagnosisSave', false);
|
||||
// 如果正在保存,则不触发更新事件
|
||||
if (!isSaving.value) {
|
||||
emits('diagnosisSave', false);
|
||||
}
|
||||
},
|
||||
{ deep: true }
|
||||
);
|
||||
|
||||
// function getDetail(encounterId) {
|
||||
// getEmrDetail(encounterId).then((res) => {
|
||||
// allowAdd.value = res.data ? true : false;
|
||||
// });
|
||||
// }
|
||||
function getDetail(encounterId) {
|
||||
if (!encounterId) {
|
||||
console.warn('未提供有效的就诊ID,无法获取病历详情');
|
||||
return;
|
||||
}
|
||||
|
||||
getEmrDetail(encounterId).then((res) => {
|
||||
allowAdd.value = res.data ? true : false;
|
||||
});
|
||||
}
|
||||
|
||||
function getList() {
|
||||
getEncounterDiagnosis(patientInfo.value.encounterId).then((res) => {
|
||||
if (!props.patientInfo || !props.patientInfo.encounterId) {
|
||||
console.warn('患者就诊信息不完整,无法获取诊断数据');
|
||||
return;
|
||||
}
|
||||
|
||||
getEncounterDiagnosis(props.patientInfo.encounterId).then((res) => {
|
||||
if (res.code == 200) {
|
||||
form.value.diagnosisList = res.data;
|
||||
// 为每个诊断项添加默认的诊断医生和时间(如果不存在)
|
||||
const diagnosisList = res.data.map(item => ({
|
||||
...item,
|
||||
diagnosisDoctor: item.diagnosisDoctor || props.patientInfo.practitionerName || props.patientInfo.doctorName || props.patientInfo.physicianName || userStore.name,
|
||||
diagnosisTime: item.diagnosisTime || new Date().toLocaleString('zh-CN')
|
||||
}));
|
||||
|
||||
// 对获取的数据进行排序
|
||||
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;
|
||||
});
|
||||
|
||||
form.value.diagnosisList = diagnosisList;
|
||||
emits('diagnosisSave', false);
|
||||
console.log(form.value.diagnosisList);
|
||||
}
|
||||
});
|
||||
getTcmDiagnosis({ encounterId: patientInfo.value.encounterId }).then((res) => {
|
||||
|
||||
getTcmDiagnosis({ encounterId: props.patientInfo.encounterId }).then((res) => {
|
||||
if (res.code == 200) {
|
||||
if (res.data.illness.length > 0) {
|
||||
if (res.data.illness && res.data.illness.length > 0 && res.data.symptom) {
|
||||
const newList = [];
|
||||
res.data.illness.forEach((item, index) => {
|
||||
form.value.diagnosisList.push({
|
||||
name: item.name + '-' + res.data.symptom[index].name,
|
||||
newList.push({
|
||||
name: item.name + '-' + (res.data.symptom[index]?.name || ''),
|
||||
ybNo: item.ybNo,
|
||||
medTypeCode: item.medTypeCode,
|
||||
diagnosisDoctor: props.patientInfo.practitionerName || props.patientInfo.doctorName || props.patientInfo.physicianName || userStore.name,
|
||||
diagnosisTime: new Date().toLocaleString('zh-CN')
|
||||
});
|
||||
});
|
||||
|
||||
// 将新数据添加到现有列表中
|
||||
form.value.diagnosisList.push(...newList);
|
||||
|
||||
// 重新排序整个列表
|
||||
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;
|
||||
});
|
||||
}
|
||||
emits('diagnosisSave', false);
|
||||
console.log(form.value.diagnosisList);
|
||||
}
|
||||
});
|
||||
|
||||
getTree();
|
||||
}
|
||||
|
||||
@@ -285,19 +338,28 @@ function init() {
|
||||
}
|
||||
|
||||
function handleImport() {
|
||||
if (patientInfo.value.contractName != '自费') {
|
||||
if (!props.patientInfo || !props.patientInfo.encounterId) {
|
||||
console.warn('患者就诊信息不完整,无法导入慢性病信息');
|
||||
return;
|
||||
}
|
||||
|
||||
if (props.patientInfo.contractName != '自费') {
|
||||
// 获取患者慢性病信息
|
||||
getChronicDisease({ encounterId: patientInfo.value.encounterId }).then((res) => {
|
||||
if (res.data.length > 0) {
|
||||
getChronicDisease({ encounterId: props.patientInfo.encounterId }).then((res) => {
|
||||
if (res.data && res.data.length > 0) {
|
||||
res.data.forEach((item, index) => {
|
||||
form.value.diagnosisList.push({
|
||||
...item,
|
||||
...{
|
||||
medTypeCode: '140104',
|
||||
verificationStatusEnum: 4,
|
||||
definitionId: item.id,
|
||||
diagSrtNo: form.value.diagnosisList.length + 1,
|
||||
},
|
||||
...item,
|
||||
...{
|
||||
medTypeCode: '140104',
|
||||
verificationStatusEnum: 4,
|
||||
definitionId: item.id,
|
||||
diagSrtNo: form.value.diagnosisList.length + 1,
|
||||
iptDiseTypeCode: 2,
|
||||
diagnosisDesc: '',
|
||||
diagnosisDoctor: props.patientInfo.practitionerName || props.patientInfo.doctorName || props.patientInfo.physicianName || userStore.name,
|
||||
diagnosisTime: new Date().toLocaleString('zh-CN')
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -340,7 +402,8 @@ const filterNode = (value, data) => {
|
||||
* 获取诊断树列表
|
||||
*/
|
||||
function getTree() {
|
||||
getConditionDefinitionInfo(patientInfo.value ? patientInfo.value.patientId : '').then((res) => {
|
||||
const patientId = props.patientInfo?.patientId || '';
|
||||
getConditionDefinitionInfo(patientId).then((res) => {
|
||||
if (res.code == 200) {
|
||||
let list = [];
|
||||
list = res.data.patientHistoryList;
|
||||
@@ -377,14 +440,20 @@ function getTree() {
|
||||
function handleAddDiagnosis() {
|
||||
proxy.$refs.formRef.validate((valid) => {
|
||||
if (valid) {
|
||||
if (!allowAdd.value) {
|
||||
proxy.$modal.msgWarning('请先填写病历');
|
||||
return;
|
||||
}
|
||||
form.value.diagnosisList.push({
|
||||
showPopover: false,
|
||||
name: undefined,
|
||||
verificationStatusEnum: 4,
|
||||
medTypeCode: '21',
|
||||
medTypeCode: '11',
|
||||
diagSrtNo: form.value.diagnosisList.length + 1,
|
||||
iptDiseTypeCode: 31,
|
||||
iptDiseTypeCode: 2,
|
||||
diagnosisDesc: '',
|
||||
diagnosisDoctor: props.patientInfo.practitionerName || props.patientInfo.doctorName || props.patientInfo.physicianName || userStore.name,
|
||||
diagnosisTime: new Date().toLocaleString('zh-CN')
|
||||
});
|
||||
if (form.value.diagnosisList.length == 1) {
|
||||
form.value.diagnosisList[0].maindiseFlag = 1;
|
||||
@@ -398,13 +467,31 @@ function handleAddTcmDiagonsis() {
|
||||
openAddDiagnosisDialog.value = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除诊断
|
||||
*/
|
||||
/**
|
||||
* 删除诊断
|
||||
*/
|
||||
function handleDeleteDiagnosis(row, index) {
|
||||
if (row.conditionId) {
|
||||
delEncounterDiagnosis(row.conditionId).then(() => {
|
||||
getList();
|
||||
// 不要立即调用getList(),而是从当前列表中移除
|
||||
form.value.diagnosisList.splice(index, 1);
|
||||
// 重新排序剩余的项目
|
||||
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;
|
||||
});
|
||||
|
||||
// 重新分配连续的序号
|
||||
sortedList.forEach((item, idx) => {
|
||||
item.diagSrtNo = idx + 1;
|
||||
});
|
||||
|
||||
// 更新列表
|
||||
form.value.diagnosisList = sortedList.map(item => ({ ...item }));
|
||||
getTree();
|
||||
});
|
||||
} else {
|
||||
@@ -428,35 +515,72 @@ function handleMaindise(value, index) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存诊断
|
||||
*/
|
||||
/**
|
||||
* 保存诊断
|
||||
*/
|
||||
/**
|
||||
* 保存诊断
|
||||
*/
|
||||
/**
|
||||
* 保存诊断
|
||||
*/
|
||||
function handleSaveDiagnosis() {
|
||||
proxy.$refs.formRef.validate((valid) => {
|
||||
if (valid) {
|
||||
if (form.value.diagnosisList.length == 0) {
|
||||
if (form.value.diagnosisList.length === 0) {
|
||||
proxy.$modal.msgWarning('诊断不能为空');
|
||||
return false;
|
||||
return;
|
||||
} else if (!form.value.diagnosisList.some((diagnosis) => diagnosis.maindiseFlag === 1)) {
|
||||
proxy.$modal.msgWarning('至少添加一条主诊断');
|
||||
} else {
|
||||
saveDiagnosis({
|
||||
patientId: patientInfo.value.patientId,
|
||||
encounterId: patientInfo.value.encounterId,
|
||||
diagnosisChildList: form.value.diagnosisList,
|
||||
}).then((res) => {
|
||||
if (res.code == 200) {
|
||||
getTree();
|
||||
getList();
|
||||
emits('diagnosisSave', false);
|
||||
proxy.$modal.msgSuccess('诊断已保存');
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// 设置保存标志,避免触发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) {
|
||||
// 步骤4:更新本地数据,使用全新对象防止响应式问题
|
||||
form.value.diagnosisList = sortedList.map(item => ({ ...item }));
|
||||
|
||||
emits('diagnosisSave', false);
|
||||
proxy.$modal.msgSuccess('诊断已保存');
|
||||
|
||||
// 食源性疾病逻辑
|
||||
isFoodDiseasesNew({ encounterId: props.patientInfo.encounterId }).then((res2) => {
|
||||
if (res2.code === 20?('data') && res2.data) {
|
||||
window.open(res2.data, '_blank');
|
||||
}
|
||||
});
|
||||
}
|
||||
}).finally(() => {
|
||||
setTimeout(() => {
|
||||
isSaving.value = false;
|
||||
}, 100);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭诊断弹窗
|
||||
*/
|
||||
@@ -519,12 +643,15 @@ function handleNodeClick(data) {
|
||||
medTypeCode: '11',
|
||||
diagSrtNo: form.value.diagnosisList.length + 1,
|
||||
definitionId: data.definitionId,
|
||||
diagnosisDoctor: props.patientInfo.practitionerName || props.patientInfo.doctorName || props.patientInfo.physicianName || userStore.name,
|
||||
diagnosisTime: new Date().toLocaleString('zh-CN')
|
||||
});
|
||||
if (form.value.diagnosisList.length == 1) {
|
||||
form.value.diagnosisList[0].maindiseFlag = 1;
|
||||
}
|
||||
}
|
||||
defineExpose({ getList, handleSaveDiagnosis });
|
||||
|
||||
defineExpose({ getList, getDetail, handleSaveDiagnosis });
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@@ -542,4 +669,5 @@ defineExpose({ getList, handleSaveDiagnosis });
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user