voluntary-result-score.vue 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <template>
  2. <view class="p-28 bg-white rounded-xl">
  3. <voluntary-result-title title="学生分数"/>
  4. <view class="p-28 gap-28 flex flex-col">
  5. <voluntary-result-progress v-for="i in progressList" :key="i.label" v-bind="i"/>
  6. </view>
  7. <voluntary-result-card tag="分析">
  8. <view class="flex-1 text-23 leading-38 text-fore-title">
  9. 该专业考试总分为<text class="text-primary">600</text>分,您当前成绩为<text class="text-primary">340</text>分。
  10. 参考<text>2025</text>年录取分数线,预估还需再提升<text class="text-primary">11</text>分即可达标!
  11. </view>
  12. </voluntary-result-card>
  13. </view>
  14. </template>
  15. <script setup lang="ts" name="VoluntaryResultScore">
  16. import VoluntaryResultTitle from "@/pagesOther/pages/voluntary/result/components/plus/voluntary-result-title.vue";
  17. import VoluntaryResultProgress from "@/pagesOther/pages/voluntary/result/components/plus/voluntary-result-progress.vue";
  18. import VoluntaryResultCard from "@/pagesOther/pages/voluntary/result/components/plus/voluntary-result-card.vue";
  19. import {VOLUNTARY_FORM, VOLUNTARY_MODEL} from "@/types/injectionSymbols";
  20. import {VoluntaryScoreItem} from "@/types/voluntary";
  21. import _ from "lodash";
  22. const model = inject(VOLUNTARY_MODEL)
  23. const data = inject(VOLUNTARY_FORM)
  24. const progressList = computed(() => {
  25. const scores = model?.value
  26. const form = data?.value
  27. if (!scores || !form) return []
  28. const results: VoluntaryScoreItem[] = []
  29. form.rules.forEach(i => {
  30. i.details.forEach(r => {
  31. results.push({
  32. label: r.label,
  33. score: Number(scores[r.fieldName]),
  34. total: Number(scores[r.fieldName + 'Total']),
  35. labelWidth: '',
  36. scoreWidth: ''
  37. })
  38. })
  39. })
  40. // 因为label score需要全局对齐,所以拼装的逻辑在progress外层
  41. const maxLabel = _.chain(results).map(i => i.label.length).max().value()
  42. const maxScore = _.chain(results).map(i => (i.score + '/' + i.total).length).max().value()
  43. const labelWidth = maxLabel * 29
  44. const scoreWidth = maxScore * 18
  45. results.forEach(i => {
  46. i.labelWidth = labelWidth + 'rpx'
  47. i.scoreWidth = scoreWidth + 'rpx'
  48. })
  49. return results
  50. })
  51. </script>
  52. <style scoped>
  53. </style>