record.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714
  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. danLevel: '',
  207. attentionScore: 50,
  208. focusScore: 50,
  209. memoryScore: 50,
  210. logicScore: 50,
  211. assessmentDate: '',
  212. durationMinutes: '',
  213. analysisReport: '',
  214. growthSuggestions: '',
  215. nextReviewDate: '',
  216. resultDescription: ''
  217. }
  218. }
  219. },
  220. computed: {
  221. overallScore() {
  222. var total = this.form.attentionScore + this.form.focusScore + this.form.memoryScore + this.form.logicScore
  223. return Math.round(total / 4)
  224. },
  225. analysisReportLen() {
  226. return (this.form.analysisReport && this.form.analysisReport.length) || 0
  227. },
  228. growthSuggestionsLen() {
  229. return (this.form.growthSuggestions && this.form.growthSuggestions.length) || 0
  230. },
  231. resultDescriptionLen() {
  232. return (this.form.resultDescription && this.form.resultDescription.length) || 0
  233. }
  234. },
  235. onLoad(options) {
  236. if (options.appointmentId) {
  237. this.appointmentId = options.appointmentId
  238. }
  239. if (options.childId) {
  240. this.childId = options.childId
  241. }
  242. if (options.childName) {
  243. this.childName = decodeURIComponent(options.childName)
  244. }
  245. if (options.age) {
  246. this.age = options.age
  247. }
  248. if (options.school) {
  249. this.school = decodeURIComponent(options.school)
  250. }
  251. // 默认测评日期为今天
  252. var now = new Date()
  253. var year = now.getFullYear()
  254. var month = String(now.getMonth() + 1).padStart(2, '0')
  255. var day = String(now.getDate()).padStart(2, '0')
  256. this.form.assessmentDate = year + '-' + month + '-' + day
  257. },
  258. methods: {
  259. onAttentionChange(e) {
  260. this.form.attentionScore = e.detail.value
  261. },
  262. onFocusChange(e) {
  263. this.form.focusScore = e.detail.value
  264. },
  265. onMemoryChange(e) {
  266. this.form.memoryScore = e.detail.value
  267. },
  268. onLogicChange(e) {
  269. this.form.logicScore = e.detail.value
  270. },
  271. onAssessmentDateChange(e) {
  272. this.form.assessmentDate = e.detail.value
  273. },
  274. onNextReviewDateChange(e) {
  275. this.form.nextReviewDate = e.detail.value
  276. },
  277. chooseMedia() {
  278. var that = this
  279. uni.chooseImage({
  280. count: 9 - that.mediaList.length,
  281. sizeType: ['compressed'],
  282. sourceType: ['album', 'camera'],
  283. success: function(res) {
  284. that.mediaList = that.mediaList.concat(res.tempFilePaths)
  285. }
  286. })
  287. },
  288. removeMedia(index) {
  289. this.mediaList.splice(index, 1)
  290. },
  291. validateForm() {
  292. if (!this.form.assessmentDate) {
  293. uni.showToast({ title: '请选择测评日期', icon: 'none' })
  294. return false
  295. }
  296. if (!this.form.durationMinutes || this.form.durationMinutes <= 0) {
  297. uni.showToast({ title: '请输入有效的测评时长', icon: 'none' })
  298. return false
  299. }
  300. if (!this.form.analysisReport || !this.form.analysisReport.trim()) {
  301. uni.showToast({ title: '请填写分析报告', icon: 'none' })
  302. return false
  303. }
  304. return true
  305. },
  306. buildRequestData(status) {
  307. var teacherId = uni.getStorageSync('userId')
  308. return {
  309. childId: this.childId,
  310. teacherId: teacherId,
  311. appointmentId: this.appointmentId,
  312. danLevel: this.form.danLevel,
  313. attentionScore: this.form.attentionScore,
  314. focusScore: this.form.focusScore,
  315. memoryScore: this.form.memoryScore,
  316. logicScore: this.form.logicScore,
  317. overallScore: this.overallScore,
  318. assessmentDate: this.form.assessmentDate,
  319. durationMinutes: Number(this.form.durationMinutes),
  320. analysisReport: this.form.analysisReport,
  321. growthSuggestions: this.form.growthSuggestions,
  322. nextReviewDate: this.form.nextReviewDate,
  323. resultDescription: this.form.resultDescription,
  324. mediaUrls: this.mediaList.join(','),
  325. status: status
  326. }
  327. },
  328. async saveDraft() {
  329. if (!this.childId) {
  330. uni.showToast({ title: '缺少孩子信息', icon: 'none' })
  331. return
  332. }
  333. try {
  334. uni.showLoading({ title: '保存中...' })
  335. this.submitting = true
  336. var data = this.buildRequestData('draft')
  337. var res = await recordAssessmentResult(data)
  338. uni.hideLoading()
  339. this.submitting = false
  340. if (res.code === 200) {
  341. uni.showToast({ title: '草稿已保存', icon: 'success' })
  342. } else {
  343. uni.showToast({ title: res.message || '保存失败', icon: 'none' })
  344. }
  345. } catch (e) {
  346. uni.hideLoading()
  347. this.submitting = false
  348. uni.showToast({ title: '保存失败', icon: 'none' })
  349. }
  350. },
  351. async submit() {
  352. if (!this.validateForm()) {
  353. return
  354. }
  355. try {
  356. uni.showLoading({ title: '提交中...' })
  357. this.submitting = true
  358. var data = this.buildRequestData('completed')
  359. var res = await recordAssessmentResult(data)
  360. uni.hideLoading()
  361. this.submitting = false
  362. if (res.code === 200) {
  363. uni.showModal({
  364. title: '提交成功',
  365. content: '测评结果已提交,家长将收到评估报告',
  366. showCancel: false,
  367. success: function() {
  368. uni.navigateBack()
  369. }
  370. })
  371. } else {
  372. uni.showToast({ title: res.message || '提交失败', icon: 'none' })
  373. }
  374. } catch (e) {
  375. uni.hideLoading()
  376. this.submitting = false
  377. uni.showToast({ title: '提交失败', icon: 'none' })
  378. }
  379. }
  380. }
  381. }
  382. </script>
  383. <style scoped>
  384. .container {
  385. padding: 30rpx;
  386. background: #F8F8F8;
  387. min-height: 100vh;
  388. }
  389. .header {
  390. text-align: center;
  391. padding: 60rpx 0 40rpx;
  392. }
  393. .title {
  394. font-size: 48rpx;
  395. font-weight: bold;
  396. color: #333;
  397. display: block;
  398. margin-bottom: 20rpx;
  399. }
  400. .subtitle {
  401. font-size: 28rpx;
  402. color: #666;
  403. }
  404. .section {
  405. background: #fff;
  406. border-radius: 20rpx;
  407. padding: 30rpx;
  408. margin-bottom: 30rpx;
  409. }
  410. .section-title {
  411. font-size: 32rpx;
  412. font-weight: bold;
  413. color: #333;
  414. margin-bottom: 20rpx;
  415. }
  416. /* 孩子信息 */
  417. .info-card {
  418. background: #F8F8F8;
  419. border-radius: 10rpx;
  420. padding: 20rpx;
  421. }
  422. .info-row {
  423. display: flex;
  424. justify-content: space-between;
  425. align-items: center;
  426. margin-bottom: 15rpx;
  427. }
  428. .info-row:last-child {
  429. margin-bottom: 0;
  430. }
  431. .info-label {
  432. font-size: 28rpx;
  433. color: #999;
  434. }
  435. .info-value {
  436. font-size: 28rpx;
  437. color: #333;
  438. font-weight: bold;
  439. }
  440. /* 评分 */
  441. .score-group {
  442. margin-bottom: 20rpx;
  443. }
  444. .score-item {
  445. margin-bottom: 20rpx;
  446. }
  447. .score-item:last-child {
  448. margin-bottom: 0;
  449. }
  450. .score-header {
  451. display: flex;
  452. justify-content: space-between;
  453. align-items: center;
  454. margin-bottom: 10rpx;
  455. }
  456. .score-label {
  457. font-size: 28rpx;
  458. color: #333;
  459. font-weight: bold;
  460. }
  461. .score-value {
  462. font-size: 32rpx;
  463. color: #667eea;
  464. font-weight: bold;
  465. }
  466. .overall-score {
  467. display: flex;
  468. justify-content: space-between;
  469. align-items: center;
  470. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  471. border-radius: 10rpx;
  472. padding: 24rpx 30rpx;
  473. margin-top: 20rpx;
  474. }
  475. .overall-label {
  476. font-size: 30rpx;
  477. color: #fff;
  478. font-weight: bold;
  479. }
  480. .overall-badge {
  481. background: rgba(255, 255, 255, 0.2);
  482. border-radius: 50%;
  483. width: 80rpx;
  484. height: 80rpx;
  485. display: flex;
  486. align-items: center;
  487. justify-content: center;
  488. }
  489. .overall-number {
  490. font-size: 36rpx;
  491. color: #fff;
  492. font-weight: bold;
  493. }
  494. /* 表单 */
  495. .form-group {
  496. margin-bottom: 20rpx;
  497. }
  498. .form-group:last-child {
  499. margin-bottom: 0;
  500. }
  501. .form-label {
  502. font-size: 28rpx;
  503. color: #333;
  504. font-weight: bold;
  505. display: block;
  506. margin-bottom: 10rpx;
  507. }
  508. .form-hint {
  509. font-size: 24rpx;
  510. color: #999;
  511. display: block;
  512. margin-bottom: 15rpx;
  513. }
  514. .form-input {
  515. height: 80rpx;
  516. background: #F8F8F8;
  517. border-radius: 10rpx;
  518. padding: 0 20rpx;
  519. font-size: 28rpx;
  520. color: #333;
  521. }
  522. .picker-value {
  523. display: flex;
  524. justify-content: space-between;
  525. align-items: center;
  526. height: 80rpx;
  527. background: #F8F8F8;
  528. border-radius: 10rpx;
  529. padding: 0 20rpx;
  530. font-size: 28rpx;
  531. color: #333;
  532. }
  533. .picker-arrow {
  534. font-size: 40rpx;
  535. color: #999;
  536. }
  537. .form-textarea {
  538. width: 100%;
  539. height: 240rpx;
  540. background: #F8F8F8;
  541. border-radius: 10rpx;
  542. padding: 20rpx;
  543. font-size: 28rpx;
  544. color: #333;
  545. box-sizing: border-box;
  546. }
  547. .form-textarea-short {
  548. height: 160rpx;
  549. }
  550. .char-count {
  551. display: block;
  552. text-align: right;
  553. font-size: 24rpx;
  554. color: #999;
  555. margin-top: 10rpx;
  556. }
  557. /* 媒体 */
  558. .media-grid {
  559. display: flex;
  560. flex-wrap: wrap;
  561. gap: 15rpx;
  562. }
  563. .media-item {
  564. position: relative;
  565. width: 200rpx;
  566. height: 200rpx;
  567. }
  568. .media-image {
  569. width: 200rpx;
  570. height: 200rpx;
  571. border-radius: 10rpx;
  572. object-fit: cover;
  573. }
  574. .media-remove {
  575. position: absolute;
  576. top: -10rpx;
  577. right: -10rpx;
  578. width: 40rpx;
  579. height: 40rpx;
  580. background: #F97316;
  581. color: #fff;
  582. border-radius: 50%;
  583. display: flex;
  584. align-items: center;
  585. justify-content: center;
  586. font-size: 24rpx;
  587. }
  588. .media-add {
  589. width: 200rpx;
  590. height: 200rpx;
  591. background: #F8F8F8;
  592. border: 2rpx dashed #D0D0D0;
  593. border-radius: 10rpx;
  594. display: flex;
  595. flex-direction: column;
  596. align-items: center;
  597. justify-content: center;
  598. }
  599. .media-add-icon {
  600. font-size: 60rpx;
  601. color: #999;
  602. line-height: 1;
  603. }
  604. .media-add-text {
  605. font-size: 24rpx;
  606. color: #999;
  607. margin-top: 10rpx;
  608. }
  609. /* 按钮 */
  610. .btn-group {
  611. display: flex;
  612. gap: 20rpx;
  613. margin-top: 40rpx;
  614. padding-bottom: 60rpx;
  615. }
  616. .btn-draft {
  617. flex: 1;
  618. height: 90rpx;
  619. background: #fff;
  620. color: #667eea;
  621. border: 2rpx solid #667eea;
  622. border-radius: 45rpx;
  623. font-size: 30rpx;
  624. font-weight: bold;
  625. line-height: 90rpx;
  626. }
  627. .btn-submit {
  628. flex: 1;
  629. height: 90rpx;
  630. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  631. color: #fff;
  632. border-radius: 45rpx;
  633. font-size: 30rpx;
  634. font-weight: bold;
  635. line-height: 90rpx;
  636. }
  637. .btn-draft[disabled],
  638. .btn-submit[disabled] {
  639. opacity: 0.6;
  640. }
  641. </style>