paper-exact-intelligent.vue 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <template>
  2. <el-row :gutter="20">
  3. <el-col :span="8">
  4. <el-form label-width="68px">
  5. <el-form-item label="批次">
  6. <el-select v-model="batchId" clearable style="width: 227px">
  7. <el-option v-for="b in batchList" :label="b.name" :value="b.batchId"/>
  8. </el-select>
  9. </el-form-item>
  10. </el-form>
  11. </el-col>
  12. <el-col :span="16">
  13. <class-statistic-table exact-mode/>
  14. </el-col>
  15. </el-row>
  16. <el-divider/>
  17. <div v-if="!hasBuiltPaper" class="text-center">
  18. <el-button type="primary" size="large" @click="handleSubmit">生成试卷</el-button>
  19. </div>
  20. <built-paper ref="built" @send="handleSubmit" />
  21. </template>
  22. <script setup name="PaperExactIntelligent">
  23. import consts from "@/utils/consts.js";
  24. import {useProvidePaperBatchCondition} from "@/views/dz/papers/hooks/usePaperBatchCondition.js";
  25. import {useProvidePaperClassStatisticCondition} from "@/views/dz/papers/hooks/usePaperClassStatisticCondition.js";
  26. import ClassStatisticTable from "@/views/dz/papers/components/plugs/class-statistic-table.vue";
  27. import {ElMessage} from "element-plus";
  28. import {buildPaperExactIntelligent} from "@/api/dz/papers.js";
  29. import {useInjectGlobalLoading} from "@/views/hooks/useGlobalLoading.js";
  30. import BuiltPaper from "@/views/dz/papers/components/plugs/built-paper.vue";
  31. const type = consts.enums.buildType.ExactIntelligent
  32. const {batchId, batchList, onBatchReady} = useProvidePaperBatchCondition(type)
  33. const {selectedClasses, classList, loadClassStatistic} = useProvidePaperClassStatisticCondition()
  34. const {loading} = useInjectGlobalLoading()
  35. const built = ref(null)
  36. const hasBuiltPaper = computed(() => built.value?.hasPaper)
  37. const handleSubmit = async function () {
  38. if (!batchId.value) return ElMessage.error('请选择批次')
  39. const classIds = selectedClasses.value.map(c => c.classId)
  40. if (!classIds.length) return ElMessage.error('请选择班级')
  41. try {
  42. loading.value = true
  43. const commit = {buildType: type, batchId: batchId.value, classIds}
  44. await buildPaperExactIntelligent(commit)
  45. ElMessage.success('生成成功')
  46. await _loadClassStatistic()
  47. } finally {
  48. loading.value = false
  49. }
  50. }
  51. let statArgs = null // 保留参数,生成组卷后刷新用
  52. const _loadClassStatistic = async () => {
  53. selectedClasses.value = []
  54. classList.value = []
  55. await loadClassStatistic(statArgs)
  56. }
  57. onBatchReady(async (payload) => {
  58. statArgs = payload
  59. await _loadClassStatistic()
  60. await built.value.loadBuiltPaper(payload)
  61. })
  62. watch(batchId, () => built.value.reset())
  63. </script>
  64. <style scoped>
  65. </style>