deason 4 年之前
父節點
當前提交
a879f08ea9
共有 1 個文件被更改,包括 107 次插入110 次删除
  1. 107 110
      src/modules/questions/views/EditPaper.vue

+ 107 - 110
src/modules/questions/views/EditPaper.vue

@@ -627,9 +627,9 @@
             <div
               v-if="
                 quesModel.questionType != 'NESTED_ANSWER_QUESTION' &&
-                quesModel.questionType != 'SINGLE_ANSWER_QUESTION' &&
-                quesModel.questionType != 'MULTIPLE_ANSWER_QUESTION' &&
-                quesModel.questionType != 'BOOL_ANSWER_QUESTION'
+                  quesModel.questionType != 'SINGLE_ANSWER_QUESTION' &&
+                  quesModel.questionType != 'MULTIPLE_ANSWER_QUESTION' &&
+                  quesModel.questionType != 'BOOL_ANSWER_QUESTION'
               "
             >
               <el-form-item label="答案">
@@ -640,7 +640,7 @@
             <div
               v-if="
                 quesModel.questionType == 'SINGLE_ANSWER_QUESTION' ||
-                quesModel.questionType == 'MULTIPLE_ANSWER_QUESTION'
+                  quesModel.questionType == 'MULTIPLE_ANSWER_QUESTION'
               "
             >
               <el-form-item label="答案">
@@ -678,7 +678,7 @@
                 paper.paperType == 'IMPORT' &&
                 (quesModel.questionType == 'SINGLE_ANSWER_QUESTION' ||
                   quesModel.questionType == 'MULTIPLE_ANSWER_QUESTION')
-              ),
+              )
             }"
           >
             <el-button
@@ -686,8 +686,8 @@
               @click="addQuesOption"
               v-if="
                 paper.paperType == 'IMPORT' &&
-                (quesModel.questionType == 'SINGLE_ANSWER_QUESTION' ||
-                  quesModel.questionType == 'MULTIPLE_ANSWER_QUESTION')
+                  (quesModel.questionType == 'SINGLE_ANSWER_QUESTION' ||
+                    quesModel.questionType == 'MULTIPLE_ANSWER_QUESTION')
               "
               ><i class="el-icon-plus"></i> 新增选项
             </el-button>
