|
@@ -9,7 +9,7 @@
|
|
|
<el-date-picker v-model="queryParams.dateRange" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" />
|
|
|
</el-form-item>
|
|
|
<el-form-item label="看诊类型">
|
|
|
- <el-select v-model="form.visitType" class="spec-unit-select">
|
|
|
+ <el-select v-model="queryParams.type" class="spec-unit-select">
|
|
|
<el-option v-for="dict in treatment_user_type" :key="dict.value" :label="dict.label" :value="dict.value" />
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
@@ -39,20 +39,27 @@
|
|
|
</template>
|
|
|
<el-table v-loading="loading" border :data="diagnosisList" @selection-change="handleSelectionChange">
|
|
|
<el-table-column type="selection" width="55" align="center" />
|
|
|
- <el-table-column label="" align="center" prop="id" v-if="true" />
|
|
|
<el-table-column label="时间" align="center" prop="createTime" />
|
|
|
- <el-table-column label="诊断依据" align="center" prop="diagnosisBasis" />
|
|
|
- <el-table-column label="看诊类型" align="center" prop="diagnosisType" />
|
|
|
- <el-table-column label="门诊/住院号" align="center" prop="outpatientNumber" />
|
|
|
- <el-table-column label="营养诊断" align="center" prop="nutritionalDiagnosis" />
|
|
|
- <el-table-column label="诊断医生" align="center" prop="diagnosisDoctor" />
|
|
|
+ <el-table-column label="诊断依据" align="center" prop="diagnosisBasis">
|
|
|
+ <template #default="scope">
|
|
|
+ <span>{{getDictLabel(treatment_user_type ,scope.row.diagnosisBasis )|| '--' }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="看诊类型" align="center" prop="type">
|
|
|
+ <template #default="scope">
|
|
|
+ <span>{{getDictLabel(treatment_user_type ,scope.row.type )|| '--' }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="门诊/住院号" align="center" prop="outpatientNo" />
|
|
|
+ <el-table-column label="营养诊断" align="center" prop="diagnosisLabelStr" width="350"/>
|
|
|
+ <el-table-column label="诊断医生" align="center" prop="createByUser" />
|
|
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
|
|
<template #default="scope">
|
|
|
- <el-tooltip content="修改" placement="top">
|
|
|
- <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)"></el-button>
|
|
|
+ <el-tooltip content="详情" placement="top">
|
|
|
+ <el-button link type="primary" icon="Edit" @click="handleDetail(scope.row)">详情</el-button>
|
|
|
</el-tooltip>
|
|
|
<el-tooltip content="删除" placement="top">
|
|
|
- <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)"></el-button>
|
|
|
+ <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)">删除</el-button>
|
|
|
</el-tooltip>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
@@ -65,8 +72,8 @@
|
|
|
<div v-show="type === 'addForm'">
|
|
|
<el-form ref="diagnosisFormRef" :model="form" :rules="rules" label-width="120px">
|
|
|
<el-form-item label="营养诊断:" prop="diagnosisLableId">
|
|
|
- <el-select v-model="labelList" multiple placeholder="请选择" style="width: 100%;" :disabled="true" @click="labelDialogVisible = true" class="custom-label-select" value-key="labelId">
|
|
|
- <el-option v-for="item in labelList" :key="item.labelId" :label="item.labelName" :value="item">
|
|
|
+ <el-select v-model="form.labelList" multiple placeholder="请选择" style="width: 100%;" :disabled="true" @click="labelDialogVisible = true" class="custom-label-select">
|
|
|
+ <el-option v-for="item in labelOptions" :key="item.labelId" :label="item.labelName" :value="item.labelId">
|
|
|
<el-tag type="info" size="small">{{ item.labelName }}</el-tag>
|
|
|
</el-option>
|
|
|
</el-select>
|
|
@@ -82,20 +89,22 @@
|
|
|
</div>
|
|
|
</el-form-item>
|
|
|
<el-form-item>
|
|
|
- <Editor v-model="form.consultationContent" placeholder="请输入内容..." style="min-height: 200px; width: 100%;" />
|
|
|
+ <Editor v-model="form.consultantResult" placeholder="请输入内容..." style="min-height: 200px; width: 100%;" />
|
|
|
</el-form-item>
|
|
|
<el-form-item label="营养医嘱:" prop="medicalOrder">
|
|
|
<el-input v-model="form.medicalOrder" placeholder="请输入" clearable />
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-form>
|
|
|
- <LabelDialog v-model="labelDialogVisible" :initial-selected-labels="labelList || []" @confirm="onLabelConfirm" />
|
|
|
+ <LabelDialog v-model="labelDialogVisible" :initial-selected-labels="labelOptions || []" @confirm="onLabelConfirm" />
|
|
|
<ConsultantTemplateDialog v-model:visible="showTemplateDialog" @select="onTemplateSelect" />
|
|
|
<div class="dialog-footer" style="text-align: center; margin-top: 100px">
|
|
|
<el-button @click="handleCancel">取 消</el-button>
|
|
|
<el-button :loading="buttonLoading" type="primary" @click="submitForm">提 交</el-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
+ <!-- 详情弹窗始终挂载在最外层div内 -->
|
|
|
+ <detail-dialog v-model="showDetailDialog" :detail="currentDetail" />
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
@@ -104,6 +113,10 @@
|
|
|
import { DiagnosisVO, DiagnosisQuery, DiagnosisForm } from '@/api/patients/diagnosis/types';
|
|
|
import { getTreatmentUser as fetchTreatmentUser } from '@/api/workbench/treatmentUser';
|
|
|
import LabelDialog from '@/views/warehouse/nutriProduct/labelDialog.vue';
|
|
|
+ import { getDiseaseLabel } from '@/api/system/diseaseLabel'; // 新增: 导入获取标签详情API
|
|
|
+ import { log } from 'console';
|
|
|
+ import DetailDialog from './detailDialog.vue';
|
|
|
+ import { watch } from 'vue';
|
|
|
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
|
|
|
|
|
const ConsultantTemplateDialog = defineAsyncComponent(() => import('./consultantTemplateDialog.vue'));
|
|
@@ -119,9 +132,10 @@
|
|
|
const multiple = ref(true);
|
|
|
const total = ref(0);
|
|
|
const type = ref('list');
|
|
|
- const labelList = ref([]);
|
|
|
- const detailData = ref({});
|
|
|
const labelDialogVisible = ref(false);
|
|
|
+ const labelOptions = ref < any[] > ([]); // 新增: 用于存储可选标签对象
|
|
|
+ const showDetailDialog = ref(false);
|
|
|
+ const currentDetail = ref({});
|
|
|
|
|
|
const queryFormRef = ref < ElFormInstance > ();
|
|
|
const diagnosisFormRef = ref < ElFormInstance > ();
|
|
@@ -131,6 +145,7 @@
|
|
|
visible: false,
|
|
|
title: ''
|
|
|
});
|
|
|
+
|
|
|
// 声明接收的 props
|
|
|
const props = defineProps({
|
|
|
patientInfo: {
|
|
@@ -147,12 +162,14 @@
|
|
|
|
|
|
const initFormData: DiagnosisForm = {
|
|
|
id: undefined,
|
|
|
- treatmentUserId: props.patientInfo ?.id, // Initialize with patient ID
|
|
|
+ labelList: [],
|
|
|
+ treatmentUserId: props.patientInfo ?.id,
|
|
|
consultantTemplateId: undefined,
|
|
|
diagnosisLableId: undefined,
|
|
|
diagnosisBasisId: undefined,
|
|
|
medicalOrder: undefined,
|
|
|
- consultationContent: undefined,
|
|
|
+ consultantResult: undefined,
|
|
|
+ consultantResultStr: undefined,
|
|
|
}
|
|
|
|
|
|
const data = reactive < PageData < DiagnosisForm,
|
|
@@ -162,6 +179,7 @@
|
|
|
pageNum: 1,
|
|
|
pageSize: 10,
|
|
|
visitType: undefined,
|
|
|
+ treatmentUserId: props.patientInfo ?.id,
|
|
|
dateRange: undefined,
|
|
|
searchValue: undefined,
|
|
|
params: {}
|
|
@@ -178,26 +196,25 @@
|
|
|
|
|
|
const { queryParams, form, rules } = toRefs(data);
|
|
|
|
|
|
+ // 监听患者ID变化,自动同步到表单和查询参数
|
|
|
+ watch(
|
|
|
+ () => props.patientInfo.id,
|
|
|
+ (newId) => {
|
|
|
+ form.value.treatmentUserId = newId;
|
|
|
+ queryParams.value.treatmentUserId = newId;
|
|
|
+ },
|
|
|
+ { immediate: true }
|
|
|
+ );
|
|
|
+
|
|
|
/** 查询营养诊断列表 */
|
|
|
const getList = async () => {
|
|
|
loading.value = true;
|
|
|
const res = await listDiagnosis(queryParams.value);
|
|
|
diagnosisList.value = res.rows;
|
|
|
- console.log("diagnosisList", JSON.stringify(diagnosisList.value));
|
|
|
|
|
|
total.value = res.total;
|
|
|
loading.value = false;
|
|
|
}
|
|
|
- // 详情按钮处理
|
|
|
- const getTreatmentUser = async () => {
|
|
|
- try {
|
|
|
- // 获取患者详细信息
|
|
|
- const res = await fetchTreatmentUser(props.patientInfo ?.id);
|
|
|
- detailData.value = res.data;
|
|
|
- } catch (error) {
|
|
|
-
|
|
|
- }
|
|
|
- };
|
|
|
|
|
|
/** 取消按钮 */
|
|
|
const cancel = () => {
|
|
@@ -206,24 +223,27 @@
|
|
|
}
|
|
|
// 标签确认回调
|
|
|
function onLabelConfirm(selectedLabels: Array < { labelId: string | number;labelName: string } > ) {
|
|
|
- labelList.value = selectedLabels;
|
|
|
+ form.value.labelList = selectedLabels.map(l => l.labelId); // 只存labelId
|
|
|
+ labelOptions.value = selectedLabels; // 用于el-option展示labelName
|
|
|
}
|
|
|
- const onTemplateSelect = async (templateContent) => {
|
|
|
+ const onTemplateSelect = async (data) => {
|
|
|
+ form.value.consultantTemplateId = data.id;
|
|
|
+ let templateContent = data.template;
|
|
|
+ console.log(JSON.stringify(data));
|
|
|
+
|
|
|
if (!templateContent) return;
|
|
|
|
|
|
try {
|
|
|
// 获取患者详细信息
|
|
|
const res = await fetchTreatmentUser(props.patientInfo ?.id);
|
|
|
const patientDetail = res.data || {};
|
|
|
-
|
|
|
- console.log('Template content:', templateContent);
|
|
|
- console.log('Patient details:', patientDetail);
|
|
|
-
|
|
|
+ form.value.consultantTemplateId = data.id;
|
|
|
// 替换模板中的占位符
|
|
|
let processedContent = templateContent;
|
|
|
|
|
|
// 定义替换规则(根据实际字段进行调整)
|
|
|
const replacements = {
|
|
|
+ 'purpose': patientDetail.type == 1 ? '住院' : '门诊' || '',
|
|
|
'height': patientDetail.height || '',
|
|
|
'weight': patientDetail.weight || '',
|
|
|
'bmi': patientDetail.bmi || '',
|
|
@@ -234,7 +254,6 @@
|
|
|
'beforeAlb': patientDetail.beforeAlb || '',
|
|
|
'way': patientDetail.way || '',
|
|
|
'glimResult': patientDetail.glimResult || '',
|
|
|
- 'purpose': patientDetail.purpose || '',
|
|
|
'lossWeight': patientDetail.lossWeight || '',
|
|
|
'totalCalories': patientDetail.totalCalories || '',
|
|
|
'totalProtein': patientDetail.totalProtein || '',
|
|
@@ -246,8 +265,6 @@
|
|
|
// 可以根据需要添加更多替换规则
|
|
|
};
|
|
|
|
|
|
- console.log('Replacements:', replacements);
|
|
|
-
|
|
|
// 执行替换
|
|
|
for (const [key, value] of Object.entries(replacements)) {
|
|
|
const placeholder = '${' + key + '}';
|
|
@@ -255,21 +272,22 @@
|
|
|
processedContent = processedContent.split(placeholder).join(value);
|
|
|
}
|
|
|
|
|
|
- console.log('Processed content:', processedContent);
|
|
|
-
|
|
|
// 将处理后的内容赋值给表单
|
|
|
- form.value.consultationContent = processedContent;
|
|
|
+ form.value.consultantResult = processedContent;
|
|
|
} catch (error) {
|
|
|
console.error('获取患者详情失败:', error);
|
|
|
proxy ?.$modal.msgError('获取患者详情失败');
|
|
|
// 如果获取详情失败,仍然使用原始模板
|
|
|
- form.value.consultationContent = templateContent;
|
|
|
+ form.value.consultantResult = templateContent;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
/** 表单重置 */
|
|
|
const reset = () => {
|
|
|
- form.value = { ...initFormData };
|
|
|
+ form.value = {
|
|
|
+ ...initFormData,
|
|
|
+ treatmentUserId: props.patientInfo ?.id // 用最新id
|
|
|
+ };
|
|
|
diagnosisFormRef.value ?.resetFields();
|
|
|
}
|
|
|
|
|
@@ -282,8 +300,19 @@
|
|
|
/** 重置按钮操作 */
|
|
|
const resetQuery = () => {
|
|
|
queryFormRef.value ?.resetFields();
|
|
|
+ queryParams.value.dateRange = undefined;
|
|
|
+ queryParams.value.type = undefined;
|
|
|
+ queryParams.value.searchValue = undefined;
|
|
|
+ queryParams.value.pageNum = 1;
|
|
|
+ queryParams.value.pageSize = 10;
|
|
|
handleQuery();
|
|
|
}
|
|
|
+ // 字典label工具
|
|
|
+ function getDictLabel(dictList: any[], value: string) {
|
|
|
+ if (!dictList || !Array.isArray(dictList)) return value || '--';
|
|
|
+ const found = dictList.find(item => item.value === value);
|
|
|
+ return found ? found.label : value || '--';
|
|
|
+ }
|
|
|
|
|
|
/** 多选框选中数据 */
|
|
|
const handleSelectionChange = (selection: DiagnosisVO[]) => {
|
|
@@ -302,7 +331,7 @@
|
|
|
type.value = 'list';
|
|
|
};
|
|
|
const clearContent = () => {
|
|
|
- form.value.consultationContent = '';
|
|
|
+ form.value.consultantResult = '';
|
|
|
}
|
|
|
|
|
|
/** 修改按钮操作 */
|
|
@@ -311,6 +340,15 @@
|
|
|
const _id = row ?.id || ids.value[0]
|
|
|
const res = await getDiagnosis(_id);
|
|
|
Object.assign(form.value, res.data);
|
|
|
+ // 适配labelList为labelId数组时,需获取完整标签对象
|
|
|
+ if (Array.isArray(form.value.labelList) && form.value.labelList.length > 0 && typeof form.value.labelList[0] !== 'object') {
|
|
|
+ // 批量获取标签详情
|
|
|
+ const labelIds = form.value.labelList;
|
|
|
+ const labelDetailPromises = labelIds.map(id => getDiseaseLabel(id).then(r => r.data));
|
|
|
+ labelOptions.value = await Promise.all(labelDetailPromises);
|
|
|
+ } else {
|
|
|
+ labelOptions.value = form.value.labelList || [];
|
|
|
+ }
|
|
|
dialog.visible = true;
|
|
|
dialog.title = "修改营养诊断";
|
|
|
}
|
|
@@ -321,8 +359,12 @@
|
|
|
if (valid) {
|
|
|
buttonLoading.value = true;
|
|
|
if (form.value.id) {
|
|
|
+ form.value.consultantResultStr = window.btoa(encodeURIComponent(form.value.consultantResult))
|
|
|
await updateDiagnosis(form.value).finally(() => buttonLoading.value = false);
|
|
|
} else {
|
|
|
+ console.log('addForm', JSON.stringify(form.value));
|
|
|
+
|
|
|
+ form.value.consultantResultStr = window.btoa(encodeURIComponent(form.value.consultantResult))
|
|
|
await addDiagnosis(form.value).finally(() => buttonLoading.value = false);
|
|
|
}
|
|
|
proxy ?.$modal.msgSuccess("操作成功");
|
|
@@ -330,7 +372,6 @@
|
|
|
await getList();
|
|
|
type.value = 'list';
|
|
|
}
|
|
|
-
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -343,7 +384,17 @@
|
|
|
await getList();
|
|
|
}
|
|
|
|
|
|
+ const handleDetail = (row: any) => {
|
|
|
+ currentDetail.value = row;
|
|
|
+ currentDetail.value.consultantResult= stripHtml(currentDetail.value.consultantResult);
|
|
|
+ showDetailDialog.value = true;
|
|
|
+ };
|
|
|
|
|
|
+ function stripHtml(html) {
|
|
|
+ const div = document.createElement('div');
|
|
|
+ div.innerHTML = html;
|
|
|
+ return div.textContent || div.innerText || '';
|
|
|
+ }
|
|
|
|
|
|
onMounted(() => {
|
|
|
getList();
|