From 25d3f18c8a473fd7d80677ec95fb3cc2be5d0562 Mon Sep 17 00:00:00 2001 From: chen <2659004835@qq.com> Date: Sat, 5 Mar 2022 16:42:19 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=91=E7=9B=AE=E9=80=89=E6=8B=A9=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/user/information/index.vue | 119 +++++++++++++++++++-------- 1 file changed, 83 insertions(+), 36 deletions(-) diff --git a/src/views/user/information/index.vue b/src/views/user/information/index.vue index b4b48a1..81b57ef 100644 --- a/src/views/user/information/index.vue +++ b/src/views/user/information/index.vue @@ -61,7 +61,7 @@ -
确认
+
确认
@@ -213,7 +213,6 @@ that.getSubjectArray(); }); }, - // 获取考试时间 getDate(){ const date = new Date(); @@ -226,7 +225,6 @@ this.dateArray = newArray; this.dateValue = this.dateArray[this.dateIndex]; }, - // 城市选择 openAddr(){ this.isAddr=!this.isAddr; @@ -234,12 +232,12 @@ getAddrValue(index,item){ this.addrValue = item.code; this.addrIndex = index; - this.isAddr=false; + this.isAddr = false; + // 每次选择城市----清空待提交科目id数组 + this.temporaryCode = []; // 查询科目 this.getSubjectArray(); - console.log(this.addrData[this.addrIndex],3636) }, - // 选择性别 openSex(){ this.isSex=!this.isSex; @@ -249,7 +247,6 @@ this.sexIndex = index; this.isSex=false; }, - // 选择时间 openDate(){ this.isDate=!this.isDate; @@ -259,7 +256,6 @@ this.dateIndex = index; this.isDate=false; }, - //选择考生类别 openCategory(){ this.isCategory=!this.isCategory; @@ -269,8 +265,6 @@ this.categoryIndex = index; this.isCategory=false; }, - - // 获取选科组合列表 getSubjectArray() { let that = this; @@ -298,34 +292,87 @@ that.subjectArray =newArray; }); }, - // 选科组合选择事件 - onChange(index,number) { - // let that = this; - let id = number; - let indexes = index + 1; - console.log(indexes,id,123) - }, - - - - // 获取考生信息 - getStudentInfo() { - let that =this; - let data = { - student_name: that.studentName,//姓名 - student_gender: that.sexIndex==0 ? 1 : 2,//性别 - student_native: that.addrData[that.addrIndex].code, //考籍(省级)编号 - student_native_str: that.addrData[that.addrIndex].name,//考籍(省级)名称 - // student_subject: this.temporaryCode.join(','),//选科组合(选科ID,多个用英文逗号分割) - student_exam_year: that.dateValue,//高考年份 - is_art: that.dateIndex==1?1:0,//是否是艺考生 - is_PE:that.dateIndex==2?1:0,//是否是体考生 - achievement_expect: that.achievementExpect,//预估或模考成绩 - province_ranking: that.provinceRanking,//预估/省内排名 - achievement_high: '',//高考成绩,-1表示未考(用户留空时默认传值为-1) + onChange(index,subId) { + let existSubid = this.temporaryCode.indexOf(subId); + let existsubIndex = this.subjectArray.findIndex(item=>item.id==subId); + console.log(existSubid,existsubIndex,299); + if(this.addrData[this.addrIndex].subject_max!=1){ + // 多选 + if(this.temporaryCode.length < this.addrData[this.addrIndex].subject_max){ + // 没有超过限制选择的科目数量 + if(existSubid==-1){ + if(this.addrData[this.addrIndex].subject_radio_group_list.length) { + // 存在限制的科目id + let limitSubid = this.addrData[this.addrIndex].subject_radio_group_list[0].findIndex(item=>item==subId); + let date = this.temporaryCode.findIndex(item => this.addrData[this.addrIndex].subject_radio_group_list[0].indexOf(item) > -1) + if(limitSubid!=-1 && date!=-1){ + // 待提交科目数组id存在限制科目的id + console.log('选择科目冲突'); + } else { + // 待提交科目数组id不存在限制科目的id + this.subjectArray[index].isActive = !this.subjectArray[index].isActive; + this.setSubList(index,subId); + } + } else { + // 不存在限制的科目的id + this.subjectArray[index].isActive = !this.subjectArray[index].isActive; + this.setSubList(index,subId); + } + } else { + this.temporaryCode.splice(existSubid,1); + this.subjectArray[existsubIndex].isActive = false; + } + } else { + // 超过了限制选择科目的数量 + if(existSubid!=-1){ + // 如果选中的科目id在待提交的数组里存在,则删除当前选中的科目 + this.temporaryCode.splice(existSubid,1); + this.subjectArray[existsubIndex].isActive = false; + } else { + console.log('提示框:xxxx'); + } + } + } else { + // 单选 + + // 清空暂存编号 + this.temporaryCode = []; + // 取消所有选中项 + this.subjectArray.forEach(item=>{item.isActive = false;}) + // 调用设置科目列表事件 + this.setSubList(index,subId); + } + }, + // 设置科目列表事件 + setSubList(index,id){ + // 设置选中项 + this.subjectArray[index].isActive = true; + // 储存选中项的id到待提交数组里 + this.temporaryCode.push(id); + console.log(this.temporaryCode,'数据'); + }, + // 获取考生信息 + setStudentInfo() { + let that =this; + if(this.temporaryCode.length != this.addrData[this.addrIndex].subject_max){ + console.log('弹框提示,必须选择多少个科目'); + } else { + let data = { + student_name: that.studentName,//姓名 + student_gender: that.sexIndex==0 ? 1 : 2,//性别 + student_native: that.addrData[that.addrIndex].code, //考籍(省级)编号 + student_native_str: that.addrData[that.addrIndex].name,//考籍(省级)名称 + // student_subject: this.temporaryCode.join(','),//选科组合(选科ID,多个用英文逗号分割) + student_exam_year: that.dateValue,//高考年份 + is_art: that.dateIndex==1?1:0,//是否是艺考生 + is_PE:that.dateIndex==2?1:0,//是否是体考生 + achievement_expect: that.achievementExpect,//预估或模考成绩 + province_ranking: that.provinceRanking,//预估/省内排名 + achievement_high: '',//高考成绩,-1表示未考(用户留空时默认传值为-1) + } + console.log(data) } - console.log(data) // let that = this; // this.axios // .post(this.HOME + "/api/area/index", {