paper-exact-intelligent.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 class="text-center">
  18. <el-button type="primary" size="large" @click="handleSubmit">生成试卷</el-button>
  19. </div>
  20. </template>
  21. <script setup name="PaperExactIntelligent">
  22. import consts from "@/utils/consts.js";
  23. import {useProvidePaperBatchCondition} from "@/views/dz/papers/components/conditions/usePaperBatchCondition.js";
  24. import {
  25. useProvidePaperClassStatisticCondition
  26. } from "@/views/dz/papers/components/conditions/usePaperClassStatisticCondition.js";
  27. import ClassStatisticTable from "@/views/dz/papers/components/plugs/class-statistic-table.vue";
  28. import {ElMessage} from "element-plus";
  29. import {buildPaperExactIntelligent} from "@/api/dz/papers.js";
  30. import {useInjectGlobalLoading} from "@/views/hooks/useGlobalLoading.js";
  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 handleSubmit = async function () {
  36. const classIds = selectedClasses.value.map(c => c.classId)
  37. if (!batchId.value) return ElMessage.error('请选择批次')
  38. if (!classIds.length) return ElMessage.error('请选择班级')
  39. try {
  40. loading.value = true
  41. const commit = {buildType: type, batchId: batchId.value, classIds}
  42. await buildPaperExactIntelligent(commit)
  43. ElMessage.success('生成成功')
  44. await _loadClassStatistic()
  45. } finally {
  46. loading.value = false
  47. }
  48. }
  49. let statArgs = null // 保留参数,生成组卷后刷新用
  50. const _loadClassStatistic = async () => {
  51. selectedClasses.value = []
  52. classList.value = []
  53. await loadClassStatistic(statArgs)
  54. }
  55. onBatchReady(async (payload) => {
  56. statArgs = payload
  57. await _loadClassStatistic()
  58. })
  59. </script>
  60. <style scoped>
  61. </style>