record.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712
  1. <template>
  2. <view class="container">
  3. <view class="header">
  4. <text class="title">录入测评结果</text>
  5. <text class="subtitle">专业的DAN测评,记录孩子的专注力评估结果</text>
  6. </view>
  7. <!-- 孩子信息 -->
  8. <view class="section">
  9. <view class="section-title">孩子信息</view>
  10. <view class="info-card">
  11. <view class="info-row">
  12. <text class="info-label">姓名</text>
  13. <text class="info-value">{{ childName || '未填写' }}</text>
  14. </view>
  15. <view class="info-row">
  16. <text class="info-label">年龄</text>
  17. <text class="info-value">{{ age || '-' }}岁</text>
  18. </view>
  19. <view class="info-row">
  20. <text class="info-label">学校</text>
  21. <text class="info-value">{{ school || '-' }}</text>
  22. </view>
  23. </view>
  24. </view>
  25. <!-- 各项评分 -->
  26. <view class="section">
  27. <view class="section-title">各项评分</view>
  28. <view class="score-group">
  29. <view class="score-item">
  30. <view class="score-header">
  31. <text class="score-label">注意力</text>
  32. <text class="score-value">{{ form.attentionScore }}</text>
  33. </view>
  34. <slider
  35. :value="form.attentionScore"
  36. :min="0"
  37. :max="100"
  38. :step="1"
  39. activeColor="#667eea"
  40. backgroundColor="#E8E8E8"
  41. block-size="20"
  42. @change="onAttentionChange"
  43. />
  44. </view>
  45. <view class="score-item">
  46. <view class="score-header">
  47. <text class="score-label">专注力</text>
  48. <text class="score-value">{{ form.focusScore }}</text>
  49. </view>
  50. <slider
  51. :value="form.focusScore"
  52. :min="0"
  53. :max="100"
  54. :step="1"
  55. activeColor="#667eea"
  56. backgroundColor="#E8E8E8"
  57. block-size="20"
  58. @change="onFocusChange"
  59. />
  60. </view>
  61. <view class="score-item">
  62. <view class="score-header">
  63. <text class="score-label">记忆力</text>
  64. <text class="score-value">{{ form.memoryScore }}</text>
  65. </view>
  66. <slider
  67. :value="form.memoryScore"
  68. :min="0"
  69. :max="100"
  70. :step="1"
  71. activeColor="#667eea"
  72. backgroundColor="#E8E8E8"
  73. block-size="20"
  74. @change="onMemoryChange"
  75. />
  76. </view>
  77. <view class="score-item">
  78. <view class="score-header">
  79. <text class="score-label">逻辑力</text>
  80. <text class="score-value">{{ form.logicScore }}</text>
  81. </view>
  82. <slider
  83. :value="form.logicScore"
  84. :min="0"
  85. :max="100"
  86. :step="1"
  87. activeColor="#667eea"
  88. backgroundColor="#E8E8E8"
  89. block-size="20"
  90. @change="onLogicChange"
  91. />
  92. </view>
  93. </view>
  94. <!-- 综合评分 -->
  95. <view class="overall-score">
  96. <text class="overall-label">综合评分</text>
  97. <view class="overall-badge">
  98. <text class="overall-number">{{ overallScore }}</text>
  99. </view>
  100. </view>
  101. </view>
  102. <!-- 测评信息 -->
  103. <view class="section">
  104. <view class="section-title">测评信息</view>
  105. <view class="form-group">
  106. <text class="form-label">测评日期</text>
  107. <picker mode="date" :value="form.assessmentDate" @change="onAssessmentDateChange">
  108. <view class="picker-value">
  109. <text>{{ form.assessmentDate || '选择日期' }}</text>
  110. <text class="picker-arrow">›</text>
  111. </view>
  112. </picker>
  113. </view>
  114. <view class="form-group">
  115. <text class="form-label">测评时长(分钟)</text>
  116. <input
  117. class="form-input"
  118. type="number"
  119. v-model="form.durationMinutes"
  120. placeholder="请输入测评时长"
  121. />
  122. </view>
  123. </view>
  124. <!-- 媒体资料 -->
  125. <view class="section">
  126. <view class="section-title">媒体资料</view>
  127. <text class="form-hint">上传测评过程中的照片、视频或音频</text>
  128. <view class="media-grid">
  129. <view
  130. class="media-item"
  131. v-for="(img, index) in mediaList"
  132. :key="index"
  133. >
  134. <image class="media-image" :src="img" mode="aspectFill" />
  135. <view class="media-remove" @click="removeMedia(index)">✕</view>
  136. </view>
  137. <view class="media-add" @click="chooseMedia" v-if="mediaList.length < 9">
  138. <text class="media-add-icon">+</text>
  139. <text class="media-add-text">添加</text>
  140. </view>
  141. </view>
  142. </view>
  143. <!-- 分析报告 -->
  144. <view class="section">
  145. <view class="section-title">分析报告</view>
  146. <textarea
  147. class="form-textarea"
  148. v-model="form.analysisReport"
  149. placeholder="请输入详细的测评分析报告"
  150. :maxlength="2000"
  151. />
  152. <text class="char-count">{{ analysisReportLen }}/2000</text>
  153. </view>
  154. <!-- 成长建议 -->
  155. <view class="section">
  156. <view class="section-title">成长建议</view>
  157. <textarea
  158. class="form-textarea"
  159. v-model="form.growthSuggestions"
  160. placeholder="请输入针对孩子的成长建议"
  161. :maxlength="1000"
  162. />
  163. <text class="char-count">{{ growthSuggestionsLen }}/1000</text>
  164. </view>
  165. <!-- 下次复查 -->
  166. <view class="section">
  167. <view class="section-title">下次复查</view>
  168. <picker mode="date" :value="form.nextReviewDate" @change="onNextReviewDateChange">
  169. <view class="picker-value">
  170. <text>{{ form.nextReviewDate || '选择复查日期' }}</text>
  171. <text class="picker-arrow">›</text>
  172. </view>
  173. </picker>
  174. </view>
  175. <!-- 结果描述 -->
  176. <view class="section">
  177. <view class="section-title">结果描述</view>
  178. <textarea
  179. class="form-textarea form-textarea-short"
  180. v-model="form.resultDescription"
  181. placeholder="请简要描述测评结果"
  182. :maxlength="500"
  183. />
  184. <text class="char-count">{{ resultDescriptionLen }}/500</text>
  185. </view>
  186. <!-- 操作按钮 -->
  187. <view class="btn-group">
  188. <button class="btn-draft" @click="saveDraft" :disabled="submitting">保存草稿</button>
  189. <button class="btn-submit" @click="submit" :disabled="submitting">提交结果</button>
  190. </view>
  191. </view>
  192. </template>
  193. <script>
  194. import { recordAssessmentResult } from '../../utils/api.js'
  195. export default {
  196. data() {
  197. return {
  198. appointmentId: '',
  199. childId: '',
  200. childName: '',
  201. age: '',
  202. school: '',
  203. mediaList: [],
  204. submitting: false,
  205. form: {
  206. attentionScore: 50,
  207. focusScore: 50,
  208. memoryScore: 50,
  209. logicScore: 50,
  210. assessmentDate: '',
  211. durationMinutes: '',
  212. analysisReport: '',
  213. growthSuggestions: '',
  214. nextReviewDate: '',
  215. resultDescription: ''
  216. }
  217. }
  218. },
  219. computed: {
  220. overallScore() {
  221. var total = this.form.attentionScore + this.form.focusScore + this.form.memoryScore + this.form.logicScore
  222. return Math.round(total / 4)
  223. },
  224. analysisReportLen() {
  225. return (this.form.analysisReport && this.form.analysisReport.length) || 0
  226. },
  227. growthSuggestionsLen() {
  228. return (this.form.growthSuggestions && this.form.growthSuggestions.length) || 0
  229. },
  230. resultDescriptionLen() {
  231. return (this.form.resultDescription && this.form.resultDescription.length) || 0
  232. }
  233. },
  234. onLoad(options) {
  235. if (options.appointmentId) {
  236. this.appointmentId = options.appointmentId
  237. }
  238. if (options.childId) {
  239. this.childId = options.childId
  240. }
  241. if (options.childName) {
  242. this.childName = decodeURIComponent(options.childName)
  243. }
  244. if (options.age) {
  245. this.age = options.age
  246. }
  247. if (options.school) {
  248. this.school = decodeURIComponent(options.school)
  249. }
  250. // 默认测评日期为今天
  251. var now = new Date()
  252. var year = now.getFullYear()
  253. var month = String(now.getMonth() + 1).padStart(2, '0')
  254. var day = String(now.getDate()).padStart(2, '0')
  255. this.form.assessmentDate = year + '-' + month + '-' + day
  256. },
  257. methods: {
  258. onAttentionChange(e) {
  259. this.form.attentionScore = e.detail.value
  260. },
  261. onFocusChange(e) {
  262. this.form.focusScore = e.detail.value
  263. },
  264. onMemoryChange(e) {
  265. this.form.memoryScore = e.detail.value
  266. },
  267. onLogicChange(e) {
  268. this.form.logicScore = e.detail.value
  269. },
  270. onAssessmentDateChange(e) {
  271. this.form.assessmentDate = e.detail.value
  272. },
  273. onNextReviewDateChange(e) {
  274. this.form.nextReviewDate = e.detail.value
  275. },
  276. chooseMedia() {
  277. var that = this
  278. uni.chooseImage({
  279. count: 9 - that.mediaList.length,
  280. sizeType: ['compressed'],
  281. sourceType: ['album', 'camera'],
  282. success: function(res) {
  283. that.mediaList = that.mediaList.concat(res.tempFilePaths)
  284. }
  285. })
  286. },
  287. removeMedia(index) {
  288. this.mediaList.splice(index, 1)
  289. },
  290. validateForm() {
  291. if (!this.form.assessmentDate) {
  292. uni.showToast({ title: '请选择测评日期', icon: 'none' })
  293. return false
  294. }
  295. if (!this.form.durationMinutes || this.form.durationMinutes <= 0) {
  296. uni.showToast({ title: '请输入有效的测评时长', icon: 'none' })
  297. return false
  298. }
  299. if (!this.form.analysisReport || !this.form.analysisReport.trim()) {
  300. uni.showToast({ title: '请填写分析报告', icon: 'none' })
  301. return false
  302. }
  303. return true
  304. },
  305. buildRequestData(status) {
  306. var teacherId = uni.getStorageSync('userId')
  307. return {
  308. childId: this.childId,
  309. teacherId: teacherId,
  310. appointmentId: this.appointmentId,
  311. attentionScore: this.form.attentionScore,
  312. focusScore: this.form.focusScore,
  313. memoryScore: this.form.memoryScore,
  314. logicScore: this.form.logicScore,
  315. overallScore: this.overallScore,
  316. assessmentDate: this.form.assessmentDate,
  317. durationMinutes: Number(this.form.durationMinutes),
  318. analysisReport: this.form.analysisReport,
  319. growthSuggestions: this.form.growthSuggestions,
  320. nextReviewDate: this.form.nextReviewDate,
  321. resultDescription: this.form.resultDescription,
  322. mediaUrls: this.mediaList.join(','),
  323. status: status
  324. }
  325. },
  326. async saveDraft() {
  327. if (!this.childId) {
  328. uni.showToast({ title: '缺少孩子信息', icon: 'none' })
  329. return
  330. }
  331. try {
  332. uni.showLoading({ title: '保存中...' })
  333. this.submitting = true
  334. var data = this.buildRequestData('draft')
  335. var res = await recordAssessmentResult(data)
  336. uni.hideLoading()
  337. this.submitting = false
  338. if (res.code === 200) {
  339. uni.showToast({ title: '草稿已保存', icon: 'success' })
  340. } else {
  341. uni.showToast({ title: res.message || '保存失败', icon: 'none' })
  342. }
  343. } catch (e) {
  344. uni.hideLoading()
  345. this.submitting = false
  346. uni.showToast({ title: '保存失败', icon: 'none' })
  347. }
  348. },
  349. async submit() {
  350. if (!this.validateForm()) {
  351. return
  352. }
  353. try {
  354. uni.showLoading({ title: '提交中...' })
  355. this.submitting = true
  356. var data = this.buildRequestData('completed')
  357. var res = await recordAssessmentResult(data)
  358. uni.hideLoading()
  359. this.submitting = false
  360. if (res.code === 200) {
  361. uni.showModal({
  362. title: '提交成功',
  363. content: '测评结果已提交,家长将收到评估报告',
  364. showCancel: false,
  365. success: function() {
  366. uni.navigateBack()
  367. }
  368. })
  369. } else {
  370. uni.showToast({ title: res.message || '提交失败', icon: 'none' })
  371. }
  372. } catch (e) {
  373. uni.hideLoading()
  374. this.submitting = false
  375. uni.showToast({ title: '提交失败', icon: 'none' })
  376. }
  377. }
  378. }
  379. }
  380. </script>
  381. <style scoped>
  382. .container {
  383. padding: 30rpx;
  384. background: #F8F8F8;
  385. min-height: 100vh;
  386. }
  387. .header {
  388. text-align: center;
  389. padding: 60rpx 0 40rpx;
  390. }
  391. .title {
  392. font-size: 48rpx;
  393. font-weight: bold;
  394. color: #333;
  395. display: block;
  396. margin-bottom: 20rpx;
  397. }
  398. .subtitle {
  399. font-size: 28rpx;
  400. color: #666;
  401. }
  402. .section {
  403. background: #fff;
  404. border-radius: 20rpx;
  405. padding: 30rpx;
  406. margin-bottom: 30rpx;
  407. }
  408. .section-title {
  409. font-size: 32rpx;
  410. font-weight: bold;
  411. color: #333;
  412. margin-bottom: 20rpx;
  413. }
  414. /* 孩子信息 */
  415. .info-card {
  416. background: #F8F8F8;
  417. border-radius: 10rpx;
  418. padding: 20rpx;
  419. }
  420. .info-row {
  421. display: flex;
  422. justify-content: space-between;
  423. align-items: center;
  424. margin-bottom: 15rpx;
  425. }
  426. .info-row:last-child {
  427. margin-bottom: 0;
  428. }
  429. .info-label {
  430. font-size: 28rpx;
  431. color: #999;
  432. }
  433. .info-value {
  434. font-size: 28rpx;
  435. color: #333;
  436. font-weight: bold;
  437. }
  438. /* 评分 */
  439. .score-group {
  440. margin-bottom: 20rpx;
  441. }
  442. .score-item {
  443. margin-bottom: 20rpx;
  444. }
  445. .score-item:last-child {
  446. margin-bottom: 0;
  447. }
  448. .score-header {
  449. display: flex;
  450. justify-content: space-between;
  451. align-items: center;
  452. margin-bottom: 10rpx;
  453. }
  454. .score-label {
  455. font-size: 28rpx;
  456. color: #333;
  457. font-weight: bold;
  458. }
  459. .score-value {
  460. font-size: 32rpx;
  461. color: #667eea;
  462. font-weight: bold;
  463. }
  464. .overall-score {
  465. display: flex;
  466. justify-content: space-between;
  467. align-items: center;
  468. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  469. border-radius: 10rpx;
  470. padding: 24rpx 30rpx;
  471. margin-top: 20rpx;
  472. }
  473. .overall-label {
  474. font-size: 30rpx;
  475. color: #fff;
  476. font-weight: bold;
  477. }
  478. .overall-badge {
  479. background: rgba(255, 255, 255, 0.2);
  480. border-radius: 50%;
  481. width: 80rpx;
  482. height: 80rpx;
  483. display: flex;
  484. align-items: center;
  485. justify-content: center;
  486. }
  487. .overall-number {
  488. font-size: 36rpx;
  489. color: #fff;
  490. font-weight: bold;
  491. }
  492. /* 表单 */
  493. .form-group {
  494. margin-bottom: 20rpx;
  495. }
  496. .form-group:last-child {
  497. margin-bottom: 0;
  498. }
  499. .form-label {
  500. font-size: 28rpx;
  501. color: #333;
  502. font-weight: bold;
  503. display: block;
  504. margin-bottom: 10rpx;
  505. }
  506. .form-hint {
  507. font-size: 24rpx;
  508. color: #999;
  509. display: block;
  510. margin-bottom: 15rpx;
  511. }
  512. .form-input {
  513. height: 80rpx;
  514. background: #F8F8F8;
  515. border-radius: 10rpx;
  516. padding: 0 20rpx;
  517. font-size: 28rpx;
  518. color: #333;
  519. }
  520. .picker-value {
  521. display: flex;
  522. justify-content: space-between;
  523. align-items: center;
  524. height: 80rpx;
  525. background: #F8F8F8;
  526. border-radius: 10rpx;
  527. padding: 0 20rpx;
  528. font-size: 28rpx;
  529. color: #333;
  530. }
  531. .picker-arrow {
  532. font-size: 40rpx;
  533. color: #999;
  534. }
  535. .form-textarea {
  536. width: 100%;
  537. height: 240rpx;
  538. background: #F8F8F8;
  539. border-radius: 10rpx;
  540. padding: 20rpx;
  541. font-size: 28rpx;
  542. color: #333;
  543. box-sizing: border-box;
  544. }
  545. .form-textarea-short {
  546. height: 160rpx;
  547. }
  548. .char-count {
  549. display: block;
  550. text-align: right;
  551. font-size: 24rpx;
  552. color: #999;
  553. margin-top: 10rpx;
  554. }
  555. /* 媒体 */
  556. .media-grid {
  557. display: flex;
  558. flex-wrap: wrap;
  559. gap: 15rpx;
  560. }
  561. .media-item {
  562. position: relative;
  563. width: 200rpx;
  564. height: 200rpx;
  565. }
  566. .media-image {
  567. width: 200rpx;
  568. height: 200rpx;
  569. border-radius: 10rpx;
  570. object-fit: cover;
  571. }
  572. .media-remove {
  573. position: absolute;
  574. top: -10rpx;
  575. right: -10rpx;
  576. width: 40rpx;
  577. height: 40rpx;
  578. background: #F97316;
  579. color: #fff;
  580. border-radius: 50%;
  581. display: flex;
  582. align-items: center;
  583. justify-content: center;
  584. font-size: 24rpx;
  585. }
  586. .media-add {
  587. width: 200rpx;
  588. height: 200rpx;
  589. background: #F8F8F8;
  590. border: 2rpx dashed #D0D0D0;
  591. border-radius: 10rpx;
  592. display: flex;
  593. flex-direction: column;
  594. align-items: center;
  595. justify-content: center;
  596. }
  597. .media-add-icon {
  598. font-size: 60rpx;
  599. color: #999;
  600. line-height: 1;
  601. }
  602. .media-add-text {
  603. font-size: 24rpx;
  604. color: #999;
  605. margin-top: 10rpx;
  606. }
  607. /* 按钮 */
  608. .btn-group {
  609. display: flex;
  610. gap: 20rpx;
  611. margin-top: 40rpx;
  612. padding-bottom: 60rpx;
  613. }
  614. .btn-draft {
  615. flex: 1;
  616. height: 90rpx;
  617. background: #fff;
  618. color: #667eea;
  619. border: 2rpx solid #667eea;
  620. border-radius: 45rpx;
  621. font-size: 30rpx;
  622. font-weight: bold;
  623. line-height: 90rpx;
  624. }
  625. .btn-submit {
  626. flex: 1;
  627. height: 90rpx;
  628. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  629. color: #fff;
  630. border-radius: 45rpx;
  631. font-size: 30rpx;
  632. font-weight: bold;
  633. line-height: 90rpx;
  634. }
  635. .btn-draft[disabled],
  636. .btn-submit[disabled] {
  637. opacity: 0.6;
  638. }
  639. </style>