安全教育(wifi安全教育):单选多选试题区分以及编辑
This commit is contained in:
parent
5a9d0f4059
commit
1a20c2e9aa
@ -178,7 +178,7 @@
|
||||
<!-- 单选 -->
|
||||
<el-radio-group v-model="radio1" v-if="radioShow" @change="checkedVal">
|
||||
<el-form-item
|
||||
prop="lsit"
|
||||
prop="list"
|
||||
v-for="(item, index) in addEditForm.optionList"
|
||||
:key="index"
|
||||
v-show="addEditForm.questionType != '2'"
|
||||
@ -201,7 +201,7 @@
|
||||
<!-- 多选 -->
|
||||
<el-form-item
|
||||
:label="'A、'"
|
||||
prop="lsit"
|
||||
prop="list"
|
||||
v-for="(item, index) in addEditForm.optionList"
|
||||
:key="index"
|
||||
v-show="addEditForm.questionType == '2'"
|
||||
@ -424,7 +424,7 @@ export default {
|
||||
searchName:'',
|
||||
pageNo:1,
|
||||
pageSize:10,
|
||||
recordsTotal:0
|
||||
recordsTotal:0,
|
||||
};
|
||||
},
|
||||
mounted(){
|
||||
@ -576,7 +576,7 @@ export default {
|
||||
|
||||
},
|
||||
checkedVal(val){
|
||||
// console.log('当前选择的值',val)
|
||||
console.log('当前选择的值',val)
|
||||
console.log('当前绑定的值',this.radio1)
|
||||
},
|
||||
saveQuesFn() {
|
||||
@ -598,6 +598,11 @@ export default {
|
||||
return;
|
||||
}
|
||||
if(index === this.radio1){
|
||||
optionList.find((item)=>{
|
||||
if(item.correctType == 1){
|
||||
item.correctType = 2
|
||||
}
|
||||
})
|
||||
correctOne = 1
|
||||
data.optionList[index].correctType=1
|
||||
}
|
||||
|
||||
@ -281,7 +281,6 @@ export default {
|
||||
justify-content: center;
|
||||
.cancel_btn{
|
||||
margin-right: 80px;
|
||||
color: #fff;
|
||||
background: transparent;
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,12 +6,10 @@
|
||||
<el-button v-if="pageType=='company'" type="primary" icon="el-icon-plus" size="small" @click="showAdd" >新增</el-button>
|
||||
</div>
|
||||
<div class="educationQuestions_table">
|
||||
<vue-scroll style="height: 100%">
|
||||
<!-- <vue-scroll style="height: 100%"> -->
|
||||
<el-table class="tables"
|
||||
:data="tableData"
|
||||
ref="refTable"
|
||||
style="width: 100%"
|
||||
height="100%"
|
||||
@cell-click="expandChange">
|
||||
<el-table-column type="expand" width="0">
|
||||
<template slot-scope="props">
|
||||
@ -80,7 +78,7 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</vue-scroll>
|
||||
<!-- </vue-scroll> -->
|
||||
</div>
|
||||
<div class="list-pagination">
|
||||
<div class="pagination-sizes">
|
||||
@ -120,22 +118,74 @@
|
||||
<div slot="content" class="dialog-content">
|
||||
<vue-scroll style="height: 580px; margin-bottom: 40px">
|
||||
<el-form class="add_form" ref="add_form" :rules="rules" size="medium" label-width="120px" label-position="right" :model="addFormData">
|
||||
<el-form-item label="试题类型" prop="questionType">
|
||||
<!-- <el-form-item label="试题类型" prop="questionType"> -->
|
||||
<!-- <el-input style="width: 292px" v-model="addFormData.type" disabled></el-input> -->
|
||||
<el-select v-model="addFormData.questionType" style="width: 100%;" placeholder="请选择">
|
||||
<!-- <el-select v-model="addFormData.questionType" style="width: 100%;" placeholder="请选择">
|
||||
<el-option
|
||||
v-for="item in selectOptions"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value">
|
||||
</el-option>
|
||||
</el-select> -->
|
||||
<!-- </el-form-item> -->
|
||||
<el-form-item :label="$t('message.safetyEducation.testQuestionType')" prop="questionType">
|
||||
<el-select v-model="addFormData.questionType" placeholder="试题类型">
|
||||
<!-- 单选题 -->
|
||||
<el-option :label="$t('message.safetyEducation.singleChoice')" :value="'1'"></el-option>
|
||||
<!-- 多选题 -->
|
||||
<el-option :label="$t('message.safetyEducation.multipleChoice')" :value="'2'"> </el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="试题名称" prop="questionName">
|
||||
<el-input type="textarea" resize="none" :rows="3" v-model="addFormData.questionName" placeholder="请输入试题名称"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item :label="'试题选项及答案:'"> </el-form-item>
|
||||
<!-- 单选 -->
|
||||
<el-radio-group v-model="radio1" v-if="radioShow">
|
||||
<el-form-item
|
||||
prop="list"
|
||||
v-for="(item, index) in addFormData.optionList"
|
||||
:key="index"
|
||||
v-show="addFormData.questionType != '2'"
|
||||
>
|
||||
<template slot="label">
|
||||
<p>
|
||||
<el-radio :label="index"
|
||||
:value="item.correctType"
|
||||
>{{ indexList[index] }}、</el-radio
|
||||
>
|
||||
</p>
|
||||
</template>
|
||||
<el-input
|
||||
v-model="item.optionName"
|
||||
:placeholder="$t('message.workType.placeholder')"
|
||||
></el-input>
|
||||
<i class="el-icon-remove" @click="removeOptions(index)"></i>
|
||||
</el-form-item>
|
||||
</el-radio-group>
|
||||
<!-- 多选 -->
|
||||
<el-form-item
|
||||
:label="'A、'"
|
||||
prop="list"
|
||||
v-for="(item, index) in addFormData.optionList"
|
||||
:key="index"
|
||||
v-show="addFormData.questionType == '2'"
|
||||
>
|
||||
<template slot="label">
|
||||
<p>
|
||||
<el-checkbox :value="item.correctType" v-model="item.correctType"
|
||||
>{{ indexList[index] }}、</el-checkbox
|
||||
>
|
||||
</p>
|
||||
</template>
|
||||
<el-input
|
||||
v-model="item.optionName"
|
||||
:placeholder="$t('message.workType.placeholder')"
|
||||
></el-input>
|
||||
<i class="el-icon-remove" @click="removeOptions(index)"></i>
|
||||
</el-form-item>
|
||||
<!-- <el-form-item
|
||||
:label="'A、'"
|
||||
prop="lsit"
|
||||
v-for="(item, index) in addFormData.optionList"
|
||||
@ -153,7 +203,7 @@
|
||||
placeholder="请输入"
|
||||
></el-input>
|
||||
<i class="el-icon-remove" @click="removeOptions(index)"></i>
|
||||
</el-form-item>
|
||||
</el-form-item> -->
|
||||
<el-form-item :label="''">
|
||||
<el-button type="primary" plain size="medium" @click="addOptions">新增选项</el-button>
|
||||
</el-form-item>
|
||||
@ -182,6 +232,8 @@ export default {
|
||||
},
|
||||
data(){
|
||||
return{
|
||||
radioShow:true,
|
||||
radio1:-1,
|
||||
searchTitle: "",
|
||||
tableData: [],
|
||||
indexList: [
|
||||
@ -226,7 +278,7 @@ export default {
|
||||
label: "多选"
|
||||
}],
|
||||
addFormData:{
|
||||
questionType: 1,
|
||||
questionType: "",
|
||||
questionName: "",
|
||||
questionAnalysis: "",
|
||||
questionScore:"",
|
||||
@ -290,7 +342,6 @@ export default {
|
||||
},
|
||||
//保存试题信息
|
||||
submitData(){
|
||||
|
||||
this.$refs["add_form"].validate((valid) => {
|
||||
if (valid) {
|
||||
var data = JSON.parse(JSON.stringify(this.addFormData))
|
||||
@ -300,11 +351,21 @@ export default {
|
||||
return;
|
||||
}
|
||||
var correctNum = 0
|
||||
var correctOne = 0
|
||||
optionList.forEach((element,index) => {
|
||||
if(element.optionName==''){
|
||||
this.$message.error('请输入选项内容')
|
||||
return;
|
||||
}
|
||||
if(index === this.radio1){
|
||||
optionList.find((item)=>{
|
||||
if(item.correctType == 1){
|
||||
item.correctType = 2
|
||||
}
|
||||
})
|
||||
correctOne = 1
|
||||
data.optionList[index].correctType=1
|
||||
}
|
||||
if(element.correctType===true||element.correctType===1){
|
||||
data.optionList[index].correctType=1
|
||||
correctNum++
|
||||
@ -313,11 +374,11 @@ export default {
|
||||
}
|
||||
});
|
||||
console.log(data)
|
||||
if(data.questionType==1&&correctNum==0){
|
||||
if(data.questionType==1&&correctNum==0&&correctOne==0){
|
||||
this.$message.error('请选中正确选项')
|
||||
return;
|
||||
}
|
||||
if(data.questionType==1&&correctNum>1){
|
||||
if(data.questionType==1&&correctOne>1){
|
||||
this.$message.error('正确选项只能是1个')
|
||||
return;
|
||||
}
|
||||
@ -325,6 +386,9 @@ export default {
|
||||
this.$message.error('正确选项必须大于1个')
|
||||
return;
|
||||
}
|
||||
this.radio1=-1
|
||||
this.showDialog = false
|
||||
// this.computeTotalScore()
|
||||
if (this.isAdd) {
|
||||
data.type=2
|
||||
data.libraryId=this.libraryId
|
||||
@ -366,17 +430,31 @@ export default {
|
||||
this.isAdd=false
|
||||
this.$nextTick(()=>{
|
||||
this.addFormData=JSON.parse(JSON.stringify(row))
|
||||
|
||||
var optionList=this.addFormData.optionlist
|
||||
this.addFormData.optionList=optionList
|
||||
// this.questionIndex=index
|
||||
optionList.forEach((element,index2) => {
|
||||
if(element.correctType==1){
|
||||
this.addFormData.optionList[index2].correctType=true
|
||||
}else{
|
||||
this.addFormData.optionList[index2].correctType=false
|
||||
}
|
||||
});
|
||||
// 多选的回显
|
||||
if(row.questionType == 2){
|
||||
optionList.forEach((element,index) => {
|
||||
if(element.correctType==1){
|
||||
this.addEditForm.optionList[index].correctType=true
|
||||
}else{
|
||||
this.addEditForm.optionList[index].correctType=false
|
||||
}
|
||||
});
|
||||
}else{
|
||||
optionList.forEach((item,index) => {
|
||||
if(item.correctType==1){
|
||||
this.radioShow =false
|
||||
this.$nextTick(()=>{
|
||||
this.radio1 = index
|
||||
this.radioShow = true
|
||||
})
|
||||
}else{
|
||||
this.radio1 = -1
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
handleDelete(index, row) {
|
||||
@ -497,6 +575,7 @@ export default {
|
||||
}
|
||||
.educationQuestions_table{
|
||||
height: 75%;
|
||||
width:100%;
|
||||
// height: 560px;
|
||||
.answers{
|
||||
display: flex;
|
||||
@ -648,7 +727,6 @@ export default {
|
||||
justify-content: center;
|
||||
.cancel_btn{
|
||||
margin-right: 80px;
|
||||
color: #fff;
|
||||
background: transparent;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user