|
|
@@ -66,14 +66,15 @@
|
|
|
<div class="rowSty">
|
|
|
<div class="colSty"><div class="grid-content bg-purple">年龄</div></div>
|
|
|
<div class="colSty">
|
|
|
- <div v-if="judgeTag()" class="grid-content bg-purple-light">
|
|
|
+ <!-- <div v-if="judgeTag()" class="grid-content bg-purple-light"> -->
|
|
|
+ <div class="grid-content bg-purple-light">
|
|
|
<div>
|
|
|
{{
|
|
|
nowData.hasOwnProperty('nianLing') > 0 ? nowData.nianLing : '/'
|
|
|
}}
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div v-else class="grid-content bg-purple-light">
|
|
|
+ <!-- <div v-else class="grid-content bg-purple-light">
|
|
|
<el-form-item prop="nianLing">
|
|
|
<el-input-number
|
|
|
v-model.number="nowData.nianLing"
|
|
|
@@ -83,7 +84,7 @@
|
|
|
size="mini"
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
- </div>
|
|
|
+ </div> -->
|
|
|
</div>
|
|
|
<div class="colSty">
|
|
|
<div class="grid-content bg-purple">最高学历学位</div>
|
|
|
@@ -486,6 +487,7 @@ export default {
|
|
|
return {
|
|
|
activeName: 'first',
|
|
|
nowData: {},
|
|
|
+ originData: null,
|
|
|
isWatch: false,
|
|
|
rules: {
|
|
|
jianDangRiQi: [{ validator: option.checkTime, trigger: 'blur' }],
|
|
|
@@ -534,28 +536,25 @@ export default {
|
|
|
// immediate: true
|
|
|
// },
|
|
|
//监听身份证变化
|
|
|
- 'nowData.shenFenZhengHao': {
|
|
|
- handler(newVal) {
|
|
|
- if (newVal && this.isWatch) {
|
|
|
- if (newVal.length === 18) {
|
|
|
- this.nowData.chuShengRiQi =
|
|
|
- newVal.substring(6, 10) +
|
|
|
- '-' +
|
|
|
- newVal.substring(10, 12) +
|
|
|
- '-' +
|
|
|
- newVal.substring(12, 14)
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- immediate: false
|
|
|
- },
|
|
|
+ // 'nowData.shenFenZhengHao': {
|
|
|
+ // handler(newVal) {
|
|
|
+ // if (!newVal || !this.isWatch || !this.isValidIdCard(newVal)) return
|
|
|
+ // this.nowData.chuShengRiQi =
|
|
|
+ // newVal.substring(6, 10) +
|
|
|
+ // '-' +
|
|
|
+ // newVal.substring(10, 12) +
|
|
|
+ // '-' +
|
|
|
+ // newVal.substring(12, 14)
|
|
|
+ // },
|
|
|
+ // immediate: false
|
|
|
+ // },
|
|
|
// 监听出生日期变化
|
|
|
'nowData.chuShengRiQi': {
|
|
|
handler(newVal) {
|
|
|
- if (newVal && this.isWatch) {
|
|
|
- const ageDifMs = Date.now() - new Date(newVal).getTime()
|
|
|
- const ageDate = new Date(ageDifMs)
|
|
|
- this.nowData.nianLing = Math.abs(ageDate.getUTCFullYear() - 1970)
|
|
|
+ if (!newVal || !this.isWatch) return
|
|
|
+ const age = this.calculateAge(newVal)
|
|
|
+ if (age !== null) {
|
|
|
+ this.nowData.nianLing = age
|
|
|
}
|
|
|
}
|
|
|
// immediate: true
|
|
|
@@ -564,9 +563,14 @@ export default {
|
|
|
handler: function (val, oldVal) {
|
|
|
// eslint-disable-next-line no-undef
|
|
|
if (this.$utils.isNotEmpty(val)) {
|
|
|
+ this.isWatch = false
|
|
|
+ // eslint-disable-next-line no-undef
|
|
|
this.nowData = structuredClone(val)
|
|
|
setTimeout(() => {
|
|
|
this.isWatch = true
|
|
|
+ this.syncBirthAndAge()
|
|
|
+ // eslint-disable-next-line no-undef
|
|
|
+ this.originData = structuredClone(this.nowData)
|
|
|
}, 0)
|
|
|
}
|
|
|
// if(this.nowData.ruZhiShiJian){
|
|
|
@@ -579,13 +583,24 @@ export default {
|
|
|
deep: true,
|
|
|
immediate: true
|
|
|
},
|
|
|
+ btnShow: {
|
|
|
+ handler(val, oldVal) {
|
|
|
+ if (val === false && oldVal === true) {
|
|
|
+ // eslint-disable-next-line no-undef
|
|
|
+ this.originData = structuredClone(this.nowData)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
btnType: {
|
|
|
handler: function (val, oldVal) {
|
|
|
if (val === 'exitEdit') {
|
|
|
- // eslint-disable-next-line no-undef
|
|
|
- this.nowData = structuredClone(this.planeData)
|
|
|
+ const source = this.$utils.isNotEmpty(this.originData)
|
|
|
+ ? this.originData
|
|
|
+ : this.planeData
|
|
|
+ this.resetNowData(source)
|
|
|
} else if (
|
|
|
val === 'save' ||
|
|
|
+ val === 'saveWorkflow' ||
|
|
|
val === 'temporaryStorage' ||
|
|
|
val === 'submit' ||
|
|
|
val === 'sendBack' ||
|
|
|
@@ -615,6 +630,66 @@ export default {
|
|
|
// this.$set(this.nowData, 'gongZuoNianXia', years > 0 ? years : '0')
|
|
|
// }
|
|
|
// },
|
|
|
+ resetNowData(data) {
|
|
|
+ this.isWatch = false
|
|
|
+ // eslint-disable-next-line no-undef
|
|
|
+ this.nowData = structuredClone(data)
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.isWatch = true
|
|
|
+ })
|
|
|
+ },
|
|
|
+ isValidIdCard(idCard) {
|
|
|
+ const idCardReg =
|
|
|
+ /^[1-9]\d{5}(?:18|19|20)\d{2}(?:0[1-9]|10|11|12)(?:0[1-9]|[1-2]\d|30|31)\d{3}[\dXx]$/
|
|
|
+ if (!idCardReg.test(idCard)) return false
|
|
|
+ const weights = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2]
|
|
|
+ const checkCodes = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2']
|
|
|
+ let sum = 0
|
|
|
+ for (let i = 0; i < 17; i++) {
|
|
|
+ sum += parseInt(idCard[i], 10) * weights[i]
|
|
|
+ }
|
|
|
+ return checkCodes[sum % 11] === idCard[17].toUpperCase()
|
|
|
+ },
|
|
|
+ calculateAge(birthDateStr) {
|
|
|
+ if (!birthDateStr || typeof birthDateStr !== 'string') return null
|
|
|
+ const parts = birthDateStr.trim().substring(0, 10).split('-')
|
|
|
+ if (parts.length !== 3) return null
|
|
|
+ const year = Number(parts[0])
|
|
|
+ const month = Number(parts[1])
|
|
|
+ const day = Number(parts[2])
|
|
|
+ if (!year || !month || !day) return null
|
|
|
+ const birth = new Date(year, month - 1, day)
|
|
|
+ if (
|
|
|
+ birth.getFullYear() !== year ||
|
|
|
+ birth.getMonth() !== month - 1 ||
|
|
|
+ birth.getDate() !== day
|
|
|
+ ) {
|
|
|
+ return null
|
|
|
+ }
|
|
|
+ const today = new Date()
|
|
|
+ let age = today.getFullYear() - year
|
|
|
+ const monthDiff = today.getMonth() - (month - 1)
|
|
|
+ if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < day)) {
|
|
|
+ age--
|
|
|
+ }
|
|
|
+ if (age < 0 || age > 150) return null
|
|
|
+ return age
|
|
|
+ },
|
|
|
+ syncBirthAndAge() {
|
|
|
+ const idCard = this.nowData.shenFenZhengHao
|
|
|
+ if (idCard && this.isValidIdCard(idCard)) {
|
|
|
+ this.nowData.chuShengRiQi =
|
|
|
+ idCard.substring(6, 10) +
|
|
|
+ '-' +
|
|
|
+ idCard.substring(10, 12) +
|
|
|
+ '-' +
|
|
|
+ idCard.substring(12, 14)
|
|
|
+ }
|
|
|
+ const age = this.calculateAge(this.nowData.chuShengRiQi)
|
|
|
+ if (age !== null) {
|
|
|
+ this.nowData.nianLing = age
|
|
|
+ }
|
|
|
+ },
|
|
|
judgeTag() {
|
|
|
// return this.planeData.length>0&& this.btnShow === true && this.buttonType!==1 ? true : false
|
|
|
return !!(
|