刘洋 1 jaar geleden
bovenliggende
commit
e88714b600

+ 9 - 9
src/modules/portal/views/home/Home.vue

@@ -198,15 +198,15 @@ export default {
     };
 
     var validatePassWeakPass = (rule, value, callback) => {
-      // if (this.passWeakForm.checkPass !== "") {
-      //   this.$refs.passWeakForm.validateField("checkPass");
-      // }
-      // callback();
-      if (!value) {
-        callback(new Error("请输入新密码!"));
-      } else {
-        callback();
+      if (this.passWeakForm.checkPass !== "") {
+        this.$refs.passWeakForm.validateField("checkPass");
       }
+      callback();
+      // if (!value) {
+      //   callback(new Error("请输入新密码!"));
+      // } else {
+      //   callback();
+      // }
     };
     var validatePassWeakPass2 = (rule, value, callback) => {
       if (value !== this.passWeakForm.pass) {
@@ -323,7 +323,7 @@ export default {
       this.$refs.passWeakForm.validate((valid) => {
         if (valid) {
           var password = encodeURIComponent(this.passWeakForm.pass);
-          var url = QUESTION_API + "/user/password?password=" + password;
+          var url = QUESTION_API + "/user/password/weak?password=" + password;
           this.$httpWithMsg.put(url).then(() => {
             this.$notify({
               type: "success",

+ 36 - 2
src/modules/question/components/import-edit/BooleanQuestion.vue

@@ -37,8 +37,9 @@
         </el-form-item>
         <el-form-item label="答案解析">
           <v-editor
-            v-model="modalForm.answerAnalysis"
+            v-model="answerAnalysis"
             :enable-audio="false"
+            @change="answerAnalysisChange"
           ></v-editor>
         </el-form-item>
       </el-form>
@@ -61,7 +62,7 @@ import { getInitQuestionModel } from "./model";
 import QuestionInfoEdit from "../QuestionInfoEdit.vue";
 import QuestionInfoView from "./QuestionInfoView.vue";
 import { mapState, mapMutations } from "vuex";
-
+import { isAnEmptyRichText } from "@/utils/utils";
 export default {
   name: "BooleanQuestion",
   components: { QuestionInfoEdit, QuestionInfoView },
@@ -86,6 +87,7 @@ export default {
           label: "正确",
         },
       ],
+      answerAnalysis: null,
     };
   },
   computed: {
@@ -101,12 +103,40 @@ export default {
     ...mapMutations("import-edit", ["setCurQuestion"]),
     initData() {
       this.modalForm = this.$objAssign(getInitQuestionModel(), this.question);
+      this.initAnswerAnalysis(this.question.answerAnalysis);
       const validAnswer = ["true", "false"];
       this.modalForm.quesAnswer = validAnswer.includes(
         this.modalForm.quesAnswer
       )
         ? this.modalForm.quesAnswer
         : null;
+      this.answerAnalysis = this.modalForm.answerAnalysis[0] || {
+        sections: [],
+      };
+    },
+    initAnswerAnalysis(answer) {
+      let answerAnalysis = [];
+      if (answer) {
+        try {
+          answerAnalysis = JSON.parse(answer);
+        } catch (err) {
+          console.log(`answer error:${answer}`);
+        }
+      }
+      this.modalForm.answerAnalysis = answerAnalysis.map((item) =>
+        isAnEmptyRichText(item)
+          ? {
+              sections: [],
+            }
+          : item
+      );
+    },
+    answerAnalysisChange() {
+      this.modalForm.answerAnalysis = [
+        {
+          ...this.answerAnalysis,
+        },
+      ];
     },
     answerChange() {
       this.$refs.modalFormComp.validateField(`answer`, () => {});
@@ -119,6 +149,10 @@ export default {
     },
     getData() {
       let data = Object.assign({}, this.question, this.modalForm);
+      data.answerAnalysis =
+        data.answerAnalysis && data.answerAnalysis?.length
+          ? data.answerAnalysis[0]
+          : { sections: [] };
       return data;
     },
     activeQuestion() {

+ 35 - 1
src/modules/question/components/import-edit/FillBlankQuestion.vue

@@ -39,8 +39,9 @@
         </el-form-item>
         <el-form-item label="答案解析">
           <v-editor
-            v-model="modalForm.answerAnalysis"
+            v-model="answerAnalysis"
             :enable-audio="false"
+            @change="answerAnalysisChange"
           ></v-editor>
         </el-form-item>
       </el-form>
@@ -80,6 +81,7 @@ export default {
   data() {
     return {
       modalForm: {},
+      answerAnalysis: null,
     };
   },
   computed: {
@@ -95,6 +97,7 @@ export default {
     ...mapMutations("import-edit", ["setCurQuestion"]),
     initData() {
       this.modalForm = this.$objAssign(getInitQuestionModel(), this.question);
+      this.initAnswerAnalysis(this.question.answerAnalysis);
       this.modalForm.quesAnswer = [];
       const quesAnswer = this.initAnswer(this.question.quesAnswer);
 
@@ -109,6 +112,33 @@ export default {
           this.modalForm.quesAnswer.push({ body: answerBody });
         });
       });
+      this.answerAnalysis = this.modalForm.answerAnalysis[0] || {
+        sections: [],
+      };
+    },
+    initAnswerAnalysis(answer) {
+      let answerAnalysis = [];
+      if (answer) {
+        try {
+          answerAnalysis = JSON.parse(answer);
+        } catch (err) {
+          console.log(`answer error:${answer}`);
+        }
+      }
+      this.modalForm.answerAnalysis = answerAnalysis.map((item) =>
+        isAnEmptyRichText(item)
+          ? {
+              sections: [],
+            }
+          : item
+      );
+    },
+    answerAnalysisChange() {
+      this.modalForm.answerAnalysis = [
+        {
+          ...this.answerAnalysis,
+        },
+      ];
     },
     initAnswer(answer) {
       let quesAnswer = [];
@@ -145,6 +175,10 @@ export default {
         };
       });
       data.quesAnswer = JSON.stringify(data.quesAnswer);
+      data.answerAnalysis =
+        data.answerAnalysis && data.answerAnalysis?.length
+          ? data.answerAnalysis[0]
+          : { sections: [] };
       return data;
     },
     activeQuestion() {

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

@@ -64,8 +64,9 @@
         </el-form-item>
         <el-form-item label="答案解析">
           <v-editor
-            v-model="modalForm.answerAnalysis"
+            v-model="answerAnalysis"
             :enable-audio="false"
+            @change="answerAnalysisChange"
           ></v-editor>
         </el-form-item>
       </el-form>
@@ -89,6 +90,7 @@ import QuestionInfoView from "./QuestionInfoView.vue";
 import { getInitQuestionModel } from "./model";
 import { mapState, mapMutations } from "vuex";
 import { objTypeOf } from "@/plugins/utils";
+import { isAnEmptyRichText } from "@/utils/utils";
 
 export default {
   name: "SelectQuestion",
@@ -119,6 +121,7 @@ export default {
           },
         ],
       },
+      answerAnalysis: null,
     };
   },
   computed: {
@@ -147,6 +150,7 @@ export default {
       // 因为会缓存答案,所以会导致答案的格式完全不确定。
       // 可能之前识别是判断题,后来识别成选择题。答案格式的不一样,会导致异常
       this.initAnswer(this.question.quesAnswer);
+      this.initAnswerAnalysis(this.question.answerAnalysis);
       if (this.IS_SIMPLE) {
         this.quesAnswer = this.modalForm.quesAnswer.length
           ? this.modalForm.quesAnswer[0]
@@ -154,6 +158,9 @@ export default {
       } else {
         this.quesAnswer = this.modalForm.quesAnswer || [];
       }
+      this.answerAnalysis = this.modalForm.answerAnalysis[0] || {
+        sections: [],
+      };
       this.options = this.question.options.map((item) => {
         let nitem = { ...item };
         nitem.isCorrect = this.modalForm.quesAnswer.includes(item.number);
@@ -180,6 +187,23 @@ export default {
         this.modalForm.quesAnswer = [];
       }
     },
+    initAnswerAnalysis(answer) {
+      let answerAnalysis = [];
+      if (answer) {
+        try {
+          answerAnalysis = JSON.parse(answer);
+        } catch (err) {
+          console.log(`answer error:${answer}`);
+        }
+      }
+      this.modalForm.answerAnalysis = answerAnalysis.map((item) =>
+        isAnEmptyRichText(item)
+          ? {
+              sections: [],
+            }
+          : item
+      );
+    },
     checkAnswerFormatValid(answer) {
       if (objTypeOf(answer) !== "array") return;
 
@@ -197,6 +221,13 @@ export default {
       }
       this.$refs.modalFormComp.validateField(`answer`, () => {});
     },
+    answerAnalysisChange() {
+      this.modalForm.answerAnalysis = [
+        {
+          ...this.answerAnalysis,
+        },
+      ];
+    },
     questionInfoChange(questionInfo) {
       this.modalForm = Object.assign({}, this.modalForm, questionInfo);
     },
@@ -206,6 +237,10 @@ export default {
     getData() {
       let data = Object.assign({}, this.question, this.modalForm);
       data.quesAnswer = JSON.stringify(this.modalForm.quesAnswer);
+      data.answerAnalysis =
+        data.answerAnalysis && data.answerAnalysis?.length
+          ? data.answerAnalysis[0]
+          : { sections: [] };
       return data;
     },
     activeQuestion() {

+ 7 - 11
src/modules/question/components/import-edit/TextAnswerQuestion.vue

@@ -131,17 +131,13 @@ export default {
           console.log(`answer error:${answer}`);
         }
       }
-      if (this.checkAnswerFormatValid(answerAnalysis)) {
-        this.modalForm.answerAnalysis = answerAnalysis.map((item) =>
-          isAnEmptyRichText(item)
-            ? {
-                sections: [],
-              }
-            : item
-        );
-      } else {
-        this.modalForm.answerAnalysis = [];
-      }
+      this.modalForm.answerAnalysis = answerAnalysis.map((item) =>
+        isAnEmptyRichText(item)
+          ? {
+              sections: [],
+            }
+          : item
+      );
     },
     checkAnswerFormatValid(answer) {
       return objTypeOf(answer) === "array";