Files
his/openhis-ui-vue3/src/views/doctorstation/components/diagnosis/diagnosis.vue
Ranyunqiao 488c311788 288 门诊医生站-》诊断TAB页面:新增诊断点【保存诊断】报错“保存诊断失败,请稍后重试”
289 手术管理-》门诊手术安排:新增手术安排点击【保存】报错提示“新增手术安排失败,请检查表单信息”
298 检查项目设置-》套餐设置:新增个人套餐【保存】报错。
2026-03-30 10:34:48 +08:00

943 lines
30 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div>
<el-row :gutter="24">
<el-col :span="4" :xs="24">
<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"
node-key="id"
:props="{ label: 'name', children: 'children' }"
highlight-current
default-expand-all
:filter-node-method="filterNode"
class="tree-with-scrollbar"
@node-click="handleNodeClick"
max-height="650"
>
<template #default="{ node, data }">
<div class="custom-tree-node">
<span>{{ node.label }}</span>
<span class="tree-node-actions">
<template v-if="node.level === 1 && data.name != '常用' && data.name != '历史'">
<el-button
style="color: #000000"
type="text"
size="small"
@click.stop="addChild(data)"
>
<el-icon>
<Plus />
</el-icon>
</el-button>
</template>
<el-popconfirm width="200" :hide-after="10" title="确认删除此常用诊断吗" placement="top-start"
@confirm="deleteChild(data)">
<template #reference>
<el-button
style="color: #000000"
v-if="
node.level === 2 &&
node.parent.data.name != '常用' &&
node.parent.data.name != '历史'
"
type="text"
size="small"
@click.stop=""
>
<el-icon>
<Minus />
</el-icon>
</el-button>
</template>
</el-popconfirm>
</span>
</div>
</template>
</el-tree>
</el-col>
<el-col :span="20" :xs="24">
<div style="margin-bottom: 10px">
<el-button type="primary" plain @click="handleAddDiagnosis()"> 新增诊断 </el-button>
<el-button type="primary" plain @click="handleSaveDiagnosis()" :loading="saveLoading"> 保存诊断 </el-button>
<el-button type="primary" plain @click="handleAddTcmDiagonsis()"> 中医诊断 </el-button>
<el-button type="primary" plain @click="handleImport()"> 导入慢性病诊断 </el-button>
<span style="font-size: 12px; margin-left: 10px"
>注意 : 若使用电子处方,请不要导入慢性病诊断</span
>
</div>
<el-form :model="form" :rules="rules" ref="formRef">
<el-table ref="diagnosisTableRef" :data="form.diagnosisList" height="650" border>
<el-table-column label="序号" type="index" width="50" />
<el-table-column label="分类" align="center" prop="classification" width="100">
<template #default="scope">
<el-form-item :prop="`diagnosisList.${scope.$index}.classification`" style="margin-bottom: 0;">
<el-select v-model="scope.row.classification" placeholder=" " style="width: 90px">
<el-option
v-for="item in diagnosis_classification"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
</template>
</el-table-column>
<el-table-column label="诊断类型" align="center" prop="medTypeCode" width="150">
<template #default="scope">
<el-form-item :prop="`diagnosisList.${scope.$index}.medTypeCode`" :rules="rules.medTypeCode" style="margin-bottom: 0;">
<el-select v-model="scope.row.medTypeCode" placeholder=" " style="width: 130px">
<el-option
v-for="item in diag_type"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
</template>
</el-table-column>
<el-table-column label="诊断" align="center" prop="name" min-width="220">
<template #default="scope">
<el-form-item :prop="`diagnosisList.${scope.$index}.name`" :rules="rules.name" style="margin-bottom: 0;">
<el-popover
:popper-style="{ padding: '0', width: '600px' }"
placement="bottom-start"
:visible="scope.row.showPopover"
trigger="manual"
:show-arrow="false"
>
<template #default>
<div class="diagnosis-popover-container">
<div class="diagnosis-popover-header">
<span class="diagnosis-popover-title">选择诊断</span>
<el-button
link
type="primary"
:icon="Close"
@click="closeDiagnosisPopover(scope.row)"
class="diagnosis-popover-close"
>关闭</el-button>
</div>
<div class="diagnosis-popover-body">
<diagnosislist
:diagnosisSearchkey="diagnosisSearchkey"
@selectDiagnosis="(row) => handleSelectDiagnosis(row, scope.row, scope.$index)"
/>
</div>
</div>
</template>
<template #reference>
<div
class="diagnosis-text"
@click="handleFocus(scope.row, scope.$index)"
:title="scope.row.name || '点击选择诊断'"
>
<span class="diagnosis-text-content">{{ scope.row.name || '点击选择诊断' }}</span>
<el-icon class="diagnosis-text-icon"><ArrowDown /></el-icon>
</div>
</template>
</el-popover>
</el-form-item>
</template>
</el-table-column>
<el-table-column label="主诊断" align="center" prop="maindiseFlag" width="90">
<template #default="scope">
<el-form-item style="display: flex;justify-content: center;margin-bottom: 0;">
<el-select
v-model="scope.row.maindiseFlag"
placeholder=" "
style="width: 70px"
@change="(value) => handleMaindise(value, scope.$index)"
>
<el-option label="是" :value="1" />
<el-option label="否" :value="0" />
</el-select>
</el-form-item>
</template>
</el-table-column>
<el-table-column label="诊断备注" align="center" prop="diagnosisDesc" width="150">
<template #default="scope">
<el-form-item :prop="`diagnosisList.${scope.$index}.diagnosisDesc`" style="margin-bottom: 0;">
<el-input v-model="scope.row.diagnosisDesc" placeholder="请输入备注" style="width: 130px" />
</el-form-item>
</template>
</el-table-column>
<el-table-column label="ICD代码" align="center" prop="ybNo" width="150" />
<el-table-column label="诊断状态" align="center" prop="verificationStatusEnum" width="100">
<template #default="scope">
<el-form-item :prop="`diagnosisList.${scope.$index}.verificationStatusEnum`" style="margin-bottom: 0;">
<el-select
v-model="scope.row.verificationStatusEnum"
placeholder=" "
style="width: 90px"
>
<el-option
v-for="item in diagnosisOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
</template>
</el-table-column>
<el-table-column label="发病日期" align="center" prop="onsetDate" width="140">
<template #default="scope">
<el-form-item :prop="`diagnosisList.${scope.$index}.onsetDate`" style="margin-bottom: 0;">
<el-date-picker
v-model="scope.row.onsetDate"
type="date"
placeholder=" "
style="width: 130px"
value-format="YYYY-MM-DD"
/>
</el-form-item>
</template>
</el-table-column>
<el-table-column label="诊断日期" align="center" prop="diagnosisTime" width="140">
<template #default="scope">
<el-form-item :prop="`diagnosisList.${scope.$index}.diagnosisTime`" style="margin-bottom: 0;">
<el-date-picker
v-model="scope.row.diagnosisTime"
type="date"
placeholder=" "
style="width: 130px"
value-format="YYYY-MM-DD"
/>
</el-form-item>
</template>
</el-table-column>
<el-table-column label="医生" align="center" prop="diagnosisDoctor" width="100" />
<el-table-column label="长效诊断标识" align="center" prop="longTermFlag" width="110">
<template #default="scope">
<el-form-item :prop="`diagnosisList.${scope.$index}.longTermFlag`" style="margin-bottom: 0;">
<el-select v-model="scope.row.longTermFlag" placeholder=" " style="width: 90px">
<el-option
v-for="item in long_term_flag"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="130">
<template #default="scope">
<el-button link type="primary" @click="handleDeleteDiagnosis(scope.row, scope.$index)">
删除
</el-button>
</template>
</el-table-column>
</el-table>
</el-form>
</el-col>
</el-row>
<diagnosisdialog
:openDiagnosis="openDiagnosis"
@close="closeDiagnosisDialog"
:radio="orgOrUser"
/>
<AddDiagnosisDialog
:openAddDiagnosisDialog="openAddDiagnosisDialog"
:updateZy="updateZy"
:patientInfo="props.patientInfo"
@close="closeDiagnosisDialog"
/>
<InfectiousDiseaseReportDialog
ref="infectiousDiseaseReportRef"
:patientInfo="props.patientInfo"
:dept-id="userStore.orgId"
:doctor-id="userStore.practitionerId"
@close="handleInfectiousReportClose"
@success="handleInfectiousReportSuccess"
/>
</div>
</template>
<script setup>
import {getCurrentInstance} from 'vue';
import { Close, ArrowDown } from '@element-plus/icons-vue';
import useUserStore from '@/store/modules/user';
import {
delEncounterDiagnosis,
deleteDiagnosisBind,
deleteTcmDiagnosis,
diagnosisInit,
getChronicDisease,
getConditionDefinitionInfo,
getEmrDetail,
getEncounterDiagnosis,
getTcmDiagnosis,
isFoodDiseasesNew,
saveDiagnosis,
} from '../api';
import { DIAG_TYPE } from '@/utils/medicalConstants';
import diagnosisdialog from '../diagnosis/diagnosisdialog.vue';
import AddDiagnosisDialog from './addDiagnosisDialog.vue';
import diagnosislist from '../diagnosis/diagnosislist.vue';
import InfectiousDiseaseReportDialog from './infectiousDiseaseReportDialog.vue';
// const diagnosisList = ref([]);
const allowAdd = ref(false);
const tree = ref([]);
const openDiagnosis = ref(false);
const updateZy = ref([]);
const openAddDiagnosisDialog = ref(false);
const diagnosisSearchkey = ref('');
const diagnosisOptions = ref([]);
const rowIndex = ref();
const diagnosis = ref();
const orgOrUser = ref();
const saveLoading = ref(false);
const form = ref({
diagnosisList: [],
isDataLoaded: false,
});
const props = defineProps({
patientInfo: {
type: Object,
required: true,
},
});
const emits = defineEmits(['diagnosisSave']);
const { proxy } = getCurrentInstance();
const userStore = useUserStore();
const { diag_type } = proxy.useDict('diag_type');
const { diagnosis_classification } = proxy.useDict('diagnosis_classification');
const { long_term_flag } = proxy.useDict('long_term_flag');
const rules = ref({
name: [{ required: true, message: '请选择诊断', trigger: 'change' }],
medTypeCode: [{ required: true, message: '请选择诊断类型', trigger: 'change' }],
diagSrtNo: [{ required: true, message: '请输入诊断序号', trigger: 'change' }],
});
watch(
() => form.value.diagnosisList,
() => {
emits('diagnosisSave', false);
},
{ deep: true }
);
function getDetail(encounterId) {
if (!encounterId) {
console.warn('未提供有效的就诊ID无法获取病历详情');
return;
}
getEmrDetail(encounterId).then((res) => {
allowAdd.value = res.data ? true : false;
});
}
function refreshData() {
getList();
}
let maxNo = 99;
async function getList() {
try {
const res = await getEncounterDiagnosis(props.patientInfo.encounterId);
if (res.code == 200) {
// 过滤掉中医诊断,只保留西医诊断
form.value.diagnosisList = res.data.filter(item => item.typeName !== '中医诊断');
// 为旧数据添加默认分类
form.value.diagnosisList.forEach(item => {
if (!item.classification) {
item.classification = '西医';
}
});
emits('diagnosisSave', false);
}
// 获取现有诊断的排序号集合,用于判断是否重复
const existingDiagSrtNoSet = new Set(form.value.diagnosisList.map(item => item.diagSrtNo));
const tcmRes = await getTcmDiagnosis({ encounterId: props.patientInfo.encounterId });
if (tcmRes.code == 200) {
if (tcmRes.data.illness.length > 0) {
tcmRes.data.illness.forEach((item, index) => {
// 如果该排序号的诊断已存在,则跳过(避免重复添加)
if (existingDiagSrtNoSet.has(item.diagSrtNo)) {
return;
}
form.value.diagnosisList.push({
name: item.name + '-' + tcmRes.data.symptom[index].name,
diagSrtNo: item.diagSrtNo,
ybNo: item.ybNo,
medTypeCode: item.medTypeCode,
syndromeGroupNo: item.syndromeGroupNo,
typeName: '中医诊断',
classification: '中医', // 中医诊断默认分类
onsetDate: item.onsetDate,
updateId:item.encounterDiagnosisId+'-'+tcmRes.data.symptom[index].encounterDiagnosisId,
illnessDefinitionId : item.definitionId,
symptomDefinitionId : tcmRes.data.symptom[index].definitionId,
symptomYbNo: tcmRes.data.symptom[index].ybNo,
});
// 添加后更新集合
existingDiagSrtNoSet.add(item.diagSrtNo);
});
}
emits('diagnosisSave', false);
}
getTree();
} catch (error) {
console.error('获取诊断列表失败:', error);
}
}
init();
function init() {
diagnosisInit().then((res) => {
if (res.code == 200) {
diagnosisOptions.value = res.data.verificationStatusOptions;
}
});
}
function handleImport() {
if (!props.patientInfo || !props.patientInfo.encounterId) {
console.warn('患者就诊信息不完整,无法导入慢性病信息');
return;
}
if (props.patientInfo.contractName != '自费') {
// 获取患者慢性病信息
getChronicDisease({ encounterId: props.patientInfo.encounterId }).then((res) => {
if (res.data && res.data.length > 0) {
// 计算现有最大排序号
const maxSortNo = form.value.diagnosisList.length > 0
? Math.max(...form.value.diagnosisList.map(item => item.diagSrtNo || 0))
: 0;
res.data.forEach((item, index) => {
form.value.diagnosisList.push({
...item,
...{
medTypeCode: DIAG_TYPE.WESTERN_MEDICINE, // 诊断类型:西医诊断 (值1)
verificationStatusEnum: 4,
definitionId: item.id,
diagSrtNo: maxSortNo + index + 1,
iptDiseTypeCode: 2,
diagnosisDesc: '',
classification: '西医', // 导入的慢性病默认为西医
onsetDate: getCurrentDate(),
diagnosisDoctor: props.patientInfo.practitionerName || props.patientInfo.doctorName || props.patientInfo.physicianName || userStore.name,
diagnosisTime: getCurrentDate(),
longTermFlag: 0 // 默认非长效诊断
},
});
});
// 导入完成后按排序号排序
form.value.diagnosisList.sort((a, b) => (a.diagSrtNo || 0) - (b.diagSrtNo || 0));
emits('diagnosisSave', false);
}
});
}
}
/**
* 添加子节点
*/
function addChild(data) {
orgOrUser.value = data.name;
openDiagnosis.value = true;
}
/**
* 删除子节点
*/
function deleteChild(data) {
deleteDiagnosisBind(data.id).then((res) => {
if (res.code == 200) {
proxy.$modal.msgSuccess('删除成功');
getTree();
}
});
}
watch(diagnosis, (val) => {
proxy.$refs['treeRef'].filter(val);
});
/** 通过条件过滤节点 */
const filterNode = (value, data) => {
console.log('filterNode', value, data);
if (!value) return true;
return data.name.indexOf(value) !== -1;
};
/**
* 获取诊断树列表
*/
function getTree() {
const patientId = props.patientInfo?.patientId || '';
getConditionDefinitionInfo(patientId).then((res) => {
if (res.code == 200) {
// 确保数据结构正确,避免直接修改数组对象
const patientHistoryList = Array.isArray(res.data.patientHistoryList) ? res.data.patientHistoryList : [];
const doctorCommonUseList = Array.isArray(res.data.doctorCommonUseList) ? res.data.doctorCommonUseList : [];
const userPersonalList = Array.isArray(res.data.userPersonalList) ? res.data.userPersonalList : [];
const organizationList = Array.isArray(res.data.organizationList) ? res.data.organizationList : [];
// 手动构造树列表;
tree.value[0] = {
id: '1',
name: '历史',
children: patientHistoryList,
};
tree.value[1] = {
id: '2',
name: '常用',
children: doctorCommonUseList,
};
tree.value[2] = {
id: '3',
name: '个人',
children: userPersonalList,
};
tree.value[3] = {
id: '4',
name: '科室',
children: organizationList,
};
console.log(tree.value);
}
});
}
/**
* 添加西医诊断
*/
function handleAddDiagnosis() {
proxy.$refs.formRef.validate((valid) => {
if (valid) {
const maxSortNo = form.value.diagnosisList.length > 0
? Math.max(...form.value.diagnosisList.map(item => item.diagSrtNo || 0))
: 0;
form.value.diagnosisList.push({
showPopover: false,
name: undefined,
verificationStatusEnum: 4,
medTypeCode: DIAG_TYPE.WESTERN_MEDICINE, // 诊断类型:西医诊断 (值1)
diagSrtNo: maxSortNo + 1,
iptDiseTypeCode: 2,
diagnosisDesc: '',
classification: '西医', // 默认为西医
onsetDate: getCurrentDate(),
diagnosisDoctor: props.patientInfo.practitionerName || props.patientInfo.doctorName || props.patientInfo.physicianName || userStore.name,
diagnosisTime: getCurrentDate(),
longTermFlag: 0 // 默认非长效诊断
});
// 添加后按排序号排序
form.value.diagnosisList.sort((a, b) => (a.diagSrtNo || 0) - (b.diagSrtNo || 0));
if (form.value.diagnosisList.length == 1) {
form.value.diagnosisList[0].maindiseFlag = 1;
}
}
});
}
// 添加中医诊断
function handleAddTcmDiagonsis() {
updateZy.value = [];
openAddDiagnosisDialog.value = true;
}
/**
* 删除诊断
*/
function handleDeleteDiagnosis(row, index) {
if (row.conditionId) {
delEncounterDiagnosis(row.conditionId).then((res) => {
if (res.code == 200) {
proxy.$modal.msgSuccess('删除成功');
getList();
getTree();
}
});
} else if (row.syndromeGroupNo) {
deleteTcmDiagnosis(row.syndromeGroupNo).then(() => {
getList();
getTree();
});
} else {
form.value.diagnosisList.splice(index, 1);
// 删除后不重新计算排序号,保持用户设置的排序不变
emits('diagnosisSave', false);
}
}
function handleMaindise(value, index) {
if (value == 1) {
let flag = 0;
form.value.diagnosisList.forEach((item) => {
if (item.maindiseFlag == 1) {
flag++;
}
});
if (flag > 1) {
form.value.diagnosisList[index].maindiseFlag = 0;
proxy.$modal.msgWarning('只能有一条主诊断');
}
}
}
/**
* 保存诊断
* 使用 async/await 重构,优化错误处理和加载状态
*/
async function handleSaveDiagnosis() {
try {
// 表单验证
const valid = await proxy.$refs.formRef.validate().catch(() => false);
if (!valid) {
return;
}
// 检查诊断列表是否为空
if (form.value.diagnosisList.length === 0) {
proxy.$modal.msgWarning('诊断不能为空');
return;
}
// 检查是否至少有一条主诊断
const hasMainDiagnosis = form.value.diagnosisList.some((diagnosis) => diagnosis.maindiseFlag === 1);
if (!hasMainDiagnosis) {
proxy.$modal.msgWarning('至少添加一条主诊断');
return;
}
// 防护性检查:确保患者信息完整
if (!props.patientInfo?.patientId || !props.patientInfo?.encounterId) {
proxy.$modal.msgWarning('患者信息不完整,无法保存诊断');
return;
}
// 开始加载状态,防止重复提交
saveLoading.value = true;
// 保存前按排序号排序并转换日期格式为ISO字符串
const diagnosisChildList = form.value.diagnosisList.map(item => ({
...item,
onsetDate: item.onsetDate ? new Date(item.onsetDate).toISOString() : null,
diagnosisTime: item.diagnosisTime ? new Date(item.diagnosisTime).toISOString() : null
}));
// 调用保存诊断接口
const res = await saveDiagnosis({
patientId: props.patientInfo.patientId,
encounterId: props.patientInfo.encounterId,
diagnosisChildList: diagnosisChildList,
});
if (res.code === 200) {
// 刷新树和列表数据等待列表数据加载完成确保获取到reportTypeCode
await getList();
getTree();
emits('diagnosisSave', false);
proxy.$modal.msgSuccess('诊断已保存并按排序号排序');
// 食源性疾病病例数据智能采集
await handleFoodDiseasesCheck();
// 传染病报告卡检查诊断的reportTypeCode弹出对应的报告卡界面
handleInfectiousDiseaseReport();
}
} catch (error) {
console.error('保存诊断失败:', error);
proxy.$modal.msgError('保存诊断失败,请稍后重试');
} finally {
// 结束加载状态
saveLoading.value = false;
}
}
/**
* 食源性疾病病例数据智能采集
*/
async function handleFoodDiseasesCheck() {
try {
const res = await isFoodDiseasesNew({
encounterId: props.patientInfo.encounterId,
});
if (res.code === 200 && res.data) {
window.open(res.data, '_blank');
}
} catch (error) {
console.error('食源性疾病检查失败:', error);
}
}
/**
* 传染病报告卡处理
* 通过诊断目录维护的'报卡类型'字段自动识别是否有需要填写的传染病报告卡
* 如果有则弹出诊断对应需登记的报告卡界面
*/
function handleInfectiousDiseaseReport() {
// 查找所有有报卡类型的诊断reportTypeCode不为空
const diagnosesWithReportType = form.value.diagnosisList.filter(d => d.reportTypeCode);
if (diagnosesWithReportType.length === 0) {
return;
}
// 优先使用主诊断,如果没有主诊断有报卡类型则使用第一个有报卡类型的诊断
const mainDiagnosisWithReport = diagnosesWithReportType.find(d => d.maindiseFlag === 1);
const targetDiagnosis = mainDiagnosisWithReport || diagnosesWithReportType[0];
// 弹出传染病报告卡弹窗
proxy.$refs.infectiousDiseaseReportRef?.show(targetDiagnosis);
}
/**
* 关闭诊断弹窗
*/
function closeDiagnosisDialog(str) {
if (str === 'success') {
proxy.$modal.msgSuccess('操作成功');
}
openAddDiagnosisDialog.value = false;
openDiagnosis.value = false;
getList();
getTree();
}
/**
* 传染病报告卡关闭
*/
function handleInfectiousReportClose() {
// 关闭传染病报告卡弹窗
}
/**
* 传染病报告卡保存成功
*/
function handleInfectiousReportSuccess() {
}
function queryDiagnosisUse(value) { }
function handleChange(value) {
diagnosisSearchkey.value = value;
}
/**
* 选择诊断并赋值到列表
*/
function handleSelectDiagnosis(row, rowData, index) {
console.log('选择诊断:', row);
rowData.name = row.name;
rowData.ybNo = row.ybNo;
rowData.definitionId = row.id;
rowData.showPopover = false;
emits('diagnosisSave', false);
}
/**
* 关闭诊断选择弹窗
*/
function closeDiagnosisPopover(row) {
row.showPopover = false;
}
/**获取焦点时 打开列表 */
function handleFocus(row, index) {
if(row.typeName==='中医诊断'){
updateZy.value = [];
updateZy.value.push({
illnessDefinitionId: row.illnessDefinitionId,
symptomDefinitionId: row.symptomDefinitionId,
syndromeGroupNo: row.syndromeGroupNo,
symptomYbNo:row.symptomYbNo,
ybNo:row.ybNo,
updateId: row.updateId,
diagSrtNo: row.diagSrtNo,
name:row.name,
});
openAddDiagnosisDialog.value = true;
}else{
// 关闭其他行的弹窗
form.value.diagnosisList.forEach((item, idx) => {
if (idx !== index) {
item.showPopover = false;
}
});
rowIndex.value = index;
row.showPopover = true;
}
}
function handleNodeClick(data) {
console.log(data.children);
// 检查节点是否为根节点
if (data.children != undefined) {
// 如果是根节点,不执行任何操作
return;
}
// if (!allowAdd.value) {
// proxy.$modal.msgWarning('请先填写病历');
// return;
// }
const isDuplicate = form.value.diagnosisList.some(
(diagnosis) => diagnosis.ybNo === data.ybNo || diagnosis.name === data.name
);
if (isDuplicate) {
proxy.$modal.msgWarning('该诊断项已存在');
return;
}
// 计算现有最大排序号
const maxSortNo = form.value.diagnosisList.length > 0
? Math.max(...form.value.diagnosisList.map(item => item.diagSrtNo || 0))
: 0;
form.value.diagnosisList.push({
ybNo: data.ybNo,
name: data.name,
verificationStatusEnum: 4,
medTypeCode: DIAG_TYPE.WESTERN_MEDICINE, // 诊断类型:西医诊断 (值1)
diagSrtNo: maxSortNo + 1,
definitionId: data.definitionId,
classification: '西医', // 默认为西医
onsetDate: getCurrentDate(),
diagnosisDoctor: props.patientInfo.practitionerName || props.patientInfo.doctorName || props.patientInfo.physicianName || userStore.name,
diagnosisTime: getCurrentDate()
});
// 添加后按排序号排序
form.value.diagnosisList.sort((a, b) => (a.diagSrtNo || 0) - (b.diagSrtNo || 0));
if (form.value.diagnosisList.length == 1) {
form.value.diagnosisList[0].maindiseFlag = 1;
}
}
function getCurrentDate() {
const date = new Date();
const year = date.getFullYear();
let month = date.getMonth() + 1;
let day = date.getDate();
month = month < 10 ? "0" + month : month;
day = day < 10 ? "0" + day : day;
return `${year}-${month}-${day}`;
}
defineExpose({ getList, getDetail, handleSaveDiagnosis });
</script>
<style lang="scss" scoped>
.el-checkbox.is-bordered.el-checkbox--small {
background-color: #ffffff;
}
.tree-with-scrollbar {
max-height: 650px;
overflow-y: auto;
}
.custom-tree-node {
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
}
.tree-node-actions {
display: flex;
align-items: center;
}
.diagnosis-text {
min-height: 32px;
line-height: 1.4;
padding: 6px 12px;
border: 1px solid #dcdfe6;
border-radius: 4px;
background-color: #fff;
cursor: pointer;
text-align: left;
word-break: break-all;
white-space: pre-wrap;
max-width: 200px;
transition: border-color 0.2s;
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
}
.diagnosis-text:hover {
border-color: #409eff;
}
.diagnosis-text-content {
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
.diagnosis-text-icon {
color: #909399;
font-size: 12px;
}
.diagnosis-text:hover .diagnosis-text-icon {
color: #409eff;
}
/* 诊断选择弹窗样式 */
.diagnosis-popover-container {
background-color: #fff;
border-radius: 4px;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
}
.diagnosis-popover-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 12px 16px;
border-bottom: 1px solid #e4e7ed;
background-color: #f5f7fa;
}
.diagnosis-popover-title {
font-size: 14px;
font-weight: 600;
color: #303133;
}
.diagnosis-popover-close {
font-size: 12px;
}
.diagnosis-popover-body {
padding: 0;
}
.diagnosis-text:empty::before {
content: '点击选择诊断';
color: #a8abb2;
}
.diagnosis-text:hover {
border-color: #409eff;
}
.diagnosis-text:empty::before {
content: '请选择诊断';
color: #a8abb2;
}
</style>