Эх сурвалжийг харах

feat(health.frontend.guheV2Display): S-cfc-428 报告详情异常菌清单/亚健康诊断 + 健康计划底部免责声明

能力键 health.frontend.guheV2Display(P1-3 前端展示增强),契约测试 health-guhe-v2-display.contract.test.js 由红转绿(16/16):

- report-detail.vue:data 新增 abnormalSpecies/speciesLibrary/subhealthLabel/fbRatio/shannonIndexNorm/parseSelfCheck,loadData 从 §6.2 详情响应写入;view 模式新增 guhe_v2 展示卡(亚健康诊断 + F/B 比值 + 菌群多样性 + 解析自检 + 异常菌清单 ↑↓ 分组);:key 走 getSpeciesKey(idx) 避免运算符表达式

- health-plan-summary.vue:底部固定免责声明条(相关关联非因果、不构成医学诊断),.plan-page 预留 padding-bottom

验证:jest 16 passed;verify-vue-compile 模板/样式/脚本 2/2 PASS;audit-mp-antipatterns ERROR 0
Administrator 1 долоо хоног өмнө
parent
commit
d9763ca4f9

+ 25 - 1
cfc-frontend/pages/health/health-plan-summary.vue

@@ -341,6 +341,11 @@
         <button class="btn-done" @click="goBack">完成</button>
       </view>
     </view>
+
+    <!-- 底部固定免责声明(§8.8 红线:相关关联非因果、测试 ≠ 诊断) -->
+    <view class="plan-disclaimer-bar">
+      <text class="plan-disclaimer-text">免责声明:本方案基于报告与问卷信息生成,仅展示相关关联而非因果关系,不构成医学诊断,结果仅供参考;如有不适请及时就医。</text>
+    </view>
   </view>
 </template>
 
