GroupProgress.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <template>
  2. <div class="p-base radius-base fill-blank">
  3. <base-form size="small" :items="items" :model="model">
  4. <template #form-item-operation>
  5. <el-button class="m-l-base" type="primary" @click="onSearch">查询</el-button>
  6. <el-button :loading="exportLoading" type="primary" custom-1 @click="onExport">导出</el-button>
  7. <el-button :loading="provinceExportLoading" custom-1 type="primary" @click="provinceExport"
  8. >省份进度导出</el-button
  9. >
  10. </template>
  11. </base-form>
  12. <base-table border stripe size="small" :columns="columns" :data="result"></base-table>
  13. </div>
  14. </template>
  15. <script setup lang="ts" name="GroupProgress">
  16. /** 组员进度 */
  17. import { reactive, ref, watch, computed } from 'vue'
  18. import { ElButton } from 'element-plus'
  19. import BaseForm from '@/components/element/BaseForm.vue'
  20. import BaseTable from '@/components/element/BaseTable.vue'
  21. import useForm from '@/hooks/useForm'
  22. import useFetch from '@/hooks/useFetch'
  23. import useOptions from '@/hooks/useOptions'
  24. import useVW from '@/hooks/useVW'
  25. import type { EpFormItem, EpTableColumn } from 'global-type'
  26. import type { ExtractApiParams, ExtractApiResponse } from '@/api/api'
  27. const { groupListWithAll, dataModel, changeModelValue, onOptionInit } = useOptions(['group'])
  28. const model = reactive<ExtractApiParams<'getMarkProgressByMarker'>>({
  29. subjectCode: dataModel.subject || '',
  30. questionMainNumber: dataModel.question,
  31. markingGroupNumber: dataModel.group,
  32. })
  33. const { fetch, result } = useFetch('getMarkProgressByMarker')
  34. const onSearch = () => {
  35. fetch({ ...model })
  36. }
  37. const { fetch: exportStatistics, loading: exportLoading } = useFetch('exportMarkProgressByMarker', 'get')
  38. const { fetch: exportProvince, loading: provinceExportLoading } = useFetch('getProvinceProcess', 'get')
  39. const onExport = () => {
  40. exportStatistics(model)
  41. }
  42. const provinceExport = () => {
  43. exportProvince({ subjectCode: model.subjectCode })
  44. }
  45. watch(dataModel, () => {
  46. model.subjectCode = dataModel.subject || ''
  47. model.questionMainNumber = dataModel.question
  48. model.markingGroupNumber = dataModel.group
  49. })
  50. onOptionInit(onSearch)
  51. const { defineColumn, _ } = useForm()
  52. const OneRow = defineColumn(_, 'row-1', { span: 5 })
  53. const items = computed<EpFormItem[]>(() => [
  54. OneRow({
  55. label: '小组',
  56. slotType: 'select',
  57. prop: 'markingGroupNumber',
  58. slot: { options: groupListWithAll.value, onChange: changeModelValue('group') },
  59. }),
  60. OneRow({ slotName: 'operation' }),
  61. ])
  62. const dateTimes = computed(() => {
  63. const times = result?.value?.reduce((total, cur) => {
  64. total.push(...cur.dayFinishCounts.map((v) => v.date))
  65. return total
  66. }, [] as string[])
  67. return [...new Set(times)]
  68. })
  69. type TableColumn = EpTableColumn<ExtractArrayValue<ExtractApiResponse<'getMarkProgressByMarker'>>>
  70. const columns = computed<TableColumn[]>(() => {
  71. return [
  72. {
  73. label: '序号',
  74. type: 'index',
  75. width: 64,
  76. align: 'center',
  77. fixed: 'left',
  78. index(index) {
  79. return index < result?.value?.length - 1 ? index + 1 : (void 0 as unknown as number)
  80. },
  81. },
  82. { label: '评卷员', prop: 'markerName', align: 'center' },
  83. ...dateTimes.value.map((d) => {
  84. return {
  85. label: d,
  86. align: 'center',
  87. formatter(row) {
  88. return row.dayFinishCounts.find((v) => v.date === d)?.count ?? ''
  89. },
  90. width: 300,
  91. sortable: true,
  92. } as TableColumn
  93. }),
  94. { label: '合计', prop: 'totalFinishCount', align: 'center', sortable: true },
  95. ]
  96. })
  97. </script>
  98. <style scoped lang="scss"></style>