Quellcode durchsuchen

'整理床位年龄'

yaodeguang vor 1 Monat
Ursprung
Commit
1d5abf20ac
1 geänderte Dateien mit 15 neuen und 1 gelöschten Zeilen
  1. 15 1
      src/views/medical-advice/patient-info/AdjustBed.vue

+ 15 - 1
src/views/medical-advice/patient-info/AdjustBed.vue

@@ -101,7 +101,7 @@
               </div>
               <div class="bodyOuter">
                 <div class="inlineBlock">{{ item.roomNo }}</div>
-                <div class="inlineBlock" v-if="item.name">{{ item.sexName }} 22岁</div>
+                <div class="inlineBlock" v-if="item.name">{{ item.sexName + ' ' + handleAge(item.birthDate, item.currentDate) }}</div>
               </div>
               <div v-if="item.name" style="width:100%">
                 <div class="bodyOuter">
@@ -368,6 +368,20 @@ function handleClickReceive(row) {
   }).catch(() => {})
 }
 
+const handleAge = (birthDate,currentDate) => {
+  const today = new Date(currentDate);
+  const birth = new Date(birthDate);
+
+  let age = today.getFullYear() - birth.getFullYear();
+  const month = today.getMonth() - birth.getMonth();
+
+  if (month < 0 || (month === 0 && today.getDate() < birth.getDate())) {
+    age--;
+  }
+
+  return age;
+}
+
 function handleSelectPh(val) {
   receiveRow.value.phry = val.code
   showSearchPh.value = false