| | |
| | | if (this.form.leaveType == null || this.form.leaveStartTime == null || this.form.leaveEndTime == null) { |
| | | return |
| | | } |
| | | // 获取年假剩余时长 |
| | | crudAttendanceLeave.getYearTimeLength((this.form.userId == null ? 1 : this.form.userId), this.form.leaveStartTime.substring(0, 4)).then(res => { |
| | | this.yearTimeLength = res |
| | | }) |
| | | // 获取调休假剩余时长 |
| | | crudAttendanceLeave.getOverTimeLength((this.form.userId == null ? 1 : this.form.userId), this.form.leaveStartTime.substring(0, 7)).then(res => { |
| | | this.overTimeLength = res |
| | | }) |
| | | // 通过后台计算时长 |
| | | var data = JSON.stringify({ |
| | | 'leaveType': this.form.leaveType, |
| | | 'leaveStartTime': this.form.leaveStartTime, |
| | | 'leaveEndTime': this.form.leaveEndTime |
| | | }) |
| | | crudAttendanceLeave.calcTimeLength(data).then(res => { |
| | | // 年假和计算的时长作比较 |
| | | if (this.form.leaveType === this.dictLeaveTypeAnnualLeave && this.yearTimeLength < res.leaveDuration) { |
| | | Promise.all([ |
| | | // 获取年假剩余时长 |
| | | crudAttendanceLeave.getYearTimeLength((this.form.userId == null ? 1 : this.form.userId), this.form.leaveStartTime.substring(0, 4)).then(res => { |
| | | this.yearTimeLength = res |
| | | }), |
| | | // 获取调休假剩余时长 |
| | | crudAttendanceLeave.getOverTimeLength((this.form.userId == null ? 1 : this.form.userId), this.form.leaveStartTime.substring(0, 7)).then(res => { |
| | | this.overTimeLength = res |
| | | }) |
| | | ]).then(() => { |
| | | // 通过后台计算时长 |
| | | var data = JSON.stringify({ |
| | | 'leaveType': this.form.leaveType, |
| | | 'leaveStartTime': this.form.leaveStartTime, |
| | | 'leaveEndTime': this.form.leaveEndTime |
| | | }) |
| | | crudAttendanceLeave.calcTimeLength(data).then(res => { |
| | | // 年假和计算的时长作比较 |
| | | if (this.form.leaveType === this.dictLeaveTypeAnnualLeave && this.yearTimeLength < res.leaveDuration) { |
| | | this.form.leaveDuration = null |
| | | this.crud.notify('年假剩余时间不足', CRUD.NOTIFICATION_TYPE.ERROR) |
| | | } else if (this.form.leaveType === this.dictLeaveTypeReplace && this.overTimeLength < res.leaveDuration) { |
| | | this.form.leaveDuration = null |
| | | this.crud.notify('调休假剩余时间不足', CRUD.NOTIFICATION_TYPE.ERROR) |
| | | } else { |
| | | this.form.leaveDuration = res.leaveDuration |
| | | } |
| | | }).catch(() => { |
| | | this.form.leaveDuration = null |
| | | this.crud.notify('年假剩余时间不足', CRUD.NOTIFICATION_TYPE.ERROR) |
| | | } else if (this.form.leaveType === this.dictLeaveTypeReplace && this.overTimeLength < res.leaveDuration) { |
| | | this.form.leaveDuration = null |
| | | this.crud.notify('调休假剩余时间不足', CRUD.NOTIFICATION_TYPE.ERROR) |
| | | } else { |
| | | this.form.leaveDuration = res.leaveDuration |
| | | } |
| | | }).catch(() => { |
| | | this.form.leaveDuration = null |
| | | }) |
| | | }) |
| | | }, |
| | | // 审批页面赋值 |