浏览代码

课程题库-分类修改

Long 1 月之前
父节点
当前提交
98b8a5eac1
共有 2 个文件被更改,包括 46 次插入24 次删除
  1. 24 18
      src/views/course/courseQuestionBank/index.vue
  2. 22 6
      src/views/course/videoResource/index.vue

+ 24 - 18
src/views/course/courseQuestionBank/index.vue

@@ -30,13 +30,13 @@
         </el-select>
       </el-form-item>
 	  <el-form-item label="题目类别" prop="questionType">
-	    <el-select v-model="queryParams.questionType" placeholder="请选择类别" clearable size="small">
+	    <el-select v-model="queryParams.questionType" ref="typeSelect" placeholder="请选择类别" clearable size="small">
 	      <el-option
-	        v-for="dict in questionTypeOptions"
-	        :key="dict.dictValue"
-	        :label="dict.dictLabel"
-	        :value="dict.dictValue"
-	      />
+          v-for="item in questionTypeOptions"
+          :key="item.cateId"
+          :label="item.cateName"
+          :value="item.cateId"
+          />
 	    </el-select>
 	  </el-form-item>
 
@@ -124,7 +124,7 @@
       </el-table-column>
 	  <el-table-column label="题目类别" align="center" prop="questionType">
 	    <template slot-scope="scope">
-	      <dict-tag :options="questionTypeOptions" :value="scope.row.questionType"/>
+        <el-tag>{{ getCategoryName(scope.row.questionType) }}</el-tag>
 	    </template>
 	  </el-table-column>
       <el-table-column label="状态" align="center" prop="status">
@@ -183,12 +183,12 @@
         </el-form-item>
 		<el-form-item label="题目类别 " prop="questionType">
 		  <el-select v-model="form.questionType" placeholder="请选择题目类别" >
-		    <el-option
-		      v-for="dict in questionTypeOptions"
-		      :key="dict.dictValue"
-		      :label="dict.dictLabel"
-		      :value="parseInt(dict.dictValue)"
-		    ></el-option>
+        <el-option
+          v-for="item in questionTypeOptions"
+          :key="item.cateId"
+          :label="item.cateName"
+          :value="item.cateId"
+        />
 		  </el-select>
 		</el-form-item>
         <el-form-item label="状态">
@@ -292,6 +292,7 @@
 <script>
 import { listCourseQuestionBank, getCourseQuestionBank, delCourseQuestionBank, addCourseQuestionBank, updateCourseQuestionBank, exportCourseQuestionBank, importTemplate } from "@/api/course/courseQuestionBank";
 import { getToken } from "@/utils/auth";
+import { listUserCourseCategory } from '@/api/course/userCourseCategory'
 
 export default {
   name: "CourseQuestionBank",
@@ -386,17 +387,22 @@ export default {
     this.getDicts("sys_company_status").then(response => {
       this.statusOptions = response.data;
     });
-	this.getDicts("sys_course_question_type").then(response => {
-	  this.questionTypeOptions = response.data;
-	});
-
+    this.getCategoryTree()
   },
   methods: {
     getOptionLabel(index) {
       return this.alphabet[index];
     },
 
-
+    // 分类树
+    getCategoryTree() {
+      listUserCourseCategory().then(response => {
+        this.questionTypeOptions = response.data
+      });
+    },
+    getCategoryName(id) {
+      return this.questionTypeOptions.find(item => item.cateId === id)?.cateName || '';
+    },
     //题目类型发生变化
     changeType(){
         this.selectedAnswers = [];

+ 22 - 6
src/views/course/videoResource/index.vue

@@ -463,7 +463,7 @@
     <el-dialog
       title="选择题目"
       :visible.sync="projectDialogVisible"
-      width="900px"
+      width="1000px"
       append-to-body
       @close="cancelSelectProject"
       :close-on-click-modal="false">
@@ -473,10 +473,9 @@
           <div class="tree-fixed-header">
             <el-input
               placeholder="请输入分类名称"
-              v-model="projectQueryParams.cateName"
+              v-model="categoryFilterText"
               size="small"
               clearable
-              @input="initCategoryTree"
               prefix-icon="el-icon-search">
             </el-input>
           </div>
@@ -486,6 +485,7 @@
               :data="categoryTreeData"
               node-key="cateId"
               highlight-current
+              :filter-node-method="filterNode"
               :props="{ label: 'cateName', children: 'children' }"
               @node-click="handleCategoryClick"
               :expand-on-click-node="false"
@@ -512,6 +512,7 @@
             height="350"
             :data="projectList"
             row-key="id"
+            v-loading="projectLoading"
             border
             @select="handleProjectSelect"
             @select-all="handleProjectSelect">
@@ -706,11 +707,13 @@ export default {
         questionType: null,
         title: null
       },
+      projectLoading: false,
       projectListTotal: 0,
       selectedProjectIds: [],
       selectedType: 0,
       currentRow: null,
       // 分类树相关数据
+      categoryFilterText: '',
       categoryTreeData: [],
       add: false,
       // 题目列表
@@ -731,6 +734,11 @@ export default {
       }
     }
   },
+  watch: {
+    categoryFilterText(val) {
+      this.$refs.categoryTree.filter(val);
+    }
+  },
   created() {
     this.getTypeList();
     this.getList();
@@ -1232,6 +1240,7 @@ export default {
       });
     },
     getProjectList() {
+      this.projectLoading = true
       listCourseQuestionBank(this.projectQueryParams).then(response => {
         this.projectList = response.rows;
         this.projectListTotal = response.total;
@@ -1252,6 +1261,7 @@ export default {
             }
           }
         });
+        this.projectLoading = false
       });
     },
     /** 打开项目选择弹窗 */
@@ -1364,15 +1374,19 @@ export default {
     /** 初始化分类树 */
     initCategoryTree(name) {
       // 获取分类列表
-      listUserCourseCategory({cateName: name}).then(response => {
+      listUserCourseCategory().then(response => {
+        const treeDate = this.handleTree(response.data, "cateId", "pid");
         this.categoryTreeData = [{
           cateId: 0,
           cateName: '全部',
-          children: response.data
+          children: treeDate
         }];
       });
     },
-
+    filterNode(value, data) {
+      if (!value) return true;
+      return data.cateName.indexOf(value) !== -1;
+    },
     /** 处理分类点击 */
     handleCategoryClick(data) {
       // 更新查询参数
@@ -1591,6 +1605,7 @@ export default {
   display: flex;
   flex-direction: column;
   overflow: hidden;
+  flex-shrink: 0;
 }
 
 .tree-fixed-header {
@@ -1613,6 +1628,7 @@ export default {
   height: 100%;
   display: flex;
   flex-direction: column;
+  width: calc(100% - 250px); /* 固定宽度为剩余空间 */
 }
 
 .project-list .filter-container {