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