|
@@ -7,7 +7,10 @@
|
|
|
label-width="100px"
|
|
|
>
|
|
|
<el-form-item prop="quesBody" label="题干">
|
|
|
- <v-editor v-model="modalForm.quesBody"></v-editor>
|
|
|
+ <v-editor
|
|
|
+ v-model="modalForm.quesBody"
|
|
|
+ @change="quesBodyChange"
|
|
|
+ ></v-editor>
|
|
|
</el-form-item>
|
|
|
<el-form-item
|
|
|
v-for="(option, oindex) in modalForm.quesOptions"
|
|
@@ -21,6 +24,7 @@
|
|
|
v-if="IS_SIMPLE"
|
|
|
v-model="quesAnswer"
|
|
|
:label="option.number"
|
|
|
+ @change="answerChange"
|
|
|
>
|
|
|
{{ (option.number - 1) | optionOrderWordFilter }}
|
|
|
</el-radio>
|
|
@@ -34,7 +38,10 @@
|
|
|
</el-checkbox>
|
|
|
</div>
|
|
|
<div class="option-body">
|
|
|
- <v-editor v-model="option.body"></v-editor>
|
|
|
+ <v-editor
|
|
|
+ v-model="option.body"
|
|
|
+ @change="() => optionBodyChange(oindex)"
|
|
|
+ ></v-editor>
|
|
|
</div>
|
|
|
<div class="option-delete">
|
|
|
<el-button
|
|
@@ -43,7 +50,7 @@
|
|
|
type="primary"
|
|
|
icon="el-icon-plus"
|
|
|
title="新增"
|
|
|
- @click.prevent="addQuesOption(index)"
|
|
|
+ @click.prevent="addQuesOption(oindex)"
|
|
|
></el-button>
|
|
|
<el-button
|
|
|
size="mini"
|
|
@@ -51,7 +58,8 @@
|
|
|
type="danger"
|
|
|
icon="el-icon-delete"
|
|
|
title="删除"
|
|
|
- @click.prevent="removeQuesOption(index)"
|
|
|
+ :disabled="deleleDisabled"
|
|
|
+ @click.prevent="removeQuesOption(oindex)"
|
|
|
></el-button>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -143,7 +151,7 @@ export default {
|
|
|
},
|
|
|
optionRule: {
|
|
|
validator: (rule, value, callback) => {
|
|
|
- if (!value || !value.length) {
|
|
|
+ if (!value || isAnEmptyRichText(value)) {
|
|
|
return callback(new Error(`请输入选项内容`));
|
|
|
}
|
|
|
callback();
|
|
@@ -163,13 +171,15 @@ export default {
|
|
|
.map((value) => String.fromCharCode(64 + value))
|
|
|
.join("");
|
|
|
},
|
|
|
+ deleleDisabled() {
|
|
|
+ return this.modalForm.quesOptions.length === 1;
|
|
|
+ },
|
|
|
},
|
|
|
created() {
|
|
|
this.initData();
|
|
|
},
|
|
|
methods: {
|
|
|
initData() {
|
|
|
- console.log("11");
|
|
|
this.modalForm = this.$objAssign(
|
|
|
getInitQuestionModel("SINGLE_ANSWER_QUESTION"),
|
|
|
this.question
|
|
@@ -193,21 +203,29 @@ export default {
|
|
|
this.resetNumberAndSaveOptions();
|
|
|
},
|
|
|
removeQuesOption(index) {
|
|
|
+ if (this.deleleDisabled) return;
|
|
|
this.modalForm.quesOptions.splice(index, 1);
|
|
|
this.resetNumberAndSaveOptions();
|
|
|
},
|
|
|
resetNumberAndSaveOptions() {
|
|
|
- this.modalForm.quesOptions = this.modalForm.quesOptions.forEach(
|
|
|
- (option, index) => {
|
|
|
- option.number = index + 1;
|
|
|
- }
|
|
|
- );
|
|
|
+ this.modalForm.quesOptions.forEach((option, index) => {
|
|
|
+ option.number = index + 1;
|
|
|
+ });
|
|
|
const optionCount = this.modalForm.quesOptions.length;
|
|
|
if (this.IS_SIMPLE && this.quesAnswer > optionCount) {
|
|
|
this.quesAnswer = null;
|
|
|
}
|
|
|
this.answerChange();
|
|
|
},
|
|
|
+ quesBodyChange() {
|
|
|
+ this.$refs.modalFormComp.validateField(`quesBody`, () => {});
|
|
|
+ },
|
|
|
+ optionBodyChange(oindex) {
|
|
|
+ this.$refs.modalFormComp.validateField(
|
|
|
+ `quesOptions.${oindex}.body`,
|
|
|
+ () => {}
|
|
|
+ );
|
|
|
+ },
|
|
|
answerChange() {
|
|
|
if (this.IS_SIMPLE) {
|
|
|
this.modalForm.quesAnswer = this.quesAnswer ? [this.quesAnswer] : [];
|
|
@@ -217,6 +235,7 @@ export default {
|
|
|
.map((item) => item.number);
|
|
|
this.modalForm.quesAnswer = this.quesAnswer;
|
|
|
}
|
|
|
+ this.$refs.modalFormComp.validateField(`quesAnswer`, () => {});
|
|
|
},
|
|
|
questionInfoChange(questionInfo) {
|
|
|
this.modalForm = Object.assign({}, this.modalForm, questionInfo);
|