From 2a7f1326b98ff5ed43d9260566caa0b53d9f2038 Mon Sep 17 00:00:00 2001 From: Auora <14587305+auoraasd@user.noreply.gitee.com> Date: Fri, 31 Oct 2025 16:23:12 +0800 Subject: [PATCH] =?UTF-8?q?[bug]=E4=BF=AE=E6=94=B9=E5=B0=B1=E8=AF=8A?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E5=B0=B1=E8=AF=8A=E6=97=B6=E9=97=B4=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../doctorstation/components/emr/emr.vue | 44 ++++++++++--------- .../src/views/doctorstation/index.vue | 14 ++++++ 2 files changed, 38 insertions(+), 20 deletions(-) diff --git a/openhis-ui-vue3/src/views/doctorstation/components/emr/emr.vue b/openhis-ui-vue3/src/views/doctorstation/components/emr/emr.vue index c4cab1ea..06ac4c58 100644 --- a/openhis-ui-vue3/src/views/doctorstation/components/emr/emr.vue +++ b/openhis-ui-vue3/src/views/doctorstation/components/emr/emr.vue @@ -203,18 +203,32 @@ import { saveEmr, getEmrDetail, saveEmrTemplate } from '../api'; import emrTemplate from '../emr/emrtemplate.vue'; import emrhistory from '../emr/emrhistory.vue'; -import { ref, computed } from 'vue'; +import { ref, computed, watch, getCurrentInstance } from 'vue'; +import { formatDate } from '@/utils/index'; + +// 2. 当前就诊日期(默认为当前时间;复诊为初诊日期) +const props = defineProps({ + patientInfo: { + type: Object, + required: true, + }, + visitType: { // 接收父组件传来的值 + type: String, + default: '', + }, + firstVisitDate: { // 父组件计算的初诊日期(若有历史病历) + type: String, + default: '', + }, +}); -// 2. 当前就诊日期(默认为当前时间) const currentVisitDate = computed(() => { - return new Date().toLocaleString('zh-CN', { - year: 'numeric', - month: '2-digit', - day: '2-digit', - hour: '2-digit', - minute: '2-digit', - second: '2-digit', - }); + // 复诊优先展示初诊日期 + if (props.visitType === 'FOLLOW_UP' && props.firstVisitDate) { + return props.firstVisitDate; + } + // 初诊或未获取初诊日期时,展示挂号时间或当前时间 + return formatDate(props.patientInfo?.registerTime || new Date()); }); const form = ref({}); @@ -228,16 +242,6 @@ const { proxy } = getCurrentInstance(); const showDialog = ref(''); const openEmrTemplate = ref(false); const templateName = ref(''); -const props = defineProps({ - patientInfo: { - type: Object, - required: true, - }, - visitType: { // ✅ 接收父组件传来的值 - type: String, - default: '', - }, -}); watch( () => form.value, diff --git a/openhis-ui-vue3/src/views/doctorstation/index.vue b/openhis-ui-vue3/src/views/doctorstation/index.vue index 0bc76c13..5d691caa 100644 --- a/openhis-ui-vue3/src/views/doctorstation/index.vue +++ b/openhis-ui-vue3/src/views/doctorstation/index.vue @@ -148,6 +148,7 @@ } " :visitType="visitType" + :firstVisitDate="firstVisitDate" /> @@ -266,6 +267,7 @@ const waitCount = ref(0); const loading = ref(false); const { proxy } = getCurrentInstance(); const visitType = ref(''); +const firstVisitDate = ref(''); const disabled = computed(() => { return Object.keys(patientInfo.value).length === 0; }); @@ -294,6 +296,7 @@ function setVisitType(type) { function checkPatientHistory(patient) { // 重置状态 visitTypeDisabled.value = false; + firstVisitDate.value = ''; // 如果患者没有身份证号,无法判断是否为初诊 if (!patient.idCard) { @@ -320,20 +323,31 @@ function checkPatientHistory(patient) { getEmrHistoryList(params).then(res => { if (res.code === 200) { + const records = res.data?.records || []; // 如果有历史记录,则为复诊 if (res.data && res.data.total > 0) { visitType.value = 'FOLLOW_UP'; + // 计算最早一次病历创建时间作为初诊日期 + const earliest = records.reduce((min, cur) => { + const ct = new Date(cur.createTime).getTime(); + return ct < min ? ct : min; + }, new Date(records[0].createTime).getTime()); + // 使用统一格式化 + firstVisitDate.value = formatDate(earliest); } else { // 如果没有历史记录,则为初诊 visitType.value = 'FIRST'; + firstVisitDate.value = ''; } } else { // 请求失败,默认设置为初诊 visitType.value = 'FIRST'; + firstVisitDate.value = ''; } }).catch(() => { // 异常情况,默认设置为初诊 visitType.value = 'FIRST'; + firstVisitDate.value = ''; }); } function getWaitPatient() {