zhangjie 2 rokov pred
rodič
commit
7a7ca2223a

+ 2 - 14
src/components/vEditor/components/FormulaDialog.vue

@@ -30,8 +30,6 @@
 </template>
 
 <script>
-import { saveFormulaImageToEditorHandle } from "./image";
-
 export default {
   name: "FormulaDialog",
   props: {
@@ -123,21 +121,11 @@ export default {
 
       const result = await this.getFormulaResult().catch((error) => {
         console.error(error);
-        this.loading = false;
       });
+      this.loading = false;
 
       if (result) {
-        let res = true;
-        await saveFormulaImageToEditorHandle
-          .bind(this.$parent.$parent)(result.dataUrl, {
-            "data-latex": result.latex,
-            style: `width: ${result.param.width}px;height:${result.param.height}px;`,
-          })
-          .catch(() => {
-            res = false;
-          });
-        this.loading = false;
-        if (!res) return;
+        this.$emit("confirm", result);
       }
       this.cancel();
     },

+ 48 - 1
src/components/vEditor/components/VMenu.vue

@@ -95,7 +95,10 @@
     > -->
 
     <!-- formula dialog -->
-    <formula-dialog ref="FormulaDialog"></formula-dialog>
+    <formula-dialog
+      ref="FormulaDialog"
+      @confirm="formulaConfirm"
+    ></formula-dialog>
   </div>
 </template>
 
@@ -109,6 +112,11 @@ import FormulaDialog from "./FormulaDialog";
 export default {
   name: "VMenu",
   components: { FormulaDialog },
+  data() {
+    return {
+      curEditFocusRange: null,
+    };
+  },
   methods: {
     setDocMode(type) {
       setDocMode(type, this.$parent.$refs.editor);
@@ -144,8 +152,47 @@ export default {
      */
     addFormula(event) {
       event.preventDefault();
+      const selection = window.getSelection();
+      if (selection.focusNode && this.checkDomInEditor(selection.focusNode)) {
+        this.curEditFocusRange = selection.getRangeAt(0);
+      } else {
+        this.$el.nextSibling.focus();
+        const selection = window.getSelection();
+        this.curEditFocusRange = selection.getRangeAt(0);
+      }
       this.$refs.FormulaDialog.open();
     },
+    checkDomInEditor(dom) {
+      let parentNode = dom;
+      while (
+        !(
+          (parentNode.className &&
+            parentNode.className.includes("v-editor-body")) ||
+          parentNode.nodeName === "BODY"
+        )
+      ) {
+        parentNode = parentNode.parentNode;
+      }
+
+      return (
+        parentNode.className && parentNode.className.includes("v-editor-body")
+      );
+    },
+    formulaConfirm(result) {
+      if (!this.curEditFocusRange) {
+        const selection = window.getSelection();
+        this.curEditFocusRange = selection.getRangeAt(0);
+      }
+      this.curEditFocusRange.deleteContents();
+
+      const el = document.createElement("img");
+      el.src = result.dataUrl;
+      el.dataset.isImage = true;
+      el.dataset.dataLatex = result.latex;
+      el.style = `width: ${result.param.width}px;height:${result.param.height}px;`;
+      this.curEditFocusRange.insertNode(el);
+      this.curEditFocusRange.collapse();
+    },
   },
 };
 </script>

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 1 - 1
src/modules/card/previewTemp.js


+ 0 - 6
src/modules/questions/views/GenPaper.vue

@@ -467,12 +467,6 @@ export default {
   created() {
     this.initVue();
   },
-  // beforeMount() {
-  //   console.log(`${this.$route.path}:${Date.now()}:beforeMount`);
-  // },
-  // mounted() {
-  //   console.log(`${this.$route.path}:${Date.now()}:mounted`);
-  // },
   methods: {
     recoveryPaper(row) {
       this.$confirm("确认回收试卷吗?", "提示", {

+ 3 - 1
src/modules/questions/views/InsertBluePaperStructure.vue

@@ -551,7 +551,9 @@ export default {
               paperDetailStruct.remark = this.paperDetailStructForm.remark;
             }
           }
-          this.paperDetailStructForm = { name: "", remark: "", id: "" };
+          this.paperDetailStructForm.id = "";
+          this.paperDetailStructForm.name = "";
+          this.paperDetailStructForm.remark = "";
           this.blueStruct.paperDetailStructs = this.paperDetailStructs;
           sessionStorage.setItem("blueStruct", JSON.stringify(this.blueStruct));
           this.detailDialog = false;

+ 6 - 2
src/modules/questions/views/InsertPaperStructure.vue

@@ -408,7 +408,9 @@ export default {
           paperDetailStruct.number = paperDetailStruct.id;
           this.paperDetailStructs.push(paperDetailStruct);
           this.paperDetailStructDialog = false;
-          this.paperDetailStructForm = { name: "", remark: "" };
+          this.paperDetailStructForm.id = "";
+          this.paperDetailStructForm.name = "";
+          this.paperDetailStructForm.remark = "";
           this.paperStruct.paperDetailStructs = this.paperDetailStructs;
           sessionStorage.setItem(
             "paperStruct",
@@ -430,7 +432,9 @@ export default {
             }
           }
           this.paperDetailStructDialog = false;
-          this.paperDetailStructForm = { name: "", remark: "" };
+          this.paperDetailStructForm.id = "";
+          this.paperDetailStructForm.name = "";
+          this.paperDetailStructForm.remark = "";
           this.paperStruct.paperDetailStructs = paperDetailStructs;
           sessionStorage.setItem(
             "paperStruct",

+ 0 - 6
src/modules/questions/views/InsertPaperTitle.vue

@@ -236,12 +236,6 @@ export default {
       }
     });
   },
-  // beforeMount() {
-  //   console.log(`${this.$route.path}:${Date.now()}:beforeMount`);
-  // },
-  // mounted() {
-  //   console.log(`${this.$route.path}:${Date.now()}:mounted`);
-  // },
   methods: {
     //远端查询课程
     queryCoursesByKeyword(query) {

+ 2 - 1
src/modules/questions/views/data_previllege.vue

@@ -210,7 +210,8 @@ export default {
         .get(QUESTION_API + "/user/" + this.form.userId)
         .then((res) => {
           this.userName = res.data.name + "(" + res.data.roleNamesStr + ")";
-          this.form.auditAuthority = res.data.auditAuthority;
+          if (!this.form.auditAuthority)
+            this.form.auditAuthority = res.data.auditAuthority;
         });
       const reqs = [];
       const defaultPrevilleges = ["COURSE"];

Niektoré súbory nie sú zobrazené, pretože je v týchto rozdielových dátach zmenené mnoho súborov