Bladeren bron

身份证年龄校验限制读配置

Handy_Cao 1 jaar geleden
bovenliggende
commit
d5d2d871dc

+ 6 - 2
src/filters/index.ts

@@ -2,7 +2,7 @@ import CryptoJS from 'crypto-js'
 import service from '@/services'
 import Long from 'long'
 import moment from 'moment'
-import { useGlobalStore } from '@/stores'
+import { useGlobalStore, useUserStore } from '@/stores'
 
 /**
  * 获取url对象方法
@@ -354,6 +354,10 @@ export function sortBy<T extends object, K extends keyof T>(arr: Array<T>, sortV
 
 // 身份证号 获取对应的证件年龄
 export function getIdCardAge(cardnum: string) {
+    /// 默认 18-60
+    const { getSystemParamValue } = useUserStore()
+    const maxAge = getSystemParamValue('325') ?? '60'
+    const minAge = 18
     // 根据身份证号提取出年 月 日 
     const idYear = Number(cardnum.substring(6, 10))
     const idMonth = Number(cardnum.substring(10, 12))
@@ -366,7 +370,7 @@ export function getIdCardAge(cardnum: string) {
     let age = year - idYear
     // 需要根据月份和具体日子判断下 
     if ((idMonth > month) || idMonth == month && idDay > day) { age-- }
-    return age
+    return age < minAge || age > Number(maxAge)
 }
 
 // 金额转大写

+ 2 - 2
src/packages/gcszt/views/account/certification/Index.vue

@@ -179,7 +179,7 @@ const PFormRules: { [key in keyof Model.PersonBankCard4]?: FieldRule[] } = {
         message: '请输入证件号码',
         validator: (val) => {
             if (validateRules.cardno.validate(val)) {
-                if ((getIdCardAge(val) < 18) || (getIdCardAge(val) > 60)) {
+                if (getIdCardAge(val)) {
                     return '开户失败,您的年龄不符合开户要求'
                 } 
                 return true
@@ -236,7 +236,7 @@ const CFormRules: { [key in keyof Model.CompanyBankCard4]?: FieldRule[] } = {
         message: '请输入法人身份证号',
         validator: (val) => {
             if (validateRules.cardno.validate(val)) {
-                if ((getIdCardAge(val) < 18) || (getIdCardAge(val) > 60)) {
+                if (getIdCardAge(val)) {
                     return '开户失败,您的年龄不符合开户要求'
                 } 
                 return true

+ 1 - 1
src/packages/mobile/views/account/certification/Index.vue

@@ -80,7 +80,7 @@ const formRules: { [key in keyof Model.AddAuthReq]?: FieldRule[] } = {
         message: '请输入证件号码',
         validator: (val) => {
             if (validateRules.cardno.validate(val)) {
-                if ((getIdCardAge(val) < 18) || (getIdCardAge(val) > 60)) {
+                if (getIdCardAge(val)) {
                     return '开户失败,您的年龄不符合开户要求'
                 } 
                 return true

+ 1 - 1
src/packages/nhgj/views/account/certification/Index.vue

@@ -104,7 +104,7 @@ const formRules: { [key in keyof Model.AddAuthReq]?: FieldRule[] } = {
         message: '请输入证件号码',
         validator: (val) => {
             if (validateRules.cardno.validate(val)) {
-                if((getIdCardAge(val) < 18) || (getIdCardAge(val) > 60)) {
+                if (getIdCardAge(val)) {
                     return '开户失败,您的年龄不符合开户要求'
                 } 
                 return true

+ 1 - 1
src/packages/qxst/views/account/certification/Index.vue

@@ -123,7 +123,7 @@ const formRules: { [key in keyof Model.AddUserReq]?: FieldRule[] } = {
         message: '请输入证件号码',
         validator: (val) => {
             if (validateRules.cardno.validate(val)) {
-                if((getIdCardAge(val) < 18) || (getIdCardAge(val) > 60)) {
+                if (getIdCardAge(val)) {
                     return '开户失败,您的年龄不符合开户要求'
                 } 
                 return true

+ 1 - 1
src/packages/sbyj/views/account/certification/Index.vue

@@ -104,7 +104,7 @@ const formRules: { [key in keyof Model.AddAuthReq]?: FieldRule[] } = {
         message: '请输入证件号码',
         validator: (val) => {
             if (validateRules.cardno.validate(val)) {
-                if((getIdCardAge(val) < 18) || (getIdCardAge(val) > 60)) {
+                if (getIdCardAge(val)) {
                     return '开户失败,您的年龄不符合开户要求'
                 } 
                 return true

+ 1 - 1
src/packages/thj/views/account/certification/Index.vue

@@ -104,7 +104,7 @@ const formRules: { [key in keyof Model.AddAuthReq]?: FieldRule[] } = {
         message: '请输入证件号码',
         validator: (val) => {
             if (validateRules.cardno.validate(val)) {
-                if ((getIdCardAge(val) < 18) || (getIdCardAge(val) > 60)) {
+                if (getIdCardAge(val)) {
                     return '开户失败,您的年龄不符合开户要求'
                 } 
                 return true

+ 1 - 1
src/packages/tjmd/views/account/certification/Index.vue

@@ -104,7 +104,7 @@ const formRules: { [key in keyof Model.AddAuthReq]?: FieldRule[] } = {
         message: '请输入证件号码',
         validator: (val) => {
             if (validateRules.cardno.validate(val)) {
-                if((getIdCardAge(val) < 18) || (getIdCardAge(val) > 60)) {
+                if (getIdCardAge(val)) {
                     return '开户失败,您的年龄不符合开户要求'
                 } 
                 return true

+ 2 - 2
src/packages/zrwyt/views/account/certification/Index.vue

@@ -179,7 +179,7 @@ const PFormRules: { [key in keyof Model.PersonBankCard4]?: FieldRule[] } = {
         message: '请输入证件号码',
         validator: (val) => {
             if (validateRules.cardno.validate(val)) {
-                if((getIdCardAge(val) < 18) || (getIdCardAge(val) > 60)) {
+                if (getIdCardAge(val)) {
                     return '开户失败,您的年龄不符合开户要求'
                 } 
                 return true
@@ -236,7 +236,7 @@ const CFormRules: { [key in keyof Model.CompanyBankCard4]?: FieldRule[] } = {
         message: '请输入法人身份证号',
         validator: (val) => {
             if (validateRules.cardno.validate(val)) {
-                if((getIdCardAge(val) < 18) || (getIdCardAge(val) > 60)) {
+                if (getIdCardAge(val)) {
                     return '开户失败,您的年龄不符合开户要求'
                 } 
                 return true