| | |
| | | <el-date-picker |
| | | v-model="ruleForm.extData.memberBirthday" |
| | | type="date" |
| | | @change="changeMemberBirthday" |
| | | placeholder="选择日期" |
| | | format="yyyy 年 MM 月 dd 日" |
| | | value-format="yyyy-MM-dd"> |
| | |
| | | } |
| | | this.getCompensations() |
| | | }, |
| | | changeMemberBirthday(e) { |
| | | if (!e) { |
| | | this.ruleForm.extData.memberAge = '' |
| | | } else { |
| | | this.ruleForm.extData.memberAge = this.calculateAge(e) |
| | | } |
| | | }, |
| | | calculateAge(birthDate) { |
| | | const today = new Date(); |
| | | const birthDateObject = new Date(birthDate); |
| | | |
| | | let age = today.getFullYear() - birthDateObject.getFullYear(); |
| | | const monthDiff = today.getMonth() - birthDateObject.getMonth(); |
| | | |
| | | if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birthDateObject.getDate())) { |
| | | age--; |
| | | } |
| | | |
| | | return age; |
| | | }, |
| | | confirm () { |
| | | this.$refs.ruleForm.validate((valid) => { |
| | | if (!valid) return |