@@ -812,7 +812,7 @@ export default {
   name: "editPaperApp",
   components: {
     reduplicate_mark,
-    ckeditor,
+    ckeditor
   },
   data() {
     return {
@@ -832,9 +832,9 @@ export default {
       paper: {
         course: {
           code: "",
-          name: "",
+          name: ""
         },
-        examRemark: "",
+        examRemark: ""
       },
       loading: false,
       dialogLoading: false,
@@ -881,7 +881,7 @@ export default {
         "SlateBlue",
         "SlateGray",
         "Tomato",
-        "VioletRed",
+        "VioletRed"
       ],
       difficultyDegreeList: [
         { label: 0.1, value: 0.1 },
@@ -893,15 +893,15 @@ export default {
         { label: 0.7, value: 0.7 },
         { label: 0.8, value: 0.8 },
         { label: 0.9, value: 0.9 },
-        { label: 1.0, value: 1.0 },
+        { label: 1.0, value: 1.0 }
       ],
       publicityList: [
         { label: "公开", value: true },
-        { label: "非公开", value: false },
+        { label: "非公开", value: false }
       ],
       answerTypes: [
         { label: "文本", value: "DIVERSIFIED_TEXT" },
-        { label: "音频", value: "SINGLE_AUDIO" },
+        { label: "音频", value: "SINGLE_AUDIO" }
       ],
       coursePropertyList: [],
       coursePropertyName: "", //课程属性名
@@ -911,7 +911,7 @@ export default {
       secondPropertyId: "", //二级属性id
       examRemark: "",
       showQuestions: [],
-      showButtons: [],
+      showButtons: []
     };
   },
   methods: {
@@ -950,7 +950,7 @@ export default {
         param.append("dataFile", file, file.name);
       }
       let config = {
-        headers: { "Content-Type": "multipart/form-data" },
+        headers: { "Content-Type": "multipart/form-data" }
       };
       this.uploadAnswerLoading = true;
       this.$http
@@ -967,7 +967,7 @@ export default {
           document.getElementById("answerFile").value = "";
           this.initPaper();
         })
-        .catch((error) => {
+        .catch(error => {
           this.answerMessage = error.response.data.desc;
           document.getElementById("answerFile").value = "";
           this.uploadAnswerLoading = false;
@@ -1006,7 +1006,7 @@ export default {
           "/" +
           this.paperDetailId +
           "/" +
-          this.parentView,
+          this.parentView
       });
     },
     //打开编辑大题题目弹窗
@@ -1028,7 +1028,7 @@ export default {
         .then(() => {
           this.$notify({
             message: "保存成功",
-            type: "success",
+            type: "success"
           });
           this.detailLoading = false;
           this.closePaperDatailDialog();
@@ -1043,63 +1043,60 @@ export default {
       this.paper = {
         course: {
           code: "",
-          name: "",
-        },
+          name: ""
+        }
       };
-      this.$http
-        .get(QUESTION_API + "/paper/" + this.paperId)
-        .then((response) => {
-          this.paper = response.data;
-          //查询所有课程属性名
-          this.initCourseProperty(this.paper.course.code);
-          //将所有小题分为公开和非公开
-          if (this.paper.paperDetails && this.paper.paperDetails.length > 0) {
-            for (let paperDetil of this.paper.paperDetails) {
-              this.showQuestions.push({ is_show: true });
-              this.showButtons.push({ up: true });
-              paperDetil.pubCount = 0;
-              paperDetil.noPubCount = 0;
-              if (
-                paperDetil.paperDetailUnits &&
-                paperDetil.paperDetailUnits.length > 0
-              ) {
-                for (let paperDetilUt of paperDetil.paperDetailUnits) {
-                  if (
-                    paperDetilUt.question.questionType !=
-                    "NESTED_ANSWER_QUESTION"
-                  ) {
-                    //非套题
-                    if (paperDetilUt.question.publicity) {
+      this.$http.get(QUESTION_API + "/paper/" + this.paperId).then(response => {
+        this.paper = response.data;
+        //查询所有课程属性名
+        this.initCourseProperty(this.paper.course.code);
+        //将所有小题分为公开和非公开
+        if (this.paper.paperDetails && this.paper.paperDetails.length > 0) {
+          for (let paperDetil of this.paper.paperDetails) {
+            this.showQuestions.push({ is_show: true });
+            this.showButtons.push({ up: true });
+            paperDetil.pubCount = 0;
+            paperDetil.noPubCount = 0;
+            if (
+              paperDetil.paperDetailUnits &&
+              paperDetil.paperDetailUnits.length > 0
+            ) {
+              for (let paperDetilUt of paperDetil.paperDetailUnits) {
+                if (
+                  paperDetilUt.question.questionType != "NESTED_ANSWER_QUESTION"
+                ) {
+                  //非套题
+                  if (paperDetilUt.question.publicity) {
+                    paperDetil.pubCount = paperDetil.pubCount + 1;
+                  } else {
+                    paperDetil.noPubCount = paperDetil.noPubCount + 1;
+                  }
+                } else {
+                  //循环所有子题
+                  for (let ques of paperDetilUt.question.subQuestions) {
+                    if (ques.publicity) {
                       paperDetil.pubCount = paperDetil.pubCount + 1;
                     } else {
                       paperDetil.noPubCount = paperDetil.noPubCount + 1;
                     }
-                  } else {
-                    //循环所有子题
-                    for (let ques of paperDetilUt.question.subQuestions) {
-                      if (ques.publicity) {
-                        paperDetil.pubCount = paperDetil.pubCount + 1;
-                      } else {
-                        paperDetil.noPubCount = paperDetil.noPubCount + 1;
-                      }
-                    }
                   }
                 }
               }
             }
           }
-          setTimeout(() => {
-            document.documentElement.scrollTop = document.body.scrollTop = scrollPosition;
-            console.log(scrollPosition);
-          }, 1000);
-          this.loading = false;
-        });
+        }
+        setTimeout(() => {
+          document.documentElement.scrollTop = document.body.scrollTop = scrollPosition;
+          console.log(scrollPosition);
+        }, 1000);
+        this.loading = false;
+      });
     },
     //查询所有课程属性名
     initCourseProperty(courseCode) {
       this.$http
         .get(QUESTION_API + "/courseProperty/enable/" + courseCode)
-        .then((response) => {
+        .then(response => {
           this.coursePropertyList = response.data;
         });
     },
@@ -1118,7 +1115,7 @@ export default {
       if (count == 0) {
         this.$alert("您确定删除吗?", "提示", {
           confirmButtonText: "确定",
-          callback: (action) => {
+          callback: action => {
             if (action == "confirm") {
               this.loading = true;
               this.$http
@@ -1128,17 +1125,17 @@ export default {
                   this.loading = true;
                   this.$notify({
                     message: "删除成功",
-                    type: "success",
+                    type: "success"
                   });
                   this.loading = false;
                 });
             }
-          },
+          }
         });
       } else {
         this.$alert("大题下还有小题,不可删除!", "提示", {
           confirmButtonText: "确定",
-          callback: () => {},
+          callback: () => {}
         });
       }
     },
@@ -1311,7 +1308,7 @@ export default {
           if (courseProperty.name == this.coursePropertyName) {
             this.$http
               .get(QUESTION_API + "/property/first/" + courseProperty.id)
-              .then((response) => {
+              .then(response => {
                 this.firstPropertyList = response.data;
               });
           }
@@ -1324,7 +1321,7 @@ export default {
       if (this.firstPropertyId) {
         this.$http
           .get(QUESTION_API + "/property/second/" + this.firstPropertyId)
-          .then((response) => {
+          .then(response => {
             this.secondPropertyList = response.data;
           });
       }
@@ -1338,7 +1335,7 @@ export default {
         id: "",
         coursePropertyName: "",
         firstProperty: {},
-        secondProperty: {},
+        secondProperty: {}
       };
       if (
         this.quesModel.quesProperties == null ||
@@ -1360,7 +1357,7 @@ export default {
         if (quesPro.id == quesProperty.id) {
           this.$notify({
             message: "该属性已存在,请重新选择",
-            type: "error",
+            type: "error"
           });
           return false;
         }
@@ -1380,7 +1377,7 @@ export default {
         if (!this.secondPropertyId) {
           this.$notify({
             message: "请选择二级属性",
-            type: "error",
+            type: "error"
           });
           return false;
         }
@@ -1405,14 +1402,14 @@ export default {
       if (!this.coursePropertyName) {
         this.$notify({
           message: "请选择属性",
-          type: "error",
+          type: "error"
         });
         return false;
       }
       if (!this.firstPropertyId) {
         this.$notify({
           message: "请选择一级属性",
-          type: "error",
+          type: "error"
         });
         return false;
       }
@@ -1447,7 +1444,7 @@ export default {
       this.quesModel.quesOptions.push({
         number: "",
         optionBody: "",
-        isCorrect: "",
+        isCorrect: ""
       });
       for (var i = 0; i < this.quesModel.quesOptions.length; i++) {
         this.quesModel.quesOptions[i]["number"] = i + 1;
@@ -1471,14 +1468,14 @@ export default {
       } else {
         this.$notify({
           message: "分数只能为正数",
-          type: "error",
+          type: "error"
         });
         return;
       }
       let paperDetailUnitExp = {
         id: this.editPaperDetailUnit.id,
         question: this.quesModel,
-        score: this.quesModel.score,
+        score: this.quesModel.score
       };
       if (
         this.quesModel.quesOptions &&
@@ -1487,12 +1484,12 @@ export default {
         this.$confirm("无选项将删除该试题, 是否继续?", "提示", {
           confirmButtonText: "确定",
           cancelButtonText: "取消",
-          type: "warning",
+          type: "warning"
         }).then(() => {
           this.dialogLoading = true;
           this.$http
             .delete(QUESTION_API + "/paper/deleteQuestion/" + this.quesModel.id)
-            .then((response) => {
+            .then(response => {
               if (response.data.length > 0) {
                 var deleteInfo =
                   "该试题被试卷:" +
@@ -1500,12 +1497,12 @@ export default {
                   "使用,不能删除";
                 this.$notify({
                   message: deleteInfo,
-                  type: "error",
+                  type: "error"
                 });
               } else {
                 this.$notify({
                   message: "保存成功",
-                  type: "success",
+                  type: "success"
                 });
               }
               this.dialogLoading = false;
@@ -1518,17 +1515,17 @@ export default {
           .then(() => {
             this.$notify({
               message: "保存成功",
-              type: "success",
+              type: "success"
             });
             this.dialogLoading = false;
             this.closeQuesDialog();
             this.initPaper();
           })
-          .catch((err) => {
+          .catch(err => {
             this.dialogLoading = false;
             this.$notify({
               type: "error",
-              message: err.response.data.desc,
+              message: err.response.data.desc
             });
           });
       }
@@ -1567,7 +1564,7 @@ export default {
     deleteQues01(paperDetailUnitId) {
       this.$alert("您确定删除吗?", "提示", {
         confirmButtonText: "确定",
-        callback: (action) => {
+        callback: action => {
           if (action == "confirm") {
             this.loading = true;
             this.$http
@@ -1579,23 +1576,23 @@ export default {
                 this.loading = true;
                 this.$notify({
                   message: "删除成功",
-                  type: "success",
+                  type: "success"
                 });
                 this.loading = false;
               });
           }
-        },
+        }
       });
     },
     deleteQues02(questionId) {
       this.$alert("您确定删除吗?", "提示", {
         confirmButtonText: "确定",
-        callback: (action) => {
+        callback: action => {
           if (action == "confirm") {
             this.loading = true;
             this.$http
               .delete(QUESTION_API + "/paper/deleteQuestion/" + questionId)
-              .then((response) => {
+              .then(response => {
                 if (response.data.length > 0) {
                   var deleteInfo =
                     "该试题被试卷:" +
@@ -1603,7 +1600,7 @@ export default {
                     "使用,不能删除";
                   this.$notify({
                     message: deleteInfo,
-                    type: "error",
+                    type: "error"
                   });
                 } else {
                   this.initPaper();
@@ -1612,13 +1609,13 @@ export default {
                   this.loading = true;
                   this.$notify({
                     message: "保存成功",
-                    type: "success",
+                    type: "success"
                   });
                 }
                 this.loading = false;
               });
           }
-        },
+        }
       });
     },
     //获取重复试题
@@ -1626,7 +1623,7 @@ export default {
       this.duplicateLoading = true;
       this.$http
         .get(QUESTION_API + "/paper/" + this.paperId + "/reduplicate-questions")
-        .then((response) => {
+        .then(response => {
           this.reduplicateQuestions = response.data;
           this.duplicateLoading = false;
           this.initReduplicateQuesColor();
@@ -1652,7 +1649,7 @@ export default {
       if (colorCount > 20) {
         this.reduplicateQuesColor = randomColor({
           luminosity: "bright",
-          count: colorCount,
+          count: colorCount
         });
       } else {
         this.reduplicateQuesColor = this.defaultColor;
@@ -1689,38 +1686,38 @@ export default {
         .then(() => {
           this.$notify({
             message: "保存成功",
-            type: "success",
+            type: "success"
           });
           this.loading = false;
           this.initPaper();
         })
-        .catch((error) => {
+        .catch(error => {
           this.loading = false;
           this.$notify({
             type: "error",
-            message: error.response.data.desc,
+            message: error.response.data.desc
           });
         });
     },
     //删除试卷
     deletePaper(id) {
       this.$confirm("确认删除试卷吗?", "提示", {
-        type: "warning",
+        type: "warning"
       }).then(() => {
         this.loading = true;
         this.$http.delete(QUESTION_API + "/paper/" + id).then(
           () => {
             this.$notify({
               message: "删除成功",
-              type: "success",
+              type: "success"
             });
             this.back();
           },
-          (error) => {
+          error => {
             this.$notify({
               message: error.response.data.desc,
               type: "error",
-              title: "错误",
+              title: "错误"
             });
             this.loading = false;
           }
@@ -1745,11 +1742,11 @@ export default {
     back() {
       if (sessionStorage.getItem("question_back") == "true") {
         this.$router.push({
-          path: "/questions/" + this.parentView + "/0",
+          path: "/questions/" + this.parentView + "/0"
         });
       } else {
         this.$router.push({
-          path: "/questions/" + this.parentView + "/1",
+          path: "/questions/" + this.parentView + "/1"
         });
       }
     },
@@ -1802,7 +1799,7 @@ export default {
           QUESTION_API + "/checkRadioFile/" + this.paperId,
           this.fileNameList
         )
-        .then((response) => {
+        .then(response => {
           console.log("response:", response);
           this.message = response.data.errorMsg;
           if (this.message == "OK") {
@@ -1812,7 +1809,7 @@ export default {
             this.isUpload = true;
           }
         })
-        .catch((error) => {
+        .catch(error => {
           console.log(error);
         });
     },
@@ -1826,7 +1823,7 @@ export default {
         param.append("files", file, file.name);
       }
       let config = {
-        headers: { "Content-Type": "multipart/form-data" },
+        headers: { "Content-Type": "multipart/form-data" }
       };
       this.$http
         .post(QUESTION_API + "/uploadRadio/" + this.paperId, param, config)
@@ -1838,15 +1835,15 @@ export default {
           document.getElementById("radioFile").value = "";
           this.initPaper();
         })
-        .catch((error) => {
+        .catch(error => {
           this.message = error.response.data.desc;
           this.uploadAudioLoading = false;
         });
-    },
+    }
   },
   computed: {
     ...mapState({
-      user: (state) => state.user,
+      user: state => state.user
     }),
     updatePorperty() {
       if (this.parentView === "gen_paper") {
@@ -1862,7 +1859,7 @@ export default {
         return obj.sort().toString();
       }
       return this.quesModel.quesAnswer;
-    },
+    }
   },
   watch: {},
   created() {
@@ -1875,10 +1872,10 @@ export default {
     this.uploadAction = QUESTION_API + "/uploadRadio/" + this.paperId;
     this.uploadHeaders = {
       key: this.user.key,
-      token: this.user.token,
+      token: this.user.token
     };
   },
-  mounted() {},
+  mounted() {}
 };
 </script>
 <style scoped src="../styles/EditPaper.css">