SubjectProgress.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. <template>
  2. <div class="p-base">
  3. <div class="fill-blank radius-base p-base chart-info">
  4. <vue-e-charts v-loading="loading" class="full" :option="totalChartsOption" autoresize></vue-e-charts>
  5. </div>
  6. <div class="m-t-base fill-blank radius-base p-base">
  7. <base-table
  8. v-loading="loading"
  9. border
  10. stripe
  11. size="small"
  12. :data="subjectProgressEndList"
  13. :columns="columns"
  14. :span-method="tableSpanMethod"
  15. ></base-table>
  16. </div>
  17. </div>
  18. </template>
  19. <script setup lang="ts" name="SubjectProgress">
  20. /** 科目进度 */
  21. import { reactive, ref, computed } from 'vue'
  22. import { minus } from '@/utils/common'
  23. import useFetch from '@/hooks/useFetch'
  24. import useMainStore from '@/store/main'
  25. import VueECharts from 'vue-echarts'
  26. import BaseTable from '@/components/element/BaseTable.vue'
  27. import type { EChartsOption } from 'echarts'
  28. import type { ExtractApiResponse } from '@/api/api'
  29. import type { EpTableColumn, InstanceTable } from 'global-type'
  30. type SubjectProgress = ExtractArrayValue<ExtractApiResponse<'subjectProgressEnd'>>
  31. const mainStore = useMainStore()
  32. const { fetch: subjectProgressEnd, result: subjectProgressEndList, loading } = useFetch('subjectProgressEnd')
  33. subjectProgressEnd({ subjectCode: mainStore.myUserInfo?.subjectCode || '' })
  34. const getMainName = (row?: SubjectProgress) => {
  35. const { questionMainName: name, questionMainNumber: number } = row || {}
  36. return [number, name].filter(Boolean).join('-')
  37. }
  38. const getYAxisData = (field: keyof SubjectProgress | 'name', data?: SubjectProgress[]) => {
  39. if (!data) {
  40. return []
  41. }
  42. return data.map((v) => {
  43. if (field === 'name') {
  44. return getMainName(v)
  45. }
  46. return v[field]
  47. })
  48. }
  49. const totalChartsOption = computed<EChartsOption>(() => {
  50. return {
  51. grid: {
  52. top: 20,
  53. bottom: -20,
  54. left: 20,
  55. right: 30,
  56. containLabel: true,
  57. },
  58. legend: {
  59. right: 0,
  60. itemWidth: 14,
  61. data: ['试卷总量', '已完成', '完成比'],
  62. },
  63. yAxis: {
  64. axisLine: { show: false },
  65. axisTick: { show: false },
  66. splitLine: { show: false },
  67. inverse: true,
  68. axisLabel: {
  69. align: 'right',
  70. verticalAlign: 'bottom',
  71. },
  72. data: getYAxisData('name', subjectProgressEndList?.value),
  73. },
  74. xAxis: [
  75. {
  76. position: 'top',
  77. type: 'value',
  78. splitLine: { show: true },
  79. },
  80. {
  81. position: 'bottom',
  82. type: 'value',
  83. show: false,
  84. axisLabel: {
  85. formatter: `{value}%`,
  86. },
  87. splitLine: { show: false },
  88. },
  89. ],
  90. series: [
  91. {
  92. name: '试卷总量',
  93. type: 'bar',
  94. barWidth: 11,
  95. barGap: '-200%',
  96. itemStyle: {
  97. color: '#3AD500',
  98. },
  99. data: getYAxisData('totalPaper', subjectProgressEndList?.value),
  100. },
  101. {
  102. name: '已完成',
  103. type: 'bar',
  104. barWidth: 11,
  105. barGap: '-200%',
  106. itemStyle: {
  107. color: '#0064FF',
  108. },
  109. data: getYAxisData('finishCount', subjectProgressEndList?.value),
  110. },
  111. {
  112. name: '完成比',
  113. type: 'bar',
  114. barWidth: 44,
  115. barGap: '-200%',
  116. showBackground: true,
  117. xAxisIndex: 1,
  118. itemStyle: {
  119. color: 'rgba(0, 186, 151,0.3)',
  120. },
  121. label: {
  122. show: true,
  123. color: '#444',
  124. fontSize: 10,
  125. formatter({ value }) {
  126. return value > 0 ? `${value}%` : ''
  127. },
  128. position: 'insideTopRight',
  129. },
  130. data: getYAxisData('finishRate', subjectProgressEndList?.value),
  131. },
  132. ],
  133. }
  134. })
  135. const columns: EpTableColumn<SubjectProgress>[] = [
  136. {
  137. label: '科目',
  138. formatter() {
  139. return mainStore.myUserInfo?.subjectCode + '-' + mainStore.myUserInfo?.subjectName
  140. },
  141. },
  142. { label: '大题', prop: 'questionMainName', width: 80 },
  143. { label: '试卷总量', prop: 'totalPaper', width: 90 },
  144. { label: '已完成', prop: 'finishCount', width: 70 },
  145. {
  146. label: '完成比',
  147. prop: 'finishRate',
  148. width: 70,
  149. formatter(row) {
  150. return `${row.finishRate}%`
  151. },
  152. },
  153. {
  154. label: '待完成',
  155. width: 90,
  156. formatter(row) {
  157. return `${minus(row.totalPaper, row.finishCount)}`
  158. },
  159. },
  160. {
  161. label: '待完成比',
  162. width: 90,
  163. prop: 'totalPaper',
  164. formatter(row) {
  165. return `${minus(100, row.finishRate)}%`
  166. },
  167. },
  168. { label: '问题卷待处理', prop: 'todoProblemPaperCount', width: 110 },
  169. { label: '雷同卷待处理', prop: 'todoSamePaperCount', width: 110 },
  170. { label: '主观题校验待处理', prop: 'subjectiveUnVerifyPaperCount', width: 140 },
  171. {
  172. label: '抽查比例',
  173. prop: 'checkPaperRate',
  174. width: 90,
  175. formatter(row) {
  176. return `${row.checkPaperRate}%`
  177. },
  178. },
  179. { label: '仲裁卷待处理', prop: 'todoArbitrationPaperCount', width: 110 },
  180. {
  181. label: '仲裁率',
  182. prop: 'arbitrationPaperRate',
  183. width: 70,
  184. formatter(row) {
  185. return `${row.arbitrationPaperRate}%`
  186. },
  187. },
  188. ]
  189. const tableSpanMethod: InstanceTable['spanMethod'] = (scope) => {
  190. if (scope.columnIndex === 0) {
  191. if (scope.rowIndex === 0) {
  192. return {
  193. rowspan: subjectProgressEndList.value?.length || 1,
  194. colspan: 1,
  195. }
  196. } else {
  197. return {
  198. rowspan: 0,
  199. colspan: 0,
  200. }
  201. }
  202. }
  203. return {
  204. rowspan: 1,
  205. colspan: 1,
  206. }
  207. }
  208. </script>
  209. <style scoped lang="scss">
  210. .chart-info {
  211. height: 260px;
  212. }
  213. </style>