Compare commits

...

2 Commits

Author SHA1 Message Date
liu.xiaofeng@ebiz-digits.com
d3af0a1f0f 根据出生日期以及证件起始日期计算证件截止日期
根据出生日期以及证件截止日期计算证件起始日期
2023-09-20 16:50:11 +08:00
liu.xiaofeng@ebiz-digits.com
a69d582732 修改自动计算证件开始日期以及截止日期的计算逻辑 2023-09-20 11:38:41 +08:00
3 changed files with 84 additions and 164 deletions

View File

@@ -1,167 +1,88 @@
import utilsAge from '@/assets/js/utils/age'
export default {
//计算身份证起始日期
getStartDate: function(age, endDate) {
getStartDate: function(birthday, endDate) {
let startDate = '' //证件起始日期
let thisDate = new Date() //当年日期
let thisyear = thisDate.getFullYear() //当前年份
let startage = ''
let endage = utilsAge.getAge(birthday, new Date(endDate))
if (age < 16) {
/**
* @Author: LiuXiaoFeng
* @Description: 16周岁以下的证件有效期为5年
* @Date: 2023/7/4
**/
startDate = String(Number(endDate.slice(0,4)) - 5) + endDate.slice(4,11)
} else if (age >= 16 && age <= 21) {
/**
* @Author: LiuXiaoFeng
* @Description: 16周岁~21周岁的证件有效期为10年或5年
* @Date: 2023/7/4
**/
if (age - (10 - (endDate.slice(0,4) - thisyear)) < 16 ) {
/**
* @Author: LiuXiaoFeng
* @Description: 如果证件有效期为10年 根据证件截止日期 判断10年前的年龄 如果小于16周岁 那么证件有效期就是5年
* @Date: 2023/7/5
**/
startDate = String(Number(endDate.slice(0,4)) - 5) + endDate.slice(4,11)
} else {
startDate = String(Number(endDate.slice(0,4)) - 10) + endDate.slice(4,11)
}
} else if(age >= 22 && age <= 25) {
/**
* @Author: LiuXiaoFeng
* @Description: 22周岁~25周岁的证件有效期为10年
* @Date: 2023/7/4
**/
startDate = String(Number(endDate.slice(0,4)) - 10) + endDate.slice(4,11)
} else if (age >= 26 && age <= 35) {
/**
* @Author: LiuXiaoFeng
* @Description: 26周岁~35周岁的证件有效期为20年或10年
* @Date: 2023/7/4
**/
if (age - (20 - (endDate.slice(0,4) - thisyear)) < 26 ) {
/**
* @Author: LiuXiaoFeng
* @Description: 如果证件有效期为20年 根据证件截止日期 判断20年前的年龄 如果小于26周岁 那么证件有效期就是10年
* @Date: 2023/7/5
**/
startDate = String(Number(endDate.slice(0,4)) - 10) + endDate.slice(4,11)
} else {
startDate = String(Number(endDate.slice(0,4)) - 20) + endDate.slice(4,11)
}
} else if (age >= 36 && age <= 45) {
/**
* @Author: LiuXiaoFeng
* @Description: 36周岁~45周岁的证件有效期为20年
* @Date: 2023/7/4
**/
startDate = String(Number(endDate.slice(0,4)) + 20) + endDate.slice(4,11)
} else if (age >= 46 && age <= 65) {
/**
* @Author: LiuXiaoFeng
* @Description: 46周岁~65周岁的证件有效期为20年或长期
* @Date: 2023/7/4
**/
if (age - (20 - (endDate.slice(0,4) - thisyear)) < 46 ) {
/**
* @Author: LiuXiaoFeng
* @Description: 如果证件有效期为20年 根据证件截止日期 判断20年前的年龄 如果小于46周岁 那么证件有效期就是20年
* @Date: 2023/7/5
**/
startDate = String(Number(endDate.slice(0,4)) - 20) + endDate.slice(4,11)
}
} else if (age > 65) {
/**
* @Author: LiuXiaoFeng
* @Description: 65周岁以上的证件有效期为长期
* @Date: 2023/7/4
**/
/**
* @Author: LiuXiaoFeng
* @Description: 未满16周岁的公民申领的居民身份证有效期为5年
* @Date: 2023/7/4
**/
if (endage - 5 < 16) {
return startDate = String(Number(endDate.slice(0,4)) - 5) + endDate.slice(4,11)
}
/**
* @Author: LiuXiaoFeng
* @Description: 年满16周岁至25周岁的公民申领的居民身份证有效期为10年
* @Date: 2023/7/4
**/
else if (endage - 5 >= 16 && endage - 10 <= 25) {
startDate = String(Number(endDate.slice(0,4)) - 10) + endDate.slice(4,11)
startage = utilsAge.getAge(birthday, new Date(startDate))
if(startage >= 16 && startage <= 25){
return startDate
}
}
/**
* @Author: LiuXiaoFeng
* @Description: 年满26周岁至45周岁的公民申领的居民身份证有效期为20年
* @Date: 2023/7/4
**/
else if(endage - 10 >= 26 && endage - 20 <= 45) {
startDate = String(Number(endDate.slice(0,4)) - 20) + endDate.slice(4,11)
startage = utilsAge.getAge(birthday, new Date(startDate))
if(startage >= 26 && startage <= 45){
return startDate
}
}
/**
* @Author: LiuXiaoFeng
* @Description: 年满46周岁的公民申领居民身份证有效期为长期
* @Date: 2023/7/4
**/
else if (endage - 20 >= 46) {
return startDate
}
return startDate
},
//计算身份证截止日期
getEndDate: function(age, startDate) {
getEndDate: function(birthday, startDate) {
let endDate = '' //证件截止日期
let thisDate = new Date() //当年日期
let thisyear = thisDate.getFullYear() //当前年份
if (age < 16) {
/**
* @Author: LiuXiaoFeng
* @Description: 16周岁以下的证件有效期为5年
* @Date: 2023/7/4
**/
endDate = String(Number(startDate.slice(0,4)) + 5) + startDate.slice(4,11)
} else if (age >= 16 && age <= 21) {
/**
* @Author: LiuXiaoFeng
* @Description: 16周岁~21周岁的证件有效期为10年或5年
* @Date: 2023/7/4
**/
if (age - (thisyear - startDate.slice(0,4)) < 16 ) {
/**
* @Author: LiuXiaoFeng
* @Description: 根据证件起始日期计算办证时年龄 如果办证时年龄小于16周岁 那么证件有效期就是5
* @Date: 2023/7/5
**/
endDate = String(Number(startDate.slice(0,4)) + 5) + startDate.slice(4,11)
} else {
endDate = String(Number(startDate.slice(0,4)) + 10) + startDate.slice(4,11)
}
} else if(age >= 22 && age <= 25) {
/**
* @Author: LiuXiaoFeng
* @Description: 22周岁~25周岁的证件有效期为10年
* @Date: 2023/7/4
**/
endDate = String(Number(startDate.slice(0,4)) + 10) + startDate.slice(4,11)
} else if (age >= 26 && age <= 35) {
/**
* @Author: LiuXiaoFeng
* @Description: 26周岁~35周岁的证件有效期为20年或10年
* @Date: 2023/7/4
**/
if (age - (thisyear - startDate.slice(0,4)) < 26 ) {
/**
* @Author: LiuXiaoFeng
* @Description: 根据证件起始日期计算办证时年龄 如果办证时年龄小于26周岁 那么证件有效期就是10年
* @Date: 2023/7/5
**/
endDate = String(Number(startDate.slice(0,4)) + 10) + startDate.slice(4,11)
} else {
endDate = String(Number(startDate.slice(0,4)) + 20) + startDate.slice(4,11)
}
} else if (age >= 36 && age <= 45) {
/**
* @Author: LiuXiaoFeng
* @Description: 36周岁~45周岁的证件有效期为20年
* @Date: 2023/7/4
**/
endDate = String(Number(startDate.slice(0,4)) + 20) + startDate.slice(4,11)
} else if (age >= 46 && age <= 65) {
/**
* @Author: LiuXiaoFeng
* @Description: 46周岁~65周岁的证件有效期为20年或长期
* @Date: 2023/7/4
**/
if (age - (thisyear - startDate.slice(0,4)) < 46 ) {
/**
* @Author: LiuXiaoFeng
* @Description: 根据证件起始日期计算办证时年龄 如果办证时年龄小于46周岁 那么证件有效期就是20年
* @Date: 2023/7/5
**/
endDate = String(Number(startDate.slice(0,4)) + 20) + startDate.slice(4,11)
}
} else if (age > 65) {
/**
* @Author: LiuXiaoFeng
* @Description: 65周岁以上的证件有效期为长期
* @Date: 2023/7/4
**/
let startage = utilsAge.getAge(birthday, new Date(startDate))
/**
* @Author: LiuXiaoFeng
* @Description: 未满16周岁的公民申领的居民身份证有效期为5年
* @Date: 2023/7/4
**/
if (startage < 16) {
return endDate = String(Number(startDate.slice(0, 4)) + 5) + startDate.slice(4, 11)
}
/**
* @Author: LiuXiaoFeng
* @Description: 年满16周岁至25周岁的公民申领的居民身份证有效期为10年
* @Date: 2023/7/4
**/
else if (startage >= 16 && startage <= 25) {
return endDate = String(Number(startDate.slice(0, 4)) + 10) + startDate.slice(4, 11)
}
/**
* @Author: LiuXiaoFeng
* @Description: 年满26周岁至45周岁的公民申领的居民身份证有效期为20
* @Date: 2023/7/4
**/
else if (startage >= 26 && startage <= 45) {
return endDate = String(Number(startDate.slice(0, 4)) + 20) + startDate.slice(4, 11)
}
/**
* @Author: LiuXiaoFeng
* @Description: 年满46周岁的公民申领居民身份证有效期为长期
* @Date: 2023/7/4
**/
else if (startage > 65) {
return endDate
}
return endDate
}
}

View File

@@ -860,7 +860,7 @@ export default {
// 长期按钮是否禁用
this.effectiveDateTypeAble = age <= 45
if(this.userInfo.birthday){
this.userInfo.certiexpiredate = countCredentialValidity.getEndDate(age,val)
this.userInfo.certiexpiredate = countCredentialValidity.getEndDate(this.userInfo.birthday,val)
}
}
}
@@ -876,9 +876,8 @@ export default {
}
//身份证证件类型的判断
if (this.userInfo.idType == '1') {
let age = utilsAge.getAge(this.userInfo.birthday, new Date())
if(this.userInfo.birthday){
this.userInfo.certificateValidate = countCredentialValidity.getStartDate(age,val)
this.userInfo.certificateValidate = countCredentialValidity.getStartDate(this.userInfo.birthday,val)
}
}
}
@@ -902,10 +901,10 @@ export default {
this.userInfo.workcompany = this.userInfo.workcompany || '无'
}
if (this.userInfo.certificateValidate && !this.userInfo.certiexpiredate) {
this.userInfo.certiexpiredate = countCredentialValidity.getEndDate(age,this.userInfo.certificateValidate)
this.userInfo.certiexpiredate = countCredentialValidity.getEndDate(this.userInfo.birthday,this.userInfo.certificateValidate)
}
if (this.userInfo.certiexpiredate && !this.userInfo.certificateValidate) {
this.userInfo.certificateValidate = countCredentialValidity.getEndDate(age,this.userInfo.certiexpiredate)
this.userInfo.certificateValidate = countCredentialValidity.getEndDate(this.userInfo.birthday,this.userInfo.certiexpiredate)
}
}
break

View File

@@ -1064,7 +1064,7 @@ export default {
// 长期按钮是否禁用
this.effectiveDateTypeAble = age <= 45
if(this.userInfo.birthday){
this.userInfo.certiexpiredate = countCredentialValidity.getEndDate(age,val)
this.userInfo.certiexpiredate = countCredentialValidity.getEndDate(this.userInfo.birthday,val)
}
}
}
@@ -1093,7 +1093,7 @@ export default {
let age = utilsAge.getAge(this.userInfo.birthday, new Date())
console.log(age)
if(this.userInfo.birthday){
this.userInfo.certificateValidate = countCredentialValidity.getStartDate(age,val)
this.userInfo.certificateValidate = countCredentialValidity.getStartDate(this.userInfo.birthday,val)
}
}
}
@@ -1124,10 +1124,10 @@ export default {
}
}
if (this.userInfo.certificateValidate && !this.userInfo.certiexpiredate) {
this.userInfo.certiexpiredate = countCredentialValidity.getEndDate(age,this.userInfo.certificateValidate)
this.userInfo.certiexpiredate = countCredentialValidity.getEndDate(this.userInfo.birthday,this.userInfo.certificateValidate)
}
if (this.userInfo.certiexpiredate && !this.userInfo.certificateValidate) {
this.userInfo.certificateValidate = countCredentialValidity.getEndDate(age,this.userInfo.certiexpiredate)
this.userInfo.certificateValidate = countCredentialValidity.getEndDate(this.userInfo.birthday,this.userInfo.certiexpiredate)
}
}
break