From 169ff9d3278ba3514b98bc63718b8427865da3d6 Mon Sep 17 00:00:00 2001
From: 赵士淞 <zhaoss@yhzhg.cn>
Date: Tue, 03 Jan 2023 00:33:34 +0000
Subject: [PATCH] Merge branch 'weicd' of http://192.168.1.110:5678/r/pms-upgrade into master

---
 eladmin-web-master/src/api/attendance/attendanceLeave.js                                                                          |   58 ++
 eladmin-master/eladmin-system/pom.xml                                                                                             |    5 
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/AttendanceLeaveService.java                    |  106 ++++
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/repository/AttendanceLeaveRepository.java              |   47 +
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/domain/AttendanceLeave.java                            |  100 +++
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceLeaveServiceImpl.java           |  290 +++++++++++
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/mapstruct/AttendanceLeaveMapper.java           |   32 +
 eladmin-web-master/src/views/attendance/attendanceLeave/index.vue                                                                 |  451 +++++++++++++++++
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/domain/Calculate.java                                  |   14 
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/AttendanceService.java                         |   17 
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/SysUserLevelOtherRepository.java                |    9 
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/constant/Constant.java                                            |   40 +
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceLeaveDto.java                    |   75 ++
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceLeaveQueryCriteria.java          |   29 +
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceCardreplacementServiceImpl.java |   23 
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/rest/AttendanceLeaveController.java                    |  119 ++++
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceServiceImpl.java                |   98 +++
 17 files changed, 1,508 insertions(+), 5 deletions(-)

diff --git a/eladmin-master/eladmin-system/pom.xml b/eladmin-master/eladmin-system/pom.xml
index 01f55a1..2dd55f1 100644
--- a/eladmin-master/eladmin-system/pom.xml
+++ b/eladmin-master/eladmin-system/pom.xml
@@ -91,6 +91,11 @@
             <artifactId>alibaba-dingtalk-service-sdk</artifactId>
             <version>2.0.0</version>
         </dependency>
