results.vue 11 KB

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