zhangjie 2 jaren geleden
bovenliggende
commit
f1cab4964e

+ 8 - 3
src/components/vEditor/components/VMenu.vue

@@ -53,7 +53,7 @@
         class="intLink"
         title="插入图片"
         src="../../img/menu_image.png"
-        @mousedown="$refs.ImageInput.click()"
+        @mousedown="insertImage"
       />
       <input
         ref="ImageInput"
@@ -141,15 +141,20 @@ export default {
     /**
      * @param {Event} event
      */
-    async addImage(event) {
+    insertImage(event) {
+      event.preventDefault();
       if (!this.checkEditorFocus()) {
         window.getSelection().removeAllRanges();
         this.$el.nextSibling.focus();
       } else {
         // console.log(event, event.target.files[0]);
-        imageHandle.bind(this.$parent)(event);
+        this.$refs.ImageInput.click();
       }
     },
+    async addImage(event) {
+      // console.log(event, event.target.files[0]);
+      imageHandle.bind(this.$parent)(event);
+    },
     /**
      * @param {Event} event
      */

+ 23 - 13
src/modules/questions/views/EditPaper.vue

@@ -2224,7 +2224,7 @@ export default {
     },
     //新增选项
     addQuesOption() {
-      if (this.quesModel.quesOptions.length == 20) {
+      if (this.quesModel.quesOptions.length >= 20) {
         this.$notify({
           message: "选项最多20个",
           type: "error",
@@ -2272,18 +2272,28 @@ export default {
           return;
         }
       }
-      if (
-        this.quesModel.quesOptions &&
-        this.quesModel.quesOptions.length &&
-        this.quesModel.quesOptions.some((item) =>
-          checkRichTextContentIsEmpty(item.optionBody)
-        )
-      ) {
-        this.$notify({
-          message: "有选项内容为空",
-          type: "error",
-        });
-        return;
+
+      if (this.quesModel.quesOptions) {
+        if (this.quesModel.quesOptions.length >= 20) {
+          this.$notify({
+            message: "选项最多20个",
+            type: "error",
+          });
+          return;
+        }
+
+        if (
+          this.quesModel.quesOptions.length &&
+          this.quesModel.quesOptions.some((item) =>
+            checkRichTextContentIsEmpty(item.optionBody)
+          )
+        ) {
+          this.$notify({
+            message: "有选项内容为空",
+            type: "error",
+          });
+          return;
+        }
       }
 
       if (this.paper.paperType == "GENERATE") {

+ 21 - 12
src/modules/questions/views/EditPaperPendingTrial.vue

@@ -2353,18 +2353,27 @@ export default {
           return;
         }
       }
-      if (
-        this.quesModel.quesOptions &&
-        this.quesModel.quesOptions.length &&
-        this.quesModel.quesOptions.some((item) =>
-          checkRichTextContentIsEmpty(item.optionBody)
-        )
-      ) {
-        this.$notify({
-          message: "有选项内容为空",
-          type: "error",
-        });
-        return;
+      if (this.quesModel.quesOptions) {
+        if (this.quesModel.quesOptions.length >= 20) {
+          this.$notify({
+            message: "选项最多20个",
+            type: "error",
+          });
+          return;
+        }
+
+        if (
+          this.quesModel.quesOptions.length &&
+          this.quesModel.quesOptions.some((item) =>
+            checkRichTextContentIsEmpty(item.optionBody)
+          )
+        ) {
+          this.$notify({
+            message: "有选项内容为空",
+            type: "error",
+          });
+          return;
+        }
       }
 
       if (this.paper.paperType == "GENERATE") {

+ 12 - 4
src/modules/questions/views/EditSelectQuestion.vue

@@ -425,13 +425,12 @@ export default {
     submitForm(formName) {
       this.$refs[formName].validate((valid) => {
         if (valid) {
-          this.setRightAnswer();
-          if (!this.hasAnswer()) {
+          if (this.quesModel.quesOptions.length >= 20) {
             this.$notify({
-              message: "请选择答案",
+              message: "选项最多20个",
               type: "error",
             });
-            return false;
+            return;
           }
 
           if (
@@ -447,6 +446,15 @@ export default {
             return;
           }
 
+          this.setRightAnswer();
+          if (!this.hasAnswer()) {
+            this.$notify({
+              message: "请选择答案",
+              type: "error",
+            });
+            return false;
+          }
+
           if (this.questionId) {
             this.editQuestion();
           } else {