+        <dependency>
+            <groupId>nl.basjes.parse.useragent</groupId>
+            <artifactId>yauaa</artifactId>
+            <version>5.23</version>
+        </dependency>
     </dependencies>
 
     <!-- 打包 -->
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/domain/AttendanceLeave.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/domain/AttendanceLeave.java
new file mode 100644
index 0000000..e28a9b3
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/domain/AttendanceLeave.java
@@ -0,0 +1,100 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.attendance.domain;
+
+import lombok.Data;
+import cn.hutool.core.bean.BeanUtil;
+import io.swagger.annotations.ApiModelProperty;
+import cn.hutool.core.bean.copier.CopyOptions;
+import me.zhengjie.base.BaseEntity;
+
+import javax.persistence.*;
+import javax.validation.constraints.*;
+import java.sql.Timestamp;
+import java.io.Serializable;
+
+/**
+* @website https://eladmin.vip
+* @description /
+* @author wcd
+* @date 2022-12-16
+**/
+@Entity
+@Data
+@Table(name="attendance_leave")
+public class AttendanceLeave extends BaseEntity implements Serializable {
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "`id`")
+    @ApiModelProperty(value = "ID")
+    private Long id;
+
+    @Column(name = "`user_id`",nullable = false)
+    @NotNull
+    @ApiModelProperty(value = "用户ID")
+    private Long userId;
+
+    @Column(name = "`approval_user_id`",nullable = false)
+    @NotNull
+    @ApiModelProperty(value = "审批用户ID")
+    private Long approvalUserId;
+
+    @Column(name = "`leave_type`",nullable = false)
+    @NotBlank
+    @ApiModelProperty(value = "请假类型")
+    private String leaveType;
+
+    @Column(name = "`leave_start_time`",nullable = false)
+    @NotNull
+    @ApiModelProperty(value = "请假开始时间")
+    private Timestamp leaveStartTime;
+
+    @Column(name = "`leave_end_time`",nullable = false)
+    @NotNull
+    @ApiModelProperty(value = "请假结束时间")
+    private Timestamp leaveEndTime;
+
+    @Column(name = "`leave_duration`",nullable = false)
+    @NotNull
+    @ApiModelProperty(value = "请假时长")
+    private Double leaveDuration;
+
+    @Column(name = "`leave_duration_unit`",nullable = false)
+    @NotNull
+    @ApiModelProperty(value = "请假时长单位")
+    private String leaveDurationUnit;
+
+    @Column(name = "`leave_reason`")
+    @ApiModelProperty(value = "请假原因")
+    private String leaveReason;
+
+    @Column(name = "`approval_status`")
+    @ApiModelProperty(value = "审批状态")
+    private String approvalStatus;
+
+    @Column(name = "`approval_description`")
+    @ApiModelProperty(value = "审批说明")
+    private String approvalDescription;
+
+    @Column(name = "`remarks`")
+    @ApiModelProperty(value = "备注")
+    private String remarks;
+
+    public void copy(AttendanceLeave source){
+        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
+    }
+}
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/domain/Calculate.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/domain/Calculate.java
new file mode 100644
index 0000000..5bfa5a8
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/domain/Calculate.java
@@ -0,0 +1,14 @@
+package me.zhengjie.modules.attendance.domain;
+
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+@Data
+public class Calculate {
+
+    private LocalDateTime start;
+
+    private LocalDateTime end;
+
+}
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/repository/AttendanceLeaveRepository.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/repository/AttendanceLeaveRepository.java
new file mode 100644
index 0000000..457ec05
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/repository/AttendanceLeaveRepository.java
@@ -0,0 +1,47 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.attendance.repository;
+
+import me.zhengjie.modules.attendance.domain.AttendanceLeave;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Query;
+
+import java.util.List;
+import java.util.Set;
+
+/**
+* @website https://eladmin.vip
+* @author wcd
+* @date 2022-12-16
+**/
+public interface AttendanceLeaveRepository extends JpaRepository<AttendanceLeave, Long>, JpaSpecificationExecutor<AttendanceLeave> {
+
+    //添加时查询请假时间是否冲突
+    @Query(value = "SELECT * FROM attendance_leave WHERE user_id = ?3 AND approval_status IN ('approval_status_under_approval', 'approval_status_passed') AND ((leave_start_time >= ?1 and leave_start_time <= ?2) OR \n" +
+            "(leave_start_time <= ?1 and leave_end_time >= ?2) OR (leave_end_time >= ?1 and leave_end_time <= ?2) OR (leave_start_time >= ?1 and leave_end_time <= ?2))", nativeQuery = true)
+    List<AttendanceLeave> checkCreateLeaveTime(String startTime, String endTime, Long userId);
+
+    //修改时查询请假时间是否冲突
+    @Query(value = "SELECT * FROM attendance_leave WHERE user_id = ?3 AND approval_status IN ('approval_status_under_approval', 'approval_status_passed') AND id NOT IN ?4 AND ((leave_start_time >= ?1 and leave_start_time <= ?2) OR \n" +
+            "(leave_start_time <= ?1 and leave_end_time >= ?2) OR (leave_end_time >= ?1 and leave_end_time <= ?2) OR (leave_start_time >= ?1 and leave_end_time <= ?2))", nativeQuery = true)
+    List<AttendanceLeave> checkUpdateForLeaveTime(String startTime, String endTime, Long userId, Set<Long> ids);
+
+    //查询今年已使用的年假时长
+    @Query(value = "SELECT sum(leave_duration) from attendance_leave WHERE user_id = ?1 AND approval_status IN ('approval_status_under_approval','approval_status_passed') " +
+            "AND leave_type = 'leave_type_annual_leave' AND leave_start_time >= ?2 AND leave_end_time <= ?3" ,nativeQuery = true)
+    Double getSurplusYearTime(Long userId,String startTime,String endTime);
+}
\ No newline at end of file
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/rest/AttendanceLeaveController.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/rest/AttendanceLeaveController.java
new file mode 100644
index 0000000..29d6b64
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/rest/AttendanceLeaveController.java
@@ -0,0 +1,119 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.attendance.rest;
+
+import me.zhengjie.annotation.Log;
+import me.zhengjie.modules.attendance.domain.AttendanceCardreplacement;
+import me.zhengjie.modules.attendance.domain.AttendanceLeave;
+import me.zhengjie.modules.attendance.service.AttendanceLeaveService;
+import me.zhengjie.modules.attendance.service.dto.AttendanceLeaveQueryCriteria;
+import org.springframework.data.domain.Pageable;
+import lombok.RequiredArgsConstructor;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+import io.swagger.annotations.*;
+import java.io.IOException;
+import java.text.ParseException;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+* @website https://eladmin.vip
+* @author wcd
+* @date 2022-12-16
+**/
+@RestController
+@RequiredArgsConstructor
+@Api(tags = "请假管理")
+@RequestMapping("/api/attendanceLeave")
+public class AttendanceLeaveController {
+
+    private final AttendanceLeaveService attendanceLeaveService;
+
+    @Log("导出数据")
+    @ApiOperation("导出数据")
+    @GetMapping(value = "/download")
+    @PreAuthorize("@el.check('attendanceLeave:download')")
+    public void exportAttendanceLeave(HttpServletResponse response, AttendanceLeaveQueryCriteria criteria) throws IOException {
+        attendanceLeaveService.download(attendanceLeaveService.queryAll(criteria), response);
+    }
+
+    @GetMapping
+    @Log("查询请假")
+    @ApiOperation("查询请假")
+    @PreAuthorize("@el.check('attendanceLeave:list')")
+    public ResponseEntity<Object> queryAttendanceLeave(AttendanceLeaveQueryCriteria criteria, Pageable pageable){
+        return new ResponseEntity<>(attendanceLeaveService.queryAll(criteria,pageable),HttpStatus.OK);
+    }
+
+    @GetMapping(value = "/all")
+    @Log("查询请假")
+    @ApiOperation("查询请假")
+    @PreAuthorize("@el.check('attendanceLeave:list')")
+    public ResponseEntity<Object> queryAttendanceLeave(AttendanceLeaveQueryCriteria criteria){
+        return new ResponseEntity<>(attendanceLeaveService.queryAll(criteria),HttpStatus.OK);
+    }
+
+    @PostMapping
+    @Log("新增请假")
+    @ApiOperation("新增请假")
+    @PreAuthorize("@el.check('attendanceLeave:add')")
+    public ResponseEntity<Object> createAttendanceLeave(@Validated @RequestBody AttendanceLeave resources) throws Exception {
+        return new ResponseEntity<>(attendanceLeaveService.create(resources),HttpStatus.CREATED);
+    }
+
+    @PutMapping
+    @Log("修改请假")
+    @ApiOperation("修改请假")
+    @PreAuthorize("@el.check('attendanceLeave:edit')")
+    public ResponseEntity<Object> updateAttendanceLeave(@Validated @RequestBody AttendanceLeave resources){
+        attendanceLeaveService.update(resources);
+        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
+    }
+
+    @PostMapping(value = "/calcTimeLength")
+    @Log("计算请假时长")
+    @ApiOperation("计算请假时长")
+    public ResponseEntity<Object> calcTimeLength(@RequestBody AttendanceLeave resources) throws Exception {
+        return new ResponseEntity<>(attendanceLeaveService.calcTimeLength(resources), HttpStatus.OK);
+    }
+
+    @PostMapping(value = "/getYearTimeLength")
+    @Log("获取年假时长")
+    @ApiOperation("计算请假时长")
+    public ResponseEntity<Object> getYearTimeLength() throws ParseException {
+        return new ResponseEntity<>(attendanceLeaveService.getYearTimeLength(), HttpStatus.OK);
+    }
+
+    @PutMapping(value = "/approve")
+    @Log("审核功能")
+    @ApiOperation("审核功能")
+    public ResponseEntity<Object> checkApprove(@Validated @RequestBody AttendanceLeave resources){
+        attendanceLeaveService.updateApprove(resources);
+        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
+    }
+
+    @DeleteMapping
+    @Log("删除请假")
+    @ApiOperation("删除请假")
+    @PreAuthorize("@el.check('attendanceLeave:del')")
+    public ResponseEntity<Object> deleteAttendanceLeave(@RequestBody Long[] ids) {
+        attendanceLeaveService.deleteAll(ids);
+        return new ResponseEntity<>(HttpStatus.OK);
+    }
+}
\ No newline at end of file
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/AttendanceLeaveService.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/AttendanceLeaveService.java
new file mode 100644
index 0000000..2ced8f5
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/AttendanceLeaveService.java
@@ -0,0 +1,106 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.attendance.service;
+
+import me.zhengjie.modules.attendance.domain.AttendanceCardreplacement;
+import me.zhengjie.modules.attendance.domain.AttendanceLeave;
+import me.zhengjie.modules.attendance.service.dto.AttendanceLeaveDto;
+import me.zhengjie.modules.attendance.service.dto.AttendanceLeaveQueryCriteria;
+import org.springframework.data.domain.Pageable;
+
+import java.text.ParseException;
+import java.util.Map;
+import java.util.List;
+import java.io.IOException;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+* @website https://eladmin.vip
+* @description 服务接口
+* @author wcd
+* @date 2022-12-16
+**/
+public interface AttendanceLeaveService {
+
+    /**
+    * 查询数据分页
+    * @param criteria 条件
+    * @param pageable 分页参数
+    * @return Map<String,Object>
+    */
+    Map<String,Object> queryAll(AttendanceLeaveQueryCriteria criteria, Pageable pageable);
+
+    /**
+    * 查询所有数据不分页
+    * @param criteria 条件参数
+    * @return List<AttendanceLeaveDto>
+    */
+    List<AttendanceLeaveDto> queryAll(AttendanceLeaveQueryCriteria criteria);
+
+    /**
+     * 根据ID查询
+     * @param id ID
+     * @return AttendanceLeaveDto
+     */
+    AttendanceLeaveDto findById(Long id);
+
+    /**
+    * 创建
+    * @param resources /
+    * @return AttendanceLeaveDto
+    */
+    AttendanceLeaveDto create(AttendanceLeave resources) throws Exception;
+
+    /**
+    * 编辑
+    * @param resources /
+    */
+    void update(AttendanceLeave resources);
+
+    /**
+     * 计算请假时长
+     * @param resources /
+     * @throws Exception /
+     */
+    AttendanceLeaveDto calcTimeLength(AttendanceLeave resources) throws Exception;
+
+    /**
+     *获取剩余年假
+     * @return
+     * @throws ParseException
+     */
+    Double getYearTimeLength() throws ParseException;
+
+    /**
+     * 审核功能
+     * @param resources /
+     */
+    void updateApprove(AttendanceLeave resources);
+
+    /**
+    * 多选删除
+    * @param ids /
+    */
+    void deleteAll(Long[] ids);
+
+    /**
+    * 导出数据
+    * @param all 待导出的数据
+    * @param response /
+    * @throws IOException /
+    */
+    void download(List<AttendanceLeaveDto> all, HttpServletResponse response) throws IOException;
+}
\ No newline at end of file
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/AttendanceService.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/AttendanceService.java
index 38b6118..d4c2c98 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/AttendanceService.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/AttendanceService.java
@@ -16,9 +16,12 @@
 package me.zhengjie.modules.attendance.service;
 
 import me.zhengjie.modules.attendance.domain.Attendance;
+import me.zhengjie.modules.attendance.domain.Calculate;
 import me.zhengjie.modules.attendance.service.dto.AttendanceDto;
 import me.zhengjie.modules.attendance.service.dto.AttendanceQueryCriteria;
 import org.springframework.data.domain.Pageable;
+
+import java.time.LocalDateTime;
 import java.util.Map;
 import java.util.List;
 import java.io.IOException;
