|
@@ -2,11 +2,11 @@
|
|
<div class="select-question">
|
|
<div class="select-question">
|
|
<el-form
|
|
<el-form
|
|
ref="modalFormComp"
|
|
ref="modalFormComp"
|
|
- :model="modelForm"
|
|
|
|
|
|
+ :model="modalForm"
|
|
:rules="rules"
|
|
:rules="rules"
|
|
label-width="100px"
|
|
label-width="100px"
|
|
>
|
|
>
|
|
- <el-form-item prop="quesBody" label="题干:">
|
|
|
|
|
|
+ <el-form-item prop="quesBody" label="题干">
|
|
<v-editor v-model="modalForm.quesBody"></v-editor>
|
|
<v-editor v-model="modalForm.quesBody"></v-editor>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
<el-form-item
|
|
<el-form-item
|
|
@@ -17,7 +17,21 @@
|
|
>
|
|
>
|
|
<div class="question-edit-option">
|
|
<div class="question-edit-option">
|
|
<div class="option-check">
|
|
<div class="option-check">
|
|
- {{ (option.nmuber - 1) | optionOrderWordFilter }}
|
|
|
|
|
|
+ <el-radio
|
|
|
|
+ v-if="IS_SIMPLE"
|
|
|
|
+ v-model="quesAnswer"
|
|
|
|
+ :label="option.number"
|
|
|
|
+ >
|
|
|
|
+ {{ (option.number - 1) | optionOrderWordFilter }}
|
|
|
|
+ </el-radio>
|
|
|
|
+ <el-checkbox
|
|
|
|
+ v-else
|
|
|
|
+ v-model="option.isCorrect"
|
|
|
|
+ :label="option.number"
|
|
|
|
+ @change="answerChange"
|
|
|
|
+ >
|
|
|
|
+ {{ (option.number - 1) | optionOrderWordFilter }}
|
|
|
|
+ </el-checkbox>
|
|
</div>
|
|
</div>
|
|
<div class="option-body">
|
|
<div class="option-body">
|
|
<v-editor v-model="option.body"></v-editor>
|
|
<v-editor v-model="option.body"></v-editor>
|
|
@@ -27,7 +41,7 @@
|
|
size="mini"
|
|
size="mini"
|
|
circle
|
|
circle
|
|
type="primary"
|
|
type="primary"
|
|
- icon="el-icon-add"
|
|
|
|
|
|
+ icon="el-icon-plus"
|
|
title="新增"
|
|
title="新增"
|
|
@click.prevent="addQuesOption(index)"
|
|
@click.prevent="addQuesOption(index)"
|
|
></el-button>
|
|
></el-button>
|
|
@@ -43,7 +57,8 @@
|
|
</div>
|
|
</div>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
<el-form-item prop="quesAnswer" label="答案">
|
|
<el-form-item prop="quesAnswer" label="答案">
|
|
- <el-radio-group
|
|
|
|
|
|
+ <span>{{ answer }}</span>
|
|
|
|
+ <!-- <el-radio-group
|
|
v-if="IS_SIMPLE"
|
|
v-if="IS_SIMPLE"
|
|
v-model="quesAnswer"
|
|
v-model="quesAnswer"
|
|
@change="answerChange"
|
|
@change="answerChange"
|
|
@@ -68,20 +83,28 @@
|
|
>
|
|
>
|
|
{{ (option.number - 1) | optionOrderWordFilter }}
|
|
{{ (option.number - 1) | optionOrderWordFilter }}
|
|
</el-checkbox>
|
|
</el-checkbox>
|
|
- </el-checkbox-group>
|
|
|
|
|
|
+ </el-checkbox-group> -->
|
|
</el-form-item>
|
|
</el-form-item>
|
|
<el-form-item label="答案解析">
|
|
<el-form-item label="答案解析">
|
|
<v-editor v-model="modalForm.comment"></v-editor>
|
|
<v-editor v-model="modalForm.comment"></v-editor>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
</el-form>
|
|
</el-form>
|
|
|
|
+ <question-info-edit
|
|
|
|
+ ref="QuestionInfoEdit"
|
|
|
|
+ :question="modalForm"
|
|
|
|
+ @change="questionInfoChange"
|
|
|
|
+ ></question-info-edit>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
import { isAnEmptyRichText } from "@/utils/utils";
|
|
import { isAnEmptyRichText } from "@/utils/utils";
|
|
|
|
+import { getInitQuestionModel } from "../model/questionModel";
|
|
|
|
+import QuestionInfoEdit from "../QuestionInfoEdit.vue";
|
|
|
|
|
|
export default {
|
|
export default {
|
|
name: "SelectQuestion",
|
|
name: "SelectQuestion",
|
|
|
|
+ components: { QuestionInfoEdit },
|
|
props: {
|
|
props: {
|
|
question: {
|
|
question: {
|
|
type: Object,
|
|
type: Object,
|
|
@@ -92,13 +115,7 @@ export default {
|
|
},
|
|
},
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
- modalForm: {
|
|
|
|
- questionType: "SINGLE_ANSWER_QUESTION",
|
|
|
|
- quesBody: null,
|
|
|
|
- quesOptions: [],
|
|
|
|
- quesAnswer: [],
|
|
|
|
- comment: null,
|
|
|
|
- },
|
|
|
|
|
|
+ modalForm: {},
|
|
quesAnswer: null,
|
|
quesAnswer: null,
|
|
rules: {
|
|
rules: {
|
|
quesBody: [
|
|
quesBody: [
|
|
@@ -140,10 +157,30 @@ export default {
|
|
return this.question.questionType === "SINGLE_ANSWER_QUESTION";
|
|
return this.question.questionType === "SINGLE_ANSWER_QUESTION";
|
|
},
|
|
},
|
|
answer() {
|
|
answer() {
|
|
- return "w";
|
|
|
|
|
|
+ if (!this.quesAnswer) return "";
|
|
|
|
+ const quesAnswer = this.IS_SIMPLE ? [this.quesAnswer] : this.quesAnswer;
|
|
|
|
+ return quesAnswer
|
|
|
|
+ .map((value) => String.fromCharCode(64 + value))
|
|
|
|
+ .join("");
|
|
},
|
|
},
|
|
},
|
|
},
|
|
|
|
+ created() {
|
|
|
|
+ this.initData();
|
|
|
|
+ },
|
|
methods: {
|
|
methods: {
|
|
|
|
+ initData() {
|
|
|
|
+ console.log("11");
|
|
|
|
+ this.modalForm = this.$objAssign(
|
|
|
|
+ getInitQuestionModel("SINGLE_ANSWER_QUESTION"),
|
|
|
|
+ this.question
|
|
|
|
+ );
|
|
|
|
+ if (!this.IS_SIMPLE) {
|
|
|
|
+ const quesAnswer = this.question.quesAnswer || [];
|
|
|
|
+ this.modalForm.quesOptions.forEach((item) => {
|
|
|
|
+ item.isCorrect = quesAnswer.includes(item.number);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ },
|
|
addQuesOption(index) {
|
|
addQuesOption(index) {
|
|
if (this.modalForm.quesOptions.length >= 20) {
|
|
if (this.modalForm.quesOptions.length >= 20) {
|
|
this.$message.error("选项最多20个");
|
|
this.$message.error("选项最多20个");
|
|
@@ -166,21 +203,30 @@ export default {
|
|
}
|
|
}
|
|
);
|
|
);
|
|
const optionCount = this.modalForm.quesOptions.length;
|
|
const optionCount = this.modalForm.quesOptions.length;
|
|
- if (this.IS_SIMPLE) {
|
|
|
|
- if (this.quesAnswer > optionCount) this.quesAnswer = null;
|
|
|
|
- } else {
|
|
|
|
- this.quesAnswer = this.quesAnswer.filter((item) => item <= optionCount);
|
|
|
|
|
|
+ if (this.IS_SIMPLE && this.quesAnswer > optionCount) {
|
|
|
|
+ this.quesAnswer = null;
|
|
}
|
|
}
|
|
this.answerChange();
|
|
this.answerChange();
|
|
},
|
|
},
|
|
answerChange() {
|
|
answerChange() {
|
|
- this.modalForm.quesAnswer = this.IS_SIMPLE
|
|
|
|
- ? [this.quesAnswer]
|
|
|
|
- : this.quesAnswer;
|
|
|
|
|
|
+ if (this.IS_SIMPLE) {
|
|
|
|
+ this.modalForm.quesAnswer = this.quesAnswer ? [this.quesAnswer] : [];
|
|
|
|
+ } else {
|
|
|
|
+ this.quesAnswer = this.modalForm.quesOptions
|
|
|
|
+ .filter((item) => item.isCorrect)
|
|
|
|
+ .map((item) => item.number);
|
|
|
|
+ this.modalForm.quesAnswer = this.quesAnswer;
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ questionInfoChange(questionInfo) {
|
|
|
|
+ this.modalForm = Object.assign({}, this.modalForm, questionInfo);
|
|
},
|
|
},
|
|
validate() {
|
|
validate() {
|
|
return this.$refs.modalFormComp.validate();
|
|
return this.$refs.modalFormComp.validate();
|
|
},
|
|
},
|
|
|
|
+ getData() {
|
|
|
|
+ return this.modalForm;
|
|
|
|
+ },
|
|
},
|
|
},
|
|
};
|
|
};
|
|
</script>
|
|
</script>
|