代码调整

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

View File

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