query-segment.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <z-paging ref="paging" v-model="list" :auto="false" :default-page-size="20"
  3. @on-refresh="handleRefresh" @query="handleQuery">
  4. <template #top>
  5. <mx-nav-bar title="一分一段"/>
  6. <uv-gap height="15"/>
  7. <uv-form ref="form" :model="queryParams" :rules="rules" error-type="toast">
  8. <view class="px-30 bg-white fx-row items-center gap-30">
  9. <uv-tags icon="lock" shape="circle" plain plain-fill :text="currentUser.examMajorName"/>
  10. <mx-condition/>
  11. </view>
  12. </uv-form>
  13. </template>
  14. <view class="px-30 py-10 bg-white">
  15. <uv-search v-model="score" placeholder="输入分数查等效分" @search="handleScoreSearch(false)"
  16. @custom="handleScoreSearch(false)"/>
  17. <view class="mt-30 grid grid-cols-7 items-center">
  18. <view class="col-span-2 fx-col fx-cen-cen gap-10">
  19. <text class="text-2xs text-tips">分数</text>
  20. <text class="text-sm text-main font-bold">{{ match.score || '-' }}</text>
  21. </view>
  22. <view class="col-span-2 fx-col fx-cen-cen gap-10">
  23. <text class="text-2xs text-tips">同分人数</text>
  24. <text class="text-sm text-main font-bold">{{ match.num || '-' }}</text>
  25. </view>
  26. <view class="col-span-3 fx-col fx-cen-cen gap-10">
  27. <text class="text-2xs text-tips">位次区间</text>
  28. <text class="text-sm text-main font-bold">{{ match.highestRank + '~' + match.lowestRank }}</text>
  29. </view>
  30. </view>
  31. </view>
  32. <template v-if="eqList.length">
  33. <view class="px-30 bg-white py-10 text-main font-bold">历年等效分</view>
  34. <segment-score-table :cols="eqTable.cols" :rows="eqTable.rows" class="p-30 bg-white"/>
  35. <view class="px-30 bg-white">
  36. <uv-text prefix-icon="error-circle" type="info" size="12"
  37. :icon-style="{color: 'var(--error-color)', marginRight: '3px', fontSize: '14px'}"
  38. text="因高考人数及招生计划每年都存在一定的增减,分数和位次也会有相应浮动,我们根据历年省控线变化幅度等比计算出历年等效位次和等效分。"/>
  39. </view>
  40. </template>
  41. <view class="py-20 bg-white">
  42. <uv-gap height="15" class="!bg-bg"/>
  43. </view>
  44. <uv-sticky :custom-nav-height="-1">
  45. <view class="bg-white px-30 py-10 text-main font-bold">一分一段表</view>
  46. </uv-sticky>
  47. <segment-score-table :cols="segCols" :rows="list" class="p-30 bg-white"/>
  48. </z-paging>
  49. </template>
  50. <script setup>
  51. import {ref, watch, computed} from 'vue'
  52. import {useUserStore} from "@/hooks/useUserStore";
  53. import {useProvideSearchModel} from "@/components/mx-condition/useSearchModelInjection";
  54. import {useConditionSegmentLocation} from "@/components/mx-condition/modules/useConditionSegmentLocation";
  55. import {useConditionSegmentYear} from "@/components/mx-condition/modules/useConditionSegmentYear";
  56. import {useConditionSegmentMode} from "@/components/mx-condition/modules/useConditionSegmentMode";
  57. import {useProvideVoluntaryData} from "@/hooks/useVoluntaryDataInjection";
  58. import {useCacheStore} from "@/hooks/useCacheStore";
  59. import {cacheActions} from "@/hooks/defineCacheActions";
  60. import SegmentScoreTable from "@/pages/career/query-segment/components/segment-score-table.vue";
  61. const paging = ref(null)
  62. const form = ref(null)
  63. const list = ref([])
  64. const eqList = ref([])
  65. const {currentUser, isCultural} = useUserStore()
  66. const {provinceName: location, examMajor: mode} = currentUser.value
  67. const queryParams = ref({location, year: '', mode})
  68. const score = ref(currentUser.value.score)
  69. const defaultMatch = {
  70. highestRank: '',
  71. lowestRank: '',
  72. num: 0,
  73. numTotal: 0,
  74. score: 0
  75. }
  76. const match = ref(defaultMatch)
  77. const segCols = [
  78. {label: '分数', prop: 'score'},
  79. {label: '位次区间', prop: 'rank'},
  80. {label: '同分人数', prop: 'num'},
  81. ]
  82. const eqTable = computed(() => {
  83. const cols = [], rows = []
  84. if (!eqList.value.length) return {cols, rows}
  85. cols.push({label: '类型/年份', prop: 'type'})
  86. const eqSeat = {type: '等效位'}
  87. const eqScore = {type: '等效分'}
  88. eqList.value.forEach(r => {
  89. cols.push({label: r.year, prop: r.year})
  90. eqSeat[r.year] = r.seat || '-'
  91. eqScore[r.year] = r.score || '-'
  92. })
  93. rows.push(eqSeat)
  94. rows.push(eqScore)
  95. return {cols, rows}
  96. })
  97. const {dispatchCache, removeCache} = useCacheStore()
  98. const {onSearch, rules} = useProvideSearchModel([
  99. // useConditionSegmentLocation(),
  100. // useConditionSegmentYear(),
  101. // useConditionSegmentMode()
  102. // 目前只需要响应年份
  103. useConditionSegmentYear()
  104. ], queryParams, form)
  105. const {voluntaryData, validate: validateScore} = useProvideVoluntaryData(() => queryParams.value.year)
  106. onSearch(() => {
  107. handleScoreSearch()
  108. paging.value.reload()
  109. })
  110. watch(voluntaryData, () => handleScoreSearch())
  111. const handleRefresh = () => {
  112. removeCache(cacheActions.getSectionList)
  113. removeCache(cacheActions.getEquivalentScore)
  114. handleScoreSearch()
  115. }
  116. const handleQuery = (pageNum, pageSize) => {
  117. const payload = {...queryParams.value, pageNum, pageSize}
  118. dispatchCache(cacheActions.getSectionList, payload)
  119. .then(res => {
  120. res.rows.forEach(r => r.rank = r.highestRank + '~' + r.lowestRank)
  121. paging.value.completeByTotal(res.rows, res.total)
  122. })
  123. .catch(e => paging.value.complete(false))
  124. }
  125. const handleScoreSearch = async (silence = true) => {
  126. await validateScore(score.value, silence)
  127. const payload = {...queryParams.value, score: score.value}
  128. const res = await dispatchCache(cacheActions.getEquivalentScore, payload)
  129. match.value = res.match || defaultMatch
  130. eqList.value = res.scores || []
  131. }
  132. </script>
  133. <style lang="scss">
  134. </style>