代码调整

This commit is contained in:
dong 2022-10-17 14:04:56 +08:00
parent 99792cd58f
commit fe9bf9b495
2 changed files with 47 additions and 18 deletions

View File

@ -39,7 +39,7 @@ export default {
type: 'select', type: 'select',
label: '类 型', label: '类 型',
config: { config: {
data: this.$ConstSelect.QuestionTypeList data: this.$ConstSelect.QuestionTypeList.filter(item => { return !['fill', 'answer'].includes(item.value); })
} }
}, },
topic: { topic: {
@ -63,7 +63,8 @@ export default {
columns: [ columns: [
{ {
title: '题 目', title: '题 目',
prop: 'topic' prop: 'topic',
type: 'html'
}, },
{ {
title: '标 签', title: '标 签',

View File

@ -1,13 +1,14 @@
<template> <template>
<el-dialog v-dialogDrag :close-on-click-moda="false" :title="title" :visible.sync="show" width="860px" :close-on-click-modal="false" :before-close="doClose"> <el-dialog v-dialogDrag :close-on-click-moda="false" :title="title" :visible.sync="show" width="860px" :close-on-click-modal="false" :before-close="doClose">
<div class="ql-editor" v-html="$escapeHTML(` : ${form.topic}`)" /> <div class="ql-editor" v-html="$escapeHTML(`${mapType[type] || ''} : ${form.topic}`)" />
<template v-if="checkType(form, 'judge')"> <template v-if="checkType(form, 'judge')">
<div class="answer"> <div class="answer">
: :
<el-radio-group v-model="active"> <div>
<el-radio :label="0"> </el-radio> <el-radio-group v-model="active">
<el-radio :label="1"> × </el-radio> <el-radio v-for="(el,i) in options" :key="i" class="option" :label="el.id"> {{ el.content }} </el-radio>
</el-radio-group> </el-radio-group>
</div>
</div> </div>
</template> </template>
@ -18,9 +19,11 @@
</div> </div>
<div class="answer"> <div class="answer">
: :
<el-radio-group v-model="active"> <div>
<el-radio v-for="(el,i) in options" :key="i" :label="el.id"> {{ $asc2chart(65+i) }} </el-radio> <el-radio-group v-model="active">
</el-radio-group> <el-radio v-for="(el,i) in options" :key="i" class="option" :label="el.id"> {{ $asc2chart(65+i) }} </el-radio>
</el-radio-group>
</div>
</div> </div>
</template> </template>
<template v-else-if="checkType(form, 'multi')"> <template v-else-if="checkType(form, 'multi')">
@ -31,7 +34,7 @@
<div class="answer"> <div class="answer">
: :
<el-checkbox-group v-model="active"> <el-checkbox-group v-model="active">
<el-checkbox v-for="(el,i) in options" :key="i" :label="el.id">{{ $asc2chart(65+i) }} </el-checkbox> <el-checkbox v-for="(el,i) in options" :key="i" class="option" :label="el.id">{{ $asc2chart(65+i) }} </el-checkbox>
</el-checkbox-group> </el-checkbox-group>
</div> </div>
</template> </template>
@ -47,9 +50,14 @@
<template v-else-if="checkType(form, 'answer')"> <template v-else-if="checkType(form, 'answer')">
<div class="answer"> <div class="answer">
: :
<el-input v-model="active" type="textarea" :autosize="{ minRows: 2, maxRows: 4}" placeholder="请输入答案" /> <div>
<el-input v-model="active" type="textarea" :autosize="{ minRows: 2, maxRows: 4}" placeholder="请输入答案" />
</div>
</div> </div>
</template> </template>
<div v-if="showAnswer" class="show-answer">
<span :class="isCorrect? 'correct': 'error'">{{ isCorrect ? '答案正确!' : '答案错误!' }}</span>
</div>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button @click="submit(true)">提交</el-button> <el-button @click="submit(true)">提交</el-button>
<el-button @click="show = false">关闭</el-button> <el-button @click="show = false">关闭</el-button>
@ -71,6 +79,8 @@ export default {
return { return {
active: '', active: '',
show: false, show: false,
showAnswer: false,
isCorrect: false,
form: { form: {
type: '', type: '',
optionList: [] optionList: []
@ -86,10 +96,19 @@ export default {
}, },
type() { type() {
return this.form.type; return this.form.type;
},
mapType() {
const obj = {};
const list = this.$ConstSelect.QuestionTypeList;
list.forEach(item => {
obj[item.value] = item.label;
});
return obj;
} }
}, },
watch: { watch: {
questionId(val) { questionId(val) {
this.showAnswer = false;
this.getQuestionInfo(); this.getQuestionInfo();
}, },
type(val) { type(val) {
@ -131,13 +150,10 @@ export default {
} }
testAnswer(this.questionId, data).then(res => { testAnswer(this.questionId, data).then(res => {
if (val) { if (val) {
if (res.data) { this.showAnswer = true;
this.$message.success('答案正确!'); this.isCorrect = res.data;
} else {
this.$message.warning('答案错误!');
}
} }
this.doClose(); // this.doClose();
}).catch(err => { }).catch(err => {
console.log(err, '===err===='); console.log(err, '===err====');
}); });
@ -159,4 +175,16 @@ export default {
color: #000; color: #000;
padding-left: 15px; padding-left: 15px;
} }
.show-answer {
padding: 15px;
span {
font-size: 18px;
}
.correct {
color: green;
}
.error {
color: red;
}
}
</style> </style>