question-hand.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <div class="text-main mb-3">
  3. 当前查询知识点(从左侧选择):
  4. <el-text size="large" type="primary" class="font-bold">{{ knowledgeNode?.name }}</el-text>
  5. </div>
  6. <div class="flex flex-row items-center gap-3">
  7. <el-input v-model="keywordLocal" clearable prefix-icon="search" placeholder="输入题目关键字-回车触发搜索"
  8. style="width: 250px" @keydown.enter="confirmKeyword" @clear="confirmKeyword"/>
  9. <el-select v-model="qtpye" clearable style="width: 220px">
  10. <el-option v-for="t in qTypes" :value="t.dictValue" :label="t.dictLabel"></el-option>
  11. </el-select>
  12. <el-popover width="250">
  13. <span v-if="subjectStat.length" class="text-lg font-bold">
  14. 科目:{{subjectStat.map(ss => `${ss.subjectName}(${ss.count})`).join('、')}}
  15. </span>
  16. <div v-for="g in groupedQuestions" class="flex flex-col">
  17. <el-divider style="margin: 10px 0"/>
  18. <span>{{ g.qtpye }}:{{ g.questions.length }}道</span>
  19. <el-link type="danger" plain icon="delete" class="self-end" @click="removeQuestionGroup(g.qtpye)">清除
  20. </el-link>
  21. </div>
  22. <el-divider style="margin: 10px 0"/>
  23. <div class="flex items-center justify-between">
  24. <el-link type="danger" plain icon="delete" @click="clearCart">全部清除</el-link>
  25. <el-button type="primary" @click="buildPaper">生成试卷</el-button>
  26. </div>
  27. <template #reference>
  28. <el-button type="primary" size="large" icon="shopping-cart" class="ml-auto">
  29. 试题篮({{ cart.length }})
  30. </el-button>
  31. </template>
  32. </el-popover>
  33. </div>
  34. <el-divider/>
  35. <div v-loading="questionLoading" element-loading-text="加载试题中...">
  36. <el-empty v-if="total==0"/>
  37. <div v-else class="flex flex-col gap-5">
  38. <question-content v-for="q in questionList" :question="q" @parse="showParseQuestion=q,showParse=true">
  39. <el-button v-if="!hasQuestion(q)" type="primary" icon="plus" class="ml-auto" @click="addQuestion(q)">
  40. 加入试题篮
  41. </el-button>
  42. <el-button v-else type="danger" plain icon="delete" class="ml-auto" @click="removeQuestion(q)">移出试题篮
  43. </el-button>
  44. </question-content>
  45. </div>
  46. <pagination v-show="total>0" :total="total" v-model:page="pageNum" v-model:limit="pageSize"
  47. @pagination="getQuestionList"/>
  48. </div>
  49. <el-dialog v-model="showParse" append-to-body show-close @close="showParse=false">
  50. <template #title>ID:{{ showParseQuestion.id }} 试题解析</template>
  51. <div v-if="showParseQuestion.answer0" v-html="`【正确答案】` + showParseQuestion.answer0"/>
  52. <div v-if="showParseQuestion.parse" v-html="`【解析】` + showParseQuestion.parse" class="mt-5"></div>
  53. <div v-if="showParseQuestion.parse0" v-html="`【解析】` + showParseQuestion.parse0" class="mt-5"></div>
  54. <template #footer>
  55. <el-button type="primary" @click="showParse=false">确 定</el-button>
  56. </template>
  57. </el-dialog>
  58. </template>
  59. <script setup name="QuestionHand">
  60. import {ElMessage} from "element-plus";
  61. import {useProvidePaperQuestionCondition} from "@/views/dz/papers/hooks/usePaperQuestionCondition.js";
  62. import {useInjectPaperBatchCondition} from "@/views/dz/papers/hooks/usePaperBatchCondition.js";
  63. import {useInjectPaperKnowledgeCondition} from "@/views/dz/papers/hooks/usePaperKnowledgeCondition.js";
  64. import {useInjectGlobalLoading} from "@/views/hooks/useGlobalLoading.js";
  65. import QuestionContent from "@/views/components/question-content.vue";
  66. const props = defineProps({
  67. allowMultiple: Boolean,
  68. exactMode: Boolean
  69. })
  70. const emits = defineEmits(['submit'])
  71. const showParse = ref(false)
  72. const showParseQuestion = ref(null)
  73. const {batchId} = useInjectPaperBatchCondition()
  74. const {knowledgeNode} = useInjectPaperKnowledgeCondition()
  75. const {loading: globalLoading} = useInjectGlobalLoading()
  76. const {
  77. keyword,
  78. qtpye,
  79. qTypes,
  80. pageNum,
  81. pageSize,
  82. total,
  83. questionList,
  84. getQuestionList,
  85. cart,
  86. groupedQuestions,
  87. currentSubject,
  88. subjectStat,
  89. hasQuestion,
  90. addQuestion,
  91. removeQuestion,
  92. removeQuestionGroup,
  93. clearCart
  94. } = useProvidePaperQuestionCondition(props.exactMode, true)
  95. // 试题列表加载状态
  96. const questionLoading = computed(() => globalLoading.value)
  97. const keywordLocal = ref('')
  98. const confirmKeyword = (val) => keyword.value = keywordLocal.value
  99. const buildPaper = function () {
  100. // validation
  101. if (!cart.value.length) return ElMessage.error('请将试题加入试题篮')
  102. emits('submit', cart.value)
  103. // const paper = {...paperArgs.value, questions: cart.value}
  104. // usePaperStorage(paper)
  105. // router.push({name: 'PaperDetail'})
  106. }
  107. </script>
  108. <style scoped>
  109. </style>