Sfoglia il codice sorgente

feat(frontend): 统一报告详情页 report-detail(blocks 渲染)

Xiaogang Liao 1 mese fa
parent
commit
6c6948bdcf

+ 6 - 0
cfc-frontend/pages.json

@@ -894,6 +894,12 @@
           "style": {
             "navigationBarTitleText": "调研记录"
           }
+        },
+        {
+          "path": "report-detail",
+          "style": {
+            "navigationBarTitleText": "报告详情"
+          }
         }
       ]
     },

+ 90 - 0
cfc-frontend/pages/health/report-detail.vue

@@ -0,0 +1,90 @@
+<template>
+  <view class="page">
+    <view class="nav-bar">
+      <view class="nav-back" @tap="goBack"><text class="back-text">‹ 返回</text></view>
+      <text class="nav-title">{{ typeLabel }}</text>
+    </view>
+    <scroll-view class="content" scroll-y>
+      <!-- 报告头 -->
+      <view class="report-head" v-if="headInfo">
+        <view class="head-name">{{ headInfo.personName || headInfo.childName || '健康报告' }}</view>
+        <view class="head-meta">
+          <text class="type-badge">{{ typeLabel }}</text>
+          <text class="head-date">{{ headInfo.reportDateText || '' }}</text>
+        </view>
+      </view>
+      <!-- blocks 渲染 -->
+      <report-blocks-renderer v-if="blocks && blocks.length > 0" :blocks="blocks" />
+      <view class="empty-hint" v-else>暂无报告内容</view>
+    </scroll-view>
+  </view>
+</template>
+
+<script>
+import ReportBlocksRenderer from '../../components/report-blocks-renderer.vue'
+import { getReportDetail, getDanReportDetail } from '../../utils/api.js'
+import { parseDate } from '../../utils/format.js'
+
+export default {
+  components: { ReportBlocksRenderer },
+  data() {
+    return {
+      reportType: '',
+      reportId: null,
+      blocks: [],
+      headInfo: null
+    }
+  },
+  computed: {
+    typeLabel: function() {
+      var map = { 'gut_flora': '肠道菌群报告', 'dan': 'DAN测评报告', 'physical_exam': '体检报告', 'tongue': '舌诊报告' }
+      return map[this.reportType] || '报告详情'
+    }
+  },
+  onLoad: function(options) {
+    this.reportType = options.reportType || 'gut_flora'
+    this.reportId = options.reportId ? parseInt(options.reportId) : null
+    if (this.reportId) this.loadData()
+  },
+  methods: {
+    goBack: function() { uni.navigateBack() },
+    loadData: function() {
+      var self = this
+      var loadFn = self.reportType === 'dan' ? getDanReportDetail : getReportDetail
+      loadFn(self.reportId).then(function(res) {
+        if (res.code === 200 && res.data) {
+          self.blocks = res.data.blocks || []
+          var report = res.data.report || res.data
+          var head = {}
+          if (self.reportType === 'dan') {
+            head.childName = report.childName
+            head.reportDateText = report.assessmentDate || ''
+          } else {
+            head.personName = report.personName
+            var d = parseDate(report.reportDate)
+            head.reportDateText = d ? (d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate()) : ''
+          }
+          self.headInfo = head
+        }
+      }).catch(function() {
+        uni.showToast({ title: '加载失败', icon: 'none' })
+      })
+    }
+  }
+}
+</script>
+
+<style scoped>
+.page { min-height: 100vh; background: #f8f8f8; }
+.nav-bar { display: flex; align-items: center; padding: 20rpx 30rpx; background: #fff; position: relative; }
+.nav-back { padding: 10rpx 0; }
+.back-text { font-size: 28rpx; color: #4A9BD7; }
+.nav-title { flex: 1; text-align: center; font-size: 32rpx; font-weight: 600; }
+.content { padding: 20rpx 30rpx; height: calc(100vh - 100rpx); }
+.report-head { background: #fff; border-radius: 16rpx; padding: 28rpx; margin-bottom: 20rpx; }
+.head-name { font-size: 34rpx; font-weight: 600; color: #333; }
+.head-meta { display: flex; align-items: center; margin-top: 12rpx; }
+.type-badge { font-size: 22rpx; color: #2E7D32; background: #E8F5E9; padding: 4rpx 16rpx; border-radius: 20rpx; margin-right: 16rpx; }
+.head-date { font-size: 24rpx; color: #999; }
+.empty-hint { text-align: center; color: #ccc; padding: 80rpx 0; font-size: 28rpx; }
+</style>

+ 2 - 0
cfc-frontend/utils/api.js

@@ -2077,6 +2077,8 @@ export const createHealthReport = (data) => request('/api/health/report/create',
 export const getReportList = (memberId) => request('/api/health/report/list', 'POST', { memberId })
 export const getFamilyReports = () => request('/api/health/reports/family', 'POST', {})
 export const getReportDetail = (reportId) => request('/api/health/report/detail', 'POST', { reportId })
+// DAN 报告详情(含 blocks)
+export const getDanReportDetail = (id) => request('/api/dan-report/' + id, 'POST', {})
 
 export const editHealthReport = (reportId, payload, subjectId) => request('/api/health/report/edit', 'POST', { reportId, payload, subjectId })