Parcourir la source

婴儿三测单的婴儿出生日

LIJU il y a 1 semaine
Parent
commit
89b97208d0
1 fichiers modifiés avec 36 ajouts et 3 suppressions
  1. 36 3
      src/components/medical-advice/temperature/babyGraphics.vue

+ 36 - 3
src/components/medical-advice/temperature/babyGraphics.vue

@@ -81,10 +81,10 @@
             :colspan="index === 0 ? 8 : 6"
             :class="[index && 'redLineTd', !index && 'table-just']"
             :style="index !== 0 ? { color: 'red' } : {}"
-            v-for="(item, index) in surgeryDays"
-            :key="index + '|surgeryDays'"
+            v-for="(item, index) in birthDays"
+            :key="index + '|birthDays'"
           >
-            {{ index === 0 ? "手术后天数" : ((item === 0 || item) ? item : '') }}
+            {{ index === 0 ? "婴儿出生日" : ((item === 0 || item) ? item : '') }}
           </td>
         </tr>
         <tr>
@@ -814,6 +814,39 @@ export default {
         return initday;
       }
     },
+    // 婴儿出生日(当日为1,之后递增;之前为空),与表头对齐返回8格
+    birthDays() {
+      try {
+        const result = [''];
+        const begin = this.info.beginDate ? dayjs(this.info.beginDate).startOf('day') : null;
+        const birth = this.info.birthDateTime ? dayjs(this.info.birthDateTime).startOf('day') : null;
+        const today = dayjs().startOf('day');
+        if (!begin || !birth) {
+          for (let i = 0; i < 7; i++) result.push('');
+          return result;
+        }
+        for (let i = 0; i < 7; i++) {
+          const cur = begin.add(i, 'day');
+          if (cur.isAfter(today)) {
+            // 超过今天不显示
+            result.push('');
+            continue;
+          }
+          const diff = cur.diff(birth, 'day');
+          if (diff < 0) {
+            result.push('');
+          } else {
+            result.push(diff + 1);
+          }
+        }
+        return result;
+      } catch (e) {
+        // 兜底:任何异常返回空行,避免影响其它显示
+        const fallback = [''];
+        for (let i = 0; i < 7; i++) fallback.push('');
+        return fallback;
+      }
+    },
   },
   mounted() {
     for (let i = 0; i < 43; i++) {