Quellcode durchsuchen

题目编辑答案修改

zhangjie vor 2 Jahren
Ursprung
Commit
6c266905a0

+ 4 - 3
src/modules/question/components/edit/BooleanQuestion.vue

@@ -56,11 +56,11 @@ export default {
       modalForm: {},
       modalForm: {},
       answerOptions: [
       answerOptions: [
         {
         {
-          value: 0,
+          value: "false",
           label: "错误",
           label: "错误",
         },
         },
         {
         {
-          value: 1,
+          value: "true",
           label: "正确",
           label: "正确",
         },
         },
       ],
       ],
@@ -102,7 +102,8 @@ export default {
       return this.$refs.modalFormComp.validate();
       return this.$refs.modalFormComp.validate();
     },
     },
     getData() {
     getData() {
-      return this.modalForm;
+      let data = { ...this.modalForm };
+      return data;
     },
     },
   },
   },
 };
 };

+ 13 - 3
src/modules/question/components/edit/FillBlankQuestion.vue

@@ -24,7 +24,10 @@
         <div class="question-edit-option">
         <div class="question-edit-option">
           <div class="option-check">({{ oindex + 1 }})</div>
           <div class="option-check">({{ oindex + 1 }})</div>
           <div class="option-body">
           <div class="option-body">
-            <v-editor v-model="answer.body"></v-editor>
+            <v-editor
+              v-model="answer.body"
+              @change="() => answerBodyChange(oindex)"
+            ></v-editor>
           </div>
           </div>
         </div>
         </div>
       </el-form-item>
       </el-form-item>
@@ -74,7 +77,7 @@ export default {
       },
       },
       answerRule: {
       answerRule: {
         validator: (rule, value, callback) => {
         validator: (rule, value, callback) => {
-          if (!value || !value.length) {
+          if (!value || isAnEmptyRichText(value)) {
             return callback(new Error(`请输入答案内容`));
             return callback(new Error(`请输入答案内容`));
           }
           }
           callback();
           callback();
@@ -99,7 +102,7 @@ export default {
       });
       });
     },
     },
     answerPointsChange(answerPointsChanged) {
     answerPointsChange(answerPointsChanged) {
-      console.log(answerPointsChanged);
+      // console.log(answerPointsChanged);
       let quesAnswer = [];
       let quesAnswer = [];
       answerPointsChanged.forEach((item) => {
       answerPointsChanged.forEach((item) => {
         const order = Number(item);
         const order = Number(item);
@@ -116,6 +119,12 @@ export default {
     quesBodyChange() {
     quesBodyChange() {
       this.$refs.modalFormComp.validateField(`quesBody`, () => {});
       this.$refs.modalFormComp.validateField(`quesBody`, () => {});
     },
     },
+    answerBodyChange(oindex) {
+      this.$refs.modalFormComp.validateField(
+        `quesAnswer.${oindex}.body`,
+        () => {}
+      );
+    },
     questionInfoChange(questionInfo) {
     questionInfoChange(questionInfo) {
       this.modalForm = Object.assign({}, this.modalForm, questionInfo);
       this.modalForm = Object.assign({}, this.modalForm, questionInfo);
     },
     },
@@ -130,6 +139,7 @@ export default {
           index,
           index,
         };
         };
       });
       });
+      data.quesAnswer = JSON.stringify(data.quesAnswer);
       return data;
       return data;
     },
     },
   },
   },

+ 3 - 1
src/modules/question/components/edit/MatchQuestion.vue

@@ -124,7 +124,9 @@ export default {
       return this.$refs.modalFormComp.validate();
       return this.$refs.modalFormComp.validate();
     },
     },
     getData() {
     getData() {
-      return this.modalForm;
+      let data = { ...this.modalForm };
+      data.quesAnswer = JSON.stringify(data.quesAnswer);
+      return data;
     },
     },
   },
   },
 };
 };

+ 9 - 1
src/modules/question/components/edit/SelectQuestion.vue

@@ -249,7 +249,15 @@ export default {
       return this.$refs.modalFormComp.validate();
       return this.$refs.modalFormComp.validate();
     },
     },
     getData() {
     getData() {
-      return this.modalForm;
+      let data = { ...this.modalForm };
+      data.quesOptions = this.modalForm.quesOptions.map((item) => {
+        return {
+          number: item.number,
+          body: item.body,
+        };
+      });
+      data.quesAnswer = JSON.stringify(this.modalForm.quesAnswer);
+      return data;
     },
     },
   },
   },
 };
 };

+ 3 - 1
src/modules/question/components/edit/TextAnswerQuestion.vue

@@ -103,7 +103,9 @@ export default {
       return this.$refs.modalFormComp.validate();
       return this.$refs.modalFormComp.validate();
     },
     },
     getData() {
     getData() {
-      return this.modalForm;
+      let data = { ...this.modalForm };
+      data.quesAnswer = JSON.stringify(data.quesAnswer);
+      return data;
     },
     },
   },
   },
 };
 };