Browse Source

BabyPatientInfo组件字段修改

LIJU 1 week ago
parent
commit
74eee6609c
1 changed files with 27 additions and 6 deletions
  1. 27 6
      src/components/medical-advice/BabyPatientInfo.vue

+ 27 - 6
src/components/medical-advice/BabyPatientInfo.vue

@@ -6,17 +6,17 @@
   <el-descriptions-item label="姓名">
     {{ props.patientInfo.name }}
   </el-descriptions-item>
-  <el-descriptions-item label="出生日期">
-    {{ props.patientInfo.birthDate }} {{ companyFunc(props.patientInfo.age, '岁') }}
+  <el-descriptions-item label="出生时间">
+    {{ props.patientInfo.birthDateTime }} {{ ageFromBirthText(props.patientInfo.birthDateTime) }}
   </el-descriptions-item>
   <el-descriptions-item label="性别">
     {{ props.patientInfo.sexName }}
   </el-descriptions-item>
-  <el-descriptions-item label="入院日期">
-    {{ props.patientInfo.admissDate }}
+  <el-descriptions-item label="出生体重">
+    {{ companyFunc(props.patientInfo.babyBirthWeight, 'g') }}
   </el-descriptions-item>
-  <el-descriptions-item label="住院天数">
-    {{ companyFunc(props.patientInfo.actIptDays,'天') }}
+  <el-descriptions-item label="出生身高">
+    {{ companyFunc(props.patientInfo.babyBirthHeight,'cm') }}
   </el-descriptions-item>
   <el-descriptions-item label="管床医生">
     {{ props.patientInfo.referPhysicianName }}
@@ -77,6 +77,27 @@ const companyFunc = (val, company) => {
   }
 }
 
+// 规则:出生未满24小时显示“X小时”,满24小时后显示“X天”(按24小时整除)
+const ageFromBirthText = (birthDateTime) => {
+  if (!stringNotBlank(birthDateTime)) return ''
+  try {
+    const birth = new Date(birthDateTime)
+    const now = new Date()
+    const diffMs = now.getTime() - birth.getTime()
+    if (diffMs < 0) return ''
+    const msPerHour = 60 * 60 * 1000
+    const msPerDay = 24 * msPerHour
+    if (diffMs < msPerDay) {
+      const hours = Math.floor(diffMs / msPerHour)
+      return hours + '小时'
+    }
+    const days = Math.floor(diffMs / msPerDay)
+    return days + '天'
+  } catch (e) {
+    return ''
+  }
+}
+
 
 onMounted(() => {
 })