zhangjie 1 рік тому
батько
коміт
575511f3e6

+ 10 - 3
card/components/CardDesign.vue

@@ -237,6 +237,7 @@
     <topic-select-dialog
       ref="TopicSelectDialog"
       :topics="topicList"
+      :insert-topic="preInsertTopic"
       @confirm="addNewTopic"
     ></topic-select-dialog>
   </div>
@@ -303,6 +304,7 @@ export default {
       isSubmit: false,
       canSave: false,
       hasUnsubmitCont: false,
+      preInsertTopic: {},
     };
   },
   computed: {
@@ -339,7 +341,6 @@ export default {
       "setOpenElementEditDialog",
       "setCurDragElement",
       "setPages",
-      "setInsetTarget",
       "initState",
     ]),
     ...mapActions("card", [
@@ -380,6 +381,10 @@ export default {
       });
     },
     addNewTopic(item) {
+      if (!item.type) {
+        this.$message.error("试题类型丢失!");
+        return;
+      }
       let element = getElementModel(item.type);
       element.w = document.getElementById("topic-column").offsetWidth;
 
@@ -388,6 +393,9 @@ export default {
           (item) => !OTHER_ELEMENT.includes(item.type)
         );
         element.sign = lastTopicElement ? lastTopicElement.sign : "objective";
+        if (item.insertTopic && item.insertTopic.id) {
+          element.insertTopic = item.insertTopic;
+        }
         this.addElement(element);
         this.setCurElement(element);
         this.$nextTick(() => {
@@ -403,8 +411,7 @@ export default {
       }
     },
     insetNewTopic({ id, type }) {
-      console.log(id, type);
-      this.setInsetTarget({ id, type });
+      this.preInsertTopic = { id, type };
       if (type === "FILL_QUESTION") {
         this.topicList = this.TOPIC_LIST;
       } else {

+ 14 - 1
card/components/TopicSelectDialog.vue

@@ -37,6 +37,12 @@ export default {
         return [];
       },
     },
+    insertTopic: {
+      type: Object,
+      default() {
+        return {};
+      },
+    },
   },
   data() {
     return {
@@ -58,7 +64,14 @@ export default {
       this.curTopic = topic;
     },
     submit() {
-      this.$emit("confirm", this.curTopic);
+      if (!this.curTopic.type) {
+        this.$message.error("请选择试题类型");
+        return;
+      }
+      this.$emit("confirm", {
+        ...this.curTopic,
+        insertTopic: this.insertTopic,
+      });
       this.cancel();
     },
   },

+ 4 - 9
card/store/card.js

@@ -18,7 +18,6 @@ const state = {
   topics: [],
   topicSeries: [], // 大题顺序号,不排重
   topicNoSeries: [], // 大题顺序号,按顺序排重
-  insetTarget: {}, // 需要在其后面插入大题的大题
   openElementEditDialog: false,
 };
 
@@ -52,9 +51,6 @@ const mutations = {
   setTopicNoSeries(state, topicNoSeries) {
     state.topicNoSeries = topicNoSeries;
   },
-  setInsetTarget(state, insetTarget) {
-    state.insetTarget = insetTarget;
-  },
   addPage(state, page) {
     state.pages.push(page);
   },
@@ -292,21 +288,22 @@ const actions = {
   addElement({ state, commit, dispatch }, element) {
     let pos = null;
     // 客观题和主观题分别对待
-    if (state.insetTarget.id) {
+    if (element.insertTopic && element.insertTopic.id) {
       // 存在插入目标元素
       if (
-        state.insetTarget.type === "FILL_QUESTION" &&
+        element.insertTopic.type === "FILL_QUESTION" &&
         element.type !== "FILL_QUESTION"
       ) {
         pos = fetchFirstSubjectiveTopicPositionInfo(state.topics);
       } else {
         let relateTopicPos = [];
         state.topics.forEach((item, index) => {
-          if (item.parent && item.parent.id === state.insetTarget.id)
+          if (item.parent && item.parent.id === element.insertTopic.id)
             relateTopicPos.push(index);
         });
         pos = relateTopicPos.slice(-1)[0] + 1;
       }
+      delete element.insertTopic;
     } else {
       // 不存在插入目标元素
       if (element.sign === "objective") {
@@ -323,8 +320,6 @@ const actions = {
       }
     });
     dispatch("resetTopicSeries");
-    commit("setInsetTarget", {});
-
     commit("setCurElement", element);
   },
   addForbidArea({ state, commit }, { element, beforeElementId }) {

+ 2 - 2
src/modules/base/components/ModifyPrintTemplate.vue

@@ -3,7 +3,7 @@
     class="modify-template"
     :visible.sync="modalIsShow"
     :title="title"
-    width="600px"
+    width="700px"
     top="10px"
     :close-on-click-modal="false"
     :close-on-press-escape="false"
@@ -12,7 +12,7 @@
   >
     <el-form
       ref="modalFormComp"
-      label-width="100px"
+      label-width="140px"
       :rules="rules"
       :model="modalForm"
     >

+ 1 - 1
src/modules/base/components/ResetPwd.vue

@@ -4,7 +4,7 @@
     :visible.sync="modalIsShow"
     :title="title"
     top="10vh"
-    width="520px"
+    width="620px"
     :close-on-click-modal="false"
     :close-on-press-escape="false"
     append-to-body