Browse Source

三测单的 入院 时间加空格

LIJU 2 months ago
parent
commit
35435ceed9
1 changed files with 49 additions and 1 deletions
  1. 49 1
      src/components/medical-advice/temperature/graphics.vue

+ 49 - 1
src/components/medical-advice/temperature/graphics.vue

@@ -225,7 +225,8 @@
             :key="y + 'td0'"
             :class="[y % 6 === 5 && y != tdList.length && 'redLineTd']"
           >
-            <div class="recorde-text" :style="recordeTextStyle">{{ getSymbolTextArr(y) }}</div>
+            <!-- <div class="recorde-text" :style="recordeTextStyle">{{ getSymbolTextArr(y) }}</div> -->
+            <div class="recorde-text" :style="recordeTextStyle" v-html="getSymbolHtml(y)"></div>
           </td>
         </tr>
         <tr
@@ -1023,6 +1024,45 @@ export default {
         return "";
       }
     },
+    // 生成可安全渲染的HTML,用于在"入院"和时间之间插入竖向间隔
+    getSymbolHtml(index) {
+      const text = this.getSymbolTextArr(index);
+      if (!text) return "";
+      // 通用处理:将"标注文字 + 中文时间(…时…分)"拆分,插入竖向间隔
+      const si = text.indexOf('时');
+      const fi = text.indexOf('分', si + 1);
+      if (si > 0 && fi > si) {
+        const numerals = '零一二三四五六七八九十';
+        let start = si - 1;
+        // 回溯找到时间数字段起始(中文数字连续区)
+        while (start >= 0 && numerals.indexOf(text.charAt(start)) !== -1) {
+          start--;
+        }
+        start++;
+        if (start > 0) {
+          const label = text.substring(0, start);
+          const timePart = text.substring(start);
+          return (
+            '<span class="admission-wrap">'
+            + '<span class="admission-label">' + this.escapeHtml(label) + '</span>'
+            + '<span class="admission-gap"></span>'
+            + '<span class="admission-time">' + this.escapeHtml(timePart) + '</span>'
+            + '</span>'
+          );
+        }
+      }
+      // 兜底:无法识别时间结构时原样转义输出
+      return this.escapeHtml(text);
+    },
+    // 简单HTML转义,防止渲染其他标注时出现不必要的HTML解析
+    escapeHtml(str) {
+      return String(str)
+        .replace(/&/g, '&amp;')
+        .replace(/</g, '&lt;')
+        .replace(/>/g, '&gt;')
+        .replace(/"/g, '&quot;')
+        .replace(/'/g, '&#39;');
+    },
     temperatureConverter(c) {
       const value = (c * 9) / 5 + 32;
       return value.toFixed(1);
@@ -2250,4 +2290,12 @@ td {
 .table_wrap .legend .legend-item {
   margin-right: 20px;
 }
+/* admission styles must be global to affect v-html content */
+.recorde-text .admission-wrap { display: inline-block; }
+.recorde-text .admission-label,
+.recorde-text .admission-time { display: block; }
+.recorde-text .admission-gap { display: block; height: 14px; }
+@media print {
+  .recorde-text .admission-gap { height: 14px; }
+}
 </style>