detail.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. <template>
  2. <view class="detail-container" :style="{ '--font-scale': fontScale }">
  3. <!-- 加载状态 -->
  4. <view class="loading-wrap" v-if="loading">
  5. <text class="loading-text">加载中...</text>
  6. </view>
  7. <!-- 方案详情 -->
  8. <view class="detail-card" v-else-if="plan">
  9. <view class="detail-header">
  10. <text class="detail-title">{{ plan.name || '测评方案' }}</text>
  11. <text class="plan-status" :class="'status-' + (plan.status || 'unknown')">{{ statusLabel(plan.status) }}</text>
  12. </view>
  13. <view class="detail-meta">
  14. <view class="meta-row">
  15. <text class="meta-label">方案周期</text>
  16. <text class="meta-value">{{ formatDate(plan.startDate) }} ~ {{ formatDate(plan.endDate) }}</text>
  17. </view>
  18. <view class="meta-row" v-if="plan.totalDays">
  19. <text class="meta-label">完成进度</text>
  20. <text class="meta-value">{{ plan.completedDays || 0 }} / {{ plan.totalDays }} 天</text>
  21. </view>
  22. <view class="meta-row" v-if="plan.remark">
  23. <text class="meta-label">方案说明</text>
  24. <text class="meta-value">{{ plan.remark }}</text>
  25. </view>
  26. <view class="meta-row" v-if="plan.reviewComment">
  27. <text class="meta-label">审核备注</text>
  28. <text class="meta-value">{{ plan.reviewComment }}</text>
  29. </view>
  30. <view class="meta-row" v-if="plan.source">
  31. <text class="meta-label">方案来源</text>
  32. <text class="meta-value">{{ sourceLabel(plan.source) }}</text>
  33. </view>
  34. <view class="meta-row" v-if="plan.createdAt">
  35. <text class="meta-label">创建时间</text>
  36. <text class="meta-value">{{ formatDateTime(plan.createdAt) }}</text>
  37. </view>
  38. </view>
  39. <view class="progress-block" v-if="plan.totalDays">
  40. <view class="progress-track">
  41. <view class="progress-fill" :style="'width:' + progressPercent(plan) + '%'"></view>
  42. </view>
  43. <text class="progress-text">{{ progressPercent(plan) }}%</text>
  44. </view>
  45. </view>
  46. <!-- 空状态 -->
  47. <view class="empty-wrap" v-else>
  48. <text class="empty-icon">📋</text>
  49. <text class="empty-title">方案不存在</text>
  50. <text class="empty-desc">该测评方案可能已被删除,请返回列表刷新</text>
  51. </view>
  52. <!-- 底部占位 -->
  53. <view class="bottom-spacer"></view>
  54. </view>
  55. </template>
  56. <script>
  57. import { getMyAssessmentPlans } from '../../utils/api.js'
  58. import { parseDate } from '../../utils/format.js'
  59. import fontScaleMixin from '@/mixins/font-scale.js'
  60. export default {
  61. mixins: [fontScaleMixin],
  62. data() {
  63. return {
  64. plan: null,
  65. loading: false,
  66. planId: null,
  67. familyId: null,
  68. childId: null
  69. }
  70. },
  71. onLoad(options) {
  72. this.planId = options.planId ? parseInt(options.planId) : null
  73. this.familyId = options.familyId ? parseInt(options.familyId) : null
  74. this.childId = options.childId ? parseInt(options.childId) : null
  75. this.loadDetail()
  76. },
  77. methods: {
  78. loadDetail() {
  79. var self = this
  80. var familyId = this.familyId || uni.getStorageSync('familyId')
  81. if (!familyId || !this.planId) {
  82. this.loading = false
  83. return
  84. }
  85. self.loading = true
  86. getMyAssessmentPlans(familyId, this.childId).then(function(res) {
  87. var list = (res && res.code === 200 && res.data) ? res.data : []
  88. var found = null
  89. for (var i = 0; i < list.length; i++) {
  90. if (list[i] && list[i].id === self.planId) {
  91. found = list[i]
  92. break
  93. }
  94. }
  95. self.plan = found
  96. }).catch(function(e) {
  97. console.log('获取方案详情失败', e)
  98. uni.showToast({ title: '加载失败', icon: 'none' })
  99. }).finally(function() {
  100. self.loading = false
  101. })
  102. },
  103. statusLabel(status) {
  104. var map = { active: '进行中', completed: '已完成', cancelled: '已取消', generated: '待审核', reviewed: '已通过', rejected: '已驳回' }
  105. return map[status] || (status || '未知')
  106. },
  107. sourceLabel(source) {
  108. var map = { manual: '手动创建', assessment: '测评生成', template: '模板创建' }
  109. return map[source] || (source || '--')
  110. },
  111. progressPercent(item) {
  112. if (!item.totalDays) return 0
  113. var completed = item.completedDays || 0
  114. var p = Math.round(completed / item.totalDays * 100)
  115. return p > 100 ? 100 : p
  116. },
  117. formatDate(dateStr) {
  118. if (!dateStr) return '--'
  119. var d = parseDate(dateStr)
  120. if (!d) return dateStr
  121. var y = d.getFullYear()
  122. var m = ('' + (d.getMonth() + 1)).padStart(2, '0')
  123. var day = ('' + d.getDate()).padStart(2, '0')
  124. return y + '-' + m + '-' + day
  125. },
  126. formatDateTime(dateStr) {
  127. if (!dateStr) return '--'
  128. var d = parseDate(dateStr)
  129. if (!d) return dateStr
  130. var hh = ('' + d.getHours()).padStart(2, '0')
  131. var mm = ('' + d.getMinutes()).padStart(2, '0')
  132. var ss = ('' + d.getSeconds()).padStart(2, '0')
  133. return this.formatDate(dateStr) + ' ' + hh + ':' + mm + ':' + ss
  134. }
  135. }
  136. }
  137. </script>
  138. <style scoped lang="scss">
  139. .detail-container {
  140. min-height: 100vh;
  141. background: $app-bg;
  142. }
  143. /* ===== 加载状态 ===== */
  144. .loading-wrap {
  145. display: flex;
  146. justify-content: center;
  147. padding: 80rpx 0;
  148. }
  149. .loading-text {
  150. font-size: calc(28rpx * var(--font-scale, 1));
  151. color: $facade-text-muted;
  152. }
  153. /* ===== 详情卡片 ===== */
  154. .detail-card {
  155. margin: $uni-space-lg;
  156. background: $app-surface;
  157. border-radius: 16rpx;
  158. padding: 32rpx 28rpx;
  159. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.04);
  160. }
  161. .detail-header {
  162. display: flex;
  163. flex-direction: row;
  164. align-items: center;
  165. justify-content: space-between;
  166. margin-bottom: 24rpx;
  167. }
  168. .detail-title {
  169. font-size: calc(34rpx * var(--font-scale, 1));
  170. font-weight: 600;
  171. color: $facade-text-strong;
  172. flex: 1;
  173. min-width: 0;
  174. }
  175. .plan-status {
  176. font-size: calc(22rpx * var(--font-scale, 1));
  177. padding: 4rpx 16rpx;
  178. border-radius: 24rpx;
  179. margin-left: 12rpx;
  180. }
  181. .status-active { background: $mat-blue-tint; color: $mat-blue-strong; }
  182. .status-completed { background: $mat-green-tint; color: $mat-green-strong; }
  183. .status-cancelled { background: $mat-bluegray-50; color: $mat-bluegray-400; }
  184. .status-generated { background: $fortune-1-tint; color: $mat-orange-strong; }
  185. .status-reviewed { background: $mat-green-tint; color: $mat-green-strong; }
  186. .status-rejected { background: $status-danger-tint-4; color: $status-danger-strong-2; }
  187. .status-unknown { background: $mat-bluegray-50; color: $mat-bluegray-400; }
  188. /* ===== 元信息 ===== */
  189. .detail-meta {
  190. border-top: 1rpx solid $facade-fill-slate;
  191. padding-top: 8rpx;
  192. }
  193. .meta-row {
  194. display: flex;
  195. flex-direction: row;
  196. align-items: flex-start;
  197. padding: 14rpx 0;
  198. }
  199. .meta-label {
  200. width: 160rpx;
  201. font-size: calc(26rpx * var(--font-scale, 1));
  202. color: $facade-text-muted;
  203. flex-shrink: 0;
  204. line-height: 1.5;
  205. }
  206. .meta-value {
  207. flex: 1;
  208. font-size: calc(26rpx * var(--font-scale, 1));
  209. color: $facade-text-strong;
  210. line-height: 1.5;
  211. word-break: break-all;
  212. }
  213. /* ===== 进度 ===== */
  214. .progress-block {
  215. display: flex;
  216. flex-direction: row;
  217. align-items: center;
  218. margin-top: 24rpx;
  219. }
  220. .progress-track {
  221. flex: 1;
  222. height: 16rpx;
  223. background: #EEF2F7;
  224. border-radius: 8rpx;
  225. overflow: hidden;
  226. margin-right: 16rpx;
  227. }
  228. .progress-fill {
  229. height: 100%;
  230. background: $brand-primary;
  231. border-radius: 8rpx;
  232. }
  233. .progress-text {
  234. font-size: calc(24rpx * var(--font-scale, 1));
  235. color: $facade-text-muted;
  236. }
  237. /* ===== 空状态 ===== */
  238. .empty-wrap {
  239. display: flex;
  240. flex-direction: column;
  241. align-items: center;
  242. padding: 120rpx 60rpx;
  243. }
  244. .empty-icon {
  245. font-size: calc($uni-font-size-5xl * var(--font-scale, 1));
  246. margin-bottom: 24rpx;
  247. }
  248. .empty-title {
  249. font-size: calc(32rpx * var(--font-scale, 1));
  250. font-weight: bold;
  251. color: $facade-text-strong;
  252. margin-bottom: 12rpx;
  253. }
  254. .empty-desc {
  255. font-size: calc(26rpx * var(--font-scale, 1));
  256. color: $facade-text-muted;
  257. text-align: center;
  258. line-height: 1.5;
  259. }
  260. /* ===== 底部 ===== */
  261. .bottom-spacer {
  262. height: 60rpx;
  263. }
  264. </style>