Преглед изворни кода

fix(frontend): 报告详情页异常数量修复 + 指标自组装异常统计补齐

- isAbnormalStatus 改为白名单逻辑(与 report-confirm 一致),
  仅 high/low/abnormal/偏高/偏低/异常/缺乏/不足/注意/高风险 计入异常数
- assembleBlocksFromPayload 生成 indicator 块时携带 abnormalCount
- report-blocks-renderer indicator 块标题行显示异常数量
liaoxg пре 2 месеци
родитељ
комит
5a9db18986

+ 6 - 2
cfc-frontend/components/report-blocks-renderer.vue

@@ -33,7 +33,10 @@
 
       <!-- indicator: 指标明细 -->
       <view v-else-if="block.type === 'indicator'" class="block indicator-block">
-        <view class="block-title">{{ block.title }}</view>
+        <view class="block-title">
+          <text>{{ block.title }}</text>
+          <text class="title-abnormal" v-if="block.abnormalCount && block.abnormalCount > 0">,{{ block.abnormalCount }} 项异常</text>
+        </view>
         <view class="indicator-item" v-for="(item, ii) in block.items" :key="getIndicatorKey(ii)">
           <text class="ind-name">{{ item.name }}</text>
           <text class="ind-value">{{ item.value }} {{ item.unit }}</text>
@@ -104,7 +107,8 @@ export default {
 <style scoped>
 .blocks-renderer { width: 100%; }
 .block { background: #fff; border-radius: 16rpx; padding: 24rpx; margin-bottom: 20rpx; }
-.block-title { font-size: 30rpx; font-weight: 600; color: #333; margin-bottom: 20rpx; }
+.block-title { font-size: 30rpx; font-weight: 600; color: #333; margin-bottom: 20rpx; display: flex; align-items: baseline; }
+.title-abnormal { font-size: 24rpx; color: #C62828; font-weight: 400; }
 /* score */
 .score-grid { display: flex; flex-wrap: wrap; }
 .score-item { width: 33.33%; display: flex; flex-direction: column; align-items: center; margin-bottom: 24rpx; }

+ 14 - 3
cfc-frontend/pages/health/report-detail.vue

@@ -759,9 +759,12 @@ export default {
       if (s === 'normal') return '正常'
       return '正常'
     },
+    // 与 report-confirm 保持一致的白名单:仅明确异常/需关注的状态计入异常数,
+    // 未知状态文本(解析器自由提取)一律视为正常,避免"样式正常却计入异常"的矛盾。
     isAbnormalStatus(status) {
-      var s = (status || '').toString()
-      return !(s === '' || s === 'normal' || s === '正常' || s === 'low-risk' || s === '低风险' || s === 'not-detected' || s === '未检出')
+      if (!status) return false
+      var abnormalMap = { 'high': 1, 'low': 1, 'abnormal': 1, '偏高': 1, '偏低': 1, '异常': 1, '缺乏': 1, '不足': 1, '注意': 1, '高风险': 1 }
+      return !!abnormalMap[String(status).trim()]
     },
     showHelp(ind) {
       this.helpData = {
@@ -941,10 +944,12 @@ export default {
       var inds = p.indicators || []
       if (inds.length > 0) {
         var byCat = {}
+        var byCatAbnormal = {}
         for (var ii = 0; ii < inds.length; ii++) {
           var ind = inds[ii]
           var cat = ind.category || '其他指标'
           if (!byCat[cat]) byCat[cat] = []
+          if (byCatAbnormal[cat] === undefined) byCatAbnormal[cat] = 0
           byCat[cat].push({
             name: ind.indicatorName || ind.name || '',
             value: ind.indicatorValue || ind.value || '',
@@ -952,10 +957,16 @@ export default {
             refRange: ind.refRange || '',
             status: ind.status || ''
           })
+          if (this.isAbnormalStatus(ind.status)) byCatAbnormal[cat]++
         }
         var catKeys = Object.keys(byCat)
         for (var ck = 0; ck < catKeys.length; ck++) {
-          blocks.push({ type: 'indicator', title: catKeys[ck], items: byCat[catKeys[ck]] })
+          blocks.push({
+            type: 'indicator',
+            title: catKeys[ck],
+            items: byCat[catKeys[ck]],
+            abnormalCount: byCatAbnormal[catKeys[ck]] || 0
+          })
         }
       }