zhangjie 2 éve
szülő
commit
e3d897e1a6

+ 63 - 42
src/modules/questions/views/EditOtherQuestion.vue

@@ -115,7 +115,7 @@
               type="primary"
               @close="handleClose(content)"
             >
-              {{ content.coursePropertyName || content.courseProperty.name }}
+              {{ content.courseProperty.name }}
             </el-tag>
           </el-tooltip>
         </el-form-item>
@@ -123,16 +123,21 @@
           <el-col :xs="6" :sm="6" :md="6" :lg="6">
             <el-form-item label="属性名">
               <el-select
-                v-model="coursePropertyName"
+                v-model="coursePropertyId"
+                :remote-method="getCoursesProperty"
+                :loading="coursePropertyLoading"
+                remote
+                filterable
+                clearable
                 placeholder="属性名"
                 class="property_with"
                 @change="searchFirst"
               >
                 <el-option
                   v-for="item in coursePropertyList"
-                  :key="item.name"
+                  :key="item.id"
                   :label="item.name"
-                  :value="item.name"
+                  :value="item.id"
                 >
                 </el-option>
               </el-select>
@@ -286,6 +291,7 @@ export default {
   name: "EditOtherApp",
   data() {
     return {
+      coursePropertyLoading: false,
       fullscreenLoading: false,
       questionTypes: QUESTION_TYPES,
       courseName: "",
@@ -336,7 +342,7 @@ export default {
         { label: "音频", value: "SINGLE_AUDIO" },
       ],
       coursePropertyList: [],
-      coursePropertyName: "", //课程属性名
+      coursePropertyId: "", //课程属性
       firstPropertyList: [], //一级属性集合
       firstPropertyId: "", //一级属性id
       secondPropertyList: [], //二级属性集合
@@ -367,7 +373,6 @@ export default {
   created() {
     this.paperId = this.$route.params.paperId;
     this.paperDetailId = this.$route.params.paperDetailId;
-    this.courseName = this.$route.params.courseName;
     this.courseId = this.$route.params.courseId;
     let questionType = this.$route.params.questionType;
     if (questionType) {
@@ -377,13 +382,8 @@ export default {
     if (this.questionId) {
       this.quesModel["id"] = this.questionId;
       this.getQues(this.questionId);
-    }
-    if (this.courseId) {
-      this.$http
-        .get(QUESTION_API + "/courseProperty/enable?courseId=" + this.courseId)
-        .then((response) => {
-          this.coursePropertyList = response.data;
-        });
+    } else if (this.courseId) {
+      this.getCoursesProperty("");
     }
 
     if (isEmptyStr(this.quesModel.answerType)) {
@@ -400,6 +400,36 @@ export default {
     }, 200);
   },
   methods: {
+    getQuesPropertyKey(quesProp) {
+      if (!quesProp) {
+        return "";
+      } else if (quesProp.secondProperty.id) {
+        return (
+          quesProp.courseProperty.id +
+          "-" +
+          quesProp.firstProperty.id +
+          "-" +
+          quesProp.secondProperty.id
+        );
+      } else {
+        return quesProp.courseProperty.id + "-" + quesProp.firstProperty.id;
+      }
+    },
+    getCoursesProperty(name) {
+      this.coursePropertyLoading = true;
+      this.$httpWithMsg
+        .get(
+          QUESTION_API +
+            "/courseProperty/enable?courseId=" +
+            this.courseId +
+            "&name=" +
+            name
+        )
+        .then((response) => {
+          this.coursePropertyList = response.data;
+          this.coursePropertyLoading = false;
+        });
+    },
     boolAnswerChange(val) {
       this.quesModel.quesAnswer = val ? "true" : "false";
     },
@@ -510,7 +540,7 @@ export default {
     getQues(id) {
       this.$http.get(QUESTION_API + "/question/" + id).then((response) => {
         this.quesModel = response.data;
-
+        this.courseId = this.quesModel.course.id;
         if (isEmptyStr(this.quesModel.answerType)) {
           this.quesModel.answerType = "DIVERSIFIED_TEXT";
         }
@@ -529,7 +559,7 @@ export default {
         } else {
           this.quesAnswer = null;
         }
-        this.initCourseProperty();
+        this.getCoursesProperty("");
       });
     },
     backToQuesList() {
@@ -537,30 +567,16 @@ export default {
         path: "/questions/question_list/1",
       });
     },
-    //查询所有课程属性名
-    initCourseProperty() {
-      var courseId = this.quesModel.course.courseId;
-      if (!courseId) return;
-      this.$http
-        .get(QUESTION_API + "/courseProperty/enable?courseId=" + courseId)
-        .then((response) => {
-          this.coursePropertyList = response.data;
-        });
-    },
     //查询一级属性
     searchFirst() {
       this.firstPropertyId = "";
       this.secondPropertyId = "";
       this.secondPropertyList = [];
-      for (let courseProperty of this.coursePropertyList) {
-        if (courseProperty.name == this.coursePropertyName) {
-          this.$http
-            .get(QUESTION_API + "/property/first/" + courseProperty.id)
-            .then((response) => {
-              this.firstPropertyList = response.data;
-            });
-        }
-      }
+      this.$http
+        .get(QUESTION_API + "/property/first/" + this.coursePropertyId)
+        .then((response) => {
+          this.firstPropertyList = response.data;
+        });
     },
     //查询二级属性
     searchSecond() {
@@ -577,8 +593,8 @@ export default {
         return false;
       }
       var quesProperty = {
-        id: "",
-        coursePropertyName: "",
+        key: "",
+        courseProperty: {},
         firstProperty: {},
         secondProperty: {},
       };
@@ -589,14 +605,14 @@ export default {
       ) {
         this.quesModel.quesProperties = [];
       }
-      quesProperty.id =
-        this.coursePropertyName +
+      let quesPropertyKey =
+        this.coursePropertyId +
         "-" +
         this.firstPropertyId +
         "-" +
         this.secondPropertyId;
       for (let quesPro of this.quesModel.quesProperties) {
-        if (quesPro.id == quesProperty.id) {
+        if (quesPro.key == quesPropertyKey) {
           this.$notify({
             message: "该属性已存在,请重新选择",
             type: "error",
@@ -604,7 +620,11 @@ export default {
           return false;
         }
       }
-      quesProperty.coursePropertyName = this.coursePropertyName;
+      for (let property of this.coursePropertyList) {
+        if (property.id == this.coursePropertyId) {
+          quesProperty.courseProperty = property;
+        }
+      }
       //取到一级属性对象
       for (let property of this.firstPropertyList) {
         if (property.id == this.firstPropertyId) {
@@ -630,10 +650,11 @@ export default {
           quesProperty.secondProperty = property;
         }
       }
+      quesProperty.key = this.getQuesPropertyKey(quesProperty);
       this.quesModel.quesProperties.push(quesProperty);
       this.quesModel = Object.assign({}, this.quesModel);
       //清空下拉框
-      this.coursePropertyName = "";
+      this.coursePropertyId = "";
       this.firstPropertyId = "";
       this.secondPropertyId = "";
       this.firstPropertyList = [];
@@ -649,7 +670,7 @@ export default {
     },
     //新增属性验证
     checkInsertPro() {
-      if (!this.coursePropertyName) {
+      if (!this.coursePropertyId) {
         this.$notify({
           message: "请选择属性",
           type: "error",

+ 51 - 16
src/modules/questions/views/EditPaper.vue

@@ -736,6 +736,11 @@
             <el-form-item label="属性名" label-width="80px">
               <el-select
                 v-model="coursePropertyId"
+                :remote-method="getCoursesProperty"
+                :loading="coursePropertyLoading"
+                remote
+                filterable
+                clearable
                 placeholder="属性名"
                 class="property_with"
                 :disabled="updatePorperty"
@@ -1180,6 +1185,7 @@ export default {
   },
   data() {
     return {
+      coursePropertyLoading: false,
       showCheckDuplicateBtn: false,
       auditInfoDialog: false,
       blueDialog: false,
@@ -1193,7 +1199,7 @@ export default {
       uploadAction: "",
       fileList: [],
       answerFileList: [],
-      paperId: "",
+      paperId: null,
       paperDetailId: "",
       editPaperDetailUnit: "",
       quesDialog: false,
@@ -1342,7 +1348,7 @@ export default {
       this.quesAnswerShow = qa == "true";
     }
     document.getElementsByTagName("body")[0].style = "";
-    this.paperId = this.$route.params.id;
+    this.paperId = Number(this.$route.params.id);
     this.parentView = this.$route.params.parentView;
     this.initPaper();
     this.uploadAction = QUESTION_API + "/uploadRadio/" + this.paperId;
@@ -1352,6 +1358,36 @@ export default {
     };
   },
   methods: {
+    getQuesPropertyKey(quesProp) {
+      if (!quesProp) {
+        return "";
+      } else if (quesProp.secondProperty.id) {
+        return (
+          quesProp.courseProperty.id +
+          "-" +
+          quesProp.firstProperty.id +
+          "-" +
+          quesProp.secondProperty.id
+        );
+      } else {
+        return quesProp.courseProperty.id + "-" + quesProp.firstProperty.id;
+      }
+    },
+    getCoursesProperty(name) {
+      this.coursePropertyLoading = true;
+      this.$httpWithMsg
+        .get(
+          QUESTION_API +
+            "/courseProperty/enable?courseId=" +
+            this.paper.course.id +
+            "&name=" +
+            name
+        )
+        .then((response) => {
+          this.coursePropertyList = response.data;
+          this.coursePropertyLoading = false;
+        });
+    },
     showCheckDuplicate() {
       if (this.paper.checkDuplicateStatus == "DISPOSED") {
         this.showCheckDuplicateBtn = false;
@@ -1773,7 +1809,7 @@ export default {
         .then((response) => {
           this.paper = response.data;
           //查询所有课程属性名
-          this.initCourseProperty(this.paper.course.id);
+          this.getCoursesProperty("");
           //将所有小题分为公开和非公开
           if (this.paper.paperDetails && this.paper.paperDetails.length > 0) {
             let dindx = 0;
@@ -1822,14 +1858,6 @@ export default {
           this.loading = false;
         });
     },
-    //查询所有课程属性名
-    initCourseProperty(courseId) {
-      this.$http
-        .get(QUESTION_API + "/courseProperty/enable?courseId=" + courseId)
-        .then((response) => {
-          this.coursePropertyList = response.data;
-        });
-    },
     //删除大题
     deletePaperDetail(paperDetailsId) {
       //先判断大题下面是否还有小题
@@ -2055,7 +2083,7 @@ export default {
         return false;
       }
       var quesProperty = {
-        id: null,
+        key: "",
         courseProperty: {},
         firstProperty: {},
         secondProperty: {},
@@ -2066,8 +2094,14 @@ export default {
       ) {
         this.quesModel.quesProperties = [];
       }
+      let quesPropertyKey =
+        this.coursePropertyId +
+        "-" +
+        this.firstPropertyId +
+        "-" +
+        this.secondPropertyId;
       for (let quesPro of this.quesModel.quesProperties) {
-        if (quesPro.id == quesProperty.id) {
+        if (quesPro.key == quesPropertyKey) {
           this.$notify({
             message: "该属性已存在,请重新选择",
             type: "error",
@@ -2075,9 +2109,9 @@ export default {
           return false;
         }
       }
-      for (let courseProperty of this.coursePropertyList) {
-        if (courseProperty.id == this.coursePropertyId) {
-          quesProperty.courseProperty = courseProperty;
+      for (let property of this.coursePropertyList) {
+        if (property.id == this.coursePropertyId) {
+          quesProperty.courseProperty = property;
         }
       }
       //取到一级属性对象
@@ -2105,6 +2139,7 @@ export default {
           quesProperty.secondProperty = property;
         }
       }
+      quesProperty.key = this.getQuesPropertyKey(quesProperty);
       this.quesModel.quesProperties.push(quesProperty);
       this.quesModel = Object.assign({}, this.quesModel);
       //清空下拉框

+ 49 - 24
src/modules/questions/views/EditPaperPendingTrial.vue

@@ -776,6 +776,11 @@
             <el-form-item label="属性名" label-width="80px">
               <el-select
                 v-model="coursePropertyId"
+                :remote-method="getCoursesProperty"
+                :loading="coursePropertyLoading"
+                remote
+                filterable
+                clearable
                 placeholder="属性名"
                 class="property_with"
                 :disabled="updatePorperty"
@@ -1234,6 +1239,7 @@ export default {
   },
   data() {
     return {
+      coursePropertyLoading: false,
       showCheckDuplicateBtn: false,
       selectedPaperIds: [],
       auditPaperDialog: false,
@@ -1410,6 +1416,36 @@ export default {
     };
   },
   methods: {
+    getQuesPropertyKey(quesProp) {
+      if (!quesProp) {
+        return "";
+      } else if (quesProp.secondProperty.id) {
+        return (
+          quesProp.courseProperty.id +
+          "-" +
+          quesProp.firstProperty.id +
+          "-" +
+          quesProp.secondProperty.id
+        );
+      } else {
+        return quesProp.courseProperty.id + "-" + quesProp.firstProperty.id;
+      }
+    },
+    getCoursesProperty(name) {
+      this.coursePropertyLoading = true;
+      this.$httpWithMsg
+        .get(
+          QUESTION_API +
+            "/courseProperty/enable?courseId=" +
+            this.paper.course.id +
+            "&name=" +
+            name
+        )
+        .then((response) => {
+          this.coursePropertyList = response.data;
+          this.coursePropertyLoading = false;
+        });
+    },
     showCheckDuplicate() {
       if (this.paper.checkDuplicateStatus == "DISPOSED") {
         this.showCheckDuplicateBtn = false;
@@ -1876,7 +1912,7 @@ export default {
         .then((response) => {
           this.paper = response.data;
           //查询所有课程属性名
-          this.initCourseProperty(this.paper.course.id);
+          this.getCoursesProperty("");
           //将所有小题分为公开和非公开
           if (this.paper.paperDetails && this.paper.paperDetails.length > 0) {
             let dindx = 0;
@@ -1925,14 +1961,6 @@ export default {
           this.loading = false;
         });
     },
-    //查询所有课程属性名
-    initCourseProperty(courseId) {
-      this.$http
-        .get(QUESTION_API + "/courseProperty/enable?courseId=" + courseId)
-        .then((response) => {
-          this.coursePropertyList = response.data;
-        });
-    },
     //删除大题
     deletePaperDetail(paperDetailsId) {
       //先判断大题下面是否还有小题
@@ -2158,7 +2186,7 @@ export default {
         return false;
       }
       var quesProperty = {
-        id: "",
+        key: "",
         courseProperty: {},
         firstProperty: {},
         secondProperty: {},
@@ -2169,18 +2197,14 @@ export default {
       ) {
         this.quesModel.quesProperties = [];
       }
-      if (this.secondPropertyId) {
-        quesProperty.id =
-          this.coursePropertyId +
-          "-" +
-          this.firstPropertyId +
-          "-" +
-          this.secondPropertyId;
-      } else {
-        quesProperty.id = this.coursePropertyId + "-" + this.firstPropertyId;
-      }
+      let quesPropertyKey =
+        this.coursePropertyId +
+        "-" +
+        this.firstPropertyId +
+        "-" +
+        this.secondPropertyId;
       for (let quesPro of this.quesModel.quesProperties) {
-        if (quesPro.id == quesProperty.id) {
+        if (quesPro.key == quesPropertyKey) {
           this.$notify({
             message: "该属性已存在,请重新选择",
             type: "error",
@@ -2188,9 +2212,9 @@ export default {
           return false;
         }
       }
-      for (let courseProperty of this.coursePropertyList) {
-        if (courseProperty.id == this.coursePropertyId) {
-          quesProperty.courseProperty = courseProperty;
+      for (let property of this.coursePropertyList) {
+        if (property.id == this.coursePropertyId) {
+          quesProperty.courseProperty = property;
         }
       }
       //取到一级属性对象
@@ -2218,6 +2242,7 @@ export default {
           quesProperty.secondProperty = property;
         }
       }
+      quesProperty.key = this.getQuesPropertyKey(quesProperty);
       this.quesModel.quesProperties.push(quesProperty);
       this.quesModel = Object.assign({}, this.quesModel);
       //清空下拉框

+ 60 - 38
src/modules/questions/views/EditSelectQuestion.vue

@@ -127,16 +127,21 @@
           <el-col :xs="6" :sm="6" :md="6" :lg="6">
             <el-form-item label="属性名">
               <el-select
-                v-model="coursePropertyName"
+                v-model="coursePropertyId"
+                :remote-method="getCoursesProperty"
+                :loading="coursePropertyLoading"
+                remote
+                filterable
+                clearable
                 placeholder="属性名"
                 class="property_with"
                 @change="searchFirst"
               >
                 <el-option
                   v-for="item in coursePropertyList"
-                  :key="item.name"
+                  :key="item.id"
                   :label="item.name"
-                  :value="item.name"
+                  :value="item.id"
                 >
                 </el-option>
               </el-select>
@@ -254,6 +259,7 @@ export default {
   // components: { ckeditor },
   data() {
     return {
+      coursePropertyLoading: false,
       questionTypes: QUESTION_TYPES,
       fullscreenLoading: false,
       paperId: "",
@@ -292,7 +298,7 @@ export default {
         { label: "音频", value: "SINGLE_AUDIO" },
       ],
       coursePropertyList: [],
-      coursePropertyName: "", //课程属性名
+      coursePropertyId: "", //课程属性名
       firstPropertyList: [], //一级属性集合
       firstPropertyId: "", //一级属性id
       secondPropertyList: [], //二级属性集合
@@ -339,11 +345,7 @@ export default {
       this.quesModel.questionType = questionType;
     }
     if (this.courseId) {
-      this.$http
-        .get(QUESTION_API + "/courseProperty/enable?courseId=" + this.courseId)
-        .then((response) => {
-          this.coursePropertyList = response.data;
-        });
+      this.getCoursesProperty("");
     }
 
     if (isEmptyStr(this.quesModel.answerType)) {
@@ -360,11 +362,42 @@ export default {
     }, 200);
   },
   methods: {
+    getQuesPropertyKey(quesProp) {
+      if (!quesProp) {
+        return "";
+      } else if (quesProp.secondProperty.id) {
+        return (
+          quesProp.courseProperty.id +
+          "-" +
+          quesProp.firstProperty.id +
+          "-" +
+          quesProp.secondProperty.id
+        );
+      } else {
+        return quesProp.courseProperty.id + "-" + quesProp.firstProperty.id;
+      }
+    },
+    getCoursesProperty(name) {
+      this.coursePropertyLoading = true;
+      this.$httpWithMsg
+        .get(
+          QUESTION_API +
+            "/courseProperty/enable?courseId=" +
+            this.courseId +
+            "&name=" +
+            name
+        )
+        .then((response) => {
+          this.coursePropertyList = response.data;
+          this.coursePropertyLoading = false;
+        });
+    },
     findQuestionById(questionId) {
       this.$http
         .get(QUESTION_API + "/question/" + questionId)
         .then((response) => {
           this.quesModel = response.data;
+          this.courseId = this.quesModel.course.id;
           if (this.quesModel.quesOptions) {
             for (var i = 0; i < this.quesModel.quesOptions.length; i++) {
               var option = this.quesModel.quesOptions[i];
@@ -386,8 +419,6 @@ export default {
           if (isEmptyStr(this.quesModel.answerType)) {
             this.quesModel.answerType = "DIVERSIFIED_TEXT";
           }
-
-          this.initCourseProperty();
         });
     },
     submitForm(formName) {
@@ -561,29 +592,16 @@ export default {
         path: "/questions/question_list/1",
       });
     },
-    //查询所有课程属性名
-    initCourseProperty() {
-      var courseId = this.quesModel.courseId;
-      this.$http
-        .get(QUESTION_API + "/courseProperty/enable?courseId=" + courseId)
-        .then((response) => {
-          this.coursePropertyList = response.data;
-        });
-    },
     //查询一级属性
     searchFirst() {
       this.firstPropertyId = "";
       this.secondPropertyId = "";
       this.secondPropertyList = [];
-      for (let courseProperty of this.coursePropertyList) {
-        if (courseProperty.name == this.coursePropertyName) {
-          this.$http
-            .get(QUESTION_API + "/property/first/" + courseProperty.id)
-            .then((response) => {
-              this.firstPropertyList = response.data;
-            });
-        }
-      }
+      this.$http
+        .get(QUESTION_API + "/property/first/" + this.coursePropertyId)
+        .then((response) => {
+          this.firstPropertyList = response.data;
+        });
     },
     //查询二级属性
     searchSecond() {
@@ -602,8 +620,8 @@ export default {
         return false;
       }
       var quesProperty = {
-        id: "",
-        coursePropertyName: "",
+        key: "",
+        courseProperty: {},
         firstProperty: {},
         secondProperty: {},
       };
@@ -614,14 +632,14 @@ export default {
       ) {
         this.quesModel.quesProperties = [];
       }
-      quesProperty.id =
-        this.coursePropertyName +
+      let quesPropertyKey =
+        this.coursePropertyId +
         "-" +
         this.firstPropertyId +
         "-" +
         this.secondPropertyId;
       for (let quesPro of this.quesModel.quesProperties) {
-        if (quesPro.id == quesProperty.id) {
+        if (quesPro.key == quesPropertyKey) {
           this.$notify({
             message: "该属性已存在,请重新选择",
             type: "error",
@@ -629,7 +647,11 @@ export default {
           return false;
         }
       }
-      quesProperty.coursePropertyName = this.coursePropertyName;
+      for (let property of this.coursePropertyList) {
+        if (property.id == this.coursePropertyId) {
+          quesProperty.courseProperty = property;
+        }
+      }
       //取到一级属性对象
       for (let property of this.firstPropertyList) {
         if (property.id == this.firstPropertyId) {
@@ -655,11 +677,11 @@ export default {
           quesProperty.secondProperty = property;
         }
       }
+      quesProperty.key = this.getQuesPropertyKey(quesProperty);
       this.quesModel.quesProperties.push(quesProperty);
       this.quesModel = Object.assign({}, this.quesModel);
-
       //清空下拉框
-      this.coursePropertyName = "";
+      this.coursePropertyId = "";
       this.firstPropertyId = "";
       this.secondPropertyId = "";
       this.firstPropertyList = [];
@@ -675,7 +697,7 @@ export default {
     },
     //新增属性验证
     checkInsertPro() {
-      if (!this.coursePropertyName) {
+      if (!this.coursePropertyId) {
         this.$notify({
           message: "请选择属性",
           type: "error",

+ 1 - 17
src/modules/questions/views/GenPaperDetail.vue

@@ -743,7 +743,6 @@ export default {
       loading: false,
       fullscreenLoading: false,
       difficulty: "",
-      coursePropertyList: [],
       paperType: "IMPORT",
       selectedNPapers: [],
       message: "",
@@ -784,7 +783,6 @@ export default {
       })
       .finally(() => {});
     this.searchPaper();
-    this.getCoursePropertyList();
   },
   methods: {
     frozenChange(val, paperId) {
@@ -889,11 +887,7 @@ export default {
         this.paperStructs = response.data;
         for (let paperStructObj of this.paperStructs) {
           if (paperStructObj.type == "BLUEPRINT") {
-            for (let couProperty of this.coursePropertyList) {
-              if (couProperty.id == paperStructObj.coursePropertyId) {
-                this.blueStructs.push(paperStructObj);
-              }
-            }
+            this.blueStructs.push(paperStructObj);
           } else {
             this.exactStructs.push(paperStructObj);
           }
@@ -1203,16 +1197,6 @@ export default {
       this.genPaper.simpleParams = simpleParams;
       return true;
     },
-    //查询课程下开启的课程属性
-    getCoursePropertyList() {
-      var courseId = this.genPaper.courseId;
-      this.$http
-        .get(QUESTION_API + "/courseProperty/enable?courseId=" + courseId)
-        .then((response) => {
-          this.coursePropertyList = response.data;
-          this.searchPaperStructs();
-        });
-    },
     changePaperType() {
       this.curSelect = 1;
       this.tempPapers = [];

+ 30 - 55
src/modules/questions/views/InsertBluePaperStructure.vue

@@ -64,7 +64,11 @@
         <el-form-item label="课程属性">
           <el-select
             v-model="blueStruct.coursePropertyId"
+            :remote-method="getCoursesProperty"
+            :loading="coursePropertyLoading"
+            remote
             filterable
+            clearable
             :disabled="showcoursePropertyId"
             placeholder="课程属性"
             @change="getCoursePropertyName"
@@ -209,6 +213,7 @@ export default {
   name: "InsertBluePaperStructure",
   data() {
     return {
+      coursePropertyLoading: false,
       hValue: "100px",
       wValue: "800px",
       display: "block",
@@ -297,6 +302,21 @@ export default {
     }, 200);
   },
   methods: {
+    getCoursesProperty(name) {
+      this.coursePropertyLoading = true;
+      this.$httpWithMsg
+        .get(
+          QUESTION_API +
+            "/courseProperty/enable?courseId=" +
+            this.blueStruct.courseId +
+            "&name=" +
+            name
+        )
+        .then((response) => {
+          this.coursePropertyList = response.data;
+          this.coursePropertyLoading = false;
+        });
+    },
     accAdd(num1, num2) {
       let sq1, sq2, m;
       try {
@@ -323,53 +343,19 @@ export default {
         this.$http
           .get(
             QUESTION_API +
-              "/courseProperty/enable?courseId=" +
-              this.blueStruct.courseId
+              "/courseProperty/find?id=" +
+              this.blueStruct.coursePropertyId
           )
           .then((response) => {
-            this.coursePropertyList = response.data;
-            if (this.coursePropertyList && this.coursePropertyList.length > 0) {
-              for (let objCouPro of this.coursePropertyList) {
-                if (objCouPro.id == this.blueStruct.coursePropertyId) {
-                  this.blueStruct.coursePropertyName = objCouPro.name;
-                  console.log("blueStruct", blueStruct);
-                }
-              }
+            if (response.data) {
+              this.coursePropertyList.push(response.data);
+              this.blueStruct.coursePropertyName = response.data.name;
             }
           });
         this.paperDetailStructs = blueStruct.paperDetailStructs;
       }
       this.loading = false;
     },
-    getProperties() {
-      for (var course of this.courseList) {
-        if (this.blueStruct.courseId == course.courseId) {
-          var courseId = course.id;
-          this.$http
-            .get(QUESTION_API + "/courseProperty/all/" + courseId)
-            .then((response) => {
-              this.coursePropertyList = response.data;
-              console.log("this.coursePropertyList:", this.coursePropertyList);
-            });
-        }
-      }
-    },
-    //查询课程下的课程属性
-    getCoursePropertyList() {
-      this.$http
-        .get(
-          QUESTION_API +
-            "/courseProperty/enable?courseId=" +
-            this.blueStruct.courseId
-        )
-        .then((response) => {
-          this.coursePropertyList = response.data;
-          console.log("this.coursePropertyList:", this.coursePropertyList);
-          if (this.coursePropertyList && this.coursePropertyList.length == 0) {
-            this.blueStruct.coursePropertyId = "";
-          }
-        });
-    },
     checkPaperStruct() {
       if (!this.blueStruct.name) {
         this.$notify({
@@ -444,7 +430,7 @@ export default {
       var url = QUESTION_API + "/paperStruct";
       if (this.paperStructId != "add") {
         //假如没ID就是新增
-        this.$http
+        this.$httpWithMsg
           .put(url, this.blueStruct)
           .then(() => {
             this.$notify({
@@ -455,15 +441,11 @@ export default {
             this.removeItem();
             this.back();
           })
-          .catch(() => {
-            this.$notify({
-              type: "error",
-              message: "试卷结构名称重复,请重新命名",
-            });
+          .finally(() => {
             this.loading = false;
           });
       } else {
-        this.$http
+        this.$httpWithMsg
           .post(url, this.blueStruct)
           .then(() => {
             this.$notify({
@@ -474,12 +456,8 @@ export default {
             this.removeItem();
             this.back();
           })
-          .catch(() => {
+          .finally(() => {
             this.loading = false;
-            this.$notify({
-              type: "error",
-              message: "试卷结构名称重复,请重新命名",
-            });
           });
       }
     },
@@ -632,15 +610,12 @@ export default {
         .then((response) => {
           this.courseList = response.data;
           this.courseLoading = false;
-          if (this.blueStruct.courseId) {
-            this.getCoursePropertyList();
-          }
         });
     },
     clearCourseProperty() {
       this.blueStruct.coursePropertyId = "";
       this.coursePropertyList = [];
-      this.getCoursePropertyList();
+      this.getCoursesProperty("");
     },
     resetForm(formData) {
       this.paperDetailStructForm.name = "";

+ 22 - 5
src/modules/questions/views/PaperBlue.vue

@@ -4,6 +4,11 @@
       <el-form-item label="可选属性">
         <el-select
           v-model="coursePropertyId"
+          :remote-method="getCoursesProperty"
+          :loading="coursePropertyLoading"
+          remote
+          filterable
+          clearable
           placeholder="属性名"
           @change="onSelChange"
         >
@@ -70,6 +75,7 @@ export default {
   },
   data() {
     return {
+      coursePropertyLoading: false,
       coursePropertyList: [],
       paperData: {},
       coursePropertyId: null,
@@ -96,6 +102,21 @@ export default {
     this.init();
   },
   methods: {
+    getCoursesProperty(name) {
+      this.coursePropertyLoading = true;
+      this.$httpWithMsg
+        .get(
+          QUESTION_API +
+            "/courseProperty/enable?courseId=" +
+            this.courseId +
+            "&name=" +
+            name
+        )
+        .then((response) => {
+          this.coursePropertyList = response.data;
+          this.coursePropertyLoading = false;
+        });
+    },
     onSelChange() {
       this.$http
         .get(
@@ -130,11 +151,7 @@ export default {
     },
 
     init() {
-      this.$http
-        .get(QUESTION_API + "/courseProperty/enable?courseId=" + this.courseId)
-        .then((response) => {
-          this.coursePropertyList = response.data;
-        });
+      this.getCoursesProperty("");
     },
   },
 };

+ 80 - 88
src/modules/questions/views/Question.vue

@@ -12,7 +12,7 @@
             remote
             clearable
             placeholder="请选择"
-            @change="initCourseProperty"
+            @change="getCoursesProperty('')"
             @clear="getCourses('')"
           >
             <el-option
@@ -58,18 +58,21 @@
         </el-form-item>
         <el-form-item label="属性名">
           <el-select
-            v-model="formSearch.coursePropertyName"
+            v-model="formSearch.coursePropertyId"
+            :remote-method="getCoursesProperty"
+            :loading="coursePropertyLoading"
+            remote
             filterable
-            clearable
+            clearablee
             :disabled="updatePorperty"
             placeholder="请选择"
             @change="searchFirst"
           >
             <el-option
               v-for="item in coursePropertyList"
-              :key="item.name"
+              :key="item.id"
               :label="item.name"
-              :value="item.name"
+              :value="item.id"
             ></el-option>
           </el-select>
         </el-form-item>
@@ -223,14 +226,15 @@ export default {
   components: { QuestionPreview },
   data() {
     return {
+      coursePropertyLoading: false,
       formSearch: {
         questionType: "",
         courseId: null,
         courseLevel: "",
         publicity: "",
-        coursePropertyId: "",
-        firstPropertyId: "",
-        secondPropertyId: "",
+        coursePropertyId: null,
+        firstPropertyId: null,
+        secondPropertyId: null,
       },
       courseList: [], //课程list
       levelList: LEVEL_TYPE, //层次list
@@ -278,7 +282,7 @@ export default {
       }
     },
     updateFirst() {
-      if (this.formSearch.coursePropertyName) {
+      if (this.formSearch.coursePropertyId) {
         return false;
       }
       return true;
@@ -316,6 +320,24 @@ export default {
     this.initVue();
   },
   methods: {
+    getCoursesProperty(name) {
+      this.coursePropertyLoading = true;
+      this.formSearch.coursePropertyId = "";
+      this.formSearch.firstPropertyId = "";
+      this.formSearch.secondPropertyId = "";
+      this.$httpWithMsg
+        .get(
+          QUESTION_API +
+            "/courseProperty/enable?courseId=" +
+            this.formSearch.courseId +
+            "&name=" +
+            name
+        )
+        .then((response) => {
+          this.coursePropertyList = response.data;
+          this.coursePropertyLoading = false;
+        });
+    },
     isMatchingQuestion(questionType) {
       if (
         questionType == "PARAGRAPH_MATCHING" ||
@@ -391,16 +413,8 @@ export default {
       this.currentPage = 1;
       this.searchQues();
     },
-    getCourseName(courseId) {
-      for (let course of this.courseList) {
-        if (course.courseId == courseId) {
-          this.formSearch.courseName = course.name;
-        }
-      }
-    },
     //修改
     updateRow(row) {
-      this.getCourseName(this.formSearch.courseId);
       //选择题:单选、多选
       if (
         row.questionType === "SINGLE_ANSWER_QUESTION" ||
@@ -464,27 +478,34 @@ export default {
       this.disposeSelectAnswer();
       this.$refs.QuestionPreview.open();
     },
+    getCourseById(cid) {
+      this.$http.get(QUESTION_API + "/course/" + cid).then((response) => {
+        this.courseList.push(response.data);
+        if (this.formSearch.coursePropertyId) {
+          this.$http
+            .get(
+              QUESTION_API +
+                "/courseProperty/find?id=" +
+                this.formSearch.coursePropertyId
+            )
+            .then((response) => {
+              if (response.data) {
+                this.coursePropertyList.push(response.data);
+                this.getFirst();
+              }
+            });
+        }
+      });
+    },
     //查询所有课程
     getCourses(query) {
       this.$http
         .get(QUESTION_API + "/course/query?name=" + query + "&enable=true")
         .then((response) => {
           this.courseList = response.data;
-          if (this.formSearch.courseId) {
-            this.$http
-              .get(
-                QUESTION_API +
-                  "/courseProperty/enable?courseId=" +
-                  this.formSearch.courseId
-              )
-              .then((response) => {
-                this.coursePropertyList = response.data;
-                //查询一级属性
-                this.getFirst();
-              });
-          } else {
-            this.coursePropertyList = [];
-          }
+          this.coursePropertyList = [];
+          this.firstPropertyList = [];
+          this.secondPropertyList = [];
         });
     },
     //重置查询表单
@@ -539,39 +560,18 @@ export default {
         }
       }
     },
-    //查询所有课程属性名
-    initCourseProperty() {
-      this.formSearch.coursePropertyName = "";
-      this.formSearch.firstPropertyId = "";
-      this.formSearch.secondPropertyId = "";
-      if (this.formSearch.courseId) {
+    //查询一级属性
+    searchFirst() {
+      if (this.formSearch.coursePropertyId) {
+        this.formSearch.firstPropertyId = "";
+        this.formSearch.secondPropertyId = "";
         this.$http
           .get(
-            QUESTION_API +
-              "/courseProperty/enable?courseId=" +
-              this.formSearch.courseId
+            QUESTION_API + "/property/first/" + this.formSearch.coursePropertyId
           )
           .then((response) => {
-            this.coursePropertyList = response.data;
+            this.firstPropertyList = response.data;
           });
-      } else {
-        this.coursePropertyList = [];
-      }
-    },
-    //查询一级属性
-    searchFirst() {
-      if (this.formSearch.coursePropertyName) {
-        this.formSearch.firstPropertyId = "";
-        this.formSearch.secondPropertyId = "";
-        for (let courseProperty of this.coursePropertyList) {
-          if (courseProperty.name == this.formSearch.coursePropertyName) {
-            this.$http
-              .get(QUESTION_API + "/property/first/" + courseProperty.id)
-              .then((response) => {
-                this.firstPropertyList = response.data;
-              });
-          }
-        }
       }
     },
     //查询二级属性
@@ -588,28 +588,30 @@ export default {
       }
     },
     getFirst() {
-      if (this.formSearch.coursePropertyName) {
-        for (let courseProperty of this.coursePropertyList) {
-          if (courseProperty.name == this.formSearch.coursePropertyName) {
-            this.$http
-              .get(QUESTION_API + "/property/first/" + courseProperty.id)
-              .then((response) => {
-                this.firstPropertyList = response.data;
-                //查询二级
-                this.getSecond();
-              });
-          }
-        }
+      if (this.formSearch.firstPropertyId) {
+        this.$http
+          .get(
+            QUESTION_API +
+              "/property/find?id=" +
+              this.formSearch.firstPropertyId
+          )
+          .then((response) => {
+            this.firstPropertyList.push(response.data);
+            //查询二级
+            this.getSecond();
+          });
       }
     },
     getSecond() {
-      if (this.formSearch.firstPropertyId) {
+      if (this.formSearch.secondPropertyId) {
         this.$http
           .get(
-            QUESTION_API + "/property/second/" + this.formSearch.firstPropertyId
+            QUESTION_API +
+              "/property/find?id=" +
+              this.formSearch.secondPropertyId
           )
           .then((response) => {
-            this.secondPropertyList = response.data;
+            this.secondPropertyList.push(response.data);
           });
       }
     },
@@ -633,19 +635,9 @@ export default {
         this.currentPage = parseInt(
           sessionStorage.getItem("question_currentPage")
         );
-      }
-      if (this.formSearch && this.formSearch.courseName) {
-        this.getCourses(this.formSearch.courseName);
-      } else {
-        this.formSearch = {
-          questionType: "",
-          courseId: "",
-          courseLevel: "",
-          publicity: "",
-          coursePropertyId: "",
-          firstPropertyId: "",
-          secondPropertyId: "",
-        };
+        if (this.formSearch && this.formSearch.courseId) {
+          this.getCourseById(this.formSearch.courseId);
+        }
       }
       this.searchQues();
     },

+ 1 - 0
src/modules/questions/views/School.vue

@@ -446,6 +446,7 @@ export default {
           type: "success",
           message: "操作成功",
         });
+        this.searchForm();
       });
     },
     //提交

+ 0 - 17
src/modules/questions/views/ViewPaper.vue

@@ -620,8 +620,6 @@ export default {
         .get(QUESTION_API + "/paper/" + this.paperId)
         .then((response) => {
           this.paper = response.data;
-          //查询所有课程属性名
-          this.initCourseProperty(this.paper.course.id);
           //将所有小题分为公开和非公开
           if (this.paper.paperDetails && this.paper.paperDetails.length > 0) {
             for (let paperDetil of this.paper.paperDetails) {
@@ -663,14 +661,6 @@ export default {
           this.loading = false;
         });
     },
-    //查询所有课程属性名
-    initCourseProperty(courseId) {
-      this.$http
-        .get(QUESTION_API + "/courseProperty/enable?courseId=" + courseId)
-        .then((response) => {
-          this.coursePropertyList = response.data;
-        });
-    },
     quesShow(id) {
       if (this.reduplicateGroup.length < 1) {
         return true;
@@ -717,13 +707,6 @@ export default {
         this.quesModel.answerType = "DIVERSIFIED_TEXT";
       }
 
-      if (this.quesModel.questionType == "FILL_BLANK_QUESTION") {
-        this.quesModel.quesBody = this.quesModel.quesBody.replace(
-          /______/g,
-          "###"
-        );
-      }
-
       this.assignAnswers(); //给singleRightAnswer或multipleRightAnswer赋值
       this.openQuesDialog();
     },