From 1a20c2e9aaff9439ce9ce2c795d0b63c01176e7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AA=86=E4=B9=90?= <342503599@qq.com> Date: Thu, 29 Sep 2022 15:34:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=89=E5=85=A8=E6=95=99=E8=82=B2(wifi?= =?UTF-8?q?=E5=AE=89=E5=85=A8=E6=95=99=E8=82=B2):=E5=8D=95=E9=80=89?= =?UTF-8?q?=E5=A4=9A=E9=80=89=E8=AF=95=E9=A2=98=E5=8C=BA=E5=88=86=E4=BB=A5?= =?UTF-8?q?=E5=8F=8A=E7=BC=96=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../safetyEducation/addCourse.vue | 13 +- .../wifiEducation/educationOutline.vue | 1 - .../wifiEducation/educationQuestions.vue | 118 +++++++++++++++--- 3 files changed, 107 insertions(+), 25 deletions(-) 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; } }