From fbcf4facd08a3d1f4890f1e1c32a2ccb6ff79b52 Mon Sep 17 00:00:00 2001 From: "li.yuetong" Date: Tue, 5 Jul 2022 16:21:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=A1=E5=8D=95=EF=BC=8C=E7=94=B5=E6=8A=95?= =?UTF-8?q?=E8=A2=AB=E4=BF=9D=E4=BA=BA=E5=92=8C=E5=8F=97=E7=9B=8A=E4=BA=BA?= =?UTF-8?q?=EF=BC=8C=E5=AE=A2=E6=88=B7=E5=88=97=E8=A1=A8=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E6=97=B6=EF=BC=8C=E5=87=BA=E7=94=9F=E8=AF=81?= =?UTF-8?q?=E8=AF=81=E4=BB=B6=E5=8F=B7=E5=8F=AA=E8=83=BD=E6=98=AF=E7=94=B1?= =?UTF-8?q?=E6=95=B0=E5=AD=97=E5=AD=97=E6=AF=8D=E7=BB=84=E5=90=88=EF=BC=8C?= =?UTF-8?q?=E8=BA=AB=E4=BB=BD=E8=AF=81=E5=92=8C=E6=88=B7=E5=8F=A3=E6=9C=AC?= =?UTF-8?q?=E8=AF=81=E4=BB=B6=E5=8F=B7=E6=A0=A1=E9=AA=8C=E8=A7=84=E5=88=99?= =?UTF-8?q?=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/js/utils/idNoCheck.js | 6 ++ src/components/ebiz/customer/formBlock.vue | 51 +++++++++- src/views/ebiz/cardList/information.vue | 112 ++++++++++++++++++++- src/views/ebiz/sale/AddBeneficiaryInfo.vue | 5 + src/views/ebiz/sale/InsuredPerson.vue | 5 + 5 files changed, 177 insertions(+), 2 deletions(-) diff --git a/src/assets/js/utils/idNoCheck.js b/src/assets/js/utils/idNoCheck.js index 6902d9550..711020fc1 100644 --- a/src/assets/js/utils/idNoCheck.js +++ b/src/assets/js/utils/idNoCheck.js @@ -9,6 +9,12 @@ const idNoCheck = { return false }, + isCardNoBirth: function(card) { + //出生证证件号由数字字母组合 + var reg = /(^[a-zA-Z0-9]{5,17}$)/ + return reg.test(card) + }, + isCardNo: function(card) { //身份证号码为15位或者18位,15位时全为数字,18位前17位为数字,最后一位是校验位,可能为数字或字符X var reg = /(^\d{17}(\d|X)$)/ diff --git a/src/components/ebiz/customer/formBlock.vue b/src/components/ebiz/customer/formBlock.vue index a36a3a65b..2599448fb 100644 --- a/src/components/ebiz/customer/formBlock.vue +++ b/src/components/ebiz/customer/formBlock.vue @@ -407,6 +407,49 @@ export default { } //证件是户口本 } else if (this.userInfo.idType == '2') { + if (this.userInfo.nativeplace != '1') { + return this.$toast('证件类型”为“身份证,国籍必须为中国哦') + } + //校验性别是否与身份证号码位相符 + if (this.userInfo.idNo.length == '15') { + //15位身份证第15位是性别位, 奇男偶女 + let sexSign = this.userInfo.idNo.substr(14, 1) + if ((parseInt(sexSign) % 2 == 0 && this.userInfo.sex != 1) || (parseInt(sexSign) % 2 != 0 && this.userInfo.sex != 0)) { + return this.$toast('性别录入与身份证不符') + } + + //15位身份证第7-12位是生日位, 年月日 + let birthSign = this.userInfo.idNo.substr(6, 6) + if ( + this.userInfo.birthday.substr(2, 2) != birthSign.substr(0, 2) || + this.userInfo.birthday.substr(5, 2) != birthSign.substr(2, 2) || + this.userInfo.birthday.substr(8, 2) != birthSign.substr(4, 2) + ) { + return this.$toast('生日录入与身份证不符') + } + } else if (this.userInfo.idNo.length == '18') { + //18位身份证第17位是性别位, 奇男偶女 + let sexSign = this.userInfo.idNo.substr(16, 1) + if ((parseInt(sexSign) % 2 == 0 && this.userInfo.sex != 1) || (parseInt(sexSign) % 2 != 0 && this.userInfo.sex != 0)) { + return this.$toast('性别录入与身份证不符') + } + + //18位身份证第7-14位是生日位, 年月日 + let birthSign = this.userInfo.idNo.substr(6, 8) + if ( + this.userInfo.birthday.substr(0, 4) != birthSign.substr(0, 4) || + this.userInfo.birthday.substr(5, 2) != birthSign.substr(4, 2) || + this.userInfo.birthday.substr(8, 2) != birthSign.substr(6, 2) + ) { + return this.$toast('生日录入与身份证不符') + } + } + + // 证件号码规则校验 + if (!idNoCheck.isIdno(this.userInfo.idNo)) { + console.log('证件号码校验有误') + return this.$toast('您填写的证件号码有误') + } if (age > 16) { return this.$toast('客户年龄在16周岁以上,不能使用户口本作为有效证件') } @@ -421,6 +464,11 @@ export default { if (age >= 2) { return this.$toast('客户年龄在2周岁及以上,不能使用出生证作为有效证件') } + // 证件号码规则校验 + if (!idNoCheck.isCardNoBirth(this.userInfo.idNo)) { + console.log('证件号码校验有误') + return this.$toast('您填写的证件号码有误') + } // else if (this.userInfo.customerIdNumber.length < 3) { // return this.$toast('出生证须大于等于3个字符') // } @@ -662,7 +710,8 @@ export default { } }, getRelatedData(val) { - if (this.userInfo.idType != '1') { + //客户列表新增时,身份证和户口本证件号校验规则一致 + if (this.userInfo.idType != '1' && this.userInfo.idType != '2' ) { return } //如果证件校验不通过,恢复默认值 diff --git a/src/views/ebiz/cardList/information.vue b/src/views/ebiz/cardList/information.vue index 87c77b23a..3e65fd327 100644 --- a/src/views/ebiz/cardList/information.vue +++ b/src/views/ebiz/cardList/information.vue @@ -1743,10 +1743,61 @@ export default { return this.$toast('证件有效期不正常,26周岁至45周岁公民身份证有效期应小于等于20年') } } + //如果证件类型是户口本 + }else if(this.userInfo.idType == '2'){ + if (this.userInfo.nativeplace != '1') { + return this.$toast('证件类型”为“身份证,国籍必须为中国哦') + } + //校验性别是否与身份证号码位相符 + if (this.userInfo.idNo.length == '15') { + //15位身份证第15位是性别位, 奇男偶女 + let sexSign = this.userInfo.idNo.substr(14, 1) + if ((parseInt(sexSign) % 2 == 0 && this.userInfo.sex != 1) || (parseInt(sexSign) % 2 != 0 && this.userInfo.sex != 0)) { + return this.$toast('性别录入与身份证不符') + } + + //15位身份证第7-12位是生日位, 年月日 + let birthSign = this.userInfo.idNo.substr(6, 6) + if ( + this.userInfo.birthday.substr(2, 2) != birthSign.substr(0, 2) || + this.userInfo.birthday.substr(5, 2) != birthSign.substr(2, 2) || + this.userInfo.birthday.substr(8, 2) != birthSign.substr(4, 2) + ) { + return this.$toast('生日录入与身份证不符') + } + } else if (this.userInfo.idNo.length == '18') { + //18位身份证第17位是性别位, 奇男偶女 + let sexSign = this.userInfo.idNo.substr(16, 1) + if ((parseInt(sexSign) % 2 == 0 && this.userInfo.sex != 1) || (parseInt(sexSign) % 2 != 0 && this.userInfo.sex != 0)) { + return this.$toast('性别录入与身份证不符') + } + + //18位身份证第7-14位是生日位, 年月日 + let birthSign = this.userInfo.idNo.substr(6, 8) + if ( + this.userInfo.birthday.substr(0, 4) != birthSign.substr(0, 4) || + this.userInfo.birthday.substr(5, 2) != birthSign.substr(4, 2) || + this.userInfo.birthday.substr(8, 2) != birthSign.substr(6, 2) + ) { + return this.$toast('生日录入与身份证不符') + } + } + + // 证件号码规则校验 + if (!idNoCheck.isIdno(this.userInfo.idNo)) { + console.log('证件号码校验有误') + return this.$toast('您填写的证件号码有误') + } + if (age >= 16) { + return this.$toast('客户年龄在16周岁以上,不能使用户口本作为有效证件') + } + // else if (this.userInfo.idNo.length != 18) { + // return this.$toast('户口本的证件号码长度应等于18位') + // } } let insuredAge = utilsAge.getAge(this.insuredInfo.birthday, new Date()) console.log('计算年龄', insuredAge) - //如果证件类型是身份证 + //如果证件类型是身份证或户口本 if (this.insuredInfo.idType == '1') { console.log('证件类型是身份证') //校验性别是否与身份证号码位相符 @@ -1821,6 +1872,65 @@ export default { return this.$toast('证件有效期不正常,26周岁至45周岁公民身份证有效期应小于等于20年') } } + }else if (this.insuredInfo.idType == '2'){ + if (this.insuredInfo.nativeplace != '1') { + return this.$toast('证件类型”为“身份证,国籍必须为中国哦') + } + //校验性别是否与身份证号码位相符 + if (this.insuredInfo.idNo.length == '15') { + //15位身份证第15位是性别位, 奇男偶女 + let sexSign = this.insuredInfo.idNo.substr(14, 1) + if ((parseInt(sexSign) % 2 == 0 && this.insuredInfo.sex != 1) || (parseInt(sexSign) % 2 != 0 && this.insuredInfo.sex != 0)) { + return this.$toast('性别录入与身份证不符') + } + + //15位身份证第7-12位是生日位, 年月日 + let birthSign = this.insuredInfo.idNo.substr(6, 6) + if ( + this.insuredInfo.birthday.substr(2, 2) != birthSign.substr(0, 2) || + this.insuredInfo.birthday.substr(5, 2) != birthSign.substr(2, 2) || + this.insuredInfo.birthday.substr(8, 2) != birthSign.substr(4, 2) + ) { + return this.$toast('生日录入与身份证不符') + } + } else if (this.insuredInfo.idNo.length == '18') { + //18位身份证第17位是性别位, 奇男偶女 + let sexSign = this.insuredInfo.idNo.substr(16, 1) + if ((parseInt(sexSign) % 2 == 0 && this.insuredInfo.sex != 1) || (parseInt(sexSign) % 2 != 0 && this.insuredInfo.sex != 0)) { + return this.$toast('性别录入与身份证不符') + } + + //18位身份证第7-14位是生日位, 年月日 + let birthSign = this.insuredInfo.idNo.substr(6, 8) + if ( + this.insuredInfo.birthday.substr(0, 4) != birthSign.substr(0, 4) || + this.insuredInfo.birthday.substr(5, 2) != birthSign.substr(4, 2) || + this.insuredInfo.birthday.substr(8, 2) != birthSign.substr(6, 2) + ) { + return this.$toast('生日录入与身份证不符') + } + } + + // 证件号码规则校验 + if (!idNoCheck.isIdno(this.insuredInfo.idNo)) { + console.log('证件号码校验有误') + return this.$toast('您填写的证件号码有误') + } + if (age >= 16) { + return this.$toast('客户年龄在16周岁以上,不能使用户口本作为有效证件') + } + // else if (this.insuredInfo.idNo.length != 18) { + // return this.$toast('户口本的证件号码长度应等于18位') + // } + }else if (this.insuredInfo.idType == '3'){ + if (insuredAge >= 2) { + return this.$toast('客户年龄在2周岁及以上,不能使用出生证作为有效证件') + } + // 证件号码规则校验 + if (!idNoCheck.isCardNoBirth(this.insuredInfo.idNo)) { + console.log('证件号码校验有误') + return this.$toast('您填写的证件号码有误') + } } if (this.itemProductDTOS.productCode === 'GFRS_M0022') { // return diff --git a/src/views/ebiz/sale/AddBeneficiaryInfo.vue b/src/views/ebiz/sale/AddBeneficiaryInfo.vue index 5e3f40237..42ff143cb 100644 --- a/src/views/ebiz/sale/AddBeneficiaryInfo.vue +++ b/src/views/ebiz/sale/AddBeneficiaryInfo.vue @@ -984,6 +984,11 @@ export default { if (age >= 2) { return this.$toast('客户年龄在2周岁及以上,不能使用出生证作为有效证件') } + // 证件号码规则校验 + if (!idNoCheck.isCardNoBirth(this.userInfo.idNo)) { + console.log('证件号码校验有误') + return this.$toast('您填写的证件号码有误') + } //证件类型是护照 } else if (this.userInfo.idType == '4') { if (this.userInfo.nativeplace == '1') { diff --git a/src/views/ebiz/sale/InsuredPerson.vue b/src/views/ebiz/sale/InsuredPerson.vue index 462d76c12..3dab888b7 100644 --- a/src/views/ebiz/sale/InsuredPerson.vue +++ b/src/views/ebiz/sale/InsuredPerson.vue @@ -1602,6 +1602,11 @@ export default { if (age >= 2) { return this.$toast('客户年龄在2周岁及以上,不能使用出生证作为有效证件') } + // 证件号码规则校验 + if (!idNoCheck.isCardNoBirth(this.userInfo.idNo)) { + console.log('证件号码校验有误') + return this.$toast('您填写的证件号码有误') + } // else if (this.userInfo.idNo.length < 3) { // return this.$toast('出生证须大于等于3个字符') // }