|
@@ -33,8 +33,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>
|
|
@@ -75,6 +76,7 @@ export default {
|
|
|
return {
|
|
|
modalForm: {},
|
|
|
quesAnswer: null,
|
|
|
+ answerAnalysis: null,
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
@@ -91,9 +93,13 @@ export default {
|
|
|
initData() {
|
|
|
this.modalForm = this.$objAssign(getInitQuestionModel(), this.question);
|
|
|
this.initAnswer(this.question.quesAnswer);
|
|
|
+ this.initAnswerAnalysis(this.question.answerAnalysis);
|
|
|
this.quesAnswer = this.modalForm.quesAnswer[0] || {
|
|
|
sections: [],
|
|
|
};
|
|
|
+ this.answerAnalysis = this.modalForm.answerAnalysis[0] || {
|
|
|
+ sections: [],
|
|
|
+ };
|
|
|
},
|
|
|
initAnswer(answer) {
|
|
|
let quesAnswer = [];
|
|
@@ -116,6 +122,27 @@ export default {
|
|
|
this.modalForm.quesAnswer = [];
|
|
|
}
|
|
|
},
|
|
|
+ initAnswerAnalysis(answer) {
|
|
|
+ let answerAnalysis = [];
|
|
|
+ if (answer) {
|
|
|
+ try {
|
|
|
+ answerAnalysis = JSON.parse(answer);
|
|
|
+ } catch (err) {
|
|
|
+ console.log(`answer error:${answer}`);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (this.checkAnswerFormatValid(answerAnalysis)) {
|
|
|
+ this.modalForm.answerAnalysis = answerAnalysis.map((item) =>
|
|
|
+ isAnEmptyRichText(item)
|
|
|
+ ? {
|
|
|
+ sections: [],
|
|
|
+ }
|
|
|
+ : item
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ this.modalForm.answerAnalysis = [];
|
|
|
+ }
|
|
|
+ },
|
|
|
checkAnswerFormatValid(answer) {
|
|
|
return objTypeOf(answer) === "array";
|
|
|
},
|
|
@@ -127,6 +154,13 @@ export default {
|
|
|
},
|
|
|
];
|
|
|
},
|
|
|
+ answerAnalysisChange() {
|
|
|
+ this.modalForm.answerAnalysis = [
|
|
|
+ {
|
|
|
+ ...this.answerAnalysis,
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ },
|
|
|
questionInfoChange(questionInfo) {
|
|
|
this.modalForm = Object.assign({}, this.modalForm, questionInfo);
|
|
|
},
|
|
@@ -136,6 +170,10 @@ export default {
|
|
|
getData() {
|
|
|
let data = Object.assign({}, this.question, this.modalForm);
|
|
|
data.quesAnswer = JSON.stringify(data.quesAnswer);
|
|
|
+ data.answerAnalysis =
|
|
|
+ data.answerAnalysis && data.answerAnalysis?.length
|
|
|
+ ? data.answerAnalysis[0]
|
|
|
+ : { sections: [] };
|
|
|
return data;
|
|
|
},
|
|
|
activeQuestion() {
|