paper-by-intelligent.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <template>
  2. <div>
  3. <el-card>
  4. <mx-condition :local-data="extraData" :query-params="queryParams" :require-fields="requireFields"
  5. @query="handleQuery" use-alias-mapping></mx-condition>
  6. </el-card>
  7. <el-container>
  8. <left-tree-side>
  9. <span slot="title">{{ !isKnowledgeBranch ? '章节目录' : '知识点目录' }}</span>
  10. <el-tree ref="branchTree" highlight-current :expand-on-click-node="false" :data="branchTree"
  11. :props="treeProps" node-key="id" @node-click="handleTreeNodeClick"></el-tree>
  12. </left-tree-side>
  13. <!-- 手动组卷 -->
  14. <el-main style="background: #fff">
  15. <div class="knowPoints">
  16. <div class="tit">
  17. <span>已选知识点({{ tags.length }})</span>
  18. <div class="clear">
  19. <img src="@/assets/images/icon_qingkong.png" alt=""/>
  20. <span>清空</span>
  21. </div>
  22. </div>
  23. <el-divider class="generating_divider"></el-divider>
  24. <!-- tags -->
  25. <div class="tags">
  26. <el-tag v-for="tag in tags" :key="tag.id" closable style="margin-right: 24px; margin-bottom: 24px"
  27. @close="handleClose(tag)">
  28. {{ tag.name }}
  29. </el-tag>
  30. </div>
  31. </div>
  32. <div class="que">
  33. <div class="tit">
  34. <span>题型/题量</span>
  35. <div class="clear">
  36. <img src="@/assets/images/icon_qingkong.png" alt=""/>
  37. <span>清空</span>
  38. </div>
  39. </div>
  40. <el-divider></el-divider>
  41. <!-- 计数器 -->
  42. <div class="computer">
  43. <div class="computer_item" v-for="(item, index) in queCount" :key="index">
  44. <div class="fx-column">
  45. <div class="fx-row fx-sta-cen mb5">
  46. <span class="f14 f-333">{{ item.name }}</span>
  47. <span class="f12 f-999">(可选{{ item.num }}道)</span>
  48. </div>
  49. <el-input-number controls-position="right" v-model="item.count" :min="0" :max="item.num"></el-input-number>
  50. </div>
  51. </div>
  52. </div>
  53. </div>
  54. <!-- 生成试卷 -->
  55. <div style="
  56. display: flex;
  57. justify-content: center;
  58. margin-top: 90px;
  59. margin-bottom: 90px;
  60. ">
  61. <span class="generateExam" @click="createdPaper">生成试卷</span>
  62. </div>
  63. </el-main>
  64. </el-container>
  65. <correct-question-dialog ref="correct"></correct-question-dialog>
  66. </div>
  67. </template>
  68. <script>
  69. import PaperByHand from '@/views/questioncenter/components/generate-tabs/paper-by-hand'
  70. import {
  71. countByChapter,
  72. countByKnowledge,
  73. getQuestionsByQTypeAndNum,
  74. knowByChapter,
  75. listBottoms
  76. } from '@/api/webApi/webQue'
  77. export default {
  78. extends: PaperByHand,
  79. name: 'paper-by-intelligent',
  80. data() {
  81. return {
  82. // override
  83. extendCollection: false,
  84. mathId: 'question_by_intelligent',
  85. enableBox: false,
  86. ignoreQType: true,
  87. // new
  88. tags: [],
  89. queCount: [],
  90. knowledgeIds: [],
  91. listBottoms: []
  92. }
  93. },
  94. methods: {
  95. loadQuestionCard() {
  96. // override do-nothing
  97. },
  98. queryQuestions() {
  99. // override core query
  100. if (this.isKnowledgeBranch) {
  101. this.getListBottoms()
  102. } else {
  103. this.getKnowByChapter()
  104. }
  105. },
  106. getKnowByChapter() {
  107. // 根据章节查找知识点
  108. if (!this.currentNode.chapterId) return // 可能是切换的中间状态
  109. knowByChapter({
  110. ...this.queryOutput,
  111. ...this.currentNode
  112. }).then((res) => {
  113. this.knowledgeIds = res.data.map(item => item.id)
  114. this.tags = res.data
  115. this.getCountByChapter()
  116. })
  117. },
  118. getListBottoms() {
  119. // 根据章节获取底层知识
  120. if (!this.currentNode.knowledgeId) return // 可能是切换的中间状态
  121. listBottoms({
  122. ...this.queryOutput,
  123. ...this.currentNode
  124. }).then((res) => {
  125. this.listBottoms = res.data.map(item => item.id)
  126. this.tags = res.data
  127. this.getCountByKnowledge()
  128. })
  129. },
  130. getCountByChapter() {
  131. // 根据章节获取题库类型和数量
  132. countByChapter({
  133. ...this.queryOutput,
  134. ...this.currentNode,
  135. knowledgeIds: this.knowledgeIds.toString()
  136. }).then((res) => {
  137. this.queCount = res.data
  138. })
  139. },
  140. getCountByKnowledge() {
  141. // 根据知识点获取题库类型和数量
  142. countByKnowledge({
  143. ...this.queryOutput,
  144. ...this.currentNode,
  145. knowledgeIds: this.listBottoms.toString()
  146. }).then((res) => {
  147. this.queCount = res.data
  148. })
  149. },
  150. handleClose(tag) {
  151. if (this.tags.length <= 1) {
  152. this.msgError('至少查询1个')
  153. }
  154. this.tags.remove(tag)
  155. if (this.isKnowledgeBranch) {
  156. this.listBottoms.remove(tag.id)
  157. this.getCountByKnowledge()
  158. } else {
  159. this.knowledgeIds.remove(tag.id)
  160. this.getCountByChapter()
  161. }
  162. },
  163. createdPaper() {
  164. let queCount = this.queCount
  165. let req = []
  166. let allQue = 0
  167. // TODO: hht 22.10.08 这里的参数构成逻辑还没有完全看明白,但目前没有报错,先保持原样
  168. queCount.forEach((item) => {
  169. if (item.count > 0) {
  170. allQue = allQue + item.count
  171. req.push({
  172. subjectid: this.queryOutput.subjectId,
  173. qtpye: item.name,
  174. diff: 1,
  175. number: item.count,
  176. chapterid: this.currentNode.chapterId,
  177. gradeid: this.queryOutput.gradeId,
  178. editionid: this.queryOutput.editionId,
  179. knowledgeIds: this.knowledgeIds
  180. })
  181. }
  182. })
  183. if (allQue > 100) {
  184. this.msgError('选题上限是100题哦')
  185. return
  186. } else if (allQue == 0) {
  187. this.msgError('你还未选择题目')
  188. return
  189. }
  190. getQuestionsByQTypeAndNum(req).then((res) => {
  191. localStorage.setItem(
  192. 'paperData',
  193. JSON.stringify({
  194. paperTitle: null,
  195. subjectId: this.queryOutput.subjectId
  196. })
  197. )
  198. localStorage.setItem('questionList', JSON.stringify(res.data))
  199. this.$router.push({
  200. path: '/question-center/generatingPaperCenter/paper',
  201. query: this.extraData
  202. })
  203. })
  204. }
  205. }
  206. }
  207. </script>
  208. <style scoped>
  209. </style>