Parcourir la source

阅读题保存题目

dusenyao il y a 1 an
Parent
commit
91497d5870

+ 0 - 7
src/views/exercise_questions/create/components/common/QuestionMixin.js

@@ -49,8 +49,6 @@ const mixin = {
   created() {
     // 题目的子题目保存
     if (this.isChild) {
-      this.$bus.$on('saveQuestion', this.saveChildQuestion);
-
       if (this.isChange) return;
       GetQuestionInfo({ question_id: this.questionId })
         .then(({ question }) => {
@@ -61,11 +59,6 @@ const mixin = {
         .catch(() => {});
     }
   },
-  beforeDestroy() {
-    if (this.isChild) {
-      this.$bus.$off('saveQuestion', this.saveChildQuestion);
-    }
-  },
   watch: {
     'data.property.score'(val) {
       if (val === undefined) return;

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

@@ -196,7 +196,12 @@ export default {
       if (this.indexList.length <= 0) return;
       if (this.loading) return;
       try {
-        this.$bus.$emit('saveQuestion');
+        let childrenExercise = this.$refs.exercise[0].$refs.exercise;
+        if (childrenExercise) {
+          childrenExercise.forEach((item) => {
+            item?.saveChildQuestion();
+          });
+        }
         await SaveQuestion(this.dataConversion());
         const curDate = timeFormatConversion(new Date());
         if (this.curSaveDate !== curDate) {