@@ -68,6 +71,20 @@
     void update(Attendance resources);
 
     /**
+     * 计算时长(小时)
+     * @param userId
+     * @return
+     */
+    Integer calculateTimes(Calculate calculate, Long userId);
+
+    /**
+     * 计算时长(天)
+     *
+     * @return
+     */
+    Integer calculateDays(Calculate calculate);
+
+    /**
     * 多选删除
     * @param ids /
     */
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceLeaveDto.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceLeaveDto.java
new file mode 100644
index 0000000..f0da612
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceLeaveDto.java
@@ -0,0 +1,75 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.attendance.service.dto;
+
+import lombok.Data;
+import me.zhengjie.base.BaseDTO;
+
+import java.sql.Timestamp;
+import java.io.Serializable;
+
+/**
+* @website https://eladmin.vip
+* @description /
+* @author wcd
+* @date 2022-12-16
+**/
+@Data
+public class AttendanceLeaveDto extends BaseDTO implements Serializable {
+
+    /** ID */
+    private Long id;
+
+    /** 用户ID */
+    private Long userId;
+
+    /** 审批用户ID */
+    private Long approvalUserId;
+
+    /** 请假类型 */
+    private String leaveType;
+
+    /** 请假开始时间 */
+    private Timestamp leaveStartTime;
+
+    /** 请假结束时间 */
+    private Timestamp leaveEndTime;
+
+    /** 请假时长 */
+    private Double leaveDuration;
+
+    /** 请假时长单位 */
+    private String leaveDurationUnit;
+
+    /** 请假原因 */
+    private String leaveReason;
+
+    /** 审批状态 */
+    private String approvalStatus;
+
+    /** 审批说明 */
+    private String approvalDescription;
+
+    /** 备注 */
+    private String remarks;
+
+    /** 用户名 */
+    private String userName;
+
+    /** 审批用户名 */
+    private String appUserName;
+
+}
\ No newline at end of file
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceLeaveQueryCriteria.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceLeaveQueryCriteria.java
new file mode 100644
index 0000000..40289cb
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceLeaveQueryCriteria.java
@@ -0,0 +1,29 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.attendance.service.dto;
+
+import lombok.Data;
+import java.util.List;
+import me.zhengjie.annotation.Query;
+
+/**
+* @website https://eladmin.vip
+* @author wcd
+* @date 2022-12-16
+**/
+@Data
+public class AttendanceLeaveQueryCriteria{
+}
\ No newline at end of file
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceCardreplacementServiceImpl.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceCardreplacementServiceImpl.java
index 7ef73ca..ae79aec 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceCardreplacementServiceImpl.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceCardreplacementServiceImpl.java
@@ -175,15 +175,21 @@
                 attendance.setStartClockResults(Constant.ATTENDANCE_STATE_NORMAL);
                 attendance.setStartLocationResults(Constant.LOCATION_RESULTS_NORMAL);
                 // 减少补卡次数待加入?
+            }else if (resources.getApprovalStatus().equals(Constant.CARD_APPROVE_STATUS_REFUSE)){
+                attendance.setStartClockResults(Constant.ATTENDANCE_STATE_NOTSIGNED);
+                attendance.setStartLocationResults(Constant.LOCATION_RESULTS_NOTSIGNED);
             }
         } else {
             // 通过
             if (resources.getApprovalStatus().equals(Constant.CARD_APPROVE_STATUS_AGREE)) {
                 // set考勤打卡时间和打卡状态
                 attendance.setActualWorkEndTime(resources.getCardReplacementTime());
-                attendance.setEndClockResults(Constant.ATTENDANCE_STATE_NORMAL);
-                attendance.setEndLocationResults(Constant.LOCATION_RESULTS_NORMAL);
+                attendance.setEndClockResults(Constant.ATTENDANCE_STATE_NOTSIGNED);
+                attendance.setEndLocationResults(Constant.LOCATION_RESULTS_NOTSIGNED);
                 // 减少补卡次数待加入?
+            }else if (resources.getApprovalStatus().equals(Constant.CARD_APPROVE_STATUS_REFUSE)){
+                attendance.setEndClockResults(Constant.ATTENDANCE_STATE_NOTSIGNED);
+                attendance.setEndLocationResults(Constant.LOCATION_RESULTS_NOTSIGNED);
             }
         }
         attendanceRepository.save(attendance);
@@ -203,6 +209,19 @@
         if(resources.getApprovalStatus().equals(Constant.CARD_APPROVE_STATUS_AGREE)) {
         }
         attendanceCardreplacement.setApprovalStatus(Constant.CARD_APPROVE_STATUS_REVIEWED);
