Explorar o código

阅读题问题修改

dusenyao hai 1 ano
pai
achega
a630ef6d67

+ 9 - 1
src/views/exercise_questions/create/components/common/QuestionMixin.js

@@ -36,6 +36,10 @@ const mixin = {
       type: Boolean,
       default: false,
     },
+    isChange: {
+      type: Boolean,
+      default: false,
+    },
   },
   components: {
     QuestionBase,
@@ -43,8 +47,11 @@ const mixin = {
     AudioPlay,
   },
   created() {
-    // 题目的子题目保存
     if (this.isChild) {
+      if (this.isChange) {
+        this.$emit('update:isChange', false);
+        return;
+      }
       GetQuestionInfo({ question_id: this.questionId })
         .then(({ question }) => {
           if (!question.content) return;
@@ -74,6 +81,7 @@ const mixin = {
   },
   methods: {
     saveChildQuestion() {
+      console.log(this.data.type);
       SaveQuestion({
         question_id: this.questionId,
         type: this.data.type,

+ 3 - 0
src/views/exercise_questions/create/components/exercises/JudgeQuestion.vue

@@ -126,6 +126,9 @@ export default {
   computed: {
     optionTypeList: {
       get() {
+        if (!this.data.property.option_type_list) {
+          return [];
+        }
         return this.data.property.option_type_list
           .map((item) => {
             let type = this.option_type_list.find(({ value }) => value === item);

+ 3 - 0
src/views/exercise_questions/create/components/exercises/ReadQuestion.vue

@@ -29,6 +29,7 @@
             :is="exerciseComponents[item.type]"
             ref="exercise"
             :is-child="true"
+            :is-change.sync="change"
             :question-id="item.id"
             @updatePreviewData="updatePreviewData(i, $event)"
           />
@@ -118,6 +119,7 @@ export default {
   inject: ['exercise_id'],
   data() {
     return {
+      change: false, // 是否修改了题目类型
       questionTypeOption,
       exerciseTypeList,
       childPreviewData: [],
@@ -173,6 +175,7 @@ export default {
      * @param {Array} arr 选中的题目类型
      */
     updateCurQuestionType(i, arr) {
+      this.change = true;
       let type = arr[arr.length - 1];
       this.data.question_list[i].type = type;
       this.data.question_list[i].additional_type = type === 'select' ? 'single' : '';