diff --git a/src/views/projectFront/safetyEducation/addCourse.vue b/src/views/projectFront/safetyEducation/addCourse.vue index 115de8d3..3707c0b8 100644 --- a/src/views/projectFront/safetyEducation/addCourse.vue +++ b/src/views/projectFront/safetyEducation/addCourse.vue @@ -178,7 +178,7 @@ { + if(item.correctType == 1){ + item.correctType = 2 + } + }) correctOne = 1 data.optionList[index].correctType=1 } diff --git a/src/views/projectLevel/wifiEducation/educationOutline.vue b/src/views/projectLevel/wifiEducation/educationOutline.vue index d6c17cc4..2cb52382 100644 --- a/src/views/projectLevel/wifiEducation/educationOutline.vue +++ b/src/views/projectLevel/wifiEducation/educationOutline.vue @@ -281,7 +281,6 @@ export default { justify-content: center; .cancel_btn{ margin-right: 80px; - color: #fff; background: transparent; } } diff --git a/src/views/projectLevel/wifiEducation/educationQuestions.vue b/src/views/projectLevel/wifiEducation/educationQuestions.vue index 89845120..5882d1f3 100644 --- a/src/views/projectLevel/wifiEducation/educationQuestions.vue +++ b/src/views/projectLevel/wifiEducation/educationQuestions.vue @@ -6,12 +6,10 @@ 新增
- + - +
@@ -120,22 +118,74 @@
- + - + + + + + + + + + + + + + + + + + + + + + + 新增选项 @@ -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; } }