report-result.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <view class="container">
  3. <!-- 报告头部 -->
  4. <view class="report-head" v-if="headInfo">
  5. <text class="head-name">{{ headInfo.personName || headInfo.childName || 'DAN 测评报告' }}</text>
  6. <text class="head-date">{{ headInfo.dateText }}</text>
  7. <text class="head-dim" v-if="dimensionLabel">{{ dimensionLabel }}</text>
  8. </view>
  9. <view class="loading-wrap" v-if="loading">
  10. <text class="loading-text">加载中...</text>
  11. </view>
  12. <template v-else-if="blocks && blocks.length > 0">
  13. <!-- 报告内容块(后端按类型组装,前端通用渲染) -->
  14. <report-blocks-renderer :blocks="blocks" />
  15. </template>
  16. <view class="empty-wrap" v-else>
  17. <text class="empty-text">暂无数据</text>
  18. </view>
  19. <view class="bottom-spacer"></view>
  20. </view>
  21. </template>
  22. <script>
  23. import ReportBlocksRenderer from '../../components/report-blocks-renderer.vue'
  24. import { getDanReportDetail } from '../../utils/api.js'
  25. export default {
  26. components: { ReportBlocksRenderer },
  27. data() {
  28. return {
  29. reportId: null,
  30. loading: true,
  31. headInfo: null,
  32. blocks: []
  33. }
  34. },
  35. computed: {
  36. dimensionLabel() {
  37. if (!this.headInfo || !this.headInfo.dimension) return ''
  38. var map = {
  39. mind: '心维度 (A2)',
  40. wisdom: '智维度 (B4)',
  41. cognition: '认知维度 (A1)',
  42. learning: '学习能力 (B3)',
  43. behavior: '行为教养 (B2)',
  44. career: '职业发展 (B6)',
  45. campus: '校园标准 (C1)',
  46. adolescent: '青春期挑战 (B5)'
  47. }
  48. return map[this.headInfo.dimension] || ''
  49. }
  50. },
  51. onLoad(options) {
  52. this.reportId = options.reportId ? parseInt(options.reportId) : null
  53. if (this.reportId) this.loadData()
  54. },
  55. methods: {
  56. loadData() {
  57. var self = this
  58. this.loading = true
  59. getDanReportDetail(this.reportId).then(function(res) {
  60. self.loading = false
  61. if (res.code !== 200 || !res.data) {
  62. uni.showToast({ title: res.message || '加载失败', icon: 'none' })
  63. return
  64. }
  65. var data = res.data
  66. self.headInfo = {
  67. personName: (data.result && data.result.childName) || data.childName || '',
  68. dateText: data.confirmedAt ? data.confirmedAt.substring(0, 10) : '',
  69. dimension: data.dimension
  70. }
  71. self.blocks = (data.blocks || []).filter(function(b) { return b && (b.items && b.items.length || b.content) })
  72. }).catch(function(e) {
  73. self.loading = false
  74. uni.showToast({ title: '加载异常', icon: 'none' })
  75. })
  76. }
  77. }
  78. }
  79. </script>
  80. <style scoped>
  81. .container { min-height: 100vh; background: #F8F8F8; padding-bottom: 40rpx; }
  82. .loading-wrap { display: flex; justify-content: center; padding: 120rpx 0; }
  83. .loading-text { font-size: 28rpx; color: #999; }
  84. .empty-wrap { display: flex; justify-content: center; padding: 120rpx 0; }
  85. .empty-text { font-size: 28rpx; color: #999; }
  86. .report-head { background: linear-gradient(135deg, #6366F1, #8B5CF6); padding: 32rpx 28rpx 28rpx; color: #fff; }
  87. .head-name { font-size: 36rpx; font-weight: bold; display: block; }
  88. .head-date { font-size: 24rpx; opacity: 0.85; display: block; margin-top: 8rpx; }
  89. .head-dim { font-size: 22rpx; background: rgba(255,255,255,0.2); border-radius: 20rpx; padding: 4rpx 16rpx; margin-top: 12rpx; display: inline-block; }
  90. .bottom-spacer { height: 40rpx; }
  91. </style>