results.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  1. <template>
  2. <view class="container">
  3. <view class="header">
  4. <text class="title">测评报告</text>
  5. <text class="subtitle">查看下级成长规划师的测评报告</text>
  6. </view>
  7. <!-- 标签页 -->
  8. <view class="tabs">
  9. <view
  10. class="tab-item"
  11. :class="{ 'active': currentTab === 'my' }"
  12. @click="switchTab('my')"
  13. >
  14. <text class="tab-text">我的报告</text>
  15. </view>
  16. <view
  17. class="tab-item"
  18. :class="{ 'active': currentTab === 'child' }"
  19. @click="switchTab('child')"
  20. >
  21. <text class="tab-text">下级报告</text>
  22. </view>
  23. </view>
  24. <!-- 我的报告列表 -->
  25. <view class="section" v-if="currentTab === 'my'">
  26. <view class="section-title">我的测评报告</view>
  27. <view class="report-list" v-if="myReports.length > 0">
  28. <view
  29. class="report-item"
  30. v-for="report in myReports"
  31. :key="report.id"
  32. @click="viewReportDetail(report)"
  33. >
  34. <view class="report-header">
  35. <text class="report-child">{{ report.childName || '未命名' }}</text>
  36. <text class="report-date">{{ formatDate(report.assessmentDate) }}</text>
  37. </view>
  38. <view class="report-scores">
  39. <view class="score-item">
  40. <text class="score-label">综合得分</text>
  41. <text class="score-value">{{ report.overallScore }}</text>
  42. </view>
  43. </view>
  44. <view class="report-preview">
  45. <text class="preview-text">{{ report.analysisReport && report.analysisReport.substring(0, 50) || '' }}...</text>
  46. </view>
  47. </view>
  48. </view>
  49. <view class="empty-state" v-else>
  50. <text class="empty-icon">📊</text>
  51. <text class="empty-text">还没有测评报告</text>
  52. <text class="empty-hint">完成测评后会生成报告</text>
  53. </view>
  54. </view>
  55. <!-- 下级报告列表 -->
  56. <view class="section" v-if="currentTab === 'child'">
  57. <view class="section-title">下级成长规划师的报告</view>
  58. <view class="report-list" v-if="childReports.length > 0">
  59. <view
  60. class="report-item"
  61. v-for="report in childReports"
  62. :key="report.id"
  63. @click="viewReportDetail(report)"
  64. >
  65. <view class="report-header">
  66. <text class="report-child">{{ report.childName || '未命名' }}</text>
  67. <text class="report-date">{{ formatDate(report.assessmentDate) }}</text>
  68. <text class="report-guide">成长规划师: {{ report.guideName || '未知' }}</text>
  69. </view>
  70. <view class="report-scores">
  71. <view class="score-item">
  72. <text class="score-label">综合得分</text>
  73. <text class="score-value">{{ report.overallScore }}</text>
  74. </view>
  75. </view>
  76. <view class="report-preview">
  77. <text class="preview-text">{{ report.analysisReport && report.analysisReport.substring(0, 50) }}...</text>
  78. </view>
  79. </view>
  80. </view>
  81. <view class="empty-state" v-else>
  82. <text class="empty-icon">📊</text>
  83. <text class="empty-text">还没有下级成长规划师的报告</text>
  84. <text class="empty-hint">下级成长规划师完成测评后会显示</text>
  85. </view>
  86. </view>
  87. <!-- 报告详情弹窗 -->
  88. <view class="report-modal" v-if="showReportModal" @click="showReportModal = false">
  89. <view class="modal-content" @click.stop>
  90. <view class="modal-header">
  91. <text class="modal-title">测评报告详情</text>
  92. <text class="modal-close" @click="showReportModal = false">✕</text>
  93. </view>
  94. <view class="report-detail">
  95. <view class="detail-section">
  96. <text class="detail-title">基本信息</text>
  97. <view class="detail-row">
  98. <text class="detail-label">孩子姓名</text>
  99. <text class="detail-value">{{ currentReport.childName || '未命名' }}</text>
  100. </view>
  101. <view class="detail-row">
  102. <text class="detail-label">测评日期</text>
  103. <text class="detail-value">{{ formatDate(currentReport.assessmentDate) }}</text>
  104. </view>
  105. <view class="detail-row">
  106. <text class="detail-label">测评时长</text>
  107. <text class="detail-value">{{ currentReport.durationMinutes }}分钟</text>
  108. </view>
  109. </view>
  110. <view class="detail-section">
  111. <text class="detail-title">DAN测评结果</text>
  112. <view class="detail-row">
  113. <text class="detail-label">注意力得分</text>
  114. <text class="detail-value">{{ currentReport.attentionScore }}</text>
  115. </view>
  116. <view class="detail-row">
  117. <text class="detail-label">专注力得分</text>
  118. <text class="detail-value">{{ currentReport.focusScore }}</text>
  119. </view>
  120. <view class="detail-row">
  121. <text class="detail-label">记忆力得分</text>
  122. <text class="detail-value">{{ currentReport.memoryScore }}</text>
  123. </view>
  124. <view class="detail-row">
  125. <text class="detail-label">逻辑思维得分</text>
  126. <text class="detail-value">{{ currentReport.logicScore }}</text>
  127. </view>
  128. <view class="detail-row">
  129. <text class="detail-label">综合得分</text>
  130. <text class="detail-value">{{ currentReport.overallScore }}</text>
  131. </view>
  132. </view>
  133. <view class="detail-section">
  134. <text class="detail-title">分析报告</text>
  135. <view class="detail-content">
  136. <text class="content-text">{{ currentReport.analysisReport }}</text>
  137. </view>
  138. </view>
  139. <view class="detail-section">
  140. <text class="detail-title">成长建议</text>
  141. <view class="detail-content">
  142. <text class="content-text">{{ currentReport.growthSuggestions }}</text>
  143. </view>
  144. </view>
  145. <view class="detail-section" v-if="currentReport.nextReviewDate">
  146. <text class="detail-title">下次复测日期</text>
  147. <view class="detail-row">
  148. <text class="detail-label">建议复测时间</text>
  149. <text class="detail-value">{{ formatDate(currentReport.nextReviewDate) }}</text>
  150. </view>
  151. </view>
  152. </view>
  153. <view class="modal-actions">
  154. <button class="btn-close" @click="showReportModal = false">关闭</button>
  155. </view>
  156. </view>
  157. </view>
  158. </view>
  159. </template>
  160. <script>
  161. import { getMyAssessmentResults, getChildAssessmentResults } from '../../utils/api.js'
  162. export default {
  163. data() {
  164. return {
  165. currentTab: 'my',
  166. myReports: [],
  167. childReports: [],
  168. currentReport: null,
  169. showReportModal: false
  170. }
  171. },
  172. onLoad() {
  173. this.loadData()
  174. },
  175. methods: {
  176. async loadData() {
  177. try {
  178. const userId = uni.getStorageSync('userId')
  179. // 并行获取数据
  180. const [myRes, childRes] = await Promise.all([
  181. getMyAssessmentResults(userId),
  182. getChildAssessmentResults(userId)
  183. ])
  184. if (myRes.code === 200) {
  185. this.myReports = myRes.data || []
  186. }
  187. if (childRes.code === 200) {
  188. this.childReports = childRes.data || []
  189. }
  190. } catch (e) {
  191. console.error('加载数据失败', e)
  192. }
  193. },
  194. switchTab(tab) {
  195. this.currentTab = tab
  196. },
  197. viewReportDetail(report) {
  198. this.currentReport = report
  199. this.showReportModal = true
  200. },
  201. formatDate(dateStr) {
  202. if (!dateStr) return ''
  203. const date = new Date(dateStr)
  204. return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`
  205. }
  206. }
  207. }
  208. </script>
  209. <style scoped>
  210. .container {
  211. padding: 30rpx;
  212. background: #F8F8F8;
  213. min-height: 100vh;
  214. }
  215. .header {
  216. text-align: center;
  217. padding: 60rpx 0 40rpx;
  218. }
  219. .title {
  220. font-size: 48rpx;
  221. font-weight: bold;
  222. color: #333;
  223. display: block;
  224. margin-bottom: 20rpx;
  225. }
  226. .subtitle {
  227. font-size: 28rpx;
  228. color: #666;
  229. }
  230. .tabs {
  231. display: flex;
  232. background: #fff;
  233. border-radius: 20rpx;
  234. padding: 10rpx;
  235. margin-bottom: 30rpx;
  236. }
  237. .tab-item {
  238. flex: 1;
  239. text-align: center;
  240. padding: 20rpx;
  241. border-radius: 10rpx;
  242. font-size: 28rpx;
  243. color: #666;
  244. }
  245. .tab-item.active {
  246. background: #667eea;
  247. color: #fff;
  248. }
  249. .section {
  250. background: #fff;
  251. border-radius: 20rpx;
  252. padding: 30rpx;
  253. margin-bottom: 30rpx;
  254. }
  255. .section-title {
  256. font-size: 32rpx;
  257. font-weight: bold;
  258. color: #333;
  259. margin-bottom: 20rpx;
  260. }
  261. .report-list {
  262. display: flex;
  263. flex-direction: column;
  264. gap: 20rpx;
  265. }
  266. .report-item {
  267. background: #F8F8F8;
  268. border-radius: 10rpx;
  269. padding: 20rpx;
  270. }
  271. .report-header {
  272. display: flex;
  273. justify-content: space-between;
  274. align-items: center;
  275. margin-bottom: 15rpx;
  276. }
  277. .report-child {
  278. font-size: 30rpx;
  279. font-weight: bold;
  280. color: #333;
  281. }
  282. .report-date {
  283. font-size: 24rpx;
  284. color: #999;
  285. }
  286. .report-guide {
  287. font-size: 24rpx;
  288. color: #667eea;
  289. }
  290. .report-scores {
  291. display: flex;
  292. gap: 20rpx;
  293. margin-bottom: 15rpx;
  294. }
  295. .score-item {
  296. background: #E8F5E9;
  297. padding: 10rpx 15rpx;
  298. border-radius: 10rpx;
  299. }
  300. .score-label {
  301. font-size: 24rpx;
  302. color: #666;
  303. display: block;
  304. margin-bottom: 5rpx;
  305. }
  306. .score-value {
  307. font-size: 28rpx;
  308. font-weight: bold;
  309. color: #333;
  310. }
  311. .report-preview {
  312. font-size: 26rpx;
  313. color: #999;
  314. line-height: 1.5;
  315. }
  316. .empty-state {
  317. text-align: center;
  318. padding: 60rpx 0;
  319. }
  320. .empty-icon {
  321. font-size: 80rpx;
  322. display: block;
  323. margin-bottom: 20rpx;
  324. }
  325. .empty-text {
  326. font-size: 28rpx;
  327. color: #999;
  328. display: block;
  329. margin-bottom: 10rpx;
  330. }
  331. .empty-hint {
  332. font-size: 24rpx;
  333. color: #CCC;
  334. }
  335. .report-modal {
  336. position: fixed;
  337. top: 0;
  338. left: 0;
  339. right: 0;
  340. bottom: 0;
  341. background: rgba(0, 0, 0, 0.5);
  342. display: flex;
  343. align-items: center;
  344. justify-content: center;
  345. z-index: 999;
  346. }
  347. .modal-content {
  348. background: #fff;
  349. border-radius: 20rpx;
  350. padding: 40rpx;
  351. width: 90%;
  352. max-height: 80vh;
  353. overflow-y: auto;
  354. }
  355. .modal-header {
  356. display: flex;
  357. justify-content: space-between;
  358. align-items: center;
  359. margin-bottom: 30rpx;
  360. }
  361. .modal-title {
  362. font-size: 32rpx;
  363. font-weight: bold;
  364. color: #333;
  365. }
  366. .modal-close {
  367. font-size: 40rpx;
  368. color: #999;
  369. padding: 10rpx;
  370. }
  371. .report-detail {
  372. margin-bottom: 30rpx;
  373. }
  374. .detail-section {
  375. margin-bottom: 30rpx;
  376. }
  377. .detail-title {
  378. font-size: 28rpx;
  379. font-weight: bold;
  380. color: #333;
  381. margin-bottom: 15rpx;
  382. }
  383. .detail-row {
  384. display: flex;
  385. justify-content: space-between;
  386. margin-bottom: 10rpx;
  387. }
  388. .detail-label {
  389. font-size: 26rpx;
  390. color: #666;
  391. }
  392. .detail-value {
  393. font-size: 26rpx;
  394. color: #333;
  395. font-weight: bold;
  396. }
  397. .detail-content {
  398. background: #F8F8F8;
  399. padding: 20rpx;
  400. border-radius: 10rpx;
  401. }
  402. .content-text {
  403. font-size: 26rpx;
  404. color: #333;
  405. line-height: 1.6;
  406. }
  407. .modal-actions {
  408. display: flex;
  409. gap: 20rpx;
  410. }
  411. .btn-close {
  412. flex: 1;
  413. height: 80rpx;
  414. background: #F0F0F0;
  415. color: #333;
  416. border-radius: 40rpx;
  417. font-size: 28rpx;
  418. font-weight: bold;
  419. }
  420. </style>