Ver Fonte

bug fix

zhangjie há 2 anos atrás
pai
commit
c0583fc057

+ 1 - 1
src/components/vEditor/VEditor.vue

@@ -4,7 +4,7 @@
     <div
       :id="'ved' + _uid"
       ref="editor"
-      class="v-editor-body"
+      :class="['v-editor-body', `v-editor-body-${_uid}`]"
       :data-placeholder="placeholder"
       contenteditable
       :style="styles"

+ 17 - 9
src/components/vEditor/components/VMenu.vue

@@ -123,7 +123,12 @@ export default {
     },
     execCommand(command, event) {
       event.preventDefault();
-      document.execCommand(command);
+      if (!this.checkEditorFocus()) {
+        window.getSelection().removeAllRanges();
+        this.$el.nextSibling.focus();
+      } else {
+        document.execCommand(command);
+      }
     },
     /**
      * @param {Event} event
@@ -147,27 +152,30 @@ export default {
       event.preventDefault();
       answerPointHandle.bind(this.$parent)(event);
     },
+    checkEditorFocus() {
+      const selection = window.getSelection();
+      return selection.focusNode && this.checkDomInEditor(selection.focusNode);
+    },
     /**
      * @param {Event} event
      */
     addFormula(event) {
       event.preventDefault();
-      const selection = window.getSelection();
-      if (selection.focusNode && this.checkDomInEditor(selection.focusNode)) {
-        this.curEditFocusRange = selection.getRangeAt(0);
-      } else {
+      if (!this.checkEditorFocus()) {
+        window.getSelection().removeAllRanges();
         this.$el.nextSibling.focus();
-        const selection = window.getSelection();
-        this.curEditFocusRange = selection.getRangeAt(0);
       }
+      this.curEditFocusRange = window.getSelection().getRangeAt(0);
       this.$refs.FormulaDialog.open();
     },
     checkDomInEditor(dom) {
+      const editorUid = this.$parent["_uid"];
+      const siblingBodyCls = `v-editor-body-${editorUid}`;
       let parentNode = dom;
       while (
         !(
           (parentNode.className &&
-            parentNode.className.includes("v-editor-body")) ||
+            parentNode.className.includes(siblingBodyCls)) ||
           parentNode.nodeName === "BODY"
         )
       ) {
@@ -175,7 +183,7 @@ export default {
       }
 
       return (
-        parentNode.className && parentNode.className.includes("v-editor-body")
+        parentNode.className && parentNode.className.includes(siblingBodyCls)
       );
     },
     formulaConfirm(result) {

+ 7 - 0
src/modules/questions/views/EditPaperPendingTrial.vue

@@ -2305,6 +2305,13 @@ export default {
     },
     //新增选项
     addQuesOption() {
+      if (this.quesModel.quesOptions.length >= 20) {
+        this.$notify({
+          message: "选项最多20个",
+          type: "error",
+        });
+        return;
+      }
       this.quesModel.quesOptions.push({
         number: "",
         optionBody: "",

+ 24 - 0
src/modules/questions/views/EditSelectQuestion.vue

@@ -252,6 +252,7 @@
 <script>
 import { QUESTION_API } from "@/constants/constants";
 import { isEmptyStr, QUESTION_TYPES } from "../constants/constants";
+import { checkRichTextContentIsEmpty } from "@/plugins/utils";
 
 export default {
   name: "EditSelectApp",
@@ -417,6 +418,8 @@ export default {
           if (isEmptyStr(this.quesModel.answerType)) {
             this.quesModel.answerType = "DIVERSIFIED_TEXT";
           }
+
+          this.getCoursesProperty("");
         });
     },
     submitForm(formName) {
@@ -430,6 +433,20 @@ export default {
             });
             return false;
           }
+
+          if (
+            this.quesModel.quesOptions.length &&
+            this.quesModel.quesOptions.some((item) =>
+              checkRichTextContentIsEmpty(item.optionBody)
+            )
+          ) {
+            this.$notify({
+              message: "有选项内容为空",
+              type: "error",
+            });
+            return;
+          }
+
           if (this.questionId) {
             this.editQuestion();
           } else {
@@ -515,6 +532,13 @@ export default {
     },
     //新增选项
     addQuesOption() {
+      if (this.quesModel.quesOptions.length >= 20) {
+        this.$notify({
+          message: "选项最多20个",
+          type: "error",
+        });
+        return;
+      }
       this.quesModel.quesOptions.push({
         number: "",
         optionBody: "",

+ 12 - 15
src/modules/questions/views/Question.vue

@@ -481,20 +481,6 @@ export default {
     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();
-              }
-            });
-        }
       });
     },
     //查询所有课程
@@ -632,12 +618,23 @@ export default {
         this.currentPage = 1;
         this.getCourses("");
       } else {
-        this.formSearch = JSON.parse(sessionStorage.getItem("question"));
+        const formSearch = JSON.parse(sessionStorage.getItem("question"));
         this.currentPage = parseInt(
           sessionStorage.getItem("question_currentPage")
         );
+        this.formSearch = { ...formSearch };
         if (this.formSearch && this.formSearch.courseId) {
           this.getCourseById(this.formSearch.courseId);
+          this.getCoursesProperty("");
+          this.formSearch.coursePropertyId = formSearch.coursePropertyId;
+          if (this.formSearch.coursePropertyId) {
+            this.searchFirst();
+            this.formSearch.firstPropertyId = formSearch.firstPropertyId;
+          }
+          if (this.formSearch.firstPropertyId) {
+            this.searchSecond();
+            this.formSearch.secondPropertyId = formSearch.secondPropertyId;
+          }
         } else {
           this.getCourses("");
         }