+        String sfd = resources.getCardReplacementTime().toLocalDateTime().toString().substring(0,10);
+        //查询考勤记录状态改为等待
+        Attendance attendance = attendanceRepository.findAllByUserIdAndAttendanceDate(resources.getUserId(),resources.getCardReplacementTime().toLocalDateTime().toString().substring(0,10));
+        // 判断是上班补卡还是下班补卡
+        if (resources.getCardReplacementDistinguish().equals(Constant.CARD_REPLACEMENT_DIFFERENTIATION_GOON)) {
+            attendance.setActualWorkStartTime(null);
+            attendance.setStartClockResults(Constant.ATTENDANCE_STATE_NOTSIGNED);
+            attendance.setStartLocationResults(null);
+        }else{
+            attendance.setActualWorkEndTime(null);
+            attendance.setEndClockResults(Constant.ATTENDANCE_STATE_NOTSIGNED);
+            attendance.setEndLocationResults(null);
+        }
         attendanceCardreplacementRepository.save(attendanceCardreplacement);
     }
 
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceLeaveServiceImpl.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceLeaveServiceImpl.java
new file mode 100644
index 0000000..4f21f65
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceLeaveServiceImpl.java
@@ -0,0 +1,290 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.attendance.service.impl;
+
+import me.zhengjie.exception.BadRequestException;
+import me.zhengjie.modules.attendance.domain.Attendance;
+import me.zhengjie.modules.attendance.domain.AttendanceLeave;
+import me.zhengjie.modules.attendance.domain.Calculate;
+import me.zhengjie.modules.attendance.service.AttendanceService;
+import me.zhengjie.modules.attendance.service.dto.AttendanceDto;
+import me.zhengjie.modules.constant.Constant;
+import me.zhengjie.modules.quartz.service.OpaiDingTalkService;
+import me.zhengjie.modules.system.domain.DictDetail;
+import me.zhengjie.modules.system.domain.SysUserLevelOther;
+import me.zhengjie.modules.system.domain.User;
+import me.zhengjie.modules.system.repository.DictDetailRepository;
+import me.zhengjie.modules.system.repository.SysUserLevelOtherRepository;
+import me.zhengjie.modules.system.repository.UserRepository;
+import me.zhengjie.utils.*;
+import lombok.RequiredArgsConstructor;
+import me.zhengjie.modules.attendance.repository.AttendanceLeaveRepository;
+import me.zhengjie.modules.attendance.service.AttendanceLeaveService;
+import me.zhengjie.modules.attendance.service.dto.AttendanceLeaveDto;
+import me.zhengjie.modules.attendance.service.dto.AttendanceLeaveQueryCriteria;
+import me.zhengjie.modules.attendance.service.mapstruct.AttendanceLeaveMapper;
+import org.apache.commons.lang3.ObjectUtils;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+
+import java.math.BigDecimal;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.ZonedDateTime;
+import java.util.*;
+import java.io.IOException;
+import java.util.function.Function;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+* @website https://eladmin.vip
+* @description 服务实现
+* @author wcd
+* @date 2022-12-16
+**/
+@Service
+@RequiredArgsConstructor
+public class AttendanceLeaveServiceImpl implements AttendanceLeaveService {
+
+    private final AttendanceLeaveRepository attendanceLeaveRepository;
+    private final AttendanceLeaveMapper attendanceLeaveMapper;
+    private final DictDetailRepository dictDetailRepository;
+    private final AttendanceService attendanceService;
+    private final SysUserLevelOtherRepository sysUserLevelOtherRepository;
+    private final UserRepository userRepository;
+    private final OpaiDingTalkService opaiDingTalkService;
+
+    @Override
+    public Map<String,Object> queryAll(AttendanceLeaveQueryCriteria criteria, Pageable pageable){
+        Page<AttendanceLeave> page = attendanceLeaveRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
+        //将实体转换为Dto(重写)
+        Function<AttendanceLeave, AttendanceLeaveDto> func = new Function<AttendanceLeave, AttendanceLeaveDto>(){
+
+            @Override
+            public AttendanceLeaveDto apply(AttendanceLeave attendanceLeave) {
+                // 将实体类转换成DTO
+                AttendanceLeaveDto attendanceLeaveDto = attendanceLeaveMapper.toDto(attendanceLeave);
+                //查询用户信息
+                User user = userRepository.findById(attendanceLeaveDto.getUserId()).orElseGet(User::new);
+                attendanceLeaveDto.setUserName(user.getNickName());
+                //查询审批用户名
+                User appUser = userRepository.findById(attendanceLeaveDto.getApprovalUserId()).orElseGet(User::new);
+                attendanceLeaveDto.setAppUserName(appUser.getNickName());
+                return attendanceLeaveDto;
+            }
+        };
+        return PageUtil.toPage(page.map(func));
+    }
+
+    @Override
+    public List<AttendanceLeaveDto> queryAll(AttendanceLeaveQueryCriteria criteria){
+        return attendanceLeaveMapper.toDto(attendanceLeaveRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
+    }
+
+    @Override
+    @Transactional
+    public AttendanceLeaveDto findById(Long id) {
+        AttendanceLeave attendanceLeave = attendanceLeaveRepository.findById(id).orElseGet(AttendanceLeave::new);
+        ValidationUtil.isNull(attendanceLeave.getId(),"AttendanceLeave","id",id);
+        return attendanceLeaveMapper.toDto(attendanceLeave);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public AttendanceLeaveDto create(AttendanceLeave resources) throws Exception {
+        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String LeaStartTime = df.format(resources.getLeaveStartTime());
+        String LeaEndTime = df.format(resources.getLeaveEndTime());
+        // 如果按天为单位请假拼接请假时间的时分秒,取上下班基准时间
+        if(resources.getLeaveDurationUnit().equals(Constant.LEAVE_TIME_TYPE_DAY)){
+            //查询用户的排班时间
+            User user = userRepository.getOne(SecurityUtils.getCurrentUserId());
+            LeaStartTime = LeaStartTime.substring(0,10) + " " + user.getSysRostering().getWorkStartTime().toString() + ":00";
+            LeaEndTime = LeaEndTime.substring(0,10) + " " + user.getSysRostering().getWorkEndTime().toString() + ":00";
+        }
+        // 验证请假时间是否冲突
+        List<AttendanceLeave> attendanceLeaveList = attendanceLeaveRepository.checkCreateLeaveTime(LeaStartTime,LeaEndTime, SecurityUtils.getCurrentUserId());
+        if(attendanceLeaveList.size() > 0){
+            AttendanceLeave errTime = attendanceLeaveList.get(0);
+            //LocalDateTime转换为Date
+            LocalDateTime strartTime = errTime.getLeaveStartTime().toLocalDateTime();
+            ZonedDateTime zonedDateTime = strartTime.atZone(ZoneId.systemDefault());
+            Instant instant = zonedDateTime.toInstant();
+            Date strTime = Date.from(instant);
+            LocalDateTime endTime = errTime.getLeaveEndTime().toLocalDateTime();
+            ZonedDateTime zonedDateTime1 = endTime.atZone(ZoneId.systemDefault());
+            Instant instant1 = zonedDateTime1.toInstant();
+            Date endTim = Date.from(instant1);
+
+            SimpleDateFormat errorFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            throw new BadRequestException("请假时间冲突," + errorFormat.format(strTime) + "至" + errorFormat.format(endTim)
+                    + "已经存在请假记录,请调整时间");
+        }else {
+            // 获取当前登陆人信息,设置为请假发起人
+            User user = userRepository.getOne(SecurityUtils.getCurrentUserId());
+            resources.setUserId(user.getId());
+            resources.setApprovalStatus(Constant.APPROVAL_STATUS_UNDER_APPROVAL);
+            //发送钉钉给审批人
+            List<String> sendList = new ArrayList<>();
+            //查询审批者信息
+            User appUser = userRepository.getOne(resources.getApprovalUserId());
+            sendList.add(appUser.getDingding());
+            opaiDingTalkService.sendNotice(sendList, "审批提醒", "### 审批提示 \n  >" + user.getNickName() + " 提交了请假审批,请登录PMS系统处理", "card");
+            return attendanceLeaveMapper.toDto(attendanceLeaveRepository.save(resources));
+        }
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void update(AttendanceLeave resources) {
+        AttendanceLeave attendanceLeave = attendanceLeaveRepository.findById(resources.getId()).orElseGet(AttendanceLeave::new);
+        ValidationUtil.isNull( attendanceLeave.getId(),"AttendanceLeave","id",resources.getId());
+        attendanceLeave.copy(resources);
+        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String LeaStartTime = df.format(resources.getLeaveStartTime());
+        String LeaEndTime = df.format(resources.getLeaveEndTime());
+        // 验证是否存在时间冲突的请假记录
+        Set<Long> ids = new HashSet<>();
+        ids.add(attendanceLeave.getId());
+        List<AttendanceLeave> attendanceLeaveList = attendanceLeaveRepository.checkUpdateForLeaveTime(LeaStartTime, LeaEndTime, attendanceLeave.getUserId(), ids);
+        if (attendanceLeaveList.size() > 0) {
+            AttendanceLeave errorSysAskForLeave = attendanceLeaveList.get(0);
+            SimpleDateFormat errorFormat = new SimpleDateFormat("yyyy年MM月dd日");
+                throw new BadRequestException("请假时间冲突," + errorFormat.format(errorSysAskForLeave.getLeaveStartTime()) + "至" + errorFormat.format(errorSysAskForLeave.getLeaveEndTime())
+                        + "已经存在请假记录,请调整时间");
+        }
+        attendanceLeaveRepository.save(attendanceLeave);
+    }
+
+    /**
+     * 计算请假时长
+     * @param resources /
+     * @return
+     * @throws Exception
+     */
+    @Override
+    public AttendanceLeaveDto calcTimeLength(AttendanceLeave resources) throws Exception {
+        AttendanceLeaveDto attendanceLeaveDto = new AttendanceLeaveDto();
+        //根据字典名称查询
+        List<DictDetail> dictDetailList = dictDetailRepository.findByDictName("leave_type");
+        List<String> leaveTypes = new ArrayList<>();
+        for(DictDetail dictDetail : dictDetailList){
+            if(dictDetail.getValue().equals(Constant.LEAVE_TYPE_ANNUAL_LEAVE) || dictDetail.getValue().equals(Constant.LEAVE_TYPE_COMPASSIONATE_LEAVE)){
+                //事假和年假
+                leaveTypes.add(dictDetail.getValue());
+            }
+        }
+        Calculate calculate = new Calculate();
+        calculate.setStart(resources.getLeaveStartTime().toLocalDateTime());
+        calculate.setEnd(resources.getLeaveEndTime().toLocalDateTime());
+        Double result = new Double(0.00);
+        //判断集合是否包含年假或事假,包含计算以时为单位,反之以天为单位进行计算
+        if(leaveTypes.contains(resources.getLeaveType())){
+            Integer timeSeconds = attendanceService.calculateTimes(calculate, SecurityUtils.getCurrentUserId());
+            result = Double.valueOf(new BigDecimal((float) timeSeconds / 3600).setScale(2, BigDecimal.ROUND_HALF_UP).toString());
+            attendanceLeaveDto.setLeaveDurationUnit(Constant.LEAVE_TIME_TYPE_HOUR);
+        }else{
+            Integer days = attendanceService.calculateDays(calculate);
+            result = Double.valueOf(new BigDecimal(days).setScale(2, BigDecimal.ROUND_HALF_UP).toString());
+            attendanceLeaveDto.setLeaveDurationUnit(Constant.LEAVE_TIME_TYPE_DAY);
+        }
+        attendanceLeaveDto.setLeaveDuration(result);
+        return attendanceLeaveDto;
+    }
+
+    /**
+     * 获取用户年假剩余时长
+     */
+    @Override
+    public Double getYearTimeLength() throws ParseException {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        // 获取当前日期
+        Date date = new Date();
+        String nowTime = sdf.format(date);
+        Date dateTime = sdf.parse(nowTime);
+        Double surplusYearTime = new Double(0.00);
+        // 查询用户剩余年假时长
+        List<SysUserLevelOther> sysUserLevelOtherList = sysUserLevelOtherRepository.findByUserId(SecurityUtils.getCurrentUserId());
+        for(SysUserLevelOther sysUserLevelOther : sysUserLevelOtherList){
+            if(ObjectUtils.isNotEmpty(sysUserLevelOther.getStartDate()) && ObjectUtils.isNotEmpty(sysUserLevelOther.getEndDate())){
+                Date dateStart = new Date(sysUserLevelOther.getStartDate().getTime());
+                Date dateEnd = new Date(sysUserLevelOther.getEndDate().getTime());
+                //取当前日期在数据中开始日期与结束日期之间的数据
+                if(dateTime.compareTo(dateStart) >= 0 && dateTime.compareTo(dateEnd) <= 0){
+                    //年假总时长
+                    Double yearTime = Double.valueOf(sysUserLevelOther.getAnnualLeaveDays() == null ? 0 : sysUserLevelOther.getAnnualLeaveDays() * 8);
+                    //已使用年假时长
+                    Calendar calendar = Calendar.getInstance();
+                    int year = calendar.get(Calendar.YEAR);
+                    String startTime = year + "-01-01 00:00:00";
+                    String endTime = year + "-12-31 23:59:59";
+                    Double usedYearTime = attendanceLeaveRepository.getSurplusYearTime(sysUserLevelOther.getUserId(),startTime,endTime);
+                    //剩余年假
+                    surplusYearTime = yearTime - (usedYearTime == null ? 0.0 : usedYearTime);
+                }
+            }
+        }
+        return surplusYearTime;
+    }
+
+    /**
+     * 审核功能
+     * @param resources /
+     */
+    @Override
+    public void updateApprove(AttendanceLeave resources) {
+        AttendanceLeave attendanceLeave = attendanceLeaveRepository.findById(resources.getId()).orElseGet(AttendanceLeave::new);
+        ValidationUtil.isNull( attendanceLeave.getId(),"AttendanceLeave","id",resources.getId());
+        attendanceLeave.copy(resources);
+        attendanceLeaveRepository.save(attendanceLeave);
+    }
+
+    @Override
+    public void deleteAll(Long[] ids) {
+        for (Long id : ids) {
+            attendanceLeaveRepository.deleteById(id);
+        }
+    }
+
+    @Override
+    public void download(List<AttendanceLeaveDto> all, HttpServletResponse response) throws IOException {
+        List<Map<String, Object>> list = new ArrayList<>();
+        for (AttendanceLeaveDto attendanceLeave : all) {
+            Map<String,Object> map = new LinkedHashMap<>();
+            map.put("用户ID", attendanceLeave.getUserId());
+            map.put("审批用户ID", attendanceLeave.getApprovalUserId());
+            map.put("请假类型", attendanceLeave.getLeaveType());
+            map.put("请假开始时间", attendanceLeave.getLeaveStartTime());
+            map.put("请假结束时间", attendanceLeave.getLeaveEndTime());
+            map.put("请假时长", attendanceLeave.getLeaveDuration());
+            map.put("请假原因", attendanceLeave.getLeaveReason());
+            map.put("审批状态", attendanceLeave.getApprovalStatus());
+            map.put("审批说明", attendanceLeave.getApprovalDescription());
+            map.put("备注", attendanceLeave.getRemarks());
+            map.put("创建者", attendanceLeave.getCreateBy());
+            map.put("创建时间", attendanceLeave.getCreateTime());
+            map.put("更新者", attendanceLeave.getUpdateBy());
+            map.put("更新时间", attendanceLeave.getUpdateTime());
+            list.add(map);
+        }
+        FileUtil.downloadExcel(list, response);
+    }
+}
\ No newline at end of file
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceServiceImpl.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceServiceImpl.java
index a4c96ca..c9b4cbe 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceServiceImpl.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceServiceImpl.java
@@ -16,9 +16,13 @@
 package me.zhengjie.modules.attendance.service.impl;
 
 import me.zhengjie.modules.attendance.domain.Attendance;
+import me.zhengjie.modules.attendance.domain.Calculate;
 import me.zhengjie.modules.constant.Constant;
+import me.zhengjie.modules.system.domain.SysConfigHoliday;
+import me.zhengjie.modules.system.domain.SysRostering;
 import me.zhengjie.modules.system.domain.User;
 import me.zhengjie.modules.system.repository.DictDetailRepository;
+import me.zhengjie.modules.system.repository.SysConfigHolidayRepository;
 import me.zhengjie.modules.system.repository.UserRepository;
 import me.zhengjie.utils.ValidationUtil;
 import me.zhengjie.utils.FileUtil;
@@ -36,6 +40,8 @@
 import me.zhengjie.utils.PageUtil;
 import me.zhengjie.utils.QueryHelp;
 
+import java.time.*;
+import java.time.temporal.ChronoUnit;
 import java.util.*;
 import java.io.IOException;
 import javax.servlet.http.HttpServletResponse;
@@ -55,6 +61,7 @@
     private final AttendanceMapper attendanceMapper;
     private final UserRepository userRepository;
     private final DictDetailRepository dictDetailRepository;
+    private final SysConfigHolidayRepository sysConfigHolidayRepository;
 
     @Override
     public Map<String,Object> queryAll(AttendanceQueryCriteria criteria, Pageable pageable){
@@ -103,6 +110,97 @@
         attendanceRepository.save(attendance);
     }
 
+    /**
+     * 计算时间(小时)
+     * @param userId
+     * @return
+     */
+    @Override
+    public Integer calculateTimes(Calculate calculate, Long userId) {
+        User userInfo = userRepository.getOne(userId);
+        SysRostering sysRostering = userInfo.getSysRostering();
+        //计算天数
+        Integer count = calculateDays(calculate);
+        Calculate startCalculate = new Calculate();
+        startCalculate.setStart(calculate.getStart());
+        startCalculate.setEnd(calculate.getStart());
+        Integer startDays = calculateDays(startCalculate);
+
+        Calculate endCalculate = new Calculate();
+        endCalculate.setStart(calculate.getEnd());
+        endCalculate.setEnd(calculate.getEnd());
+        Integer endDays = calculateDays(endCalculate);
+
+        Integer time = 0;
+        time = (count - startDays - endDays) * 8 * 3600;
+        calculate.setStart(formateDateTime(calculate.getStart(), sysRostering));
+        calculate.setEnd(formateDateTime(calculate.getEnd(), sysRostering));
+
+        if (startDays > 0) {
+            Duration startDuration = Duration.between(calculate.getStart(), calculate.getStart().toLocalDate().atTime(sysRostering.getWorkEndTime()));
+            Long StartSeconds = startDuration.getSeconds();
+            if (calculate.getStart().toLocalTime().isBefore(LocalTime.NOON)) {
+                time += StartSeconds.intValue() - 3600;
+            }else if(calculate.getStart().toLocalTime().compareTo(LocalTime.NOON) >= 0 && calculate.getStart().toLocalTime().compareTo(calculate.getStart().toLocalDate().atTime(sysRostering.getLunchEndTime()).toLocalTime()) < 0){
+                //补充,请假开始时间大于等于中午基准休息时间小于休息结束时间
+                time += StartSeconds.intValue() - 3600;
+            } else {
+                time += StartSeconds.intValue();
+            }
+        }
+        if (endDays > 0) {
+            Duration endDuration = Duration.between(calculate.getEnd().toLocalDate().atTime(sysRostering.getWorkStartTime()), calculate.getEnd());
+            Long endSeconds = endDuration.getSeconds();
+            if (calculate.getEnd().toLocalTime().isAfter(LocalTime.NOON)) {
+                time += endSeconds.intValue() - 3600;
+            } else {
+                time += endSeconds.intValue();
+            }
+        }
+        return time;
+    }
+
+    /**
+     * 计算时间(天)
+     * @param calculate
+     * @return
+     */
+    @Override
+    public Integer calculateDays(Calculate calculate) {
+        List<String> holiday = new ArrayList<>(), isWork = new ArrayList<>();
+        //查询节假日表
+        List<SysConfigHoliday> sysConfigHolidayList = sysConfigHolidayRepository.findAll();
+        for(SysConfigHoliday sysConfigHoliday : sysConfigHolidayList){
+            if(sysConfigHoliday.getDateType().equals(Constant.DATE_TYPE_WEEKDAY)){
+                //工作日
+                isWork.add(sysConfigHoliday.getHolidayDate().toString());
+            }else{
+                holiday.add(sysConfigHoliday.getHolidayDate().toString());
+            }
+        }
+        Long chronoUnit =  ChronoUnit.DAYS.between(calculate.getStart().toLocalDate(), calculate.getEnd().toLocalDate());
+        Integer count = 0;
+        for (Integer i = 0; i <= chronoUnit; i++) {
+            LocalDate date = calculate.getStart().toLocalDate().plusDays(i);
+            Boolean isWeekend = date.getDayOfWeek() == DayOfWeek.SATURDAY || date.getDayOfWeek() == DayOfWeek.SUNDAY;
+            if ((!isWeekend && !holiday.contains(date.toString())) || (isWeekend && isWork.contains(date.toString()))) {
+                count++;
+            }
+        }
+        return count;
+    }
+
+    public LocalDateTime formateDateTime(LocalDateTime localDateTime, SysRostering sysRostering) {
+        if (localDateTime.toLocalTime().isBefore(sysRostering.getWorkStartTime())) {
+            return localDateTime.toLocalDate().atTime(sysRostering.getWorkStartTime());
+        } else if (localDateTime.toLocalTime().isAfter(sysRostering.getLunchStartTime()) && localDateTime.toLocalTime().isBefore(sysRostering.getLunchEndTime())) {
+            return localDateTime.toLocalDate().atTime(sysRostering.getWorkEndTime());
+        } else if (localDateTime.toLocalTime().isAfter(sysRostering.getWorkEndTime())) {
+            return localDateTime.toLocalDate().atTime(sysRostering.getWorkEndTime());
+        }
+        return localDateTime;
+    }
+
     @Override
     public void deleteAll(Long[] ids) {
         for (Long id : ids) {
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/mapstruct/AttendanceLeaveMapper.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/mapstruct/AttendanceLeaveMapper.java
new file mode 100644
index 0000000..e04670d
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/mapstruct/AttendanceLeaveMapper.java
@@ -0,0 +1,32 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.attendance.service.mapstruct;
+
+import me.zhengjie.base.BaseMapper;
+import me.zhengjie.modules.attendance.domain.AttendanceLeave;
+import me.zhengjie.modules.attendance.service.dto.AttendanceLeaveDto;
+import org.mapstruct.Mapper;
+import org.mapstruct.ReportingPolicy;
+
+/**
+* @website https://eladmin.vip
+* @author wcd
+* @date 2022-12-16
+**/
+@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
+public interface AttendanceLeaveMapper extends BaseMapper<AttendanceLeaveDto, AttendanceLeave> {
+
+}
\ No newline at end of file
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/constant/Constant.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/constant/Constant.java
index 6d0d766..3b941ae 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/constant/Constant.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/constant/Constant.java
@@ -59,11 +59,11 @@
 
     // 补卡审批状态
     public static final String CARD_APPROVE_STATUS = "card_approve_status";
-    // 补卡审批状态:待审核
+    // 审批状态:待审核
     public static final String CARD_APPROVE_STATUS_REVIEWED = "card_approve_status_reviewed";
-    // 补卡审批状态:已同意
+    // 审批状态:已同意
     public static final String CARD_APPROVE_STATUS_AGREE = "card_approve_status_agree";
-    // 补卡审批状态:已拒绝
+    // 审批状态:已拒绝
     public static final String CARD_APPROVE_STATUS_REFUSE = "card_approve_status_refuse";
 
     // 批准状态
@@ -132,6 +132,40 @@
     // 优先度:高
     public static final String PRIORITY_HIGH = "priority_high";
 
+    //请假时间单位
+    public static final String LEAVE_TIME_TYPE = "leave_time_type";
+    //请假时间单位: 小时
+    public static final String LEAVE_TIME_TYPE_HOUR = "leave_time_type_hour";
+    //请假时间单位: 天
+    public static final String LEAVE_TIME_TYPE_DAY = "leave_time_type_day";
+
+    // 请假状态
+    public static final String LEAVE_TYPE = "leave_type";
+    // 请假状态:年假
+    public static final String LEAVE_TYPE_ANNUAL_LEAVE = "leave_type_annual_leave";
+    // 请假状态:事假
+    public static final String LEAVE_TYPE_COMPASSIONATE_LEAVE = "leave_type_compassionate_leave";
+    // 请假状态:病假
+    public static final String LEAVE_TYPE_SICk_leave = "leave_type_sick_leave";
+    // 请假状态:产假
+    public static final String LEAVE_TYPE_maternity_leave = "leave_type_maternity_leave";
+    // 请假状态:婚假
+    public static final String LEAVE_TYPE_marriage_holiday = "leave_type_marriage_holiday";
+    // 请假状态:丧假
+    public static final String LEAVE_TYPE_bereavement_leave = "leave_type_bereavement_leave";
+    // 请假状态:哺乳假
+    public static final String LEAVE_TYPE_lactation_leave = "leave_type_lactation_leave";
+
+    // 请假审批状态
+    public static final String APPROVAL_STATUS = "approval_status";
+    // 审批状态:待审核
+    public static final String APPROVAL_STATUS_UNDER_APPROVAL = "approval_status_under_approval";
+    // 审批状态:已同意
+    public static final String APPROVAL_STATUS_PASSED = "approval_status_passed";
+    // 审批状态:已拒绝
+    public static final String APPROVAL_STATUS_RETURNED = "approval_status_returned";
+
+
     // 任务状态
     public static final String TASK_STATUS = "task_status";
     // 任务状态:未开始
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/SysUserLevelOtherRepository.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/SysUserLevelOtherRepository.java
index 3a6c095..8047c7c 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/SysUserLevelOtherRepository.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/SysUserLevelOtherRepository.java
@@ -20,6 +20,8 @@
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
 import org.springframework.data.jpa.repository.Query;
 
+import java.util.List;
+
 /**
 * @website https://eladmin.vip
 * @author 赵士淞
@@ -34,4 +36,11 @@
      */
     @Query(value = "SELECT * FROM sys_user_level_other WHERE user_id = ?1 ORDER BY start_date DESC, create_time DESC LIMIT 1", nativeQuery = true)
     SysUserLevelOther findLastByUserId(Long userId);
+
+    /**
+     * 根据用户查询记录
+     * @param userId
+     * @return
+     */
+    List<SysUserLevelOther> findByUserId(Long userId);
 }
\ No newline at end of file
diff --git a/eladmin-web-master/src/api/attendance/attendanceLeave.js b/eladmin-web-master/src/api/attendance/attendanceLeave.js
new file mode 100644
index 0000000..a53cb04
--- /dev/null
+++ b/eladmin-web-master/src/api/attendance/attendanceLeave.js
@@ -0,0 +1,58 @@
+import request from '@/utils/request'
+
+export function getAll(params) {
+  return request({
+    url: 'api/attendanceLeave/all',
+    method: 'get',
+    params
+  })
+}
+
+export function add(data) {
+  return request({
+    url: 'api/attendanceLeave',
+    method: 'post',
+    data
+  })
+}
+
+export function del(ids) {
+  return request({
+    url: 'api/attendanceLeave/',
+    method: 'delete',
+    data: ids
+  })
+}
+
+export function edit(data) {
+  return request({
+    url: 'api/attendanceLeave',
+    method: 'put',
+    data
+  })
+}
+
+export function calcTimeLength(data) {
+  return request({
+    url: 'api/attendanceLeave/calcTimeLength',
+    method: 'post',
+    data
+  })
+}
+
+export function getYearTimeLength() {
+  return request({
+    url: 'api/attendanceLeave/getYearTimeLength',
+    method: 'post',
+  })
+}
+
+export function approve(data) {
+  return request({
+    url: 'api/attendanceLeave/approve',
+    method: 'put',
+    data
+  })
+}
+
+export default { add, edit, del, getAll, calcTimeLength, getYearTimeLength, approve }
diff --git a/eladmin-web-master/src/views/attendance/attendanceLeave/index.vue b/eladmin-web-master/src/views/attendance/attendanceLeave/index.vue
new file mode 100644
index 0000000..944ad4f
--- /dev/null
+++ b/eladmin-web-master/src/views/attendance/attendanceLeave/index.vue
@@ -0,0 +1,451 @@
+<template>
+  <div class="app-container">
+    <!--工具栏-->
+    <div class="head-container">
+      <div>
+        <el-select v-model="query.userId" filterable clearable placeholder="请选择发起员工" style="width: 170px;" class="filter-item" @keyup.enter.native="crud.toQuery">
+          <el-option
+            v-for="item in users"
+            :key="item.id"
+            :label="item.nickName"
+            :value="item.id"
+          />
+        </el-select>
+        <el-select v-model="query.leaveType" filterable clearable placeholder="请选择请假类型" style="width: 170px;" class="filter-item" @keyup.enter.native="crud.toQuery">
+          <el-option
+            v-for="item in dict[dictLeaveType]"
+            :key="item.value"
+            :label="item.label"
+            :value="item.value"
+          />
+        </el-select>
+        <el-select v-model="query.approvalStatus" filterable clearable placeholder="请选择审批状态" style="width: 170px;" class="filter-item" @keyup.enter.native="crud.toQuery">
+          <el-option
+            v-for="item in dict[dictApprovalStart]"
+            :key="item.value"
+            :label="item.label"
+            :value="item.value"
+          />
+        </el-select>
+        <el-date-picker
+          v-model="query.leaveStartTime"
+          clearable
+          class="filter-item"
+          value-format="yyyy-MM-dd HH:mm:ss"
+          placeholder="请选择开始时间"
+        />
+        <el-date-picker
+          v-model="query.leaveEndTime"
+          clearable
+          class="filter-item"
+          value-format="yyyy-MM-dd HH:mm:ss"
+          placeholder="请选择结束时间"
+        />
+        <rrOperation />
+      </div>
+      <!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'-->
+      <crudOperation :permission="permission" />
+      <!--表单组件-->
+      <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
+        <el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
+          <el-form-item label="审批员工" prop="approvalUserId">
+            <el-select v-model="form.approvalUserId" filterable clearable placeholder="请选择审批员工" style="width: 370px;" class="filter-item" @keyup.enter.native="crud.toQuery">
+              <el-option
+                v-for="item in users"
+                :key="item.id"
+                :label="item.nickName"
+                :value="item.id"
+              />
+            </el-select>
+          </el-form-item>
+          <el-form-item label="请假类型" prop="leaveType">
+            <el-select v-model="form.leaveType" filterable clearable placeholder="请选择请假类型" style="width: 370px;" @change="checkLeaveTime">
+              <el-option
+                v-for="item in dict[dictLeaveType]"
+                :key="item.value"
+                :label="item.label"
+                :value="item.value"
+              />
+            </el-select>
+          </el-form-item>
+          <el-form-item label="开始时间" prop="leaveStartTime">
+            <el-date-picker
+              v-model="form.leaveStartTime"
+              :type="form.leaveType !== dictLeaveTypeAnnualLeave && form.leaveType !== dictLeaveTypeCompassionateLeave ? 'date' : 'datetime'"
+              placeholder="选择日期时间"
+              style="width: 370px;"
+              value-format="yyyy-MM-dd HH:mm:ss"
+              align="right"
+              :picker-options="{ disabledDate(time) {
+                return form.leaveEndTime ? time.getTime() > new Date(form.leaveEndTime).getTime() - 8.64e7 : false;
+              }
+              }"
+              @change="checkLeaveTime"
+              default-time="09:00:00"
+            />
+          </el-form-item>
+          <el-form-item label="结束时间" prop="leaveEndTime">
+            <el-date-picker
+              v-model="form.leaveEndTime"
+              :type="form.leaveType !== dictLeaveTypeAnnualLeave && form.leaveType !== dictLeaveTypeCompassionateLeave ? 'date' : 'datetime'"
+              placeholder="选择日期时间"
+              style="width: 370px;"
+              value-format="yyyy-MM-dd HH:mm:ss"
+              align="right"
+              @change="checkLeaveTime"
+              default-time="18:00:00"
+            />
+          </el-form-item>
+          <el-form-item label="请假时长" prop="leaveDuration">
+            <el-input v-model="form.leaveDuration" disabled style="width: 370px;">
+              <template slot="append">{{ dict.label[dictLeaveTimeType][form.leaveDurationUnit] }}</template>
+            </el-input>
+          </el-form-item>
+          <el-form-item label="请假原因">
+            <el-input v-model="form.leaveReason" type="textarea" rows="3" style="width: 370px;" />
+          </el-form-item>
+          <el-form-item label="审批说明">
+            <el-input v-model="form.approvalDescription" type="textarea" rows="3" style="width: 370px;" />
+          </el-form-item>
+          <el-form-item label="备注">
+            <el-input v-model="form.remarks" type="textarea" rows="3" style="width: 370px;" />
+          </el-form-item>
+        </el-form>
+        <div slot="footer" class="dialog-footer">
+          <el-button type="text" @click="crud.cancelCU">取消</el-button>
+          <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
+        </div>
+      </el-dialog>
+      <!--审核表单-->
+      <el-dialog :close-on-click-modal="false" :before-close="closeCard" :visible.sync="makeUpCardVisible" title="请假审批" width="500px">
+        <div class="form-item">
+          <div class="form-item-label">
+            <label>申请人:</label>
+          </div>
+          <div class="form-item-value">{{ form.userName }}</div>
+        </div>
+        <div class="form-item">
+          <div class="form-item-label">
+            <label>请假类型:</label>
+          </div>
+          <div class="form-item-value"><el-tag>{{ dict.label[dictLeaveType][form.leaveType] }}</el-tag></div>
+        </div>
+        <div class="form-item">
+          <div class="form-item-label">
+            <label>开始时间:</label>
+          </div>
+          <div class="form-item-value">{{ form.leaveDurationUnit === dictLeaveTimeTypeHour ? form.leaveStartTime : crud.toDate(form.leaveStartTime) }}</div>
+        </div>
+        <div class="form-item">
+          <div class="form-item-label">
+            <label>结束时间:</label>
+          </div>
+          <div class="form-item-value">{{ form.leaveDurationUnit === dictLeaveTimeTypeHour ? form.leaveEndTime : crud.toDate(form.leaveEndTime) }}</div>
+        </div>
+        <div class="form-item">
+          <div class="form-item-label">
+            <label>请假时长:</label>
+          </div>
+          <div class="form-item-value">{{ form.leaveDuration + '(' + dict.label[dictLeaveTimeType][form.leaveDurationUnit] + ')' }}</div>
+        </div>
+        <div class="form-item">
+          <div class="form-item-label">
+            <label>请假原因:</label>
+          </div>
+          <div class="form-item-value">{{ form.leaveReason }}</div>
+        </div>
+        <div class="form-item">
+          <div class="form-item-label">
+            <label>备注:</label>
+          </div>
+          <div class="form-item-value">{{ form.remarks }}</div>
+        </div>
+        <el-form ref="form" :model="form" :rules="rules" size="small" label-width="92px">
+          <el-form-item v-if="form.approvalStatus === dictAppRovalStatusReturn" label="退回原因:" prop="approvalDescription">
+            <div style="color: red;">*审核退回需要填写退回原因,请填写后再次点击审核退回</div>
+            <el-input v-model="form.approvalDescription" type="textarea" :rows="3" style="width: 370px;" />
+          </el-form-item>
+        </el-form>
+        <div slot="footer" class="dialog-footer">
+          <el-button type="danger" style="margin-right: 10px;" @click="approveFunction(1,form)">审核退回</el-button>
+          <el-button v-if="form.approvalStatus !== dictAppRovalStatusReturn" :loading="successLoading" type="success" @click="approveFunction(2,form)">审核通过</el-button>
+        </div>
+      </el-dialog>
+      <!--表格渲染-->
+      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
+        <el-table-column type="selection" width="55" />
+        <el-table-column v-if="false" prop="id" label="id" show-overflow-tooltip />
+        <el-table-column v-if="false" prop="userId" label="申请人ID" show-overflow-tooltip />
+        <el-table-column prop="userName" label="员工" />
+        <el-table-column prop="appUserName" label="审批员工" />
+        <el-table-column prop="leaveType" label="请假类型" show-overflow-tooltip>
+          <template slot-scope="scope">
+            <el-tag>{{ dict.label[dictLeaveType][scope.row.leaveType] }}</el-tag>
+          </template>
+        </el-table-column>
+        <el-table-column prop="leaveStartTime" min-width="120" label="请假开始时间" show-overflow-tooltip>
+          <template slot-scope="scope">
+            {{ scope.row.leaveDurationUnit === dictLeaveTimeTypeHour ? scope.row.leaveStartTime : crud.toDate(scope.row.leaveStartTime) }}
+          </template>
+        </el-table-column>
+        <el-table-column prop="leaveEndTime" min-width="120" label="请假结束时间" show-overflow-tooltip>
+          <template slot-scope="scope">
+            {{ scope.row.leaveDurationUnit === dictLeaveTimeTypeHour ? scope.row.leaveEndTime : crud.toDate(scope.row.leaveEndTime) }}
+          </template>
+        </el-table-column>
+        <el-table-column prop="leaveDuration" label="请假时长" show-overflow-tooltip>
+          <template slot-scope="scope">
+            {{ scope.row.leaveDuration + '(' + dict.label[dictLeaveTimeType][scope.row.leaveDurationUnit] + ')' }}
+          </template>
+        </el-table-column>
+        <el-table-column prop="leaveReason" label="请假原因" show-overflow-tooltip />
+        <el-table-column prop="approvalStatus" label="审批状态" show-overflow-tooltip>
+          <template slot-scope="scope">
+            <el-tag v-if="scope.row.approvalStatus === dictAppRovalStatusUnderAppover" type="warning">{{ dict.label[dictApprovalStart][scope.row.approvalStatus] }}</el-tag>
+            <el-tag v-if="scope.row.approvalStatus === dictAppRovalStatusPassed" type="success">{{ dict.label[dictApprovalStart][scope.row.approvalStatus] }}</el-tag>
+            <el-tag v-if="scope.row.approvalStatus === dictAppRovalStatusReturn" type="danger">{{ dict.label[dictApprovalStart][scope.row.approvalStatus] }}</el-tag>
+          </template>
+        </el-table-column>
+        <el-table-column prop="approvalDescription" label="审批说明" show-overflow-tooltip />
+        <el-table-column prop="remarks" label="备注" show-overflow-tooltip />
+        <el-table-column prop="createTime" label="创建时间" show-overflow-tooltip />
+        <el-table-column label="审核操作" min-width="120px" align="center">
+          <template slot-scope="scope">
+            <el-button
+              v-if="scope.row.approvalUserId === $store.state.user.user.id"
+              :loading="crud.status.cu === 2"
+              size="mini"
+              type="primary"
+              icon="el-icon-s-check"
+              :disabled="scope.row.approvalStatus === dictAppRovalStatusUnderAppover ? false : true"
+              @click="toApprove(scope.row)"
+            >审核
+            </el-button>
+          </template>
+        </el-table-column>
+        <el-table-column v-if="checkPer(['admin','attendanceLeave:edit','attendanceLeave:del'])" label="操作" width="150px" align="center">
+          <template slot-scope="scope">
+            <udOperation
+              :data="scope.row"
+              :permission="permission"
+            />
+          </template>
+        </el-table-column>
+      </el-table>
+      <!--分页组件-->
+      <pagination />
+    </div>
+  </div>
+</template>
+
+<script>
+import crudAttendanceLeave from '@/api/attendance/attendanceLeave'
+import crudUser from '@/api/system/user'
+import CRUD, { presenter, header, form, crud } from '@crud/crud'
+import rrOperation from '@crud/RR.operation'
+import crudOperation from '@crud/CRUD.operation'
+import udOperation from '@crud/UD.operation'
+import pagination from '@crud/Pagination'
+import constant from '@/utils/constant'
+
+const defaultForm = { id: null, userId: null, approvalUserId: null, leaveType: null, leaveStartTime: null, leaveEndTime: null, leaveDuration: null, leaveDurationUnit: null, leaveReason: null, approvalStatus: null, approvalDescription: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null }
+export default {
+  name: 'AttendanceLeave',
+  components: { pagination, crudOperation, rrOperation, udOperation },
+  mixins: [presenter(), header(), form(defaultForm), crud()],
+  cruds() {
+    return CRUD({ title: '请假', url: 'api/attendanceLeave', idField: 'id', sort: 'id,desc', crudMethod: { ...crudAttendanceLeave }})
+  },
+  // 数据字典
+  dicts: [constant.LEAVE_TYPE, constant.APPROVAL_STATUS, constant.LEAVE_TIME_TYPE],
+  data() {
+    return {
+      permission: {
+        add: ['admin', 'attendanceLeave:add'],
+        edit: ['admin', 'attendanceLeave:edit'],
+        del: ['admin', 'attendanceLeave:del'],
+        download: ['admin', 'attendanceLeave:download']
+      },
+      rules: {
+        approvalUserId: [
+          { required: true, message: '审批用户ID不能为空', trigger: 'change' }
+        ],
+        leaveType: [
+          { required: true, message: '请假类型不能为空', trigger: 'change' }
+        ],
+        leaveStartTime: [
+          { required: true, message: '请假开始时间不能为空', trigger: 'change' }
+        ],
+        leaveEndTime: [
+          { required: true, message: '请假结束时间不能为空', trigger: 'blchangeur' }
+        ],
+        leaveDuration: [
+          { required: true, message: '请假时长不能为空', trigger: 'blur' }
+        ],
+        approvalStatus: [
+          { required: true, message: '审批状态不能为空', trigger: 'change' }
+        ],
+        approvalDescription: [
+          { required: true, message: '审批说明不能为空', trigger: 'change' }
+        ],
+        createBy: [
+          { required: true, message: '创建者不能为空', trigger: 'blur' }
+        ],
+        createTime: [
+          { required: true, message: '创建时间不能为空', trigger: 'blur' }
+        ]
+      },
+      users: [],
+      dictLeaveType: constant.LEAVE_TYPE,
+      dictLeaveTypeAnnualLeave: constant.LEAVE_TYPE_ANNUAL_LEAVE,
+      dictLeaveTypeCompassionateLeave: constant.LEAVE_TYPE_COMPASSIONATE_LEAVE,
+      dictApprovalStart: constant.APPROVAL_STATUS,
+      dictAppRovalStatusUnderAppover: constant.APPROVAL_STATUS_UNDER_APPROVAL,
+      dictAppRovalStatusPassed: constant.APPROVAL_STATUS_PASSED,
+      dictAppRovalStatusReturn: constant.APPROVAL_STATUS_RETURNED,
+      dictLeaveTimeType: constant.LEAVE_TIME_TYPE,
+      dictLeaveTimeTypeHour: constant.LEAVE_TIME_TYPE_HOUR,
+      dictLeaveTimeTypeDay: constant.LEAVE_TIME_TYPE_DAY,
+      yearTimeLenght: null,
+      makeUpCardVisible: false,
+      successLoading: false }
+  },
+  created() {
+    this.getUsers()
+    this.getUserTimes()
+  },
+  methods: {
+    // 钩子:在获取表格数据之前执行,false 则代表不获取数据
+    [CRUD.HOOK.beforeRefresh]() {
+      return true
+    },
+    // 钩子:在编辑之前执行
+    [CRUD.HOOK.beforeToEdit]() {
+      this.getUserTimes()
+    },
+    // 钩子:在提交表单之后执行
+    [CRUD.HOOK.afterSubmit]() {
+      this.getUserTimes()
+    },
+    // 查询员工
+    getUsers() {
+      crudUser.getAll().then(res => {
+        this.users = res
+      })
+    },
+    checkLeaveTime() {
+      // 根据请假类型改变时间单位
+      if (this.form.leaveType === this.dictLeaveTypeAnnualLeave || this.form.leaveType === this.dictLeaveTypeCompassionateLeave) {
+        this.form.leaveDurationUnit = this.dictLeaveTimeTypeHour
+      } else {
+        this.form.leaveDurationUnit = this.dictLeaveTimeTypeDay
+      }
+      if (this.form.leaveType == null || this.form.leaveStartTime == null || this.form.leaveEndTime == null) {
+        return
+      }
+      // 通过后台计算时长
+      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.yearTimeLenght < res.leaveDuration) {
+          this.form.leaveDuration = null
+          this.$message({
+            message: '年假剩余时间不足',
+            type: 'error'
+          })
+        } else {
+          this.form.leaveDuration = res.leaveDuration
+        }
+        console.log(res)
+      })
+    },
+    // 查询员工剩余年假时长
+    getUserTimes() {
+      crudAttendanceLeave.getYearTimeLength().then(res => {
+        console.log(res)
+        this.yearTimeLenght = res
+      })
+    },
+    // 审批页面赋值
+    toApprove(data) {
+      this.makeUpCardVisible = true
+      this.form.id = data.id
+      this.form.userId = data.userId
+      this.form.userName = data.userName
+      this.form.leaveType = data.leaveType
+      this.form.leaveStartTime = data.leaveStartTime
+      this.form.leaveEndTime = data.leaveEndTime
+      this.form.leaveDuration = data.leaveDuration
+      this.form.leaveDurationUnit = data.leaveDurationUnit
+      this.form.leaveReason = data.leaveReason
+      this.form.remarks = data.remarks
+    },
+    // 审核提交功能
+    approveFunction(Number, data) {
+      this.form.userId = data.userId
+      const msg = Number === 2 ? '通过' : '拒绝'
+      this.$refs['form'].validate(valid => {
+        if (!valid) {
+          return
+        }
+        // 判断通过状态
+        if (Number === 2) {
+          this.form.approvalStatus = this.dictAppRovalStatusPassed
+        } else {
+          // 退回改状态显示退回原因
+          this.form.approvalStatus = this.dictAppRovalStatusReturn
+          if (this.form.approvalDescription == null) {
+            return
+          }
+        }
+        crudAttendanceLeave.approve(this.form).then(res => {
+          this.crud.refresh()
+          this.makeUpCardVisible = false
+          this.successLoading = false
+          this.$message({
+            type: 'success',
+            message: '审核' + msg + '成功'
+          })
+        }).catch(() => {
+          this.makeUpCardVisible = false
+          this.successLoading = false
+        })
+        if (this.$refs['form']) {
+          this.$refs['form'].resetFields()
+        }
+      })
+    },
+    // 关闭
+    closeCard() {
+      if (this.$refs['form']) {
+        this.$refs['form'].resetFields()
+      }
+      this.crud.cancelCU()
+      this.makeUpCardVisible = false
+    }
+  }
+}
+</script>
+
+<style scoped>
+.form-item {
+  width: 100%;
+  display: flex;
+  margin-bottom: 20px;
+}
+.form-item-label {
+  width: 20%;
+  display: flex;
+  padding-left: 20px;
+}
+.form-item-value {
+  width: 80%;
+  display: flex;
+  padding-left: 25px;
+  padding-right: 25px;
+}
+</style>

--
Gitblit v1.9.3