index.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <template>
  2. <div class="flex direction-column full">
  3. <div class="p-l-base p-t-medium-base fill-blank">
  4. <base-form ref="formRef" size="small" :rules="rules" :items="items" :model="model" :disabled="loading">
  5. <template #form-item-operation>
  6. <el-button :loading="loading" type="primary" @click="onSearch">查询</el-button>
  7. <el-button type="primary" custom-1 @click="onExport">导出</el-button>
  8. </template>
  9. </base-form>
  10. </div>
  11. <div class="flex-1 p-base">
  12. <div class="p-base radius-base fill-blank">
  13. <base-table border stripe :columns="columns" :data="data" size="small"></base-table>
  14. <el-pagination
  15. v-bind="pagination"
  16. v-model:current-page="currentPage"
  17. background
  18. right
  19. layout="total,pager"
  20. ></el-pagination>
  21. </div>
  22. </div>
  23. <base-dialog v-model="modalVisible" title="选择导出文件的格式" destroy-on-close :width="350">
  24. <el-radio-group v-model="exportFileType" class="ml-4">
  25. <el-radio label="TXT" size="large">TXT</el-radio>
  26. <el-radio label="DBF" size="large">DBF</el-radio>
  27. </el-radio-group>
  28. <template #footer>
  29. <div class="flex justify-end">
  30. <confirm-button @confirm="sureExport" @cancel="cancelExport"></confirm-button>
  31. </div>
  32. </template>
  33. </base-dialog>
  34. </div>
  35. </template>
  36. <script setup lang="ts" name="DataExport">
  37. /** CET成绩导出 */
  38. import { reactive, watch, computed, ref } from 'vue'
  39. import { ElButton, ElPagination, ElMessage, ElRadio, ElRadioGroup } from 'element-plus'
  40. import BaseForm from '@/components/element/BaseForm.vue'
  41. import BaseTable from '@/components/element/BaseTable.vue'
  42. import useForm from '@/hooks/useForm'
  43. import useTable from '@/hooks/useTable'
  44. import useOptions from '@/hooks/useOptions'
  45. import useFetch from '@/hooks/useFetch'
  46. import BaseDialog from '@/components/element/BaseDialog.vue'
  47. import ConfirmButton from '@/components/common/ConfirmButton.vue'
  48. import type { ExtractMultipleApiParams } from '@/api/api'
  49. import type { EpFormItem, EpTableColumn, EpFormRules } from 'global-type'
  50. const { subjectList, dataModel, changeModelValue } = useOptions(['subject'])
  51. const model = reactive<ExtractMultipleApiParams<'getCetScoreList'>>({
  52. subjectCode: dataModel.subject || '',
  53. })
  54. const modalVisible = ref(false)
  55. // const exportFileType = ref('TXT')
  56. const exportFileType = ref('DBF')
  57. const { formRef, elFormRef, defineColumn, _ } = useForm()
  58. watch(dataModel, () => {
  59. model.subjectCode = dataModel.subject || ''
  60. })
  61. const OneRowSpan5 = defineColumn(_, 'row-1', { span: 5 })
  62. const rules: EpFormRules = {
  63. subjectCode: [{ required: true, message: '请选择科目' }],
  64. }
  65. const items = computed<EpFormItem[]>(() => {
  66. return [
  67. OneRowSpan5({
  68. label: '科目',
  69. prop: 'subjectCode',
  70. slotType: 'select',
  71. slot: { options: subjectList.value, onChange: changeModelValue('subject') },
  72. }),
  73. OneRowSpan5({ slotName: 'operation', labelWidth: '20px' }),
  74. ]
  75. })
  76. const { pagination, currentPage, loading, data, fetchTable } = useTable('getCetScoreList', model, { pageSize: 20 })
  77. const columns: EpTableColumn[] = [
  78. { label: '准考证号', prop: 'examNumber', minWidth: 160, fixed: 'left' },
  79. { label: '科目代码', prop: 'subjectCode', minWidth: 90 },
  80. { label: '作文分', prop: 'compositionScore', minWidth: 70 },
  81. { label: '主观分', prop: 'subjectScore', minWidth: 70 },
  82. { label: '作文评卷员代码', prop: 'compositionMarker', minWidth: 110 },
  83. { label: '作文题评卷标志', prop: 'compositionTag', minWidth: 110 },
  84. { label: '翻译题得分', prop: 'translateScore', minWidth: 90 },
  85. { label: '翻译题评卷员代码', prop: 'translateMarker', minWidth: 120 },
  86. { label: '翻译题评卷标志', prop: 'translateTag', minWidth: 110 },
  87. { label: '作文雷同标记', prop: 'compositionSame', minWidth: 90 },
  88. { label: '翻译雷同标记', prop: 'translateSame', minWidth: 90 },
  89. ]
  90. const onSearch = async () => {
  91. try {
  92. const valid = await elFormRef?.value?.validate()
  93. if (valid) {
  94. fetchTable()
  95. }
  96. } catch (error) {
  97. console.error(error)
  98. }
  99. }
  100. const { fetch: exportCetScoreList } = useFetch('exportCetScoreList', 'get')
  101. const onExport = async () => {
  102. try {
  103. const valid = await elFormRef?.value?.validate()
  104. if (valid) {
  105. // modalVisible.value = true
  106. sureExport()
  107. }
  108. } catch (error) {
  109. console.error(error)
  110. }
  111. }
  112. const sureExport = async () => {
  113. try {
  114. await exportCetScoreList({ ...model, exportFileType: exportFileType.value })
  115. ElMessage.success('操作成功,后台导出中,您可以稍后去“任务信息报告”页面进行查询')
  116. modalVisible.value = false
  117. } catch (err) {}
  118. }
  119. const cancelExport = () => {
  120. modalVisible.value = false
  121. }
  122. </script>
  123. <style scoped lang="scss"></style>