refactor(ui): 优化按钮样式和数据加载逻辑

- 将多个按钮组件从 type="text" 改为 link 属性,提升界面美观性
- 修复 PatientList 组件中姓名显示的文本截断功能
- 在住院记录模板中添加对 patientInfo 变化的监听,自动更新表单数据
- 优化打印机列表获取逻辑,添加连接状态检查和警告信息
- 移除不必要的防抖和重复请求防护逻辑,简化代码实现
- 修复多处组件中对 patientInfo 属性访问的安全性问题
- 优化病历数据加载时机,移除防抖包装直接调用加载函数
- 改进数据设置逻辑,避免覆盖未传入字段的原有值
- 调整组件属性定义,使 patientInfo 参数变为可选并设置默认值
- 优化患者切换时的组件重置和数据加载流程
This commit is contained in:
2026-01-27 17:32:03 +08:00
parent 0f0dc70c7e
commit 4f0cc1a0c4
21 changed files with 232 additions and 387 deletions

View File

@@ -106,7 +106,7 @@ watch(
getList();
function getList() {
loading.value = true;
queryParams.value.organizationId = props.patientInfo.inHospitalOrgId;
queryParams.value.organizationId = props.patientInfo?.inHospitalOrgId || '';
getAdviceBaseInfo(queryParams.value)
.then((res) => {
console.log(res.data.records);

View File

@@ -203,7 +203,8 @@ const form = ref({
const props = defineProps({
patientInfo: {
type: Object,
required: true,
required: false,
default: () => ({}),
},
});
const emits = defineEmits(['diagnosisSave']);

View File

@@ -10,25 +10,25 @@
<el-button
type="primary"
@click="showApplicationFormDialog('LaboratoryTests')"
:disabled="!patientInfo?.inHospitalOrgId"
:disabled="!props.patientInfo?.inHospitalOrgId"
>检验</el-button
>
<el-button
type="primary"
@click="showApplicationFormDialog('MedicalExaminations')"
:disabled="!patientInfo?.inHospitalOrgId"
:disabled="!props.patientInfo?.inHospitalOrgId"
>检查</el-button
>
<el-button
type="primary"
@click="showApplicationFormDialog('BloodTransfusion')"
:disabled="!patientInfo?.inHospitalOrgId"
:disabled="!props.patientInfo?.inHospitalOrgId"
>输血</el-button
>
<el-button
type="primary"
@click="showApplicationFormDialog('Surgery')"
:disabled="!patientInfo?.inHospitalOrgId"
:disabled="!props.patientInfo?.inHospitalOrgId"
>手术</el-button
>
</el-button-group>
@@ -58,14 +58,19 @@
<script setup>
import {computed, getCurrentInstance, nextTick, onBeforeMount, onMounted, reactive, ref,} from 'vue';
import BloodTransfusion from './bloodTransfusion.vue';
import {patientInfo} from '../../../store/patient.js';
import Surgery from './surgery.vue';
import LaboratoryTests from './laboratoryTests.vue';
import MedicalExaminations from './medicalExaminations.vue';
const { proxy } = getCurrentInstance();
const emits = defineEmits(['refResh']);
const props = defineProps({});
const props = defineProps({
patientInfo: {
type: Object,
required: false,
default: () => ({}),
},
});
const state = reactive({});
const components = ref({
BloodTransfusion,

View File

@@ -297,16 +297,17 @@
</el-table>
</div>
<!-- // 底部按钮 -->
<application-form-bottom-btn @refResh="refresh" />
<application-form-bottom-btn :patientInfo="patientInfo" @refResh="refresh" />
<OrderGroupDrawer
ref="orderFroupRef"
:diagnosis="diagnosisInfo"
:organizationId="patientInfo?.orgId || ''"
@useOrderGroup="handleSaveGroup"
/>
<PrescriptionHistory
ref="prescriptionHistoryRef"
:diagnosis="diagnosisInfo"
:patientInfo="patientInfo"
:patientInfo="patientInfo || {}"
@userPrescriptionHistory="handleSaveHistory"
/>
<LeaveHospitalDialog
@@ -405,7 +406,8 @@ const buttonDisabled = computed(() => {
const props = defineProps({
patientInfo: {
type: Object,
required: true,
required: false,
default: () => ({}),
},
activeTab: {
type: String,
@@ -525,33 +527,19 @@ function getList() {
function refresh() {
getListInfo(false);
}
// 防止重复请求的标志
let listInfoRequestPromise = null;
// 获取列表信息
function getListInfo(addNewRow) {
// 如果已经有正在进行的请求则返回该请求的Promise
if (listInfoRequestPromise) {
return listInfoRequestPromise;
}
loadingInstance = ElLoading.service({ fullscreen: true });
setTimeout(() => {
if (loadingInstance) {
loadingInstance.close();
}
loadingInstance.close();
}, 180);
isAdding.value = false;
expandOrder.value = [];
getPrescriptionList(patientInfo.value.encounterId).then((res) => {
console.log('getListInfo==========>', JSON.stringify(res.data));
// 并行请求两个API并将结果合并处理
listInfoRequestPromise = Promise.all([
getPrescriptionList(patientInfo.value.encounterId),
getContract({ encounterId: patientInfo.value.encounterId })
])
.then(([prescriptionRes, contractRes]) => {
// 处理处方列表
prescriptionList.value = prescriptionRes.data
loadingInstance.close();
prescriptionList.value = res.data
.map((item) => {
return {
...JSON.parse(item.contentJson),
@@ -563,35 +551,15 @@ function getListInfo(addNewRow) {
.sort((a, b) => {
return new Date(b.requestTime) - new Date(a.requestTime);
});
// 处理合同列表
contractList.value = contractRes.data;
// 更新账户ID
accountId.value = patientInfo.value.accountId;
// 更新标记
getGroupMarkers();
getGroupMarkers(); // 更新标记
if (props.activeTab == 'prescription' && addNewRow) {
handleAddPrescription();
}
console.log('getListInfo==========>', JSON.stringify(prescriptionRes.data));
})
.catch(error => {
console.error('获取列表信息失败:', error);
ElMessage.error('获取列表信息失败');
})
.finally(() => {
if (loadingInstance) {
loadingInstance.close();
}
// 请求完成后清除Promise引用
listInfoRequestPromise = null;
});
return listInfoRequestPromise;
getContract({ encounterId: patientInfo.value.encounterId }).then((res) => {
contractList.value = res.data;
});
accountId.value = patientInfo.value.accountId;
}
// 数据过滤
const filterPrescriptionList = computed(() => {
@@ -605,37 +573,18 @@ const filterPrescriptionList = computed(() => {
return pList;
});
// 防止诊断信息重复请求的标志
let diagnosisInfoRequestPromise = null;
function getDiagnosisInfo() {
// 如果已经有正在进行的请求则返回该请求的Promise
if (diagnosisInfoRequestPromise) {
return diagnosisInfoRequestPromise;
}
diagnosisInfoRequestPromise = getEncounterDiagnosis(patientInfo.value.encounterId)
.then((res) => {
diagnosisList.value = res.data;
let diagnosisInfo = diagnosisList.value.filter((item) => {
return item.maindiseFlag == 1;
});
diagnosisInfo.value = diagnosisInfo[0];
conditionDefinitionId.value = diagnosisInfo[0].definitionId;
conditionId.value = diagnosisInfo[0].conditionId;
encounterDiagnosisId.value = diagnosisInfo[0].encounterDiagnosisId;
diagnosisName.value = diagnosisInfo[0].name;
})
.catch(error => {
console.error('获取诊断信息失败:', error);
ElMessage.error('获取诊断信息失败');
})
.finally(() => {
// 请求完成后清除Promise引用
diagnosisInfoRequestPromise = null;
getEncounterDiagnosis(patientInfo.value.encounterId).then((res) => {
diagnosisList.value = res.data;
let diagnosisInfo = diagnosisList.value.filter((item) => {
return item.maindiseFlag == 1;
});
return diagnosisInfoRequestPromise;
diagnosisInfo.value = diagnosisInfo[0];
conditionDefinitionId.value = diagnosisInfo[0].definitionId;
conditionId.value = diagnosisInfo[0].conditionId;
encounterDiagnosisId.value = diagnosisInfo[0].encounterDiagnosisId;
diagnosisName.value = diagnosisInfo[0].name;
});
}
function getRowDisabled(row) {