hehaitao 1 рік тому
батько
коміт
5cee9ce8b9

+ 8 - 0
src/common/MxConst.js

@@ -132,6 +132,10 @@ export default {
       knowledge: {
         label: '按知识点选题',
         value: 'knowledge'
+      },
+      collect: {
+        label: '试题收藏',
+        value: 'collection'
       }
     },
     electiveReportType: {
@@ -177,6 +181,10 @@ export default {
         3: '体育类',
         4: '职高对口'
       }
+    },
+    collectionType: {
+      question: { type: 'question', name: '试题收藏' },
+      paper: { type: 'paper', name: '试卷收藏' }
     }
   },
   recommendOptions: {

+ 1 - 0
src/components/MxCondition/condition-object/condition-fav-quetype.js

@@ -9,6 +9,7 @@ export default {
   dependentKeys: ['favSubject'],
   key: 'favQueType',
   title: '题型',
+  alias: 'qtype',
   getList: function(param) {
     return new Promise((resolve, reject) => {
       favQueTypes({

+ 1 - 0
src/components/MxCondition/condition-object/condition-fav-subject.js

@@ -9,6 +9,7 @@ export default {
   dependentKeys: ['favCollectType'],
   key: 'favSubject',
   title: '学科',
+  alias: 'subjectName',
   getList: function(param) {
     return new Promise((resolve, reject) => {
       favSubjects({

+ 4 - 4
src/components/MxCondition/condition-object/condition-local-favCollectType.js

@@ -1,17 +1,17 @@
 import conditionBase from '../condition-object-base'
+import MxConst from "@/common/MxConst";
 
 export default {
   ...conditionBase,
   key: 'favCollectType',
   title: '类型',
+  alias: 'collectType',
   getList: function(param, $vue) {
     return this._getList(param, $vue)
   },
   _getList: function(param, $vue) {
-    return Promise.resolve([
-      { type: 'question', name: '试题收藏' },
-      { type: 'paper', name: '试卷收藏' }
-    ])
+    const types = Object.values(MxConst.enum.collectionType)
+    return Promise.resolve(types)
   },
   getCode(item) {
     return item.type

+ 38 - 11
src/views/questioncenter/components/generate-tabs/paper-by-hand.vue

@@ -2,10 +2,10 @@
   <div>
     <el-card>
       <mx-condition :local-data="extraData" :query-params="queryParams" :require-fields="requireFields"
-                    @query="handleQuery" use-alias-mapping></mx-condition>
+                    :invisible-fields="invisibleFields" @query="handleQuery" use-alias-mapping/>
     </el-card>
     <el-container>
-      <left-tree-side>
+      <left-tree-side v-if="!isCollectionBranch">
         <span slot="title">{{ !isKnowledgeBranch ? '章节目录' : '知识点目录' }}</span>
         <el-tree ref="branchTree" highlight-current :expand-on-click-node="false" :data="branchTree"
                  :props="treeProps" node-key="id" @node-click="handleTreeNodeClick"></el-tree>
@@ -13,7 +13,7 @@
       <!-- 手动组卷 -->
       <el-main style="background: #fff">
         <!-- 头部 -->
-        <div class="main_header">
+        <div class="main_header" v-if="!isCollectionBranch">
           <div class="left">
             <div class="main_tit">{{ title }}</div>
             <!-- 暂不支持 -->
@@ -89,12 +89,13 @@
 </template>
 
 <script>
-import consts from '@/common/mx-const'
+import consts from '@/common/MxConst'
 import MxCondition from '@/components/MxCondition/mx-condition'
 import {
   addToQuestionCard,
   chapterTree,
   deleteQuestionCard,
+  favQuestions,
   getQuestionCardList,
   knowledgeTree,
   listByChapter,
@@ -111,12 +112,13 @@ import MxQuestionReadonly from "@/components/MxQuestionReadonly/MxQuestionReadon
 export default {
   mixins: [PaperWorkIdentifierMixin],
   name: 'paper-by-hand',
-  components: {MxQuestionReadonly, LeftTreeSide, CorrectQuestionDialog, MxCondition },
+  components: {MxQuestionReadonly, LeftTreeSide, CorrectQuestionDialog, MxCondition},
   data() {
     return {
       queryParams: null,
       queryOutput: null,
       requireFields: [],
+      invisibleFields: [],
       chapterTree: [],
       knowledgeTree: [],
       treeProps: {
@@ -143,6 +145,9 @@ export default {
     }
   },
   computed: {
+    isCollectionBranch() {
+      return this.queryParams?.exeBranch == consts.enum.questionBranches.collect.value
+    },
     isKnowledgeBranch() {
       return this.queryParams?.exeBranch == consts.enum.questionBranches.knowledge.value
     },
@@ -160,7 +165,7 @@ export default {
     }
   },
   watch: {
-    'queryParams.exeBranch': async function(newVal, oldVal) {
+    'queryParams.exeBranch': async function (newVal, oldVal) {
       if (newVal && oldVal) {
         // ignored first mx-condition model assign
         await this.$nextTick()
@@ -186,6 +191,7 @@ export default {
       if (!this.queryParams || force) {
         const model = {}
         model.exeBranch = this.queryParams?.exeBranch || consts.enum.questionBranches.chapter.value
+        this.invisibleFields = []
         switch (model.exeBranch) {
           case consts.enum.questionBranches.chapter.value:
             model.exeSubject = '' // 科目
@@ -201,6 +207,13 @@ export default {
             this.requireFields = ['exeBranch', 'exeSubject']
             if (this.isPaperWork && !this.ignoreQType) this.requireFields.push('exeQTypeKnowledge')
             break
+          case consts.enum.questionBranches.collect.value:
+            model.favCollectType = consts.enum.collectionType.question.type
+            model.favSubject = ''
+            model.favQueType = ''
+            this.requireFields = ['exeBranch', 'favSubject', 'favQueType']
+            this.invisibleFields = ['favCollectType']
+            break
           default:
             console.log('unexpected type for branch', model.exeBranch)
             return
@@ -212,11 +225,12 @@ export default {
       // temporary save & parameter check
       this.queryOutput = model
       delete this.queryOutput.exeBranch // 本页API调用并不需要这个参数
+      if (this.isCollectionBranch) return this.queryCollections()
       if (!this.isKnowledgeBranch && !this.queryOutput.gradeId) return // 这是exeBranch条件切换时的中间状态,不要触发后续查询
 
       // refresh tree by need
       // TODO: 这里最好是由mx-condition解析依赖关系,但现在mx-condition的渲染逻辑不太方便切入
-      const treeCacheObj = { ...this.queryOutput }
+      const treeCacheObj = {...this.queryOutput}
       delete treeCacheObj.qtpye // 树和题型无关
       const newTreeCacheKey = `${model.exeBranch}_${JSON.stringify(treeCacheObj)}`
       if (newTreeCacheKey != this.treeCacheKey) {
@@ -255,6 +269,18 @@ export default {
       this.pageNum = 1
       this.queryQuestions()
     },
+    async queryCollections() {
+      console.log('queryCollections', this.queryOutput)
+      if (!this.queryOutput.subjectName) return // 条件切换中间状态
+      delete this.queryOutput.collectType // favQuestions接口不需要这个参数
+      const res = await favQuestions({
+        pageNum: this.pageNum,
+        pageSize: this.pageSize,
+        ...this.queryOutput,
+        ...this.extraData
+      })
+      await this._renderQuestions(res)
+    },
     async queryQuestions() {
       const commit = {
         pageNum: this.pageNum,
@@ -265,11 +291,12 @@ export default {
       }
       const queryFunc = this.isKnowledgeBranch ? listByKnowledge : listByChapter
       const res = await queryFunc(commit)
+      await this._renderQuestions(res)
+    },
+    async _renderQuestions(res) {
+      res.rows.forEach(r => r.expand = false) // add reactive field before render
       this.total = res.total
-      this.queList = res.rows.map(r => {
-        r.expand = false // add reactive field
-        return r
-      })
+      this.queList = res.rows
 
       await this.$nextTick()
       this.mxGlobal.MathQueue(this.mathId)

+ 1 - 1
src/views/questioncenter/generating.vue

@@ -168,7 +168,7 @@ export default {
   }
 
   .el-main {
-    padding: 37px 28px 0 28px;
+    //padding: 37px 28px 0 28px;
   }
 
   .main_header {