From 4f0cc1a0c4e77293c1467366e0b067ea11495068 Mon Sep 17 00:00:00 2001 From: chenqi Date: Tue, 27 Jan 2026 17:32:03 +0800 Subject: [PATCH] =?UTF-8?q?refactor(ui):=20=E4=BC=98=E5=8C=96=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E6=A0=B7=E5=BC=8F=E5=92=8C=E6=95=B0=E6=8D=AE=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将多个按钮组件从 type="text" 改为 link 属性,提升界面美观性 - 修复 PatientList 组件中姓名显示的文本截断功能 - 在住院记录模板中添加对 patientInfo 变化的监听,自动更新表单数据 - 优化打印机列表获取逻辑,添加连接状态检查和警告信息 - 移除不必要的防抖和重复请求防护逻辑,简化代码实现 - 修复多处组件中对 patientInfo 属性访问的安全性问题 - 优化病历数据加载时机,移除防抖包装直接调用加载函数 - 改进数据设置逻辑,避免覆盖未传入字段的原有值 - 调整组件属性定义,使 patientInfo 参数变为可选并设置默认值 - 优化患者切换时的组件重置和数据加载流程 --- .../src/components/PatientList/index.vue | 4 +- .../src/components/TableLayout/Filter.vue | 2 +- .../src/template/inHospitalRecord.vue | 26 +- openhis-ui-vue3/src/utils/his.js | 12 +- openhis-ui-vue3/src/utils/printUtils.js | 12 +- .../basicmanage/ordersCombination/index.vue | 4 +- .../hospitalizationEmr/components/history.vue | 30 +-- .../components/hospitalizationEmr/index.vue | 42 +-- .../inspection/inspectionApplication.vue | 8 +- .../src/views/doctorstation/index.vue | 11 +- .../components/admissionRecord.vue | 7 +- .../home/components/adviceBaseList.vue | 2 +- .../home/components/diagnosis/diagnosis.vue | 3 +- .../applicationFormBottomBtn.vue | 17 +- .../home/components/order/index.vue | 101 ++------ .../home/emr/components/history.vue | 22 +- .../views/inpatientDoctor/home/emr/index.vue | 240 ++++++++---------- .../src/views/inpatientDoctor/home/index.vue | 70 +---- .../InpatientBilling/components/FeeDialog.vue | 2 +- .../components/OrderBilling.vue | 2 +- .../components/billingList.vue | 2 +- 21 files changed, 232 insertions(+), 387 deletions(-) diff --git a/openhis-ui-vue3/src/components/PatientList/index.vue b/openhis-ui-vue3/src/components/PatientList/index.vue index 25931875..7b83d75c 100644 --- a/openhis-ui-vue3/src/components/PatientList/index.vue +++ b/openhis-ui-vue3/src/components/PatientList/index.vue @@ -12,7 +12,7 @@ @keyup.enter="handleSearch" :prefix-icon="Search" /> - + @@ -36,7 +36,7 @@
- + {{ item.patientName || '-' }}
diff --git a/openhis-ui-vue3/src/components/TableLayout/Filter.vue b/openhis-ui-vue3/src/components/TableLayout/Filter.vue index a9c1711d..c42fed9f 100644 --- a/openhis-ui-vue3/src/components/TableLayout/Filter.vue +++ b/openhis-ui-vue3/src/components/TableLayout/Filter.vue @@ -23,7 +23,7 @@ 搜索 重置 - + {{ isExpanded ? '收起' : '展开' }} diff --git a/openhis-ui-vue3/src/template/inHospitalRecord.vue b/openhis-ui-vue3/src/template/inHospitalRecord.vue index 0da2a4cb..2b33b258 100644 --- a/openhis-ui-vue3/src/template/inHospitalRecord.vue +++ b/openhis-ui-vue3/src/template/inHospitalRecord.vue @@ -565,6 +565,26 @@ const rules = reactive({ chiefComplaint: [{ required: true, message: '请填写主诉', trigger: ['blur', 'submit'] }], }); +// 监听 patientInfo 变化,更新表单数据 +watch( + () => props.patientInfo, + (newPatientInfo) => { + if (newPatientInfo) { + // 更新基础信息 + formData.patientName = newPatientInfo.patientName || newPatientInfo.name || ''; + formData.hospitalNo = newPatientInfo.busNo || newPatientInfo.hospitalNo || ''; + formData.gender = newPatientInfo.genderEnum_enumText || newPatientInfo.gender || ''; + formData.age = newPatientInfo.age || ''; + formData.nation = newPatientInfo.nation || ''; + formData.occupation = newPatientInfo.profession || ''; + formData.marriage = newPatientInfo.maritalStatus || ''; + formData.birthplace = newPatientInfo.birthPlace || ''; + // 可以根据需要更新更多字段 + } + }, + { deep: true, immediate: true } +); + // 生命周期 onMounted(() => { // 初始化记录时间为当前时间 @@ -578,16 +598,16 @@ onMounted(() => { formData.signDate = formatDateTime(new Date()); } if (!formData.patientName) { - formData.patientName = patient?.patientName || ''; + formData.patientName = patient?.patientName || patient?.name || ''; } if (!formData.gender) { - formData.gender = patient?.genderEnum_enumText || ''; + formData.gender = patient?.genderEnum_enumText || patient?.gender || ''; } if (!formData.age) { formData.age = patient?.age || ''; } if (!formData.hospitalNo) { - formData.hospitalNo = patient?.busNo || ''; + formData.hospitalNo = patient?.busNo || patient?.hospitalNo || ''; } }); diff --git a/openhis-ui-vue3/src/utils/his.js b/openhis-ui-vue3/src/utils/his.js index 48b59c36..afef3ce3 100644 --- a/openhis-ui-vue3/src/utils/his.js +++ b/openhis-ui-vue3/src/utils/his.js @@ -334,11 +334,13 @@ export function handleColor(a, b, status) { */ export function getPrinterList() { try { - const printerList = - window.hiprint && window.hiprint.hiwebSocket - ? window.hiprint.hiwebSocket.getPrinterList() - : []; - return printerList || []; + if (window.hiprint && window.hiprint.hiwebSocket && window.hiprint.hiwebSocket.connected) { + const printerList = window.hiprint.hiwebSocket.getPrinterList(); + return printerList || []; + } else { + console.warn('打印服务未连接,返回空打印机列表'); + return []; + } } catch (error) { console.error('获取打印机列表失败:', error); return []; diff --git a/openhis-ui-vue3/src/utils/printUtils.js b/openhis-ui-vue3/src/utils/printUtils.js index 9a760cbf..0deeb324 100644 --- a/openhis-ui-vue3/src/utils/printUtils.js +++ b/openhis-ui-vue3/src/utils/printUtils.js @@ -151,11 +151,13 @@ export const PRINT_TEMPLATE = { */ export function getPrinterList() { try { - const printerList = - window.hiprint && window.hiprint.hiwebSocket - ? window.hiprint.hiwebSocket.getPrinterList() - : []; - return printerList || []; + if (window.hiprint && window.hiprint.hiwebSocket && window.hiprint.hiwebSocket.connected) { + const printerList = window.hiprint.hiwebSocket.getPrinterList(); + return printerList || []; + } else { + console.warn('打印服务未连接,返回空打印机列表'); + return []; + } } catch (error) { console.error('获取打印机列表失败:', error); return []; diff --git a/openhis-ui-vue3/src/views/basicmanage/ordersCombination/index.vue b/openhis-ui-vue3/src/views/basicmanage/ordersCombination/index.vue index 77bf5fb5..4c70b6a1 100644 --- a/openhis-ui-vue3/src/views/basicmanage/ordersCombination/index.vue +++ b/openhis-ui-vue3/src/views/basicmanage/ordersCombination/index.vue @@ -52,8 +52,8 @@ diff --git a/openhis-ui-vue3/src/views/doctorstation/components/hospitalizationEmr/components/history.vue b/openhis-ui-vue3/src/views/doctorstation/components/hospitalizationEmr/components/history.vue index 31c7f375..4608d09f 100644 --- a/openhis-ui-vue3/src/views/doctorstation/components/hospitalizationEmr/components/history.vue +++ b/openhis-ui-vue3/src/views/doctorstation/components/hospitalizationEmr/components/history.vue @@ -42,7 +42,6 @@ import {defineEmits, ref, unref} from 'vue'; import {deleteRecord, getRecordByEncounterIdList} from '../api'; import {ElMessage} from 'element-plus'; import {patientInfo} from '../../store/patient.js'; -import apiRequestManager from '@/utils/apiRequestManager.js'; const emits = defineEmits(['historyClick']); const props = defineProps({ @@ -68,30 +67,15 @@ const queryParams = ref({ isPage: 0, }); const historyData = ref([]); -// 防止重复加载的标志 -let isLoadingHistory = false; - const queryList = async () => { - // 防止重复加载 - if (isLoadingHistory) { - console.log('History data is already loading, skipping duplicate call'); - return; - } - - isLoadingHistory = true; - try { if (patientInfo.value.encounterId && unref(definitionId) && unref(definitionId) !== '') { - const res = await apiRequestManager.execute( - getRecordByEncounterIdList, - '/document/record/getRecordByEncounterIdList', - { - isPage: 0, // 确保参数一致,便于去重 - encounterId: patientInfo.value.encounterId, - patientId: patientInfo.value.patientId, - definitionId: unref(definitionId), - } - ); + const res = await getRecordByEncounterIdList({ + ...queryParams.value, + encounterId: patientInfo.value.encounterId, + patientId: patientInfo.value.patientId, + definitionId: unref(definitionId), + }); historyData.value = res.data || []; } else { historyData.value = []; @@ -99,8 +83,6 @@ const queryList = async () => { } catch (error) { // ElMessage.error(' 获取模板树失败 '); historyData.value = []; - } finally { - isLoadingHistory = false; // 重置加载标志 } }; const handleNodeClick = (data) => { diff --git a/openhis-ui-vue3/src/views/doctorstation/components/hospitalizationEmr/index.vue b/openhis-ui-vue3/src/views/doctorstation/components/hospitalizationEmr/index.vue index f05eeac2..300b6cf5 100644 --- a/openhis-ui-vue3/src/views/doctorstation/components/hospitalizationEmr/index.vue +++ b/openhis-ui-vue3/src/views/doctorstation/components/hospitalizationEmr/index.vue @@ -103,7 +103,6 @@ import dayjs from 'dayjs'; // 打印工具 import {PRINT_TEMPLATE, simplePrint} from '@/utils/printUtils.js'; import {getEncounterDiagnosis} from '../api'; -import apiRequestManager from '@/utils/apiRequestManager.js'; import History from './components/history'; import Template from './components/template'; import TemplateEdit from './components/templateEdit.vue'; @@ -206,7 +205,7 @@ const handleNodeClick = (data, node) => { // 选择任何病历模板后,都加载该病历类型的最新历史记录 if (node.isLeaf && props.patientInfo && props.patientInfo.patientId) { - debouncedLoadLatestMedicalRecord(); + loadLatestMedicalRecord(); } }, 100); }); @@ -280,7 +279,7 @@ const handleSubmitOk = async (data) => { // 等待历史记录列表更新后,重新加载最新病历并更新选中状态 setTimeout(() => { - debouncedLoadLatestMedicalRecord(); + loadLatestMedicalRecord(); }, 100); } catch (error) { ElMessage.error('提交失败'); @@ -411,7 +410,7 @@ const selectOutpatientMedicalRecordTemplate = async () => { // 等待模板加载完成,然后获取并回显最新病历数据 setTimeout(() => { historyRef.value?.queryList(); - debouncedLoadLatestMedicalRecord(); + loadLatestMedicalRecord(); }, 500); }); } else { @@ -422,36 +421,19 @@ const selectOutpatientMedicalRecordTemplate = async () => { // 当前选中的历史病历ID,用于在History组件中高亮显示 const selectedHistoryRecordId = ref(''); -import { debounce } from 'lodash-es'; - -// 防止重复加载的标志 -let isLoadingLatestRecord = false; - // 加载最新的病历数据并回显 const loadLatestMedicalRecord = async () => { if (!patientInfo.value.encounterId || !currentSelectTemplate.value.id) return; - // 防止重复加载 - if (isLoadingLatestRecord) { - console.log('Latest medical record is already loading, skipping duplicate call'); - return; - } - - isLoadingLatestRecord = true; loading.value = true; - try { // 获取患者的历史病历记录 - const res = await apiRequestManager.execute( - getRecordByEncounterIdList, - '/document/record/getRecordByEncounterIdList', - { - isPage: 0, - encounterId: patientInfo.value.encounterId, - patientId: patientInfo.value.patientId, - definitionId: currentSelectTemplate.value.id, - } - ); + const res = await getRecordByEncounterIdList({ + isPage: 0, + encounterId: patientInfo.value.encounterId, + patientId: patientInfo.value.patientId, + definitionId: currentSelectTemplate.value.id, + }); const historyRecords = res.data || []; if (historyRecords.length > 0) { @@ -537,12 +519,8 @@ const loadLatestMedicalRecord = async () => { }); } finally { loading.value = false; - isLoadingLatestRecord = false; // 重置加载标志 } }; - -// 防抖版本的加载最新病历数据函数 -const debouncedLoadLatestMedicalRecord = debounce(loadLatestMedicalRecord, 300); const templateRef = ref(null); const handleTemplateClick = (data) => { @@ -772,7 +750,7 @@ const selectDefaultTemplate = () => { // 直接加载最新病历数据,不再使用额外的setTimeout延迟 // 因为handleNodeClick中已经有nextTick和setTimeout处理组件渲染 - debouncedLoadLatestMedicalRecord(); + loadLatestMedicalRecord(); }); } else { console.log('未找到门诊病历模板'); diff --git a/openhis-ui-vue3/src/views/doctorstation/components/inspection/inspectionApplication.vue b/openhis-ui-vue3/src/views/doctorstation/components/inspection/inspectionApplication.vue index 55cc219c..9d761a01 100644 --- a/openhis-ui-vue3/src/views/doctorstation/components/inspection/inspectionApplication.vue +++ b/openhis-ui-vue3/src/views/doctorstation/components/inspection/inspectionApplication.vue @@ -59,8 +59,8 @@ @@ -379,7 +379,7 @@
已选择 - 清空 + 清空
@@ -393,7 +393,7 @@ {{ item.itemName }} ¥{{ item.itemPrice }} { @@ -493,8 +492,7 @@ function handleOpen() { patientDrawerRef.value.refreshList(); } -// 原始的handleCardClick函数 -function handleCardClickOriginal(item, index) { +function handleCardClick(item, index) { console.log('handleCardClick 被调用'); console.log('点击的患者项目:', item); console.log('患者项目中的encounterId:', item.encounterId); @@ -560,9 +558,6 @@ function handleCardClickOriginal(item, index) { }); } -// 使用防抖的handleCardClick函数,防止短时间内多次点击 -const handleCardClick = debounce(handleCardClickOriginal, 500); - function handleLeave(encounterId) { leaveEncounter(encounterId).then((res) => { if (res.code == 200) { @@ -615,7 +610,7 @@ function handleHospitalizationClick() { // 接诊回调 function handleReceive(row) { - handleCardClickOriginal(row); + handleCardClick(row); currentEncounterId.value = row.encounterId; drawer.value = false; getPatientList(); @@ -802,7 +797,7 @@ const markSeen = async () => { currentCallPatient.value = {}; }; const callThis = (row) => { - handleCardClickOriginal(row); + handleCardClick(row); currentCallPatient.value = row; dialogVisible.value = false; // 刷新患者列表和候诊列表 diff --git a/openhis-ui-vue3/src/views/hospitalRecord/components/admissionRecord.vue b/openhis-ui-vue3/src/views/hospitalRecord/components/admissionRecord.vue index 9c7818fc..75529d46 100644 --- a/openhis-ui-vue3/src/views/hospitalRecord/components/admissionRecord.vue +++ b/openhis-ui-vue3/src/views/hospitalRecord/components/admissionRecord.vue @@ -699,7 +699,12 @@ const getDom = () => { }; const setData = (data) => { console.log('设置数据=========>', JSON.stringify(data)); - Object.assign(formData, data); + // 仅更新传入的数据,保留未传入字段的原有值 + Object.keys(data).forEach(key => { + if (formData.hasOwnProperty(key)) { + formData[key] = data[key]; + } + }); }; defineExpose({ setData, diff --git a/openhis-ui-vue3/src/views/inpatientDoctor/home/components/adviceBaseList.vue b/openhis-ui-vue3/src/views/inpatientDoctor/home/components/adviceBaseList.vue index 576f9216..2b568c0b 100644 --- a/openhis-ui-vue3/src/views/inpatientDoctor/home/components/adviceBaseList.vue +++ b/openhis-ui-vue3/src/views/inpatientDoctor/home/components/adviceBaseList.vue @@ -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); diff --git a/openhis-ui-vue3/src/views/inpatientDoctor/home/components/diagnosis/diagnosis.vue b/openhis-ui-vue3/src/views/inpatientDoctor/home/components/diagnosis/diagnosis.vue index e888fff1..48fd7566 100644 --- a/openhis-ui-vue3/src/views/inpatientDoctor/home/components/diagnosis/diagnosis.vue +++ b/openhis-ui-vue3/src/views/inpatientDoctor/home/components/diagnosis/diagnosis.vue @@ -203,7 +203,8 @@ const form = ref({ const props = defineProps({ patientInfo: { type: Object, - required: true, + required: false, + default: () => ({}), }, }); const emits = defineEmits(['diagnosisSave']); diff --git a/openhis-ui-vue3/src/views/inpatientDoctor/home/components/order/applicationForm/applicationFormBottomBtn.vue b/openhis-ui-vue3/src/views/inpatientDoctor/home/components/order/applicationForm/applicationFormBottomBtn.vue index 38efb596..7b779ec9 100644 --- a/openhis-ui-vue3/src/views/inpatientDoctor/home/components/order/applicationForm/applicationFormBottomBtn.vue +++ b/openhis-ui-vue3/src/views/inpatientDoctor/home/components/order/applicationForm/applicationFormBottomBtn.vue @@ -10,25 +10,25 @@ 检验 检查 输血 手术 @@ -58,14 +58,19 @@