瀏覽代碼

自动组卷

zhangjie 2 年之前
父節點
當前提交
39732165d6

+ 71 - 31
src/modules/paper/components/QuestionGroupStruct.vue

@@ -1,17 +1,17 @@
 <template>
   <div class="question-group-struct">
     <div class="struct-set">
-      <el-checkbox v-model="isClassify" @change="setChange"
+      <el-checkbox v-model="useClassify" @change="setChange"
         >指定文件夹抽题</el-checkbox
       >
-      <el-checkbox v-model="isDifficult" @change="setChange"
+      <el-checkbox v-model="useDifficult" @change="setChange"
         >按难度抽题</el-checkbox
       >
-      <el-checkbox v-model="isProperty" @change="setChange"
+      <el-checkbox v-model="useProperty" @change="setChange"
         >按课程属性抽题</el-checkbox
       >
       <el-select
-        v-if="isProperty"
+        v-if="useProperty"
         v-model="curCoursePropertyId"
         class="margin-left-10"
         size="small"
@@ -24,8 +24,8 @@
         ></el-option>
       </el-select>
     </div>
-    <div v-if="!IS_NONE_SET" class="struct-box">
-      <div v-if="isClassify" class="struct-folder">
+    <div v-if="!USE_NONE_SET" class="struct-box">
+      <div v-if="useClassify" class="struct-folder">
         <el-tree
           ref="folderTree"
           class="folder-tree"
@@ -58,7 +58,7 @@
             </template>
           </el-table-column>
           <el-table-column
-            v-if="!isDifficult || IS_ONLY_DIFFICULT"
+            v-if="!useDifficult || USE_ONLY_DIFFICULT"
             label="数量"
             width="150"
           >
@@ -86,7 +86,7 @@
             <template
               v-if="
                 scope.row.difficultDistributeInfo &&
-                !(scope.row.isClassify && isProperty)
+                !(scope.row.useClassify && useProperty)
               "
               slot-scope="scope"
             >
@@ -117,6 +117,7 @@
 <script>
 import folderTree from "../datas/folderTree.json";
 import { questionGroupStructListApi } from "../api";
