dusenyao 1 år sedan
förälder
incheckning
f3db0cebc3

+ 14 - 8
src/views/exercise_questions/create/components/common/QuestionMixin.js

@@ -47,14 +47,7 @@ const mixin = {
   created() {
     // 题目的子题目保存
     if (this.isChild) {
-      this.$bus.$on('saveQuestion', () => {
-        SaveQuestion({
-          question_id: this.questionId,
-          type: this.data.type,
-          additional_type: this.data.property.select_type || '',
-          content: JSON.stringify(this.data),
-        }).catch(() => {});
-      });
+      this.$bus.$on('saveQuestion', this.saveChildQuestion);
 
       if (this.isChange) return;
       GetQuestionInfo({ question_id: this.questionId })
@@ -66,6 +59,11 @@ const mixin = {
         .catch(() => {});
     }
   },
+  beforeDestroy() {
+    if (this.isChild) {
+      this.$bus.$off('saveQuestion', this.saveChildQuestion);
+    }
+  },
   watch: {
     'data.property.score'(val) {
       if (val === undefined) return;
@@ -85,6 +83,14 @@ const mixin = {
     },
   },
   methods: {
+    saveChildQuestion() {
+      SaveQuestion({
+        question_id: this.questionId,
+        type: this.data.type,
+        additional_type: this.data.property.select_type || '',
+        content: JSON.stringify(this.data),
+      }).catch(() => {});
+    },
     upload(file_id) {
       this.data.file_id_list.push(file_id);
     },

+ 1 - 1
src/views/exercise_questions/create/components/create.vue

@@ -151,7 +151,7 @@ export default {
      */
     selectExerciseItem(i) {
       if (this.indexList.length <= 0) return;
-      this.$emit('selectExerciseItem', i, this.dataConversion());
+      this.$emit('selectExerciseItem', i);
     },
     /**
      * 设置

+ 5 - 5
src/views/exercise_questions/create/index.vue

@@ -155,11 +155,12 @@ export default {
       this.addQuestionToExercise('select', 'single', questionDataList['select']);
     },
     // 创建新题
-    createNewQuestion() {
+    async createNewQuestion() {
       if (this.index_list.length === 0) {
         this.createDefaultQuestion();
         return;
       }
+      await this.$refs.createMain.saveQuestion();
       let { type, additional_type } = this.index_list[this.curIndex];
       this.addQuestionToExercise(type, additional_type, questionDataList[type]);
     },
@@ -240,13 +241,12 @@ export default {
     },
     /**
      * 选择练习
-     * @param {Number} index 练习索引
-     * @param {object} data 练习数据
+     * @param {number} index 练习索引
      */
-    selectExerciseItem(index, data) {
+    selectExerciseItem(index) {
       if (index < 0 || index > this.index_list.length - 1) return;
       this.$refs.createMain.clearSaveDate();
-      this.$refs.createMain.saveQuestion(data);
+      this.$refs.createMain.saveQuestion();
       this.curIndex = index;
     },
     // 设置

+ 3 - 3
src/views/share/ShareExercise.vue

@@ -87,8 +87,8 @@ export default {
     tip() {
       if (this.share_record.access_popedom === -1) return '正在加载...';
       return this.share_record.access_popedom === 1
-        ? '分享链接为练习题答题链接,登录后可以开始答题'
-        : '分享链接为练习题编辑链接,登录后可以开始编辑练习题';
+        ? '分享链接为练习题编辑链接,登录后可以开始编辑练习题'
+        : '分享链接为练习题答题链接,登录后可以开始答题';
     },
   },
   created() {
@@ -183,7 +183,7 @@ export default {
 .share-exercise {
   width: 100%;
   height: 100%;
-  padding-top: 20%;
+  padding-top: 15%;
   background-color: $content-color;
 
   .login {