|
@@ -0,0 +1,194 @@
|
|
|
|
|
+<template>
|
|
|
|
|
+ <view class="page">
|
|
|
|
|
+ <scroll-view class="content" scroll-y>
|
|
|
|
|
+ <!-- 加载中 -->
|
|
|
|
|
+ <view v-if="loading" class="panel">
|
|
|
|
|
+ <text class="panel-text">报告加载中...</text>
|
|
|
|
|
+ </view>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 生成中:异步生成期间给出明确提示,不白屏 -->
|
|
|
|
|
+ <view v-if="statusText" class="panel">
|
|
|
|
|
+ <text class="panel-text">{{ statusText || '报告生成中,请稍后再看' }}</text>
|
|
|
|
|
+ </view>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 加载失败:明确失败/重试提示 -->
|
|
|
|
|
+ <view v-if="errorMessage" class="panel">
|
|
|
|
|
+ <text class="panel-text">{{ errorMessage }}</text>
|
|
|
|
|
+ <view class="retry-btn" @click="retry"><text class="retry-text">重试</text></view>
|
|
|
|
|
+ </view>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 空数据:明确「暂无」提示 -->
|
|
|
|
|
+ <view v-if="!loading && !statusText && !errorMessage && reportDiseaseRespList.length === 0" class="panel">
|
|
|
|
|
+ <text class="panel-text">暂无报告数据</text>
|
|
|
|
|
+ </view>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 一期按爱云医原始结构渲染:reportDiseaseRespList[].diseaseDetailList[] -->
|
|
|
|
|
+ <view v-if="!loading && !statusText && !errorMessage && reportDiseaseRespList.length > 0" class="report-list">
|
|
|
|
|
+ <view v-for="(group, index) in reportDiseaseRespList" :key="getGroupKey(index)" class="group-card">
|
|
|
|
|
+ <view class="group-title"><text class="group-name">{{ group.diseaseName || '检测结果' }}</text></view>
|
|
|
|
|
+ <view v-for="(detail, dindex) in group.diseaseDetailList" :key="getDetailKey(dindex)" class="detail-row">
|
|
|
|
|
+ <view class="detail-head">
|
|
|
|
|
+ <text class="detail-name">{{ detail.diseaseDetailNameCn || detail.diseaseDetailName || '检测指标' }}</text>
|
|
|
|
|
+ <text class="detail-level">{{ detail.diseaseLevel || '未检出' }}</text>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ <!-- A.6 空值规则:accuracy 为空显示参考值提示,不自行填 0 -->
|
|
|
|
|
+ <view class="detail-value">
|
|
|
|
|
+ <text v-if="detail.accuracy" class="detail-accuracy">{{ detail.accuracy }}</text>
|
|
|
|
|
+ <text v-else class="detail-reference">参考值</text>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ </scroll-view>
|
|
|
|
|
+ </view>
|
|
|
|
|
+</template>
|
|
|
|
|
+
|
|
|
|
|
+<script>
|
|
|
|
|
+import { aiyunyi } from '@/utils/api.js'
|
|
|
|
|
+
|
|
|
|
|
+// 同一组生命周期处理函数同时挂到根选项(uni-app 页面生命周期)和 methods
|
|
|
|
|
+// (页面内可显式调用;契约单测的轻量实例也只从 methods 取函数)。
|
|
|
|
|
+function onLoad(options) {
|
|
|
|
|
+ // §4.5 R3:报告只走 report/get 按 id 拉取,id 来自跳转参数(上游 ai-detect 传 reportId)
|
|
|
|
|
+ var id = options && (options.id || options.reportId)
|
|
|
|
|
+ if (id === null || id === undefined || id === '') {
|
|
|
|
|
+ this.reportId = null
|
|
|
|
|
+ this.errorMessage = '报告参数无效,报告不存在'
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ this.reportId = id
|
|
|
|
|
+ this.loadReport(id)
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+export default {
|
|
|
|
|
+ onLoad: onLoad,
|
|
|
|
|
+ data() {
|
|
|
|
|
+ return {
|
|
|
|
|
+ reportId: null,
|
|
|
|
|
+ report: null,
|
|
|
|
|
+ reportDiseaseRespList: [],
|
|
|
|
|
+ loading: false,
|
|
|
|
|
+ errorMessage: '',
|
|
|
|
|
+ statusText: '',
|
|
|
|
|
+ emptyText: ''
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ methods: {
|
|
|
|
|
+ onLoad: onLoad,
|
|
|
|
|
+ loadReport: function (reportId) {
|
|
|
|
|
+ var self = this
|
|
|
|
|
+ this.loading = true
|
|
|
|
|
+ this.errorMessage = ''
|
|
|
|
|
+ this.statusText = ''
|
|
|
|
|
+ this.emptyText = ''
|
|
|
|
|
+ aiyunyi.getReport(reportId).then(function (res) {
|
|
|
|
|
+ self.loading = false
|
|
|
|
|
+ var data = res && res.data ? res.data : null
|
|
|
|
|
+ self.report = data
|
|
|
|
|
+ if (data && data.status === 'GENERATING') {
|
|
|
|
|
+ self.statusText = data.statusText || '报告生成中,请稍后再看'
|
|
|
|
|
+ self.reportDiseaseRespList = []
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ self.reportDiseaseRespList = (data && data.reportDiseaseRespList) || []
|
|
|
|
|
+ if (self.reportDiseaseRespList.length === 0) {
|
|
|
|
|
+ self.emptyText = '暂无报告数据'
|
|
|
|
|
+ }
|
|
|
|
|
+ }).catch(function () {
|
|
|
|
|
+ self.loading = false
|
|
|
|
|
+ self.errorMessage = '报告加载失败,请重试'
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+ retry: function () {
|
|
|
|
|
+ if (this.reportId !== null && this.reportId !== undefined) {
|
|
|
|
|
+ this.loadReport(this.reportId)
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ getGroupKey: function (index) {
|
|
|
|
|
+ return 'group-' + index
|
|
|
|
|
+ },
|
|
|
|
|
+ getDetailKey: function (index) {
|
|
|
|
|
+ return 'detail-' + index
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+</script>
|
|
|
|
|
+
|
|
|
|
|
+<style scoped>
|
|
|
|
|
+.page {
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ flex-direction: column;
|
|
|
|
|
+ min-height: 100vh;
|
|
|
|
|
+ background: #f7f8fa;
|
|
|
|
|
+}
|
|
|
|
|
+.content {
|
|
|
|
|
+ flex: 1;
|
|
|
|
|
+ padding: 24rpx;
|
|
|
|
|
+}
|
|
|
|
|
+.panel {
|
|
|
|
|
+ padding: 40rpx 24rpx;
|
|
|
|
|
+ align-items: center;
|
|
|
|
|
+ justify-content: center;
|
|
|
|
|
+}
|
|
|
|
|
+.panel-text {
|
|
|
|
|
+ font-size: 28rpx;
|
|
|
|
|
+ color: #666;
|
|
|
|
|
+}
|
|
|
|
|
+.retry-btn {
|
|
|
|
|
+ margin-top: 24rpx;
|
|
|
|
|
+ padding: 16rpx 40rpx;
|
|
|
|
|
+ background: #ff8a4c;
|
|
|
|
|
+ border-radius: 8rpx;
|
|
|
|
|
+}
|
|
|
|
|
+.retry-text {
|
|
|
|
|
+ color: #fff;
|
|
|
|
|
+ font-size: 28rpx;
|
|
|
|
|
+}
|
|
|
|
|
+.report-list {
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ flex-direction: column;
|
|
|
|
|
+}
|
|
|
|
|
+.group-card {
|
|
|
|
|
+ margin-bottom: 24rpx;
|
|
|
|
|
+ padding: 24rpx;
|
|
|
|
|
+ background: #fff;
|
|
|
|
|
+ border-radius: 12rpx;
|
|
|
|
|
+}
|
|
|
|
|
+.group-title {
|
|
|
|
|
+ margin-bottom: 16rpx;
|
|
|
|
|
+}
|
|
|
|
|
+.group-name {
|
|
|
|
|
+ font-size: 32rpx;
|
|
|
|
|
+ font-weight: bold;
|
|
|
|
|
+ color: #333;
|
|
|
|
|
+}
|
|
|
|
|
+.detail-row {
|
|
|
|
|
+ padding: 16rpx 0;
|
|
|
|
|
+ border-top: 1rpx solid #eee;
|
|
|
|
|
+}
|
|
|
|
|
+.detail-head {
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ flex-direction: row;
|
|
|
|
|
+ justify-content: space-between;
|
|
|
|
|
+ align-items: center;
|
|
|
|
|
+}
|
|
|
|
|
+.detail-name {
|
|
|
|
|
+ font-size: 28rpx;
|
|
|
|
|
+ color: #333;
|
|
|
|
|
+}
|
|
|
|
|
+.detail-level {
|
|
|
|
|
+ font-size: 26rpx;
|
|
|
|
|
+ color: #e8833a;
|
|
|
|
|
+}
|
|
|
|
|
+.detail-value {
|
|
|
|
|
+ margin-top: 8rpx;
|
|
|
|
|
+}
|
|
|
|
|
+.detail-accuracy {
|
|
|
|
|
+ font-size: 30rpx;
|
|
|
|
|
+ color: #333;
|
|
|
|
|
+}
|
|
|
|
|
+.detail-reference {
|
|
|
|
|
+ font-size: 26rpx;
|
|
|
|
|
+ color: #999;
|
|
|
|
|
+}
|
|
|
|
|
+</style>
|