Просмотр исходного кода

fix(health): 手风琴异常统计口径改为白名单

- 新增 isAbnormalStatus 方法:明确白名单(high/low/abnormal/偏高/偏低/异常/缺乏/不足/注意/高风险/过多)计入异常数
- 原来 'status !== '正常'' 会将未知/英文状态误判为异常(如 PHYLUM/CLASS 等层级行的空 status)
- _cssForStatus 增加中英文双语言映射,与 report-confirm 保持一致
E2E Test Bot 2 месяцев назад
Родитель
Сommit
6b0168802f
1 измененных файлов с 15 добавлено и 7 удалено
  1. 15 7
      cfc-frontend/pages/health/gut-flora-detail.vue

+ 15 - 7
cfc-frontend/pages/health/gut-flora-detail.vue

@@ -286,7 +286,7 @@ export default {
       for (var i = 0; i < list.length; i++) {
         var item = list[i]
         if (item.indicatorValue && String(item.indicatorValue).trim() !== '') valid++
-        if (item.status && item.status !== '正常') abnormal++
+        if (this.isAbnormalStatus(item.status)) abnormal++
       }
       return { total: list.length, valid: valid, abnormal: abnormal }
     },
@@ -300,7 +300,7 @@ export default {
       for (var i = 0; i < list.length; i++) {
         var item = list[i]
         if (item.indicatorValue && String(item.indicatorValue).trim() !== '') valid++
-        if (item.status && item.status !== '正常') abnormal++
+        if (this.isAbnormalStatus(item.status)) abnormal++
       }
       return { total: list.length, valid: valid, abnormal: abnormal }
     }
@@ -317,10 +317,18 @@ export default {
   },
   methods: {
     goBack: function() { uni.navigateBack() },
-    /** 中文状态 → CSS安全英文 */
+    /** 状态 → CSS安全英文(兼容中英文,与 report-confirm 保持一致) */
     _cssForStatus: function(s) {
-      var map = { '偏高': 'high', '过多': 'excess', '偏低': 'low', '缺乏': 'deficient', '不足': 'insufficient', '异常': 'abnormal', '注意': 'warning' }
-      return map[s] || 'normal'
+      var k = String(s || '').trim()
+      var map = { 'high': 'high', 'low': 'low', 'abnormal': 'abnormal', 'normal': 'normal', '缺乏': 'deficient', '偏低': 'low', '不足': 'insufficient', '正常': 'normal', '注意': 'warning', '偏高': 'high', '异常': 'abnormal', '过多': 'excess', '高风险': 'high-risk', '低风险': 'low-risk', '未检出': 'not-detected' }
+      return map[k] || 'normal'
+    },
+    // 与 _cssForStatus 保持同一白名单:仅明确异常/需关注的状态计入异常数,未知状态视为正常,避免“样式正常却计入异常”
+    isAbnormalStatus: function(status) {
+      if (!status) return false
+      var k = String(status).trim()
+      var abnormalMap = { 'high': 1, 'low': 1, 'abnormal': 1, '偏高': 1, '偏低': 1, '异常': 1, '缺乏': 1, '不足': 1, '注意': 1, '高风险': 1, '过多': 1 }
+      return !!abnormalMap[k]
     },
     statusKey: function(s) {
       var map = { '良好': 'good', '注意': 'warning', '需关注': 'danger', '关注': 'danger', '正常': 'normal', '偏高': 'high', '偏低': 'low' }
@@ -336,10 +344,10 @@ export default {
           self.buildScores(res.data)
           self.buildIndicators(res.data)
           self.floraCount = (res.data.gutFlora || []).length
-          // 菌群详情:统计异常/需关注的数量(状态非"正常"即视为需关注)
+          // 菌群详情:统计异常/需关注的数量(白名单,与手风琴异常口径一致)
           var flora = res.data.gutFlora || []
           self.floraAbnormalCount = flora.filter(function(i) {
-            return i.status && i.status !== '正常'
+            return self.isAbnormalStatus(i.status)
           }).length
           self.riskCount = (res.data.diseaseRisks || []).length
           // 疾病风险:统计需关注的数量(风险等级非"低风险"即视为需关注)