@@ -1677,7 +1682,26 @@ selectedMembers: function() {
 .plan-page {
   min-height: 100vh;
   background: $app-bg;
-  padding-bottom: 40rpx;
+  padding-bottom: 140rpx; /* 底部固定免责声明条预留空间 */
+}
+
+/* 底部固定免责声明(§8.8 红线:相关关联非因果、测试 ≠ 诊断) */
+.plan-disclaimer-bar {
+  position: fixed;
+  left: 0;
+  right: 0;
+  bottom: 0;
+  background: $app-surface;
+  border-top: 2rpx solid $facade-hairline;
+  padding: 16rpx 24rpx;
+  z-index: 99;
+}
+.plan-disclaimer-text {
+  display: block;
+  font-size: calc(20rpx * var(--font-scale, 1));
+  color: $facade-text-muted;
+  line-height: 1.6;
+  text-align: center;
 }
 
 /* 步骤条 */

+ 185 - 1
cfc-frontend/pages/health/report-detail.vue

@@ -25,6 +25,46 @@
       <view v-if="pageMode==='view'">
         <report-blocks-renderer v-if="blocks && blocks.length > 0" :blocks="blocks" @help="onBlockHelp" />
         <view class="empty-hint" v-else>暂无报告内容</view>
+
+        <!-- guhe_v2 报告:异常菌清单 + 亚健康诊断(§6.2 接口附加字段 · 入库前核对) -->
+        <view class="card guhe-v2-card" v-if="guheV2SummaryVisible">
+          <view class="guhe-summary-block" v-if="subhealthLabel || fbRatio || shannonIndexNorm">
+            <view class="card-title">
+              <text>亚健康诊断</text>
+            </view>
+            <view class="guhe-subhealth-row" v-if="subhealthLabel">
+              <text class="guhe-label">亚健康诊断</text>
+              <text class="guhe-subhealth-value">{{ subhealthLabel }}</text>
+            </view>
+            <view class="guhe-ratio-row" v-if="fbRatio || shannonIndexNorm">
+              <text class="guhe-ratio-item" v-if="fbRatio">F/B 比值:{{ fbRatio }}</text>
+              <text class="guhe-ratio-item" v-if="shannonIndexNorm">菌群多样性:{{ shannonIndexNorm }}</text>
+            </view>
+            <view class="guhe-selfcheck" v-if="hasParseSelfCheck">
+              <text class="guhe-selfcheck-text">解析自检:{{ parseSelfCheckText }}</text>
+            </view>
+          </view>
+
+          <view class="card-title" v-if="abnormalSpecies && abnormalSpecies.length > 0">
+            <text>异常菌清单</text>
+            <text class="title-count">共 {{ abnormalSpecies.length }} 条</text>
+          </view>
+          <view class="guhe-species-item" v-for="(item, idx) in abnormalSpecies" :key="getSpeciesKey(idx)">
+            <view class="guhe-species-head">
+              <text class="guhe-species-name">{{ item.cnName || item.latinName || '未知菌种' }}</text>
+              <text class="guhe-species-latin" v-if="item.latinName">{{ item.latinName }}</text>
+              <text class="guhe-species-dir" v-if="item.direction">{{ item.direction }}</text>
+            </view>
+            <view class="guhe-species-detail">
+              <text class="guhe-species-meta" v-if="item.abundance">丰度 {{ item.abundance }}</text>
+              <text class="guhe-species-meta" v-if="item.refRange">参考 {{ item.refRange }}</text>
+              <text class="guhe-species-meta" v-if="item.category">{{ item.category }}</text>
+            </view>
+            <text class="guhe-species-func" v-if="item.functionDesc">{{ item.functionDesc }}</text>
+          </view>
+          <view class="empty-hint" v-if="!abnormalSpecies || abnormalSpecies.length === 0">暂无非异常菌记录</view>
+        </view>
+
         <view class="edit-btn" v-if="isGutFlora && pageMode==='view'">
           <view class="nav-edit" @tap="enterEditMode"><text>{{ backendBlocksExist ? '编辑' : '查看完整数据 ›' }}</text></view>
         </view>
@@ -536,7 +576,16 @@ export default {
       // 三档筛选:all 全部 / changed 有变化 / abnormal 异常
       indicatorFilter: 'all',
       // D1 裁定:「显示变化对照」默认开
-      showChangeCompare: true
+      showChangeCompare: true,
+      // ===== 谷禾新版(guhe_v2)报告详情附加字段(§6.2 接口契约)=====
+      // 异常菌清单(↑↓ 分组 12 条)、物种功能库(76 条)、F/B 比值、菌群多样性评级、
+      // 亚健康诊断标签、解析自检 JSON —— 由详情接口响应透传到组件状态,供展示卡片消费
+      abnormalSpecies: [],
+      speciesLibrary: [],
+      subhealthLabel: '',
+      fbRatio: '',
+      shannonIndexNorm: '',
+      parseSelfCheck: {}
     }
   },
   computed: {
@@ -727,6 +776,25 @@ export default {
         if (lists[i] && lists[i].length) total += lists[i].length
       }
       return total
+    },
+    // ===== guhe_v2 报告展示卡片相关计算属性(§6.2 契约)=====
+    guheV2SummaryVisible() {
+      return !!(this.subhealthLabel || this.fbRatio || this.shannonIndexNorm ||
+                (this.abnormalSpecies && this.abnormalSpecies.length > 0))
+    },
+    hasParseSelfCheck() {
+      return this.parseSelfCheck && typeof this.parseSelfCheck === 'object' &&
+             Object.keys(this.parseSelfCheck).length > 0
+    },
+    parseSelfCheckText() {
+      if (!this.hasParseSelfCheck) return ''
+      var p = this.parseSelfCheck
+      var parts = []
+      if (p.通过 !== undefined) parts.push(p.通过 ? '通过' : '未通过')
+      if (p.P0 !== undefined) parts.push('P0: ' + p.P0)
+      if (p.P1 !== undefined) parts.push('P1: ' + p.P1)
+      if (p.errorText) parts.push(p.errorText)
+      return parts.length ? parts.join(';') : JSON.stringify(p)
     }
   },
   onLoad(options) {
@@ -752,6 +820,10 @@ export default {
     openFeedback: function() {
       this.feedbackVisible = true
     },
+    // guhe_v2 异常菌条目 :key(数组无稳定业务主键,用遍历序号;模板禁带运算符表达式)
+    getSpeciesKey: function(idx) {
+      return 'species-' + idx
+    },
     closeFeedback: function() {
       this.feedbackVisible = false
     },
@@ -771,6 +843,13 @@ export default {
           head.reportDate = report.reportDate ? formatDate(report.reportDate) : ''
           head.reportDateText = head.reportDate
           self.headInfo = head
+          // ===== §6.2 guhe_v2 报告详情附加字段:透传到组件状态供展示卡片消费 =====
+          self.abnormalSpecies = (res.data.abnormalSpecies && Array.isArray(res.data.abnormalSpecies)) ? res.data.abnormalSpecies : []
+          self.speciesLibrary = (res.data.speciesLibrary && Array.isArray(res.data.speciesLibrary)) ? res.data.speciesLibrary : []
+          self.subhealthLabel = res.data.subhealthLabel || ''
+          self.fbRatio = res.data.fbRatio || ''
+          self.shannonIndexNorm = res.data.shannonIndexNorm || ''
+          self.parseSelfCheck = (res.data.parseSelfCheck && typeof res.data.parseSelfCheck === 'object') ? res.data.parseSelfCheck : {}
           var backendBlocks = (res.data && res.data.blocks) || report.blocks || []
           if (res.data.payload) {
             self.payload = Object.assign({}, self.defaultPayload(), res.data.payload)
@@ -1712,6 +1791,111 @@ $c-rptd-orange-line: #FFD4A8; // 暖橙描边
   color: $app-text-subtle;
   margin-left: 8rpx;
 }
+
+/* ===== guhe_v2 报告展示卡(§6.2 异常菌清单 + 亚健康诊断) ===== */
+.guhe-v2-card {
+  margin: 20rpx 0;
+  padding: 24rpx;
+  background: $app-surface;
+  border-radius: 16rpx;
+}
+.guhe-summary-block {
+  margin-bottom: 20rpx;
+}
+.guhe-subhealth-row {
+  display: flex;
+  flex-direction: row;
+  align-items: center;
+  flex-wrap: wrap;
+  margin-top: 12rpx;
+}
+.guhe-label {
+  font-size: calc(24rpx * var(--font-scale, 1));
+  color: $facade-text-muted;
+  margin-right: 12rpx;
+}
+.guhe-subhealth-value {
+  font-size: calc(28rpx * var(--font-scale, 1));
+  font-weight: 600;
+  color: $mat-orange-strong;
+}
+.guhe-ratio-row {
+  display: flex;
+  flex-direction: row;
+  flex-wrap: wrap;
+  gap: 24rpx;
+  margin-top: 12rpx;
+}
+.guhe-ratio-item {
+  font-size: calc(24rpx * var(--font-scale, 1));
+  color: $facade-text-body;
+  background: $c-rptd-card;
+  padding: 8rpx 16rpx;
+  border-radius: 10rpx;
+}
+.guhe-selfcheck {
+  margin-top: 12rpx;
+}
+.guhe-selfcheck-text {
+  font-size: calc(22rpx * var(--font-scale, 1));
+  color: $facade-text-muted;
+  line-height: 1.6;
+}
+.guhe-species-item {
+  border: 2rpx solid $c-rptd-line;
+  border-radius: 14rpx;
+  padding: 18rpx;
+  margin-bottom: 16rpx;
+  background: $facade-fill-slate;
+}
+.guhe-species-head {
+  display: flex;
+  flex-direction: row;
+  align-items: center;
+  flex-wrap: wrap;
+}
+.guhe-species-name {
+  font-size: calc(28rpx * var(--font-scale, 1));
+  font-weight: 600;
+  color: $facade-text-strong;
+  margin-right: 12rpx;
+}
+.guhe-species-latin {
+  font-size: calc(22rpx * var(--font-scale, 1));
+  color: $facade-text-muted;
+  font-style: italic;
+  margin-right: 12rpx;
+  flex: 1;
+}
+.guhe-species-dir {
+  font-size: calc(24rpx * var(--font-scale, 1));
+  font-weight: 600;
+  color: $mat-orange-strong;
+  background: $c-rptd-orange-tint;
+  padding: 2rpx 12rpx;
+  border-radius: 8rpx;
+}
+.guhe-species-detail {
+  display: flex;
+  flex-direction: row;
+  flex-wrap: wrap;
+  gap: 16rpx;
+  margin-top: 12rpx;
+}
+.guhe-species-meta {
+  font-size: calc(22rpx * var(--font-scale, 1));
+  color: $facade-text-body;
+  background: $app-surface;
+  padding: 4rpx 12rpx;
+  border-radius: 8rpx;
+}
+.guhe-species-func {
+  display: block;
+  font-size: calc(22rpx * var(--font-scale, 1));
+  color: $facade-text-muted;
+  line-height: 1.6;
+  margin-top: 10rpx;
+}
 .title-abnormal {
   font-size: calc(24rpx * var(--font-scale, 1));
   font-weight: normal;