+import { deepCopy } from "@/plugins/utils";
 
 export default {
   name: "QuestionGroupStruct",
@@ -133,9 +134,9 @@ export default {
   },
   data() {
     return {
-      isClassify: false,
-      isDifficult: false,
-      isProperty: false,
+      useClassify: false,
+      useDifficult: false,
+      useProperty: false,
       checkedSet: [],
       selectedFolderIds: [],
       classifyTree: folderTree,
@@ -156,14 +157,14 @@ export default {
     };
   },
   computed: {
-    IS_ONLY_DIFFICULT() {
-      return !this.isClassify && this.isDifficult && !this.isProperty;
+    USE_ONLY_DIFFICULT() {
+      return !this.useClassify && this.useDifficult && !this.useProperty;
     },
-    IS_ONLY_PROPERTY() {
-      return !this.isClassify && !this.isDifficult && this.isProperty;
+    USE_ONLY_PROPERTY() {
+      return !this.useClassify && !this.useDifficult && this.useProperty;
     },
-    IS_NONE_SET() {
-      return !this.isClassify && !this.isDifficult && !this.isProperty;
+    USE_NONE_SET() {
+      return !this.useClassify && !this.useDifficult && !this.useProperty;
     },
   },
   watch: {
@@ -180,7 +181,7 @@ export default {
   },
   methods: {
     setChange() {
-      if (!this.isClassify) this.selectedFolderIds = [];
+      if (!this.useClassify) this.selectedFolderIds = [];
       this.resetDataList();
     },
     checkChange() {
@@ -190,29 +191,29 @@ export default {
     async resetDataList() {
       await this.getOriginList();
 
-      if (this.isProperty) {
+      if (this.useProperty) {
         this.parsePropertyInfo();
       }
       this.buildDataList();
     },
     async getOriginList() {
-      if (this.isClassify && !this.selectedFolderIds.length) {
+      if (this.useClassify && !this.selectedFolderIds.length) {
         this.$message.error("请选择选择文件夹!");
         return;
       }
       let data = {
         ...this.filterData,
-        isDifficult: this.isDifficult,
-        isProperty: this.isProperty,
+        useDifficult: this.useDifficult,
+        useProperty: this.useProperty,
       };
-      if (this.isClassify && this.selectedFolderIds.length)
+      if (this.useClassify && this.selectedFolderIds.length)
         data.classifyIdList = this.selectedFolderIds.join();
 
       const res = await questionGroupStructListApi(data);
       this.originList = res.data || [];
     },
     parsePropertyInfo() {
-      if (!this.isProperty) {
+      if (!this.useProperty) {
         this.propertyInfo = [];
         return;
       }
@@ -266,10 +267,13 @@ export default {
             data.difficultDistributeInfo
           );
         }
-        if (!data.propertyDistributeInfo || !data.propertyDistributeInfo.length)
+        if (
+          !data.coursePropertyDistributeInfo ||
+          !data.coursePropertyDistributeInfo.length
+        )
           return classifyData;
 
-        const curCourseProp = data.propertyDistributeInfo.find(
+        const curCourseProp = data.coursePropertyDistributeInfo.find(
           (item) => item.coursePropertyId === _this.curCoursePropertyId
         );
         if (!curCourseProp) {
@@ -325,27 +329,63 @@ export default {
       this.dataList = this.originList.map((item) => buildClassifyData(item));
       this.tableData = this.dataList;
 
-      if (this.IS_ONLY_DIFFICULT) {
+      if (this.USE_ONLY_DIFFICULT) {
         this.tableData = this.dataList[0].difficultDistributeInfo;
         this.tableData.map((item) => {
           let nitem = { ...item };
-          (item.id = item.difficultLevel), (item.name = item.difficultLevel);
+          nitem.id = item.difficultLevel;
+          nitem.name = item.difficultLevel;
           return nitem;
         });
         return;
       }
-      if (this.isClassify && !this.isProperty) {
+      if (this.useClassify && !this.useProperty) {
         this.tableData = this.dataList.map((item) => {
           let nitem = { ...item };
-          nitem.propertyDistributeInfo = [];
+          nitem.propertyDistributeInfo = null;
           return nitem;
         });
       }
-      if (!this.isClassify && this.isProperty) {
+      if (!this.useClassify && this.useProperty) {
         this.tableData = this.dataList[0].propertyDistributeInfo;
         return;
       }
     },
+    getDataList() {
+      let dataList = deepCopy(this.dataList);
+
+      if (this.USE_ONLY_DIFFICULT) {
+        dataList[0].difficultDistributeInfo = this.tableData.map((item) => {
+          return {
+            difficultLevel: item.difficultLevel,
+            questionCount: item.questionCount,
+            selectCount: item.selectCount,
+          };
+        });
+        return dataList;
+      } else if (this.useClassify && !this.useProperty) {
+        dataList = deepCopy(this.tableData);
+        return dataList;
+      } else if (!this.useClassify && this.useProperty) {
+        dataList[0].propertyDistributeInfo = this.tableData;
+      }
+
+      const curCourseProp = this.propertyInfo.find(
+        (item) => item.id === this.curCoursePropertyId
+      );
+      dataList = dataList.map((item) => {
+        item.coursePropertyDistributeInfo = [
+          {
+            coursePropertyId: curCourseProp.id,
+            coursePropertyName: curCourseProp.name,
+            propertyDistributeInfo: item.propertyDistributeInfo,
+          },
+        ];
+        return item;
+      });
+
+      return dataList;
+    },
   },
 };
 </script>

+ 1 - 1
src/modules/paper/datas/folderPropStruct.json

@@ -21,7 +21,7 @@
         "selectCount": 0
       }
     ],
-    "propertyDistributeInfo": [
+    "coursePropertyDistributeInfo": [
       {
         "coursePropertyId": 3,
         "coursePropertyName": "知识",

+ 9 - 0
src/modules/question/api.js

@@ -79,6 +79,15 @@ export function questionPropertyDistributionStatisticsApi(data) {
   return Promise.resolve({ data: distributionPropData, filter: data });
 }
 // classify-manage
+export function classifyListApi(parentId) {
+  return $httpWithMsg.post(
+    `${QUESTION_API}/question/classify/list`,
+    {},
+    {
+      params: { parentId },
+    }
+  );
+}
 export function classifyTreeApi() {
   return $httpWithMsg.post(`${QUESTION_API}/question/classify/find_all`, {});
 }

+ 37 - 47
src/modules/question/components/ModifyFolder.vue

@@ -2,8 +2,8 @@
   <el-dialog
     custom-class="side-dialog"
     :visible.sync="modalIsShow"
-    title="试题导入"
-    width="700px"
+    :title="title"
+    width="500px"
     :modal="false"
     :close-on-click-modal="false"
     :close-on-press-escape="false"
@@ -16,52 +16,22 @@
       :rules="rules"
       label-width="120px"
     >
-      <el-form-item label="导入类型">
-        <el-radio-group v-model="modalForm.importType">
-          <el-radio label="word">word</el-radio>
-          <el-radio label="zip">zip</el-radio>
-        </el-radio-group>
-      </el-form-item>
-      <el-form-item prop="courseId" label="导入类型">
-        <course-select v-model="modalForm.courseId"> </course-select>
-      </el-form-item>
-      <el-form-item label="是否使用原卷">
-        <el-radio-group v-model="modalForm.userPaper">
-          <el-radio :label="true">是</el-radio>
-          <el-radio :label="false">否</el-radio>
-        </el-radio-group>
-      </el-form-item>
-      <el-form-item
-        v-if="modalForm.userPaper"
-        prop="paperName"
-        label="试卷名称"
-      >
+      <el-form-item v-if="modalForm.name" prop="name" label="文件夹名称">
         <el-input
-          v-model="modalForm.paperName"
-          placeholder="请输入试卷名称"
+          v-model="modalForm.name"
+          placeholder="请输入文件夹名称"
           clearable
         >
         </el-input>
       </el-form-item>
-      <el-form-item label="总分校验">
-        <el-radio-group v-model="modalForm.scoreCheck">
-          <el-radio :label="true">开启</el-radio>
-          <el-radio :label="false">关闭</el-radio>
-        </el-radio-group>
-      </el-form-item>
-      <el-form-item prop="file">
-        <import-file
-          ref="ImportFile"
-          :format="[modalForm.importType]"
-          :template-url="templateUrl"
-          only-fetch-file
-          @file-change="fileChange"
-          @confirm="confirm"
-        ></import-file>
-      </el-form-item>
     </el-form>
 
-    <div slot="footer"></div>
+    <div slot="footer">
+      <el-button type="primary" :disabled="loading" @click="confirm"
+        >确认</el-button
+      >
+      <el-button @click="cancel">取消</el-button>
+    </div>
   </el-dialog>
 </template>
 
@@ -70,11 +40,20 @@ import { updateClassifyApi } from "../api";
 
 const initModalForm = {
   id: "",
+  parentId: "",
   name: "",
 };
 
 export default {
   name: "ModifyFolder",
+  props: {
+    instance: {
+      type: Object,
+      default() {
+        return {};
+      },
+    },
+  },
   data() {
     return {
       modalIsShow: false,
@@ -88,14 +67,27 @@ export default {
             message: "请输入文件夹名称",
             trigger: "change",
           },
+          {
+            max: 100,
+            message: "文件夹名称不能超过100",
+            trigger: "change",
+          },
         ],
       },
       loading: false,
     };
   },
+  computed: {
+    isEdit() {
+      return !!this.instance.id;
+    },
+    title() {
+      return (this.isEdit ? "编辑" : "新增") + "文件夹";
+    },
+  },
   methods: {
     visibleChange() {
-      this.modalForm = { ...initModalForm };
+      this.modalForm = this.$objAssign(initModalForm, this.instance);
     },
     cancel() {
       this.modalIsShow = false;
@@ -110,16 +102,14 @@ export default {
       if (this.loading) return;
       this.loading = true;
 
-      const res = await updateClassifyApi(this.modalForm, {
-        md5: this.fileData.md5,
-      }).catch(() => {});
+      const datas = { ...this.modalForm };
+      const res = await updateClassifyApi(datas).catch(() => {});
       this.loading = false;
-
       if (!res) return;
 
       this.$message.success("修改成功!");
-      this.$emit("modified");
       this.cancel();
+      this.$emit("modified");
     },
   },
 };

+ 27 - 5
src/modules/question/views/QuestionManage.vue

@@ -253,11 +253,18 @@
       ref="QuestionImportDialog"
       @modified="toPage(1)"
     ></question-import-dialog>
+    <!-- ModifyFolder -->
+    <modify-folder
+      ref="ModifyFolder"
+      :instance="curFolder"
+      @modified="folderModified"
+    ></modify-folder>
   </div>
 </template>
 
 <script>
 import {
+  classifyListApi,
   questionPageListApi,
   deleteQuestionApi,
   moveQuestionApi,
@@ -270,6 +277,7 @@ import QuestionSafetySetDialog from "../components/QuestionSafetySetDialog.vue";
 import QuestionFolderDialog from "../components/QuestionFolderDialog.vue";
 import QuestionImportDialog from "../components/QuestionImportDialog.vue";
 import QuestionEditDialog from "../components/QuestionEditDialog.vue";
+import ModifyFolder from "../components/ModifyFolder.vue";
 
 export default {
   name: "QuestionMamage",
@@ -279,6 +287,7 @@ export default {
     QuestionFolderDialog,
     QuestionImportDialog,
     QuestionEditDialog,
+    ModifyFolder,
   },
   data() {
     return {
@@ -308,6 +317,15 @@ export default {
     this.toPage(1);
   },
   methods: {
+    async getFolderList() {
+      const res = await classifyListApi(this.filter.classifyId);
+      this.folderList = res.data || [];
+    },
+    toFolder(classifyId) {
+      this.filter.classifyId = classifyId;
+      this.toPage(1);
+      this.getFolderList();
+    },
     toPage(page) {
       this.currentPage = page;
       this.getList();
@@ -342,10 +360,6 @@ export default {
     toSafetySet() {
       this.$refs.QuestionSafetySetDialog.open();
     },
-    toAddFolder() {
-      this.isEditFolder = true;
-      this.$refs.QuestionFolderDialog.open();
-    },
     toCreateQuestion() {
       if (!this.filter.courseId) {
         this.$message.error("请先选择课程!");
@@ -423,8 +437,13 @@ export default {
     toLinkQuestion(row) {
       console.log(row);
     },
+    toAddFolder() {
+      this.curFolder = { parentId: this.filter.classifyId };
+      this.$refs.ModifyFolder.open();
+    },
     toEditFolder(row) {
-      console.log(row);
+      this.curFolder = row;
+      this.$refs.ModifyFolder.open();
     },
     toMoveFolder(row) {
       console.log(row);
@@ -447,6 +466,9 @@ export default {
       this.$message.success("操作成功");
       await this.getClassifyTree();
     },
+    folderModified() {
+      this.getFolderList();
+    },
   },
 };
 </script>