赵士淞
2023-01-06 34d353e6e27240ed1ecbcf1318fcba31800bf064
Merge branch 'weicd' of http://192.168.1.110:5678/r/pms-upgrade into master

# Conflicts:
# eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/constant/Constant.java
# eladmin-web-master/src/api/attendance/attendance.js
# eladmin-web-master/src/utils/constant.js
20 files added
13 files modified
3653 ■■■■■ changed files
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/domain/AttendanceBusinessTravel.java 105 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/domain/AttendanceGoOut.java 102 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/repository/AttendanceBusinessTravelRepository.java 44 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/repository/AttendanceCardreplacementRepository.java 2 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/repository/AttendanceGoOutRepository.java 43 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/rest/AttendanceBusinessTravelController.java 120 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/rest/AttendanceController.java 16 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/rest/AttendanceGoOutController.java 112 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/AttendanceBusinessTravelService.java 103 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/AttendanceGoOutService.java 97 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/AttendanceService.java 8 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceBusinessTravelDto.java 75 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceBusinessTravelQueryCriteria.java 45 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceGoOutDto.java 72 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceGoOutQueryCriteria.java 49 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceLeaveQueryCriteria.java 20 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceBusinessTravelServiceImpl.java 347 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceCardreplacementServiceImpl.java 39 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceGoOutServiceImpl.java 365 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceLeaveServiceImpl.java 212 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceServiceImpl.java 64 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/mapstruct/AttendanceBusinessTravelMapper.java 32 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/mapstruct/AttendanceGoOutMapper.java 32 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/constant/Constant.java 38 ●●●●● patch | view | raw | blame | history
eladmin-web-master/src/api/attendance/attendance.js 17 ●●●●● patch | view | raw | blame | history
eladmin-web-master/src/api/attendance/attendanceBusinessTravel.js 59 ●●●●● patch | view | raw | blame | history
eladmin-web-master/src/api/attendance/attendanceGoOut.js 51 ●●●●● patch | view | raw | blame | history
eladmin-web-master/src/utils/constant.js 37 ●●●●● patch | view | raw | blame | history
eladmin-web-master/src/views/attendance/attendance/index.vue 402 ●●●●● patch | view | raw | blame | history
eladmin-web-master/src/views/attendance/attendanceBusinessTravel/index.vue 421 ●●●●● patch | view | raw | blame | history
eladmin-web-master/src/views/attendance/attendanceCardReplacement/index.vue 61 ●●●●● patch | view | raw | blame | history
eladmin-web-master/src/views/attendance/attendanceGoOut/index.vue 429 ●●●●● patch | view | raw | blame | history
eladmin-web-master/src/views/attendance/attendanceLeave/index.vue 34 ●●●●● patch | view | raw | blame | history
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/domain/AttendanceBusinessTravel.java
New file
@@ -0,0 +1,105 @@
/*
*  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 2023-01-05
**/
@Entity
@Data
@Table(name="attendance_business_travel")
public class AttendanceBusinessTravel 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 = "`travel_start_time`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "出差开始时间")
    private Timestamp travelStartTime;
    @Column(name = "`travel_end_time`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "出差结束时间")
    private Timestamp travelEndTime;
    @Column(name = "`travel_duration`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "出差时长")
    private Double travelDuration;
    @Column(name = "`duration_unit`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "时长单位")
    private String durationUnit;
    @Column(name = "`travel_reason`")
    @ApiModelProperty(value = "出差原因")
    private String travelReason;
    @Column(name = "`departure_city`")
    @ApiModelProperty(value = "出发城市")
    private String departureCity;
    @Column(name = "`arrival_city`")
    @ApiModelProperty(value = "到达城市")
    private String arrivalCity;
    @Column(name = "`approval_status`",nullable = false)
    @NotBlank
    @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(AttendanceBusinessTravel source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/domain/AttendanceGoOut.java
New file
@@ -0,0 +1,102 @@
/*
*  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 2023-01-04
**/
@Entity
@Data
@Table(name="attendance_go_out")
public class AttendanceGoOut 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 = "`out_start_time`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "外出开始时间")
    private Timestamp outStartTime;
    @Column(name = "`out_end_time`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "外出结束时间")
    private Timestamp outEndTime;
    @Column(name = "`out_duration`",nullable = false)
    @NotNull
    @ApiModelProperty(value = "外出时长")
    private Double outDuration;
    @Column(name = "`duration_unit`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "时长单位")
    private String durationUnit;
    @Column(name = "`out_of_office_type`",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "外出类型")
    private String outOfOfficeType;
    @Column(name = "`out_reason`")
    @ApiModelProperty(value = "外出原因")
    private String outReason;
    @Column(name = "`approval_status`",nullable = false)
    @NotBlank
    @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(AttendanceGoOut source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/repository/AttendanceBusinessTravelRepository.java
New file
@@ -0,0 +1,44 @@
/*
*  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.AttendanceBusinessTravel;
import me.zhengjie.modules.attendance.domain.AttendanceGoOut;
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 2023-01-05
**/
public interface AttendanceBusinessTravelRepository extends JpaRepository<AttendanceBusinessTravel, Long>, JpaSpecificationExecutor<AttendanceBusinessTravel> {
    //添加时查询出差时间是否冲突(添加)
    @Query(value = "SELECT * FROM attendance_business_travel WHERE user_id = ?3 AND approval_status IN ('business_approve_status_reviewed', 'business_approve_status_agree') AND ((travel_start_time >= ?1 and travel_start_time <= ?2) OR \n" +
            "(travel_start_time <= ?1 and travel_end_time >= ?2) OR (travel_end_time >= ?1 and travel_end_time <= ?2) OR (travel_start_time >= ?1 and travel_end_time <= ?2))", nativeQuery = true)
    List<AttendanceBusinessTravel> checkCreateTime(String startTime, String endTime, Long userId);
    //查询出差记录是否存在或时间冲突(修改)
    @Query(value = "SELECT * FROM attendance_business_travel WHERE user_id = ?3 AND approval_status IN ('business_approve_status_reviewed', 'business_approve_status_agree') AND id NOT IN ?4 AND ((travel_start_time >= ?1 and travel_start_time <= ?2) OR \n" +
            "(travel_start_time <= ?1 and travel_end_time >= ?2) OR (travel_end_time >= ?1 and travel_end_time <= ?2) OR (travel_start_time >= ?1 and travel_end_time <= ?2))", nativeQuery = true)
    List<AttendanceBusinessTravel> checkCreateUpdateTime(String startTime, String endTime, Long userId, Set<Long> ids);
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/repository/AttendanceCardreplacementRepository.java
@@ -21,6 +21,7 @@
import org.springframework.data.jpa.repository.Query;
import java.sql.Timestamp;
import java.util.Optional;
/**
* @website https://eladmin.vip
@@ -32,4 +33,5 @@
    //查询补卡记录是否存
    @Query(value = "SELECT * from attendance_cardreplacement WHERE user_id = ? and card_replacement_time = ? and approval_status != 'card_approve_status_refuse'",nativeQuery = true)
    AttendanceCardreplacement findByUserIdAndCardReplacementTime(Long userId, Timestamp checkTime);
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/repository/AttendanceGoOutRepository.java
New file
@@ -0,0 +1,43 @@
/*
*  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.AttendanceGoOut;
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 2023-01-04
**/
public interface AttendanceGoOutRepository extends JpaRepository<AttendanceGoOut, Long>, JpaSpecificationExecutor<AttendanceGoOut> {
    //查询外出记录是否存在或时间冲突(添加)
    @Query(value = "SELECT * FROM attendance_go_out WHERE user_id = ?3 AND approval_status IN ('go_out_approve_status_reviewed', 'go_out_approve_status_agree') AND ((out_start_time >= ?1 and out_start_time <= ?2) OR \n" +
            "(out_start_time <= ?1 and out_end_time >= ?2) OR (out_end_time >= ?1 and out_end_time <= ?2) OR (out_start_time >= ?1 and out_end_time <= ?2))", nativeQuery = true)
    List<AttendanceGoOut> checkCreateTime(String startTime, String endTime, Long userId);
    //查询外出记录是否存在或时间冲突(修改)
    @Query(value = "SELECT * FROM attendance_go_out WHERE user_id = ?3 AND approval_status IN ('go_out_approve_status_reviewed', 'go_out_approve_status_agree') AND id NOT IN ?4 AND ((out_start_time >= ?1 and out_start_time <= ?2) OR \n" +
            "(out_start_time <= ?1 and out_end_time >= ?2) OR (out_end_time >= ?1 and out_end_time <= ?2) OR (out_start_time >= ?1 and out_end_time <= ?2))", nativeQuery = true)
    List<AttendanceGoOut> checkCreateUpdateTime(String startTime, String endTime, Long userId, Set<Long> ids);
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/rest/AttendanceBusinessTravelController.java
New file
@@ -0,0 +1,120 @@
/*
*  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.AttendanceBusinessTravel;
import me.zhengjie.modules.attendance.domain.AttendanceCardreplacement;
import me.zhengjie.modules.attendance.domain.AttendanceGoOut;
import me.zhengjie.modules.attendance.service.AttendanceBusinessTravelService;
import me.zhengjie.modules.attendance.service.dto.AttendanceBusinessTravelQueryCriteria;
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 javax.servlet.http.HttpServletResponse;
/**
* @website https://eladmin.vip
* @author wcd
* @date 2023-01-05
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "考勤出差管理")
@RequestMapping("/api/attendanceBusinessTravel")
public class AttendanceBusinessTravelController {
    private final AttendanceBusinessTravelService attendanceBusinessTravelService;
    @Log("导出数据")
    @ApiOperation("导出数据")
    @GetMapping(value = "/download")
    @PreAuthorize("@el.check('attendanceBusinessTravel:list')")
    public void exportAttendanceBusinessTravel(HttpServletResponse response, AttendanceBusinessTravelQueryCriteria criteria) throws IOException {
        attendanceBusinessTravelService.download(attendanceBusinessTravelService.queryAll(criteria), response);
    }
    @GetMapping
    @Log("查询考勤出差")
    @ApiOperation("查询考勤出差")
    @PreAuthorize("@el.check('attendanceBusinessTravel:list')")
    public ResponseEntity<Object> queryAttendanceBusinessTravel(AttendanceBusinessTravelQueryCriteria criteria, Pageable pageable){
        return new ResponseEntity<>(attendanceBusinessTravelService.queryAll(criteria,pageable),HttpStatus.OK);
    }
    @GetMapping(value = "/all")
    @Log("查询考勤出差")
    @ApiOperation("查询考勤出差")
    @PreAuthorize("@el.check('attendanceBusinessTravel:list')")
    public ResponseEntity<Object> queryAttendanceBusinessTravel(AttendanceBusinessTravelQueryCriteria criteria){
        return new ResponseEntity<>(attendanceBusinessTravelService.queryAll(criteria),HttpStatus.OK);
    }
    @PostMapping
    @Log("新增考勤出差")
    @ApiOperation("新增考勤出差")
    @PreAuthorize("@el.check('attendanceBusinessTravel:add')")
    public ResponseEntity<Object> createAttendanceBusinessTravel(@Validated @RequestBody AttendanceBusinessTravel resources) throws Exception {
        return new ResponseEntity<>(attendanceBusinessTravelService.create(resources),HttpStatus.CREATED);
    }
    @PutMapping
    @Log("修改考勤出差")
    @ApiOperation("修改考勤出差")
    @PreAuthorize("@el.check('attendanceBusinessTravel:edit')")
    public ResponseEntity<Object> updateAttendanceBusinessTravel(@Validated @RequestBody AttendanceBusinessTravel resources){
        attendanceBusinessTravelService.update(resources);
        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
    }
    @DeleteMapping
    @Log("删除考勤出差")
    @ApiOperation("删除考勤出差")
    @PreAuthorize("@el.check('attendanceBusinessTravel:del')")
    public ResponseEntity<Object> deleteAttendanceBusinessTravel(@RequestBody Long[] ids) {
        attendanceBusinessTravelService.deleteAll(ids);
        return new ResponseEntity<>(HttpStatus.OK);
    }
    @PostMapping(value = "/getRemainingTime")
    @Log("获取出差时长")
    @ApiOperation("获取出差时长")
    public ResponseEntity<Object> getRemainingTime(@Validated @RequestBody AttendanceBusinessTravel resources){
        return new ResponseEntity<>(attendanceBusinessTravelService.getRemainingTime(resources),HttpStatus.CREATED);
    }
    @PutMapping(value = "/approve")
    @Log("审核功能")
    @ApiOperation("审核功能")
    public ResponseEntity<Object> checkApprove(@Validated @RequestBody AttendanceBusinessTravel resources){
        attendanceBusinessTravelService.updateApprove(resources);
        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
    }
    @PutMapping(value = "/revoke")
    @Log("出差撤销")
    @ApiOperation("出差撤销")
    public ResponseEntity<Object> revokeBussiness(@Validated @RequestBody AttendanceBusinessTravel resources){
        attendanceBusinessTravelService.updateRevoke(resources);
        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
    }
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/rest/AttendanceController.java
@@ -97,4 +97,20 @@
        attendanceService.deleteAll(ids);
        return new ResponseEntity<>(HttpStatus.OK);
    }
    @PostMapping(value = "/getExceptional")
    @Log("获取异常")
    @ApiOperation("获取异常")
    public ResponseEntity<Object> getExceptional(@Validated @RequestBody String Number){
        attendanceService.getExceptional(Number);
        return new ResponseEntity<>(HttpStatus.CREATED);
    }
    @PostMapping(value = "/getUserMakeUpCard")
    @Log("补卡判断登录人")
    @ApiOperation("补卡判断登录人")
    public ResponseEntity<Object> getUserMakeUpCard(@Validated @RequestBody String userId){
        attendanceService.getUserMakeUpCard(userId);
        return new ResponseEntity<>(HttpStatus.CREATED);
    }
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/rest/AttendanceGoOutController.java
New file
@@ -0,0 +1,112 @@
/*
*  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.AttendanceGoOut;
import me.zhengjie.modules.attendance.domain.AttendanceLeave;
import me.zhengjie.modules.attendance.service.AttendanceGoOutService;
import me.zhengjie.modules.attendance.service.dto.AttendanceGoOutQueryCriteria;
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 javax.servlet.http.HttpServletResponse;
/**
* @website https://eladmin.vip
* @author wcd
* @date 2023-01-04
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "考勤外出管理")
@RequestMapping("/api/attendanceGoOut")
public class AttendanceGoOutController {
    private final AttendanceGoOutService attendanceGoOutService;
    @Log("导出数据")
    @ApiOperation("导出数据")
    @GetMapping(value = "/download")
    @PreAuthorize("@el.check('attendanceGoOut:list')")
    public void exportAttendanceGoOut(HttpServletResponse response, AttendanceGoOutQueryCriteria criteria) throws IOException {
        attendanceGoOutService.download(attendanceGoOutService.queryAll(criteria), response);
    }
    @GetMapping
    @Log("查询考勤外出")
    @ApiOperation("查询考勤外出")
    @PreAuthorize("@el.check('attendanceGoOut:list')")
    public ResponseEntity<Object> queryAttendanceGoOut(AttendanceGoOutQueryCriteria criteria, Pageable pageable){
        return new ResponseEntity<>(attendanceGoOutService.queryAll(criteria,pageable),HttpStatus.OK);
    }
    @GetMapping(value = "/all")
    @Log("查询考勤外出")
    @ApiOperation("查询考勤外出")
    @PreAuthorize("@el.check('attendanceGoOut:list')")
    public ResponseEntity<Object> queryAttendanceGoOut(AttendanceGoOutQueryCriteria criteria){
        return new ResponseEntity<>(attendanceGoOutService.queryAll(criteria),HttpStatus.OK);
    }
    @PostMapping
    @Log("新增考勤外出")
    @ApiOperation("新增考勤外出")
    @PreAuthorize("@el.check('attendanceGoOut:add')")
    public ResponseEntity<Object> createAttendanceGoOut(@Validated @RequestBody AttendanceGoOut resources) throws Exception {
        return new ResponseEntity<>(attendanceGoOutService.create(resources),HttpStatus.CREATED);
    }
    @PutMapping
    @Log("修改考勤外出")
    @ApiOperation("修改考勤外出")
    @PreAuthorize("@el.check('attendanceGoOut:edit')")
    public ResponseEntity<Object> updateAttendanceGoOut(@Validated @RequestBody AttendanceGoOut resources){
        attendanceGoOutService.update(resources);
        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
    }
    @DeleteMapping
    @Log("删除考勤外出")
    @ApiOperation("删除考勤外出")
    @PreAuthorize("@el.check('attendanceGoOut:del')")
    public ResponseEntity<Object> deleteAttendanceGoOut(@RequestBody Long[] ids) {
        attendanceGoOutService.deleteAll(ids);
        return new ResponseEntity<>(HttpStatus.OK);
    }
    @PostMapping(value = "/getRemainingTime")
    @Log("获取外出时长")
    @ApiOperation("获取外出时长")
    public ResponseEntity<Object> getRemainingTime(@Validated @RequestBody AttendanceGoOut resources){
        return new ResponseEntity<>(attendanceGoOutService.getRemainingTime(resources),HttpStatus.CREATED);
    }
    @PutMapping(value = "/approve")
    @Log("审核功能")
    @ApiOperation("审核功能")
    public ResponseEntity<Object> checkApprove(@Validated @RequestBody AttendanceGoOut resources){
        attendanceGoOutService.updateApprove(resources);
        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
    }
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/AttendanceBusinessTravelService.java
New file
@@ -0,0 +1,103 @@
/*
*  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.AttendanceBusinessTravel;
import me.zhengjie.modules.attendance.domain.AttendanceGoOut;
import me.zhengjie.modules.attendance.service.dto.AttendanceBusinessTravelDto;
import me.zhengjie.modules.attendance.service.dto.AttendanceBusinessTravelQueryCriteria;
import org.springframework.data.domain.Pageable;
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 2023-01-05
**/
public interface AttendanceBusinessTravelService {
    /**
    * 查询数据分页
    * @param criteria 条件
    * @param pageable 分页参数
    * @return Map<String,Object>
    */
    Map<String,Object> queryAll(AttendanceBusinessTravelQueryCriteria criteria, Pageable pageable);
    /**
    * 查询所有数据不分页
    * @param criteria 条件参数
    * @return List<AttendanceBusinessTravelDto>
    */
    List<AttendanceBusinessTravelDto> queryAll(AttendanceBusinessTravelQueryCriteria criteria);
    /**
     * 根据ID查询
     * @param id ID
     * @return AttendanceBusinessTravelDto
     */
    AttendanceBusinessTravelDto findById(Long id);
    /**
    * 创建
    * @param resources /
    * @return AttendanceBusinessTravelDto
    */
    AttendanceBusinessTravelDto create(AttendanceBusinessTravel resources) throws Exception;
    /**
    * 编辑
    * @param resources /
    */
    void update(AttendanceBusinessTravel resources);
    /**
    * 多选删除
    * @param ids /
    */
    void deleteAll(Long[] ids);
    /**
    * 导出数据
    * @param all 待导出的数据
    * @param response /
    * @throws IOException /
    */
    void download(List<AttendanceBusinessTravelDto> all, HttpServletResponse response) throws IOException;
    /**
     * 获取时长
     * @param attendanceBusinessTravel
     * @return
     */
    Double getRemainingTime(AttendanceBusinessTravel attendanceBusinessTravel);
    /**
     * 审核功能
     * @param resources /
     */
    void updateApprove(AttendanceBusinessTravel resources);
    /**
     * 审核撤销
     * @param resources
     */
    void updateRevoke(AttendanceBusinessTravel resources);
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/AttendanceGoOutService.java
New file
@@ -0,0 +1,97 @@
/*
*  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.AttendanceGoOut;
import me.zhengjie.modules.attendance.domain.AttendanceLeave;
import me.zhengjie.modules.attendance.service.dto.AttendanceGoOutDto;
import me.zhengjie.modules.attendance.service.dto.AttendanceGoOutQueryCriteria;
import org.springframework.data.domain.Pageable;
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 2023-01-04
**/
public interface AttendanceGoOutService {
    /**
    * 查询数据分页
    * @param criteria 条件
    * @param pageable 分页参数
    * @return Map<String,Object>
    */
    Map<String,Object> queryAll(AttendanceGoOutQueryCriteria criteria, Pageable pageable);
    /**
    * 查询所有数据不分页
    * @param criteria 条件参数
    * @return List<AttendanceGoOutDto>
    */
    List<AttendanceGoOutDto> queryAll(AttendanceGoOutQueryCriteria criteria);
    /**
     * 根据ID查询
     * @param id ID
     * @return AttendanceGoOutDto
     */
    AttendanceGoOutDto findById(Long id);
    /**
    * 创建
    * @param resources /
    * @return AttendanceGoOutDto
    */
    AttendanceGoOutDto create(AttendanceGoOut resources) throws Exception;
    /**
    * 编辑
    * @param resources /
    */
    void update(AttendanceGoOut resources);
    /**
    * 多选删除
    * @param ids /
    */
    void deleteAll(Long[] ids);
    /**
    * 导出数据
    * @param all 待导出的数据
    * @param response /
    * @throws IOException /
    */
    void download(List<AttendanceGoOutDto> all, HttpServletResponse response) throws IOException;
    /**
     * 获取时长
     * @param attendanceGoOut
     * @return
     */
    Double getRemainingTime(AttendanceGoOut attendanceGoOut);
    /**
     * 审核功能
     * @param resources /
     */
    void updateApprove(AttendanceGoOut resources);
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/AttendanceService.java
@@ -97,4 +97,12 @@
    * @throws IOException /
    */
    void download(List<AttendanceDto> all, HttpServletResponse response) throws IOException;
    /**
     * 获取异常信息
     * @param Number
     */
    void getExceptional(String Number);
    void getUserMakeUpCard(String userId);
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceBusinessTravelDto.java
New file
@@ -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 2023-01-05
**/
@Data
public class AttendanceBusinessTravelDto extends BaseDTO implements Serializable {
    /** 主键id */
    private Long id;
    /** 用户id */
    private Long userId;
    /** 审批用户id */
    private Long approvalUserId;
    /** 出差开始时间 */
    private Timestamp travelStartTime;
    /** 出差结束时间 */
    private Timestamp travelEndTime;
    /** 出差时长 */
    private Double travelDuration;
    /** 时长单位 */
    private String durationUnit;
    /** 出差原因 */
    private String travelReason;
    /** 出发城市 */
    private String departureCity;
    /** 到达城市 */
    private String arrivalCity;
    /** 审批状态 */
    private String approvalStatus;
    /** 审批说明 */
    private String approvalDescription;
    /** 备注 */
    private String remarks;
    private String userName;
    private String appUserName;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceBusinessTravelQueryCriteria.java
New file
@@ -0,0 +1,45 @@
/*
*  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.sql.Timestamp;
import java.util.List;
import me.zhengjie.annotation.Query;
/**
* @website https://eladmin.vip
* @author wcd
* @date 2023-01-05
**/
@Data
public class AttendanceBusinessTravelQueryCriteria{
    //员工查询
    @Query
    private Long userId;
    //审批查询
    @Query
    private String approvalStatus;
    @Query
    private String travelStartTime;
    @Query
    private String travelEndTime;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceGoOutDto.java
New file
@@ -0,0 +1,72 @@
/*
*  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 2023-01-04
**/
@Data
public class AttendanceGoOutDto extends BaseDTO implements Serializable {
    /** 主键id */
    private Long id;
    /** 用户id */
    private Long userId;
    /** 审批用户id */
    private Long approvalUserId;
    /** 外出开始时间 */
    private Timestamp outStartTime;
    /** 外出结束时间 */
    private Timestamp outEndTime;
    /** 外出时长 */
    private Double outDuration;
    /** 时长单位 */
    private String durationUnit;
    /** 外出类型 */
    private String outOfOfficeType;
    /** 外出原因 */
    private String outReason;
    /** 审批状态 */
    private String approvalStatus;
    /** 审批说明 */
    private String approvalDescription;
    /** 备注 */
    private String remarks;
    private String userName;
    private String appUserName;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceGoOutQueryCriteria.java
New file
@@ -0,0 +1,49 @@
/*
*  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.sql.Timestamp;
import java.util.List;
import me.zhengjie.annotation.Query;
/**
* @website https://eladmin.vip
* @author wcd
* @date 2023-01-04
**/
@Data
public class AttendanceGoOutQueryCriteria{
    //员工查询
    @Query
    private Long userId;
    //外出类型
    @Query
    private String outOfOfficeType;
    //审批查询
    @Query
    private String approvalStatus;
    @Query(type = Query.Type.BETWEEN, propName = "outStartTime")
    private List<Timestamp> outStartTime;
    @Query(type = Query.Type.BETWEEN, propName = "outEndTime")
    private List<Timestamp> outEndTime;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/dto/AttendanceLeaveQueryCriteria.java
@@ -16,6 +16,8 @@
package me.zhengjie.modules.attendance.service.dto;
import lombok.Data;
import java.sql.Timestamp;
import java.util.List;
import me.zhengjie.annotation.Query;
@@ -26,4 +28,22 @@
**/
@Data
public class AttendanceLeaveQueryCriteria{
    //员工查询
    @Query
    private Long userId;
    //请假类型
    @Query
    private String leaveType;
    //审批查询
    @Query
    private String approvalStatus;
    @Query(type = Query.Type.BETWEEN, propName = "leaveStartTime")
    private List<Timestamp> leaveStartTime;
    @Query(type = Query.Type.BETWEEN, propName = "leaveEndTime")
    private List<Timestamp> leaveEndTime;
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceBusinessTravelServiceImpl.java
New file
@@ -0,0 +1,347 @@
/*
*  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.AttendanceBusinessTravel;
import me.zhengjie.modules.attendance.domain.AttendanceGoOut;
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.AttendanceGoOutDto;
import me.zhengjie.modules.constant.Constant;
import me.zhengjie.modules.quartz.service.OpaiDingTalkService;
import me.zhengjie.modules.system.domain.Job;
import me.zhengjie.modules.system.domain.SysConfigHoliday;
import me.zhengjie.modules.system.domain.User;
import me.zhengjie.modules.system.repository.SysConfigHolidayRepository;
import me.zhengjie.modules.system.repository.UserRepository;
import me.zhengjie.utils.*;
import lombok.RequiredArgsConstructor;
import me.zhengjie.modules.attendance.repository.AttendanceBusinessTravelRepository;
import me.zhengjie.modules.attendance.service.AttendanceBusinessTravelService;
import me.zhengjie.modules.attendance.service.dto.AttendanceBusinessTravelDto;
import me.zhengjie.modules.attendance.service.dto.AttendanceBusinessTravelQueryCriteria;
import me.zhengjie.modules.attendance.service.mapstruct.AttendanceBusinessTravelMapper;
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.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import java.util.function.Function;
/**
* @website https://eladmin.vip
* @description 服务实现
* @author wcd
* @date 2023-01-05
**/
@Service
@RequiredArgsConstructor
public class AttendanceBusinessTravelServiceImpl implements AttendanceBusinessTravelService {
    private final AttendanceBusinessTravelRepository attendanceBusinessTravelRepository;
    private final AttendanceBusinessTravelMapper attendanceBusinessTravelMapper;
    private final UserRepository userRepository;
    private final OpaiDingTalkService opaiDingTalkService;
    private final AttendanceLeaveServiceImpl attendanceLeaveService;
    private final SysConfigHolidayRepository sysConfigHolidayRepository;
    private final AttendanceService attendanceService;
    @Override
    public Map<String,Object> queryAll(AttendanceBusinessTravelQueryCriteria criteria, Pageable pageable){
        Page<AttendanceBusinessTravel> page = attendanceBusinessTravelRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
        //将实体转换为Dto(重写)
        Function<AttendanceBusinessTravel, AttendanceBusinessTravelDto> func = new Function<AttendanceBusinessTravel, AttendanceBusinessTravelDto>(){
            @Override
            public AttendanceBusinessTravelDto apply(AttendanceBusinessTravel attendanceBusinessTravel) {
                // 将实体类转换成DTO
                AttendanceBusinessTravelDto attendanceBusinessTravelDto = attendanceBusinessTravelMapper.toDto(attendanceBusinessTravel);
                //查询用户信息
                User user = userRepository.findById(attendanceBusinessTravelDto.getUserId()).orElseGet(User::new);
                attendanceBusinessTravelDto.setUserName(user.getNickName());
                //查询审批用户名
                User appUser = userRepository.findById(attendanceBusinessTravelDto.getApprovalUserId()).orElseGet(User::new);
                attendanceBusinessTravelDto.setAppUserName(appUser.getNickName());
                return attendanceBusinessTravelDto;
            }
        };
        return PageUtil.toPage(page.map(func));
    }
    @Override
    public List<AttendanceBusinessTravelDto> queryAll(AttendanceBusinessTravelQueryCriteria criteria){
        return attendanceBusinessTravelMapper.toDto(attendanceBusinessTravelRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
    }
    @Override
    @Transactional
    public AttendanceBusinessTravelDto findById(Long id) {
        AttendanceBusinessTravel attendanceBusinessTravel = attendanceBusinessTravelRepository.findById(id).orElseGet(AttendanceBusinessTravel::new);
        ValidationUtil.isNull(attendanceBusinessTravel.getId(),"AttendanceBusinessTravel","id",id);
        return attendanceBusinessTravelMapper.toDto(attendanceBusinessTravel);
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public AttendanceBusinessTravelDto create(AttendanceBusinessTravel resources) throws Exception {
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String bussStartTime = df.format(resources.getTravelStartTime());
        String bussEndTime = df.format(resources.getTravelEndTime());
        // 验证请假时间是否冲突
        List<AttendanceBusinessTravel> attendanceBusinessTravelList = attendanceBusinessTravelRepository.checkCreateTime(bussStartTime,bussEndTime, SecurityUtils.getCurrentUserId());
        if(attendanceBusinessTravelList.size() > 0){
            AttendanceBusinessTravel errorSysAskForLeave = attendanceBusinessTravelList.get(0);
            SimpleDateFormat errorFormat = new SimpleDateFormat("yyyy年MM月dd日");
            throw new BadRequestException("出差时间冲突," + errorFormat.format(errorSysAskForLeave.getTravelStartTime()) + "至" + errorFormat.format(errorSysAskForLeave.getTravelEndTime())
                    + "已经存在出差记录,请调整时间");
        }else {
            // 获取当前登陆人信息,设置为请假发起人
            User user = userRepository.getOne(SecurityUtils.getCurrentUserId());
            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());
                }
            }
            // 循环添加开始时间到结束时间的每一天
            List<String> dateList = attendanceLeaveService.getBetweenDate(resources.getTravelStartTime().toLocalDateTime().toString(),resources.getTravelEndTime().toLocalDateTime().toString());
            int i = 0;
            for(String date : dateList){
                LocalDate localDate = LocalDate.parse(date);
                Boolean isWeekend = localDate.getDayOfWeek() == DayOfWeek.SATURDAY || localDate.getDayOfWeek() == DayOfWeek.SUNDAY;
                // 不是周末并且节假日表中不存在在创建
                if((!isWeekend && !holiday.contains(date)) || (isWeekend && isWork.contains(date))){
                    AttendanceBusinessTravel attendanceBusinessTravel = getAttendanceBuss(resources,date,user,i,bussStartTime,bussEndTime,null);
                    i++;
                    attendanceBusinessTravelRepository.save(attendanceBusinessTravel);
                }
            }
            //发送钉钉给审批人
            List<String> sendList = new ArrayList<>();
            //查询审批者信息
            User appUser = userRepository.getOne(resources.getApprovalUserId());
            sendList.add(appUser.getDingding());
            opaiDingTalkService.sendNotice(sendList, "审批提醒", "### 审批提示 \n  >" + user.getNickName() + " 提交了请假审批,请登录PMS系统处理", "card");
        }
        return attendanceBusinessTravelMapper.toDto(resources);
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void update(AttendanceBusinessTravel resources) {
        AttendanceBusinessTravel attendanceBusinessTravel = attendanceBusinessTravelRepository.findById(resources.getId()).orElseGet(AttendanceBusinessTravel::new);
        ValidationUtil.isNull( attendanceBusinessTravel.getId(),"AttendanceBusinessTravel","id",resources.getId());
        attendanceBusinessTravel.copy(resources);
        //审核通过或者退回不能修改
        if(attendanceBusinessTravel.getApprovalStatus().equals(Constant.BUSSINESS_APPROVE_STATUS_AGREE) || attendanceBusinessTravel.getApprovalStatus().equals(Constant.BUSSINESS_APPROVE_STATUS_REFUSE)){
            throw new BadRequestException("审核通过或退回的不能进行修改");
        }
        //获取当前登入人信息
        User user1 = userRepository.getOne(SecurityUtils.getCurrentUserId());
        Job job = user1.getJobs().iterator().next();
        //除超管、总经理只能修改自己信息
        if(!job.getId().equals(Constant.ROLE_LEVEL_SUPER) || !job.getId().equals(Constant.ROLE_LEVEL_GENERAL)){
            if (!Long.valueOf(resources.getUserId()).equals(SecurityUtils.getCurrentUserId())){
                throw new BadRequestException("只能修改自己的记录");
            }
        }
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String bussStartTime = df.format(resources.getTravelStartTime());
        String bussEndTime = df.format(resources.getTravelEndTime());
        // 验证是否存在时间冲突的请假记录
        Set<Long> ids = new HashSet<>();
        ids.add(attendanceBusinessTravel.getId());
        // 验证请假时间是否冲突
        List<AttendanceBusinessTravel> attendanceBusinessTravelList = attendanceBusinessTravelRepository.checkCreateUpdateTime(bussStartTime,bussEndTime, SecurityUtils.getCurrentUserId(), ids);
        if(attendanceBusinessTravelList.size() > 0){
            AttendanceBusinessTravel errorSysAskForLeave = attendanceBusinessTravelList.get(0);
            SimpleDateFormat errorFormat = new SimpleDateFormat("yyyy年MM月dd日");
            throw new BadRequestException("出差时间冲突," + errorFormat.format(errorSysAskForLeave.getTravelStartTime()) + "至" + errorFormat.format(errorSysAskForLeave.getTravelEndTime())
                    + "已经存在出差记录,请调整时间");
        }else {
            //暂存userId
            Long resUserId = attendanceBusinessTravel.getUserId();
            // 删除以前的记录
            for (Long id : ids) {
                attendanceBusinessTravelRepository.deleteById(id);
            }
            // 获取当前登陆人信息,设置为请假发起人
            User user = userRepository.getOne(SecurityUtils.getCurrentUserId());
            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());
                }
            }
            // 循环添加开始时间到结束时间的每一天
            List<String> dateList = attendanceLeaveService.getBetweenDate(resources.getTravelStartTime().toLocalDateTime().toString(),resources.getTravelEndTime().toLocalDateTime().toString());
            int i = 0;
            for(String date : dateList){
                LocalDate localDate = LocalDate.parse(date);
                Boolean isWeekend = localDate.getDayOfWeek() == DayOfWeek.SATURDAY || localDate.getDayOfWeek() == DayOfWeek.SUNDAY;
                // 不是周末并且节假日表中不存在在创建
                if((!isWeekend && !holiday.contains(date)) || (isWeekend && isWork.contains(date))){
                    AttendanceBusinessTravel attendanceBusinessTravel1 = getAttendanceBuss(resources,date,user,i,bussStartTime,bussEndTime,resUserId);
                    i++;
                    attendanceBusinessTravelRepository.save(attendanceBusinessTravel1);
                }
            }
        }
    }
    /**
     * 添加多条记录
     * @param resources
     * @param date
     * @param user
     * @param i
     * @param LeaStartTime
     * @param LeaEndTime
     * @param resUserId
     * @return
     */
    public AttendanceBusinessTravel getAttendanceBuss(AttendanceBusinessTravel resources,String date,User user,int i,String LeaStartTime,String LeaEndTime,Long resUserId){
        DateTimeFormatter sdf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        AttendanceBusinessTravel attendanceBusinessTravel = new AttendanceBusinessTravel();
        //resUserId为null说明是添加,反之
        if(resUserId == null){
            resources.setUserId(user.getId());
        }else{
            resources.setUserId(resUserId);
        }
        String startTime = date + " " + "00:00:00";
        String endTime = date + " " + "00:00:00";
        resources.setTravelStartTime(Timestamp.valueOf(startTime));
        resources.setTravelEndTime(Timestamp.valueOf(endTime));
        resources.setTravelDuration(Constant.NUMBER_ONE);
        resources.setApprovalStatus(Constant.BUSSINESS_APPROVE_STATUS_REVIEWED);
        attendanceBusinessTravel.copy(resources);
        return attendanceBusinessTravel;
    }
    @Override
    public void deleteAll(Long[] ids) {
        for (Long id : ids) {
            //根据id查询记录
            Optional<AttendanceBusinessTravel> attendanceBusinessTravel = attendanceBusinessTravelRepository.findById(id);
            //审核通过或者退回不能删除
            if(attendanceBusinessTravel.get().getApprovalStatus().equals(Constant.BUSSINESS_APPROVE_STATUS_AGREE) || attendanceBusinessTravel.get().getApprovalStatus().equals(Constant.BUSSINESS_APPROVE_STATUS_REFUSE)){
                throw new BadRequestException("审核通过或退回的不能进行删除");
            }
            //获取当前登入人信息
            User user = userRepository.getOne(SecurityUtils.getCurrentUserId());
            Job job = user.getJobs().iterator().next();
            //除超管、总经理只能删除自己信息
            if(!job.getId().equals(Constant.ROLE_LEVEL_SUPER) || !job.getId().equals(Constant.ROLE_LEVEL_GENERAL)){
                if (!Long.valueOf(attendanceBusinessTravel.get().getUserId()).equals(SecurityUtils.getCurrentUserId())){
                    throw new BadRequestException("只能删除自己的记录");
                }
            }
            attendanceBusinessTravelRepository.deleteById(id);
        }
    }
    @Override
    public void download(List<AttendanceBusinessTravelDto> all, HttpServletResponse response) throws IOException {
        List<Map<String, Object>> list = new ArrayList<>();
        for (AttendanceBusinessTravelDto attendanceBusinessTravel : all) {
            Map<String,Object> map = new LinkedHashMap<>();
            map.put("用户id", attendanceBusinessTravel.getUserId());
            map.put("审批用户id", attendanceBusinessTravel.getApprovalUserId());
            map.put("出差开始时间", attendanceBusinessTravel.getTravelStartTime());
            map.put("出差结束时间", attendanceBusinessTravel.getTravelEndTime());
            map.put("出差时长", attendanceBusinessTravel.getTravelDuration());
            map.put("时长单位", attendanceBusinessTravel.getDurationUnit());
            map.put("出差原因", attendanceBusinessTravel.getTravelReason());
            map.put("出发城市", attendanceBusinessTravel.getDepartureCity());
            map.put("到达城市", attendanceBusinessTravel.getArrivalCity());
            map.put("审批状态", attendanceBusinessTravel.getApprovalStatus());
            map.put("审批说明", attendanceBusinessTravel.getApprovalDescription());
            map.put("备注", attendanceBusinessTravel.getRemarks());
            map.put("创建者", attendanceBusinessTravel.getCreateBy());
            map.put("创建时间", attendanceBusinessTravel.getCreateTime());
            map.put("更新者", attendanceBusinessTravel.getUpdateBy());
            map.put("更新时间", attendanceBusinessTravel.getUpdateTime());
            list.add(map);
        }
        FileUtil.downloadExcel(list, response);
    }
    /**
     * 获取出差时长
     * @param attendanceBusinessTravel
     * @return
     */
    @Override
    public Double getRemainingTime(AttendanceBusinessTravel attendanceBusinessTravel) {
        Calculate calculate = new Calculate();
        calculate.setStart(attendanceBusinessTravel.getTravelStartTime().toLocalDateTime());
        calculate.setEnd(attendanceBusinessTravel.getTravelEndTime().toLocalDateTime());
        Double result = new Double(0.00);
        Integer days = attendanceService.calculateDays(calculate);
        result = Double.valueOf(new BigDecimal(days).setScale(2, BigDecimal.ROUND_HALF_UP).toString());
        return result;
    }
    /**
     * 审核功能
     * @param resources /
     */
    @Override
    public void updateApprove(AttendanceBusinessTravel resources) {
        AttendanceBusinessTravel attendanceBusinessTravel = attendanceBusinessTravelRepository.findById(resources.getId()).orElseGet(AttendanceBusinessTravel::new);
        ValidationUtil.isNull( attendanceBusinessTravel.getId(),"AttendanceBusinessTravel","id",resources.getId());
        attendanceBusinessTravel.copy(resources);
        attendanceBusinessTravelRepository.save(attendanceBusinessTravel);
    }
    /**
     * 审核撤销
     * @param resources
     */
    @Override
    public void updateRevoke(AttendanceBusinessTravel resources) {
    }
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceCardreplacementServiceImpl.java
@@ -22,6 +22,7 @@
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.Job;
import me.zhengjie.modules.system.domain.User;
import me.zhengjie.modules.system.repository.RoleRepository;
import me.zhengjie.modules.system.repository.UserRepository;
@@ -39,12 +40,9 @@
import org.springframework.data.domain.Pageable;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.function.Function;
/**
@@ -68,10 +66,6 @@
    public Map<String,Object> queryAll(AttendanceCardreplacementQueryCriteria criteria, Pageable pageable){
        //查询当前登录人
        User user = userRepository.findById(SecurityUtils.getCurrentUserId()).get();
        //当前登录人角色包含职员就添加查询条件只能查询自己申请的或审批人是自己的记录
        if (user.getRoles().contains(roleRepository.findById(Constant.JOB_STAFF).get())) {
            criteria.setApprover(SecurityUtils.getCurrentUserId());
        }
        Page<AttendanceCardreplacement> page = attendanceCardreplacementRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
        //将实体转换为Dto(重写)
        Function<AttendanceCardreplacement, AttendanceCardreplacementDto> func = new Function<AttendanceCardreplacement,AttendanceCardreplacementDto >(){
@@ -148,6 +142,20 @@
        Attendance attendance = attendanceRepository.findAllByUserIdAndAttendanceDate(resources.getUserId(),attDate.substring(0,10));
        if(ObjectUtils.isEmpty(attendance)){
            throw new BadRequestException("考勤记录不存在");
        }
        //获取当前登入人信息
        User user = userRepository.getOne(SecurityUtils.getCurrentUserId());
        Job job = user.getJobs().iterator().next();
        //除超管、总经理只能修改自己信息
        if(!job.getId().equals(Constant.ROLE_LEVEL_SUPER) || !job.getId().equals(Constant.ROLE_LEVEL_GENERAL)){
            if (!Long.valueOf(resources.getUserId()).equals(SecurityUtils.getCurrentUserId())){
                throw new BadRequestException("只能修改自己的记录");
            }
        }
        //审核通过或者退回不能删除
        if(attendanceCardreplacement.getApprovalStatus().equals(Constant.CARD_APPROVE_STATUS_AGREE) || attendanceCardreplacement.getApprovalStatus().equals(Constant.CARD_APPROVE_STATUS_REFUSE)){
            throw new BadRequestException("审核通过或退回的不能进行修改");
        }
        attendanceCardreplacementRepository.save(attendanceCardreplacement);
@@ -228,6 +236,21 @@
    @Override
    public void deleteAll(Long[] ids) {
        for (Long id : ids) {
            //获取当前登入人信息
            User user = userRepository.getOne(SecurityUtils.getCurrentUserId());
            Job job = user.getJobs().iterator().next();
            //根据id查询记录
            Optional<AttendanceCardreplacement> attendanceCardreplacement = attendanceCardreplacementRepository.findById(id);
            //除超管、总经理只能删除自己信息
            if(!job.getId().equals(Constant.ROLE_LEVEL_SUPER) || !job.getId().equals(Constant.ROLE_LEVEL_GENERAL)){
                if (!Long.valueOf(attendanceCardreplacement.get().getUserId()).equals(SecurityUtils.getCurrentUserId())){
                    throw new BadRequestException("只能删除自己的记录");
                }
            }
            //审核通过或者退回不能删除
            if(attendanceCardreplacement.get().getApprovalStatus().equals(Constant.CARD_APPROVE_STATUS_AGREE) || attendanceCardreplacement.get().getApprovalStatus().equals(Constant.CARD_APPROVE_STATUS_REFUSE)){
                throw new BadRequestException("审核通过或退回的不能进行删除");
            }
            attendanceCardreplacementRepository.deleteById(id);
        }
    }
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceGoOutServiceImpl.java
New file
@@ -0,0 +1,365 @@
/*
*  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.AttendanceGoOut;
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.AttendanceLeaveDto;
import me.zhengjie.modules.constant.Constant;
import me.zhengjie.modules.quartz.service.OpaiDingTalkService;
import me.zhengjie.modules.system.domain.Job;
import me.zhengjie.modules.system.domain.SysConfigHoliday;
import me.zhengjie.modules.system.domain.User;
import me.zhengjie.modules.system.repository.SysConfigHolidayRepository;
import me.zhengjie.modules.system.repository.UserRepository;
import me.zhengjie.utils.*;
import lombok.RequiredArgsConstructor;
import me.zhengjie.modules.attendance.repository.AttendanceGoOutRepository;
import me.zhengjie.modules.attendance.service.AttendanceGoOutService;
import me.zhengjie.modules.attendance.service.dto.AttendanceGoOutDto;
import me.zhengjie.modules.attendance.service.dto.AttendanceGoOutQueryCriteria;
import me.zhengjie.modules.attendance.service.mapstruct.AttendanceGoOutMapper;
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.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.time.*;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import java.util.function.Function;
/**
* @website https://eladmin.vip
* @description 服务实现
* @author wcd
* @date 2023-01-04
**/
@Service
@RequiredArgsConstructor
public class AttendanceGoOutServiceImpl implements AttendanceGoOutService {
    private final AttendanceGoOutRepository attendanceGoOutRepository;
    private final AttendanceGoOutMapper attendanceGoOutMapper;
    private final UserRepository userRepository;
    private final AttendanceService attendanceService;
    private final SysConfigHolidayRepository sysConfigHolidayRepository;
    private final AttendanceLeaveServiceImpl attendanceLeaveService;
    private final OpaiDingTalkService opaiDingTalkService;
    @Override
    public Map<String,Object> queryAll(AttendanceGoOutQueryCriteria criteria, Pageable pageable){
        Page<AttendanceGoOut> page = attendanceGoOutRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
        //将实体转换为Dto(重写)
        Function<AttendanceGoOut, AttendanceGoOutDto> func = new Function<AttendanceGoOut, AttendanceGoOutDto>(){
            @Override
            public AttendanceGoOutDto apply(AttendanceGoOut attendanceGoOut) {
                // 将实体类转换成DTO
                AttendanceGoOutDto attendanceGoOutDto = attendanceGoOutMapper.toDto(attendanceGoOut);
                //查询用户信息
                User user = userRepository.findById(attendanceGoOutDto.getUserId()).orElseGet(User::new);
                attendanceGoOutDto.setUserName(user.getNickName());
                //查询审批用户名
                User appUser = userRepository.findById(attendanceGoOutDto.getApprovalUserId()).orElseGet(User::new);
                attendanceGoOutDto.setAppUserName(appUser.getNickName());
                return attendanceGoOutDto;
            }
        };
        return PageUtil.toPage(page.map(func));
    }
    @Override
    public List<AttendanceGoOutDto> queryAll(AttendanceGoOutQueryCriteria criteria){
        return attendanceGoOutMapper.toDto(attendanceGoOutRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
    }
    @Override
    @Transactional
    public AttendanceGoOutDto findById(Long id) {
        AttendanceGoOut attendanceGoOut = attendanceGoOutRepository.findById(id).orElseGet(AttendanceGoOut::new);
        ValidationUtil.isNull(attendanceGoOut.getId(),"AttendanceGoOut","id",id);
        return attendanceGoOutMapper.toDto(attendanceGoOut);
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public AttendanceGoOutDto create(AttendanceGoOut resources) throws Exception {
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String goStartTime = df.format(resources.getOutStartTime());
        String goEndTime = df.format(resources.getOutEndTime());
        // 验证请假时间是否冲突
        List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.checkCreateTime(goStartTime, goEndTime, SecurityUtils.getCurrentUserId());
        if(attendanceGoOutList.size() > 0){
            AttendanceGoOut errTime = attendanceGoOutList.get(0);
            //LocalDateTime转换为Date
            LocalDateTime strartTime = errTime.getOutStartTime().toLocalDateTime();
            ZonedDateTime zonedDateTime = strartTime.atZone(ZoneId.systemDefault());
            Instant instant = zonedDateTime.toInstant();
            Date strTime = Date.from(instant);
            LocalDateTime endTime = errTime.getOutEndTime().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());
            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());
                }
            }
            // 循环添加开始时间到结束时间的每一天
            List<String> dateList = attendanceLeaveService.getBetweenDate(resources.getOutStartTime().toLocalDateTime().toString(),resources.getOutEndTime().toLocalDateTime().toString());
            int i = 0;
            for(String date : dateList){
                LocalDate localDate = LocalDate.parse(date);
                Boolean isWeekend = localDate.getDayOfWeek() == DayOfWeek.SATURDAY || localDate.getDayOfWeek() == DayOfWeek.SUNDAY;
                // 不是周末并且节假日表中不存在在创建
                if((!isWeekend && !holiday.contains(date)) || (isWeekend && isWork.contains(date))){
                    AttendanceGoOut attendanceGoOut = getAttendanceOut(resources,date,user,i,goStartTime,goEndTime,null);
                    i++;
                    attendanceGoOutRepository.save(attendanceGoOut);
                }
            }
            //发送钉钉给审批人
            List<String> sendList = new ArrayList<>();
            //查询审批者信息
            User appUser = userRepository.getOne(resources.getApprovalUserId());
            sendList.add(appUser.getDingding());
            opaiDingTalkService.sendNotice(sendList, "审批提醒", "### 审批提示 \n  >" + user.getNickName() + " 提交了请假审批,请登录PMS系统处理", "card");
        }
        return attendanceGoOutMapper.toDto(resources);
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void update(AttendanceGoOut resources) {
        AttendanceGoOut attendanceGoOut = attendanceGoOutRepository.findById(resources.getId()).orElseGet(AttendanceGoOut::new);
        ValidationUtil.isNull( attendanceGoOut.getId(),"AttendanceGoOut","id",resources.getId());
        attendanceGoOut.copy(resources);
        //审核通过或者退回不能修改
        if(attendanceGoOut.getApprovalStatus().equals(Constant.GOOUT_APPROVE_STATUS_AGREE) || attendanceGoOut.getApprovalStatus().equals(Constant.GOOUT_APPROVE_STATUS_REFUSE)){
            throw new BadRequestException("审核通过或退回的不能进行修改");
        }
        //获取当前登入人信息
        User user1 = userRepository.getOne(SecurityUtils.getCurrentUserId());
        Job job = user1.getJobs().iterator().next();
        //除超管、总经理只能修改自己信息
        if(!job.getId().equals(Constant.ROLE_LEVEL_SUPER) || !job.getId().equals(Constant.ROLE_LEVEL_GENERAL)){
            if (!Long.valueOf(resources.getUserId()).equals(SecurityUtils.getCurrentUserId())){
                throw new BadRequestException("只能修改自己的记录");
            }
        }
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String goStartTime = df.format(resources.getOutStartTime());
        String goEndTime = df.format(resources.getOutEndTime());
        // 验证是否存在时间冲突的请假记录
        Set<Long> ids = new HashSet<>();
        ids.add(attendanceGoOut.getId());
        List<AttendanceGoOut> attendanceGoOutList = attendanceGoOutRepository.checkCreateUpdateTime(goStartTime, goEndTime, SecurityUtils.getCurrentUserId(), ids);
        if(attendanceGoOutList.size() > 0){
            AttendanceGoOut errorSysAskForLeave = attendanceGoOutList.get(0);
            SimpleDateFormat errorFormat = new SimpleDateFormat("yyyy年MM月dd日");
            throw new BadRequestException("外出时间冲突," + errorFormat.format(errorSysAskForLeave.getOutStartTime()) + "至" + errorFormat.format(errorSysAskForLeave.getOutEndTime())
                    + "已经存在外出记录,请调整时间");
        }else {
            //暂存userId
            Long resUserId = attendanceGoOut.getUserId();
            // 删除以前的记录
            for (Long id : ids) {
                attendanceGoOutRepository.deleteById(id);
            }
            // 获取当前登陆人信息,设置为请假发起人
            User user = userRepository.getOne(SecurityUtils.getCurrentUserId());
            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());
                }
            }
            // 循环添加开始时间到结束时间的每一天
            List<String> dateList = attendanceLeaveService.getBetweenDate(resources.getOutStartTime().toLocalDateTime().toString(),resources.getOutEndTime().toLocalDateTime().toString());
            int i = 0;
            for(String date : dateList){
                LocalDate localDate = LocalDate.parse(date);
                Boolean isWeekend = localDate.getDayOfWeek() == DayOfWeek.SATURDAY || localDate.getDayOfWeek() == DayOfWeek.SUNDAY;
                // 不是周末并且节假日表中不存在在创建
                if((!isWeekend && !holiday.contains(date)) || (isWeekend && isWork.contains(date))){
                    AttendanceGoOut attendanceGoOut1 = getAttendanceOut(resources,date,user,i,goStartTime,goEndTime,resUserId);
                    i++;
                    attendanceGoOutRepository.save(attendanceGoOut1);
                }
            }
        }
    }
    /**
     * 添加多条记录
     * @param resources
     * @param date
     * @param user
     * @param i
     * @param LeaStartTime
     * @param LeaEndTime
     * @param resUserId
     * @return
     */
    public AttendanceGoOut getAttendanceOut(AttendanceGoOut resources,String date,User user,int i,String LeaStartTime,String LeaEndTime,Long resUserId){
        DateTimeFormatter sdf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        AttendanceGoOut attendanceGoOut = new AttendanceGoOut();
        //resUserId为null说明是添加,反之
        if(resUserId == null){
            resources.setUserId(user.getId());
        }else{
            resources.setUserId(resUserId);
        }
            Calculate calculate = new Calculate();
            String startTime = date + " " + LeaStartTime.substring(11,19);
            String endTime = date + " " + LeaEndTime.substring(11,19);
            //外出开始时间结束时间不相等的情况
            if(!LeaStartTime.substring(0,10).equals(LeaEndTime.substring(0,10))){
                //第一次循环用下班基准时间和外出开始时间算时长
                if(i == 0){
                    calculate.setStart(LocalDateTime.parse(startTime,sdf));
                    calculate.setEnd(LocalDateTime.parse(date + " " + user.getSysRostering().getWorkEndTime() + ":00",sdf));
                    resources.setOutStartTime(Timestamp.valueOf(startTime));
                    resources.setOutEndTime(Timestamp.valueOf(date + " " + user.getSysRostering().getWorkEndTime() + ":00"));
                }else if(date.equals(LeaEndTime.substring(0,10))){
                    //最后一次循环
                    calculate.setStart(LocalDateTime.parse(date + " " + user.getSysRostering().getWorkStartTime() + ":00",sdf));
                    calculate.setEnd(LocalDateTime.parse(endTime,sdf));
                    resources.setOutStartTime(Timestamp.valueOf(date + " " + user.getSysRostering().getWorkStartTime() + ":00"));
                    resources.setOutEndTime(Timestamp.valueOf(endTime));
                }else{
                    calculate.setStart(LocalDateTime.parse(date + " " + user.getSysRostering().getWorkStartTime() + ":00",sdf));
                    calculate.setEnd(LocalDateTime.parse(date + " " + user.getSysRostering().getWorkEndTime() + ":00",sdf));
                    resources.setOutStartTime(Timestamp.valueOf(date + " " + user.getSysRostering().getWorkStartTime() + ":00"));
                    resources.setOutEndTime(Timestamp.valueOf(date + " " + user.getSysRostering().getWorkEndTime() + ":00"));
                }
                Integer timeSeconds = attendanceService.calculateTimes(calculate, SecurityUtils.getCurrentUserId());
                Double result = Double.valueOf(new BigDecimal((float) timeSeconds / 3600).setScale(2, BigDecimal.ROUND_HALF_UP).toString());
                resources.setOutDuration(result);
            }
        resources.setApprovalStatus(Constant.GOOUT_APPROVE_STATUS_REVIEWED);
        attendanceGoOut.copy(resources);
        return attendanceGoOut;
    }
    @Override
    public void deleteAll(Long[] ids) {
        for (Long id : ids) {
            //根据id查询记录
            Optional<AttendanceGoOut> attendanceGoOut = attendanceGoOutRepository.findById(id);
            //审核通过或者退回不能删除
            if(attendanceGoOut.get().getApprovalStatus().equals(Constant.GOOUT_APPROVE_STATUS_AGREE) || attendanceGoOut.get().getApprovalStatus().equals(Constant.GOOUT_APPROVE_STATUS_REFUSE)){
                throw new BadRequestException("审核通过或退回的不能进行删除");
            }
            //获取当前登入人信息
            User user = userRepository.getOne(SecurityUtils.getCurrentUserId());
            Job job = user.getJobs().iterator().next();
            //除超管、总经理只能删除自己信息
            if(!job.getId().equals(Constant.ROLE_LEVEL_SUPER) || !job.getId().equals(Constant.ROLE_LEVEL_GENERAL)){
                if (!Long.valueOf(attendanceGoOut.get().getUserId()).equals(SecurityUtils.getCurrentUserId())){
                    throw new BadRequestException("只能删除自己的记录");
                }
            }
            attendanceGoOutRepository.deleteById(id);
        }
    }
    @Override
    public void download(List<AttendanceGoOutDto> all, HttpServletResponse response) throws IOException {
        List<Map<String, Object>> list = new ArrayList<>();
        for (AttendanceGoOutDto attendanceGoOut : all) {
            Map<String,Object> map = new LinkedHashMap<>();
            map.put("用户id", attendanceGoOut.getUserId());
            map.put("审批用户id", attendanceGoOut.getApprovalUserId());
            map.put("外出开始时间", attendanceGoOut.getOutStartTime());
            map.put("外出结束时间", attendanceGoOut.getOutEndTime());
            map.put("外出时长", attendanceGoOut.getOutDuration());
            map.put("时长单位", attendanceGoOut.getDurationUnit());
            map.put("外出类型", attendanceGoOut.getOutOfOfficeType());
            map.put("外出原因", attendanceGoOut.getOutReason());
            map.put("审批状态", attendanceGoOut.getApprovalStatus());
            map.put("审批说明", attendanceGoOut.getApprovalDescription());
            map.put("备注", attendanceGoOut.getRemarks());
            map.put("创建者", attendanceGoOut.getCreateBy());
            map.put("创建时间", attendanceGoOut.getCreateTime());
            map.put("更新者", attendanceGoOut.getUpdateBy());
            map.put("更新时间", attendanceGoOut.getUpdateTime());
            list.add(map);
        }
        FileUtil.downloadExcel(list, response);
    }
    /**
     * 计算外出时长
     * @param attendanceGoOut
     * @return
     */
    @Override
    public Double getRemainingTime(AttendanceGoOut attendanceGoOut) {
        Calculate calculate = new Calculate();
        calculate.setStart(attendanceGoOut.getOutStartTime().toLocalDateTime());
        calculate.setEnd(attendanceGoOut.getOutEndTime().toLocalDateTime());
        Double result = new Double(0.00);
        Integer timeSeconds = attendanceService.calculateTimes(calculate, SecurityUtils.getCurrentUserId());
        result = Double.valueOf(new BigDecimal((float) timeSeconds / 3600).setScale(2, BigDecimal.ROUND_HALF_UP).toString());
        return result;
    }
    /**
     * 审核功能
     * @param resources /
     */
    @Override
    public void updateApprove(AttendanceGoOut resources) {
        AttendanceGoOut attendanceGoOut = attendanceGoOutRepository.findById(resources.getId()).orElseGet(AttendanceGoOut::new);
        ValidationUtil.isNull( attendanceGoOut.getId(),"AttendanceGoOut","id",resources.getId());
        attendanceGoOut.copy(resources);
        attendanceGoOutRepository.save(attendanceGoOut);
    }
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceLeaveServiceImpl.java
@@ -17,16 +17,16 @@
import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.attendance.domain.Attendance;
import me.zhengjie.modules.attendance.domain.AttendanceCardreplacement;
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.domain.*;
import me.zhengjie.modules.system.repository.DictDetailRepository;
import me.zhengjie.modules.system.repository.SysConfigHolidayRepository;
import me.zhengjie.modules.system.repository.SysUserLevelOtherRepository;
import me.zhengjie.modules.system.repository.UserRepository;
import me.zhengjie.utils.*;
@@ -43,12 +43,11 @@
import org.springframework.data.domain.Pageable;
import java.math.BigDecimal;
import java.sql.Timestamp;
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.time.*;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.io.IOException;
import java.util.function.Function;
@@ -71,6 +70,7 @@
    private final SysUserLevelOtherRepository sysUserLevelOtherRepository;
    private final UserRepository userRepository;
    private final OpaiDingTalkService opaiDingTalkService;
    private final SysConfigHolidayRepository sysConfigHolidayRepository;
    @Override
    public Map<String,Object> queryAll(AttendanceLeaveQueryCriteria criteria, Pageable pageable){
@@ -111,6 +111,7 @@
    @Transactional(rollbackFor = Exception.class)
    public AttendanceLeaveDto create(AttendanceLeave resources) throws Exception {
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        DateTimeFormatter sdf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        String LeaStartTime = df.format(resources.getLeaveStartTime());
        String LeaEndTime = df.format(resources.getLeaveEndTime());
        // 如果按天为单位请假拼接请假时间的时分秒,取上下班基准时间
@@ -140,16 +141,98 @@
        }else {
            // 获取当前登陆人信息,设置为请假发起人
            User user = userRepository.getOne(SecurityUtils.getCurrentUserId());
            resources.setUserId(user.getId());
            resources.setApprovalStatus(Constant.APPROVAL_STATUS_UNDER_APPROVAL);
            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());
                }
            }
            // 循环添加开始时间到结束时间的每一天
            List<String> dateList = getBetweenDate(resources.getLeaveStartTime().toLocalDateTime().toString(),resources.getLeaveEndTime().toLocalDateTime().toString());
            int i = 0;
            for(String date : dateList){
                LocalDate localDate = LocalDate.parse(date);
                Boolean isWeekend = localDate.getDayOfWeek() == DayOfWeek.SATURDAY || localDate.getDayOfWeek() == DayOfWeek.SUNDAY;
                // 不是周末并且节假日表中不存在在创建
                if((!isWeekend && !holiday.contains(date)) || (isWeekend && isWork.contains(date))){
                AttendanceLeave attendanceLeave = getAttendanceLeave(resources,date,user,i,LeaStartTime,LeaEndTime,null);
                i++;
                attendanceLeaveRepository.save(attendanceLeave);
                }
            }
            //发送钉钉给审批人
            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));
            return attendanceLeaveMapper.toDto(resources);
        }
    }
    /**
     * 添加多条记录
     * @param resources
     * @param date
     * @param user
     * @param i
     * @param LeaStartTime
     * @param LeaEndTime
     * @return
     */
    public AttendanceLeave getAttendanceLeave(AttendanceLeave resources,String date,User user,int i,String LeaStartTime,String LeaEndTime,Long resUserId){
        DateTimeFormatter sdf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        AttendanceLeave attendanceLeave = new AttendanceLeave();
        //resUserId为null说明是添加,反之
        if(resUserId == null){
            resources.setUserId(user.getId());
        }else{
            resources.setUserId(resUserId);
        }
        //日期时间单位是小时
        if(resources.getLeaveDurationUnit().equals(Constant.LEAVE_TIME_TYPE_HOUR)){
            Calculate calculate = new Calculate();
            String startTime = date + " " + LeaStartTime.substring(11,19);
            String endTime = date + " " + LeaEndTime.substring(11,19);
            //请假开始时间结束时间不相等的情况
            if(!LeaStartTime.substring(0,10).equals(LeaEndTime.substring(0,10))){
                //第一次循环用下班基准时间和请假开始时间算时长
                if(i == 0){
                    calculate.setStart(LocalDateTime.parse(startTime,sdf));
                    calculate.setEnd(LocalDateTime.parse(date + " " + user.getSysRostering().getWorkEndTime() + ":00",sdf));
                    resources.setLeaveStartTime(Timestamp.valueOf(startTime));
                    resources.setLeaveEndTime(Timestamp.valueOf(date + " " + user.getSysRostering().getWorkEndTime() + ":00"));
                }else if(date.equals(LeaEndTime.substring(0,10))){
                    //最后一次循环
                    calculate.setStart(LocalDateTime.parse(date + " " + user.getSysRostering().getWorkStartTime() + ":00",sdf));
                    calculate.setEnd(LocalDateTime.parse(endTime,sdf));
                    resources.setLeaveStartTime(Timestamp.valueOf(date + " " + user.getSysRostering().getWorkStartTime() + ":00"));
                    resources.setLeaveEndTime(Timestamp.valueOf(endTime));
                }else{
                    calculate.setStart(LocalDateTime.parse(date + " " + user.getSysRostering().getWorkStartTime() + ":00",sdf));
                    calculate.setEnd(LocalDateTime.parse(date + " " + user.getSysRostering().getWorkEndTime() + ":00",sdf));
                    resources.setLeaveStartTime(Timestamp.valueOf(date + " " + user.getSysRostering().getWorkStartTime() + ":00"));
                    resources.setLeaveEndTime(Timestamp.valueOf(date + " " + user.getSysRostering().getWorkEndTime() + ":00"));
                }
                Integer timeSeconds = attendanceService.calculateTimes(calculate, SecurityUtils.getCurrentUserId());
                Double result = Double.valueOf(new BigDecimal((float) timeSeconds / 3600).setScale(2, BigDecimal.ROUND_HALF_UP).toString());
                resources.setLeaveDuration(result);
            }
        }else{
            String startTime = date + " " + user.getSysRostering().getWorkStartTime() + ":00";
            String endTime = date + " " + user.getSysRostering().getWorkEndTime() + ":00";
            resources.setLeaveStartTime(Timestamp.valueOf(startTime));
            resources.setLeaveEndTime(Timestamp.valueOf(endTime));
            resources.setLeaveDuration(Constant.NUMBER_ONE);
        }
        resources.setApprovalStatus(Constant.APPROVAL_STATUS_UNDER_APPROVAL);
        attendanceLeave.copy(resources);
        return attendanceLeave;
    }
    @Override
@@ -158,9 +241,32 @@
        AttendanceLeave attendanceLeave = attendanceLeaveRepository.findById(resources.getId()).orElseGet(AttendanceLeave::new);
        ValidationUtil.isNull( attendanceLeave.getId(),"AttendanceLeave","id",resources.getId());
        attendanceLeave.copy(resources);
        //审核通过或者退回不能删除
        if(attendanceLeave.getApprovalStatus().equals(Constant.APPROVAL_STATUS_PASSED) || attendanceLeave.getApprovalStatus().equals(Constant.APPROVAL_STATUS_RETURNED)){
            throw new BadRequestException("审核通过或退回的不能进行修改");
        }
        //获取当前登入人信息
        User user1 = userRepository.getOne(SecurityUtils.getCurrentUserId());
        Job job = user1.getJobs().iterator().next();
        //除超管、总经理只能修改自己信息
        if(!job.getId().equals(Constant.ROLE_LEVEL_SUPER) || !job.getId().equals(Constant.ROLE_LEVEL_GENERAL)){
            if (!Long.valueOf(resources.getUserId()).equals(SecurityUtils.getCurrentUserId())){
                throw new BadRequestException("只能修改自己的记录");
            }
        }
        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";
        }
        // 验证是否存在时间冲突的请假记录
        Set<Long> ids = new HashSet<>();
        ids.add(attendanceLeave.getId());
@@ -170,8 +276,74 @@
            SimpleDateFormat errorFormat = new SimpleDateFormat("yyyy年MM月dd日");
                throw new BadRequestException("请假时间冲突," + errorFormat.format(errorSysAskForLeave.getLeaveStartTime()) + "至" + errorFormat.format(errorSysAskForLeave.getLeaveEndTime())
                        + "已经存在请假记录,请调整时间");
        }else{
            //暂存userId
            Long resUserId = attendanceLeave.getUserId();
            // 删除以前的记录
            for (Long id : ids) {
                attendanceLeaveRepository.deleteById(id);
            }
            // 获取当前登陆人信息,设置为请假发起人
            User user = userRepository.getOne(SecurityUtils.getCurrentUserId());
            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());
                }
            }
            // 循环添加开始时间到结束时间的每一天
            List<String> dateList = getBetweenDate(resources.getLeaveStartTime().toLocalDateTime().toString(),resources.getLeaveEndTime().toLocalDateTime().toString());
            int i = 0;
            for(String date : dateList){
                LocalDate localDate = LocalDate.parse(date);
                Boolean isWeekend = localDate.getDayOfWeek() == DayOfWeek.SATURDAY || localDate.getDayOfWeek() == DayOfWeek.SUNDAY;
                // 不是周末并且节假日表中不存在在创建
                if((!isWeekend && !holiday.contains(date)) || (isWeekend && isWork.contains(date))){
                    AttendanceLeave attendanceLeave1 = getAttendanceLeave(resources,date,user,i,LeaStartTime,LeaEndTime,resUserId);
                    i++;
                    attendanceLeaveRepository.save(attendanceLeave1);
                }
            }
        }
        attendanceLeaveRepository.save(attendanceLeave);
    }
    /**
     * 获取两个日期之间的所有日期
     * @param startTime
     * @param endTime
     * @return
     */
    public List<String> getBetweenDate(String startTime, String endTime){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        // 声明保存日期集合
        List<String> list = new ArrayList<String>();
        try {
            // 转化成日期类型
            Date startDate = sdf.parse(startTime);
            Date endDate = sdf.parse(endTime);
            //用Calendar 进行日期比较判断
            Calendar calendar = Calendar.getInstance();
            while (startDate.getTime()<=endDate.getTime()){
                // 把日期添加到集合
                list.add(sdf.format(startDate));
                // 设置日期
                calendar.setTime(startDate);
                //把日期增加一天
                calendar.add(Calendar.DATE, 1);
                // 获取增加后的日期
                startDate=calendar.getTime();
            }
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return list;
    }
    /**
@@ -260,6 +432,24 @@
    @Override
    public void deleteAll(Long[] ids) {
        for (Long id : ids) {
            //根据id查询记录
            Optional<AttendanceLeave> attendanceLeave = attendanceLeaveRepository.findById(id);
            //审核通过或者退回不能删除
            if(attendanceLeave.get().getApprovalStatus().equals(Constant.APPROVAL_STATUS_PASSED) || attendanceLeave.get().getApprovalStatus().equals(Constant.APPROVAL_STATUS_RETURNED)){
                throw new BadRequestException("审核通过或退回的不能进行删除");
            }
            //获取当前登入人信息
            User user = userRepository.getOne(SecurityUtils.getCurrentUserId());
            Job job = user.getJobs().iterator().next();
            //根据id查询记录
            Optional<AttendanceLeave> attendanceLeave1 = attendanceLeaveRepository.findById(id);
            //除超管、总经理只能删除自己信息
            if(!job.getId().equals(Constant.ROLE_LEVEL_SUPER) || !job.getId().equals(Constant.ROLE_LEVEL_GENERAL)){
                if (!Long.valueOf(attendanceLeave1.get().getUserId()).equals(SecurityUtils.getCurrentUserId())){
                    throw new BadRequestException("只能删除自己的记录");
                }
            }
            attendanceLeaveRepository.deleteById(id);
        }
    }
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceServiceImpl.java
@@ -15,17 +15,16 @@
*/
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.AttendanceCardreplacement;
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.domain.*;
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;
import me.zhengjie.utils.*;
import lombok.RequiredArgsConstructor;
import me.zhengjie.modules.attendance.repository.AttendanceRepository;
import me.zhengjie.modules.attendance.service.AttendanceService;
@@ -37,8 +36,6 @@
import org.springframework.transaction.annotation.Transactional;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import me.zhengjie.utils.PageUtil;
import me.zhengjie.utils.QueryHelp;
import java.time.*;
import java.time.temporal.ChronoUnit;
@@ -107,6 +104,17 @@
        Attendance attendance = attendanceRepository.findById(resources.getId()).orElseGet(Attendance::new);
        ValidationUtil.isNull( attendance.getId(),"Attendance","id",resources.getId());
        attendance.copy(resources);
        //获取当前登入人信息
        User user = userRepository.getOne(SecurityUtils.getCurrentUserId());
        Job job = user.getJobs().iterator().next();
        //除超管、总经理只能修改自己信息
        if(!job.getId().equals(Constant.ROLE_LEVEL_SUPER) || !job.getId().equals(Constant.ROLE_LEVEL_GENERAL)){
            if (!Long.valueOf(resources.getUserId()).equals(SecurityUtils.getCurrentUserId())){
                throw new BadRequestException("只能修改自己的记录");
            }
        }
        attendanceRepository.save(attendance);
    }
@@ -204,10 +212,52 @@
    @Override
    public void deleteAll(Long[] ids) {
        for (Long id : ids) {
            //获取当前登入人信息
            User user = userRepository.getOne(SecurityUtils.getCurrentUserId());
            Job job = user.getJobs().iterator().next();
            //根据id查询记录
            Optional<Attendance> attendance = attendanceRepository.findById(id);
            //除超管、总经理只能删除自己信息
            if(!job.getId().equals(Constant.ROLE_LEVEL_SUPER) || !job.getId().equals(Constant.ROLE_LEVEL_GENERAL)){
                if (!Long.valueOf(attendance.get().getUserId()).equals(SecurityUtils.getCurrentUserId())){
                    throw new BadRequestException("只能删除自己的记录");
                }
            }
            attendanceRepository.deleteById(id);
        }
    }
    /**
     * 补卡获取异常信息
     * @param Number
     */
    @Override
    public void getExceptional(String Number) {
        if(Number.equals("1")){
            throw new BadRequestException("上班无需补卡");
        }else{
            throw new BadRequestException("下班无需补卡");
        }
    }
    /**
     * 补卡判断登录人
     */
    @Override
    public void getUserMakeUpCard(String userId) {
        //获取当前登入人信息
        User user = userRepository.getOne(SecurityUtils.getCurrentUserId());
        Job job = user.getJobs().iterator().next();
        //除超管、总经理只能补自己的卡
        if(!job.getId().equals(Constant.ROLE_LEVEL_SUPER) || !job.getId().equals(Constant.ROLE_LEVEL_GENERAL)){
            if (!Long.valueOf(userId).equals(SecurityUtils.getCurrentUserId())){
                throw new BadRequestException("只能补自己的卡");
            }
        }
    }
    @Override
    public void download(List<AttendanceDto> all, HttpServletResponse response) throws IOException {
        List<Map<String, Object>> list = new ArrayList<>();
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/mapstruct/AttendanceBusinessTravelMapper.java
New file
@@ -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.AttendanceBusinessTravel;
import me.zhengjie.modules.attendance.service.dto.AttendanceBusinessTravelDto;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @website https://eladmin.vip
* @author wcd
* @date 2023-01-05
**/
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface AttendanceBusinessTravelMapper extends BaseMapper<AttendanceBusinessTravelDto, AttendanceBusinessTravel> {
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/mapstruct/AttendanceGoOutMapper.java
New file
@@ -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.AttendanceGoOut;
import me.zhengjie.modules.attendance.service.dto.AttendanceGoOutDto;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @website https://eladmin.vip
* @author wcd
* @date 2023-01-04
**/
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface AttendanceGoOutMapper extends BaseMapper<AttendanceGoOutDto, AttendanceGoOut> {
}
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/constant/Constant.java
@@ -1,12 +1,16 @@
package me.zhengjie.modules.constant;
public class Constant {
    // 人员岗位:系统负责人
    public static final Long JOB_SYSTEM_LEADER = 1L;
    // 人员岗位:负责人
    public static final Long JOB_LEADER = 2L;
    // 人员岗位:职员
    public static final Long JOB_STAFF = 3L;
    // 角色级别:超级管理员
    public static final Long ROLE_LEVEL_SUPER = 1L;
    // 角色级别:总经理
    public static final Long ROLE_LEVEL_GENERAL = 2L;
    // 角色级别:项目经理
    public static final Long ROLE_LEVEL_MANAGER = 3L;
    // 角色级别:项目组长
    public static final Long ROLE_LEVEL_LEADER = 4L;
    // 角色级别:普通员工
    public static final Long ROLE_LEVEL_ORDINARY = 5L;
    // 日期类型
    public static final String DATE_TYPE = "date_type";
@@ -184,4 +188,26 @@
    public static final String CONFIGURATION_TYPE_MINUTE = "configuration_type_minute";
    // 配置类型:次
    public static final String CONFIGURATION_TYPE_FREQUENCY = "configuration_type_frequency";
    // 数字
    public static final Double NUMBER_ONE = 1.0;
    // 外出审批状态
    public static final String GOOUT_APPROVE_STATUS = "go_out_approve_status";
    // 审批状态:待审核
    public static final String GOOUT_APPROVE_STATUS_REVIEWED = "go_out_approve_status_reviewed";
    // 审批状态:已同意
    public static final String GOOUT_APPROVE_STATUS_AGREE = "go_out_approve_status_agree";
    // 审批状态:已拒绝
    public static final String GOOUT_APPROVE_STATUS_REFUSE = "go_out_approve_status_refuse";
    // 出差审批状态
    public static final String BUSSINESS_APPROVE_STATUS = "business_approve_status";
    // 审批状态:待审核
    public static final String BUSSINESS_APPROVE_STATUS_REVIEWED = "business_approve_status_reviewed";
    // 审批状态:已同意
    public static final String BUSSINESS_APPROVE_STATUS_AGREE = "business_approve_status_agree";
    // 审批状态:已拒绝
    public static final String BUSSINESS_APPROVE_STATUS_REFUSE = "business_approve_status_refuse";
}
eladmin-web-master/src/api/attendance/attendance.js
@@ -39,5 +39,20 @@
    params
  })
}
export function getExceptional(data) {
  return request({
    url: 'api/attendance/getExceptional',
    method: 'post',
    data
  })
}
export default { add, edit, del, getAll, attendanceHours }
export function getUserMakeUpCard(data) {
  return request({
    url: 'api/attendance/getUserMakeUpCard',
    method: 'post',
    data
  })
}
export default { add, edit, del, getAll, attendanceHours, getExceptional, getUserMakeUpCard }
eladmin-web-master/src/api/attendance/attendanceBusinessTravel.js
New file
@@ -0,0 +1,59 @@
import request from '@/utils/request'
export function getAll(params) {
  return request({
    url: 'api/attendanceBusinessTravel/all',
    method: 'get',
    params
  })
}
export function add(data) {
  return request({
    url: 'api/attendanceBusinessTravel',
    method: 'post',
    data
  })
}
export function del(ids) {
  return request({
    url: 'api/attendanceBusinessTravel/',
    method: 'delete',
    data: ids
  })
}
export function edit(data) {
  return request({
    url: 'api/attendanceBusinessTravel',
    method: 'put',
    data
  })
}
export function getRemainingTime(data) {
  return request({
    url: 'api/attendanceBusinessTravel/getRemainingTime',
    method: 'post',
    data
  })
}
export function approve(data) {
  return request({
    url: 'api/attendanceBusinessTravel/approve',
    method: 'put',
    data
  })
}
export function revoke(data) {
  return request({
    url: 'api/attendanceBusinessTravel/revoke',
    method: 'put',
    data
  })
}
export default { add, edit, del, getAll, getRemainingTime, approve, revoke }
eladmin-web-master/src/api/attendance/attendanceGoOut.js
New file
@@ -0,0 +1,51 @@
import request from '@/utils/request'
export function getAll(params) {
  return request({
    url: 'api/attendanceGoOut/all',
    method: 'get',
    params
  })
}
export function add(data) {
  return request({
    url: 'api/attendanceGoOut',
    method: 'post',
    data
  })
}
export function del(ids) {
  return request({
    url: 'api/attendanceGoOut/',
    method: 'delete',
    data: ids
  })
}
export function edit(data) {
  return request({
    url: 'api/attendanceGoOut',
    method: 'put',
    data
  })
}
export function getRemainingTime(data) {
  return request({
    url: 'api/attendanceGoOut/getRemainingTime',
    method: 'post',
    data
  })
}
export function approve(data) {
  return request({
    url: 'api/attendanceGoOut/approve',
    method: 'put',
    data
  })
}
export default { add, edit, del, getAll, getRemainingTime, approve }
eladmin-web-master/src/utils/constant.js
@@ -222,6 +222,31 @@
// 配置类型:次
export const CONFIGURATION_TYPE_FREQUENCY = 'configuration_type_frequency'
// 外出审批状态
export const GO_OUT_APPROVE_STATUS = 'go_out_approve_status'
// 外出审批状态:审核中
export const GO_OUT_APPROVE_STATUS_REVIEWED = 'go_out_approve_status_reviewed'
// 外出审批状态:已通过
export const GO_OUT_APPROVE_STATUS_AGREE = 'go_out_approve_status_agree'
// 外出审批状态:已退回
export const GO_OUT_APPROVE_STATUS_REFUSE = 'go_out_approve_status_refuse'
// 外出类型
export const GO_OUT_TYPE = 'go_out_type'
// 外出类型:居家外出
export const GO_OUT_TYPE_HOME = 'go_out_type_home'
// 外出类型:外勤外出
export const GO_OUT_TYPE_PERSONNEL = 'go_out_type_personnel'
// 出差审批状态
export const BUSSINESS_APPROVE_STATUS = 'business_approve_status'
// 出差审批状态:审核中
export const BUSSINESS_APPROVE_STATUS_REVIEWED = 'business_approve_status_reviewed'
// 出差审批状态:已通过
export const BUSSINESS_APPROVE_STATUS_AGREE = 'business_approve_status_agree'
// 出差审批状态:已退回
export const BUSSINESS_APPROVE_STATUS_REFUSE = 'business_approve_status_refuse'
export default {
  ROLE_LEVEL_SUPER,
  ROLE_LEVEL_GENERAL,
@@ -325,4 +350,16 @@
  CONFIGURATION_TYPE_DAY,
  CONFIGURATION_TYPE_MINUTE,
  CONFIGURATION_TYPE_FREQUENCY
  TASK_STATUS_COMPLETED,
  GO_OUT_APPROVE_STATUS,
  GO_OUT_APPROVE_STATUS_REVIEWED,
  GO_OUT_APPROVE_STATUS_AGREE,
  GO_OUT_APPROVE_STATUS_REFUSE,
  GO_OUT_TYPE,
  GO_OUT_TYPE_HOME,
  GO_OUT_TYPE_PERSONNEL,
  BUSSINESS_APPROVE_STATUS,
  BUSSINESS_APPROVE_STATUS_REVIEWED,
  BUSSINESS_APPROVE_STATUS_AGREE,
  BUSSINESS_APPROVE_STATUS_REFUSE
}
eladmin-web-master/src/views/attendance/attendance/index.vue
@@ -80,6 +80,32 @@
          >下班补卡
          </el-button>
        </template>
        <template slot="left">
          <el-button
            slot="right"
            size="mini"
            type="info"
            icon="el-icon-suitcase-1"
            class="filter-item"
            style="margin-right: 7.5px"
            :disabled="crud.selections.length == null"
            @click="toGoOutRequest('goOut')"
          >外出
          </el-button>
        </template>
        <template slot="left">
          <el-button
            slot="right"
            size="mini"
            type="info"
            icon="el-icon-timer"
            class="filter-item"
            style="margin-right: 7.5px"
            :disabled="crud.selections.length == null"
            @click="toGoOutRequest()"
          >出差
          </el-button>
        </template>
      </crudOperation>
      <!--表单组件-->
      <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
@@ -217,11 +243,8 @@
        </div>
      </el-dialog>
      <!--补卡-->
      <el-dialog :close-on-click-modal="false" :before-close="closeCard" :visible.sync="makeUpCardVisible" :title="makeUpCardTitle" width="505px">
        <el-form ref="makeUpCardForm" :model="makeUpCardForm" :rules="makeRules" size="small" label-width="110px" style="height: 400px">
          <el-form-item label="打卡状态">
            <el-tag v-if="makeUpCardForm.timeResult === dictAttendanceStateNotSigned" type="danger">{{ dict.label[attendanceState][makeUpCardForm.timeResult] }}</el-tag>
          </el-form-item>
      <el-dialog :close-on-click-modal="false" :before-close="closeCard" :visible.sync="makeUpCardVisible" :title="makeUpCardTitle" width="500px">
        <el-form ref="makeUpCardForm" :model="makeUpCardForm" :rules="makeRules" size="small" label-width="140px" style="height: 400px">
          <el-form-item label="基准时间">
            <span>{{ makeUpCardForm.rosterTime }}</span>
          </el-form-item>
@@ -259,17 +282,159 @@
          <el-button :loading="makeUpCardLoading" type="primary" @click="submitMakeUpCard">确认</el-button>
        </div>
      </el-dialog>
      <!--外出表单-->
      <el-dialog :close-on-click-modal="false" :before-close="closeCard" :visible.sync="goOutVisible" :title="goOutTitle" width="500px">
        <el-form ref="goOutForm" :model="goOutForm" :rules="goOutRules" size="small" label-width="100px">
          <el-form-item label="开始时间" prop="outStartTime">
            <el-date-picker
              v-model="goOutForm.outStartTime"
              type="datetime"
              placeholder="选择日期时间"
              style="width: 310px;"
              value-format="yyyy-MM-dd HH:mm:ss"
              align="right"
              :picker-options="{ disabledDate(time) {
                return goOutForm.outEndTime ? time.getTime() > new Date(goOutForm.outEndTime).getTime() - 8.64e7 : false;
              }
              }"
              default-time="09:00:00"
              @change="checkTime('goOut')"
            />
          </el-form-item>
          <el-form-item label="结束时间" prop="outEndTime">
            <el-date-picker
              v-model="goOutForm.outEndTime"
              type="datetime"
              placeholder="选择日期时间"
              style="width: 310px;"
              value-format="yyyy-MM-dd HH:mm:ss"
              align="right"
              :picker-options="{ disabledDate(time) {
                return goOutForm.outStartTime ? time.getTime() < new Date(goOutForm.outStartTime).getTime() - 8.64e7 : false;
              }
              }"
              default-time="18:00:00"
              @change="checkTime('goOut')"
            />
          </el-form-item>
          <el-form-item label="外出时长" prop="outDuration">
            <el-input v-model="goOutForm.outDuration" disabled style="width: 310px;">
              <template slot="append">{{ dict.label[dictLeaveTimeType][goOutForm.durationUnit] }}</template>
            </el-input>
          </el-form-item>
          <el-form-item label="外出类型" prop="outOfOfficeType">
            <el-select v-model="goOutForm.outOfOfficeType" filterable clearable placeholder="请选择外出类型" style="width: 310px;">
              <el-option
                v-for="item in dict[dictGoOutTypr]"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="审批员工" prop="approvalUserId">
            <el-select v-model="goOutForm.approvalUserId" filterable clearable placeholder="请选择审批员工" style="width: 310px;" 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="外出原因">
            <el-input v-model="goOutForm.outReason" type="textarea" rows="3" style="width: 310px;" />
          </el-form-item>
          <el-form-item label="备注">
            <el-input v-model="goOutForm.remarks" type="textarea" rows="3" style="width: 310px;" />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="closeCard">取消</el-button>
          <el-button :loading="goSuccessLoading" type="primary" @click="submitGoOut">确认</el-button>
        </div>
      </el-dialog>
      <!--出差表单-->
      <el-dialog :close-on-click-modal="false" :before-close="closeCard" :visible.sync="bussVisible" :title="bussTitle" width="500px">
        <el-form ref="bussForm" :model="bussForm" :rules="bussRules" size="small" label-width="100px">
          <el-form-item label="开始时间" prop="travelStartTime">
            <el-date-picker
              v-model="bussForm.travelStartTime"
              type="date"
              placeholder="选择日期时间"
              style="width: 310px;"
              value-format="yyyy-MM-dd"
              align="right"
              :picker-options="{ disabledDate(time) {
                return bussForm.travelEndTime ? time.getTime() > new Date(bussForm.travelEndTime).getTime() - 8.64e7 : false;
              }
              }"
              @change="checkTime()"
            />
          </el-form-item>
          <el-form-item label="结束时间" prop="travelEndTime">
            <el-date-picker
              v-model="bussForm.travelEndTime"
              type="date"
              placeholder="选择日期时间"
              style="width: 310px;"
              value-format="yyyy-MM-dd"
              align="right"
              :picker-options="{ disabledDate(time) {
                return bussForm.travelStartTime ? time.getTime() < new Date(bussForm.travelStartTime).getTime() - 8.64e7 : false;
              }
              }"
              @change="checkTime()"
            />
          </el-form-item>
          <el-form-item label="出差时长" prop="travelDuration">
            <el-input v-model="bussForm.travelDuration" disabled style="width: 310px;">
              <template slot="append">{{ dict.label[dictLeaveTimeType][bussForm.durationUnit] }}</template>
            </el-input>
          </el-form-item>
          <el-form-item label="审批员工" prop="approvalUserId">
            <el-select v-model="bussForm.approvalUserId" filterable clearable placeholder="请选择审批员工" style="width: 310px;" 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="出差原因">
            <el-input v-model="bussForm.travelReason" type="textarea" rows="3" style="width: 310px;" />
          </el-form-item>
          <el-form-item label="出发城市">
            <el-input v-model="bussForm.departureCity" style="width: 310px;" />
          </el-form-item>
          <el-form-item label="到达城市">
            <el-input v-model="bussForm.arrivalCity" style="width: 310px;" />
          </el-form-item>
          <el-form-item label="备注">
            <el-input v-model="bussForm.remarks" type="textarea" rows="3" style="width: 310px;" />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="closeCard">取消</el-button>
          <el-button :loading="bussSuccessLoading" type="primary" @click="submitBuss">确认</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 prop="userName" label="员工" fixed="left" width="80px" show-overflow-tooltip />
        <el-table-column prop="userName" label="员工" fixed="left" width="100" show-overflow-tooltip>
          <template slot-scope="scope">
            <el-tag>{{ scope.row.userName }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="attendanceDate" label="考勤日期" fixed="left" width="100px" show-overflow-tooltip>
          <template slot-scope="scope">
            {{ crud.toDate(scope.row.attendanceDate) }}
          </template>
        </el-table-column>
        <el-table-column prop="rosteringWorkStartTime" min-width="120" label="排班工作开始时间" show-overflow-tooltip />
        <el-table-column prop="actualWorkStartTime" min-width="120" label="实际工作开始时间" show-overflow-tooltip />
        <el-table-column prop="rosteringWorkStartTime" min-width="140" label="排班工作开始时间" show-overflow-tooltip />
        <el-table-column prop="actualWorkStartTime" min-width="140" label="实际工作开始时间" show-overflow-tooltip />
        <el-table-column prop="startLocationResults" min-width="100" label="开始位置结果" show-overflow-tooltip>
          <template slot-scope="scope">
            <el-tag v-if="scope.row.startLocationResults === dictlocationResultsNormal" type="success">{{ dict.label[lacationResules][scope.row.startLocationResults] }}</el-tag>
@@ -289,8 +454,8 @@
            <el-tag v-if="scope.row.startClockResults === dictAttendanceStateRest" type="warning">{{ dict.label[attendanceState][scope.row.startClockResults] }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="rosteringWorkEndTime" min-width="120" label="排班工作结束时间" show-overflow-tooltip />
        <el-table-column prop="actualWorkEndTime" min-width="120" label="实际工作结束时间" show-overflow-tooltip />
        <el-table-column prop="rosteringWorkEndTime" min-width="140" label="排班工作结束时间" show-overflow-tooltip />
        <el-table-column prop="actualWorkEndTime" min-width="140" label="实际工作结束时间" show-overflow-tooltip />
        <el-table-column prop="endLocationResults" min-width="100" label="结束位置结果" show-overflow-tooltip>
          <template slot-scope="scope">
            <el-tag v-if="scope.row.endLocationResults === dictlocationResultsNormal" type="success">{{ dict.label[lacationResules][scope.row.endLocationResults] }}</el-tag>
@@ -334,6 +499,8 @@
<script>
import crudAttendance from '@/api/attendance/attendance'
import crudAttendanceCardreplacement from '@/api/attendance/attendanceCardreplacement'
import crudAttendanceGoOut from '@/api/attendance/attendanceGoOut'
import crudAttendanceBusinessTravel from '@/api/attendance/attendanceBusinessTravel'
import crudUser from '@/api/system/user'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
@@ -351,7 +518,7 @@
    return CRUD({ title: '考勤记录', url: 'api/attendance', idField: 'id', sort: 'id,desc', crudMethod: { ...crudAttendance }})
  },
  // 数据字典
  dicts: [constant.ATTENDANCE_STATE, constant.DATE_TYPE, constant.LOCATION_RESULTS, constant.CARD_REPLACEMENT_DIFFERENTIATION, constant.CARD_APPROVE_STATUS],
  dicts: [constant.ATTENDANCE_STATE, constant.DATE_TYPE, constant.LOCATION_RESULTS, constant.CARD_REPLACEMENT_DIFFERENTIATION, constant.CARD_APPROVE_STATUS, constant.LEAVE_TIME_TYPE, constant.GO_OUT_TYPE],
  data() {
    return {
      permission: {
@@ -383,6 +550,37 @@
        ],
        approvalUserId: [
          { required: true, message: '审批人不能为空', trigger: 'change' }
        ]
      },
      goOutRules: {
        approvalUserId: [
          { required: true, message: '审批人不能为空', trigger: 'change' }
        ],
        outStartTime: [
          { required: true, message: '外出开始时间不能为空', trigger: 'blur' }
        ],
        outEndTime: [
          { required: true, message: '外出结束时间不能为空', trigger: 'blur' }
        ],
        outOfOfficeType: [
          { required: true, message: '外出类型不能为空', trigger: 'change' }
        ],
        outDuration: [
          { required: true, message: '外出时长不能为空', trigger: 'change' }
        ]
      },
      bussRules: {
        approvalUserId: [
          { required: true, message: '审批人不能为空', trigger: 'change' }
        ],
        travelStartTime: [
          { required: true, message: '出差开始时间不能为空', trigger: 'blur' }
        ],
        travelEndTime: [
          { required: true, message: '出差结束时间不能为空', trigger: 'blur' }
        ],
        travelDuration: [
          { required: true, message: '出差时长不能为空', trigger: 'change' }
        ]
      },
      attendanceState: constant.ATTENDANCE_STATE,
@@ -417,9 +615,41 @@
        timeResult: null,
        checkDate: null
      },
      goOutForm: {
        id: null,
        userId: null,
        approvalUserId: null,
        outStartTime: null,
        outEndTime: null,
        outDuration: null,
        outReason: null,
        remarks: null
      },
      bussForm: {
        id: null,
        userId: null,
        approvalUserId: null,
        travelStartTime: null,
        travelEndTime: null,
        travelDuration: null,
        travelReason: null,
        departureCity: null,
        arrivalCity: null,
        remarks: null
      },
      dictCardReplacementGoOn: constant.CARD_REPLACEMENT_DIFFERENTIATION_GOON,
      dictCardReplacementOffOn: constant.CARD_REPLACEMENT_DIFFERENTIATION_GOOFF,
      dictCardApproveStatusReviewed: constant.CARD_APPROVE_STATUS_REVIEWED }
      dictCardApproveStatusReviewed: constant.CARD_APPROVE_STATUS_REVIEWED,
      goOutVisible: false,
      goSuccessLoading: false,
      dictLeaveTimeType: constant.LEAVE_TIME_TYPE,
      dictGoOutTypr: constant.GO_OUT_TYPE,
      goOutTitle: '外出申请',
      dictLeaveTimeTypeHour: constant.LEAVE_TIME_TYPE_HOUR,
      dictLeaveTimeTypeDay: constant.LEAVE_TIME_TYPE_DAY,
      bussVisible: false,
      bussSuccessLoading: false,
      bussTitle: '出差申请' }
  },
  methods: {
    // 钩子:在获取表格数据之前执行,false 则代表不获取数据
@@ -448,38 +678,38 @@
      this.makeUpCardForm.checkDate = this.crud.toDate(data.attendanceDate)
      this.makeUpCardForm.userId = data.userId
      this.makeUpCardForm.approvalStatus = this.dictCardApproveStatusReviewed
      // 判断上班打卡状态,给提示
      if (Number === 1) {
        if (data.startClockResults !== null && data.startClockResults === this.dictAttendanceStateNotSigned) {
          this.makeUpCardTitle = '上班补卡申请'
          this.makeUpCardForm.timeResult = data.startClockResults
          this.makeUpCardForm.rosterTime = data.rosteringWorkStartTime
          this.makeUpCardForm.cardReplacementTime = data.rosteringWorkStartTime.substring(11, 19)
          this.makeUpCardForm.cardReplacementDistinguish = this.dictCardReplacementGoOn
          this.makeUpCardVisible = true
        } else {
          this.$message({
            type: 'warning',
            message: '上班无需补卡'
          })
      // 除了超管总经理只能补自己的卡
      crudAttendance.getUserMakeUpCard(this.makeUpCardForm.userId).then(res => {
        // 判断上班打卡状态,给提示
        if (Number === 1) {
          if (data.startClockResults !== null && data.startClockResults === this.dictAttendanceStateNotSigned) {
            this.makeUpCardTitle = '上班补卡申请'
            this.makeUpCardForm.timeResult = data.startClockResults
            this.makeUpCardForm.rosterTime = data.rosteringWorkStartTime
            this.makeUpCardForm.cardReplacementTime = data.rosteringWorkStartTime.substring(11, 19)
            this.makeUpCardForm.cardReplacementDistinguish = this.dictCardReplacementGoOn
            this.makeUpCardVisible = true
          } else {
            crudAttendance.getExceptional(Number).then(res => {
            })
          }
        }
      }
      // 判断下班打卡状态,给提示
      if (Number === 2) {
        if (data.endClockResults !== null && data.endClockResults === this.dictAttendanceStateNotSigned) {
          this.makeUpCardTitle = '下班补卡申请'
          this.makeUpCardForm.timeResult = data.endClockResults
          this.makeUpCardForm.rosterTime = data.rosteringWorkEndTime
          this.makeUpCardForm.cardReplacementTime = data.rosteringWorkEndTime.substring(11, 19)
          this.makeUpCardForm.cardReplacementDistinguish = this.dictCardReplacementOffOn
          this.makeUpCardVisible = true
        } else {
          this.$message({
            type: 'warning',
            message: '下班无需补卡'
          })
        // 判断下班打卡状态,给提示
        if (Number === 2) {
          if (data.endClockResults !== null && data.endClockResults === this.dictAttendanceStateNotSigned) {
            this.makeUpCardTitle = '下班补卡申请'
            this.makeUpCardForm.timeResult = data.endClockResults
            this.makeUpCardForm.rosterTime = data.rosteringWorkEndTime
            this.makeUpCardForm.cardReplacementTime = data.rosteringWorkEndTime.substring(11, 19)
            this.makeUpCardForm.cardReplacementDistinguish = this.dictCardReplacementOffOn
            this.makeUpCardVisible = true
          } else {
            crudAttendance.getExceptional(Number).then(res => {
            })
          }
        }
      }
      }).catch(() => {
      })
    },
    // 补卡提交
    submitMakeUpCard() {
@@ -492,26 +722,98 @@
        crudAttendanceCardreplacement.add(this.makeUpCardForm).then(res => {
          this.makeUpCardVisible = false
          this.makeUpCardLoading = false
          this.$message({
            type: 'success',
            message: '补卡申请成功'
          })
          this.crud.addSuccessNotify()
          if (this.$refs['makeUpCardForm']) {
            this.$refs['makeUpCardForm'].resetFields()
          }
        }).catch(() => {
          this.makeUpCardVisible = false
          this.makeUpCardLoading = false
          this.makeUpCardVisible = true
        })
      })
      if (this.$refs['makeUpCardForm']) {
        this.$refs['makeUpCardForm'].resetFields()
    },
    // 外出和出差打开画面
    toGoOutRequest(data) {
      if (data === 'goOut') {
        this.goOutVisible = true
      }else {
        this.bussVisible = true
      }
    },
    // 计算时长
    checkTime(data) {
      if (data === 'goOut') {
        this.goOutForm.durationUnit = this.dictLeaveTimeTypeHour
        var data = JSON.stringify({
        'outStartTime': this.goOutForm.outStartTime,
        'outEndTime': this.goOutForm.outEndTime
        })
        crudAttendanceGoOut.getRemainingTime(data).then(res => {
        this.goOutForm.outDuration = res
        })
      }else {
        this.bussForm.durationUnit = this.dictLeaveTimeTypeDay
        var data = JSON.stringify({
        'travelStartTime': this.bussForm.travelStartTime,
        'travelEndTime': this.bussForm.travelEndTime
        })
        crudAttendanceBusinessTravel.getRemainingTime(data).then(res => {
        this.bussForm.travelDuration = res
        })
      }
    },
    // 外出提交
    submitGoOut() {
      this.$refs['goOutForm'].validate(valid => {
        if (!valid) {
          return
        }
        this.goOutVisible = true
        crudAttendanceGoOut.add(this.goOutForm).then(res => {
          this.goOutVisible = false
          this.goSuccessLoading = false
          this.crud.addSuccessNotify()
          if (this.$refs['goOutForm']) {
            this.$refs['goOutForm'].resetFields()
          }
        }).catch(() => {
          this.goOutVisible = true
        })
      })
    },
    // 出差提交
    submitBuss() {
      this.$refs['bussForm'].validate(valid => {
        if (!valid) {
          return
        }
        this.bussVisible = true
        crudAttendanceBusinessTravel.add(this.bussForm).then(res => {
          this.bussVisible = false
          this.bussSuccessLoading = false
          this.crud.addSuccessNotify()
          if (this.$refs['bussForm']) {
            this.$refs['bussForm'].resetFields()
          }
        }).catch(() => {
          this.bussVisible = true
        })
      })
    },
    // 关闭
    closeCard() {
      if (this.$refs['makeUpCardForm']) {
        this.$refs['makeUpCardForm'].resetFields()
      }
      if (this.$refs['goOutForm']) {
        this.$refs['goOutForm'].resetFields()
      }
      if (this.$refs['bussForm']) {
        this.$refs['bussForm'].resetFields()
      }
      this.crud.cancelCU()
      this.makeUpCardVisible = false
      this.goOutVisible = false
      this.bussVisible = false
    }
  }
}
eladmin-web-master/src/views/attendance/attendanceBusinessTravel/index.vue
New file
@@ -0,0 +1,421 @@
<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-date-picker
          v-model="query.travelStartTime"
          type="date"
          clearable
          class="filter-item"
          value-format="yyyy-MM-dd HH:mm:ss"
          placeholder="请选择开始时间"
        />
        <el-date-picker
          v-model="query.travelEndTime"
          type="date"
          clearable
          class="filter-item"
          value-format="yyyy-MM-dd HH:mm:ss"
          placeholder="请选择结束时间"
        />
        <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[dictBussinessStatus]"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
        <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="travelStartTime">
            <el-date-picker
              v-model="form.travelStartTime"
              :type="'date'"
              placeholder="选择日期时间"
              value-format="yyyy-MM-dd"
              style="width: 370px;"
              align="right"
              :picker-options="{ disabledDate(time) {
                return form.travelEndTime ? time.getTime() > new Date(form.travelEndTime).getTime() - 8.64e7 : false;
              }
              }"
              @change="checkTime"
            />
          </el-form-item>
          <el-form-item label="结束时间" prop="travelEndTime">
            <el-date-picker
              v-model="form.travelEndTime"
              :type="'date'"
              placeholder="选择日期时间"
              style="width: 370px;"
              value-format="yyyy-MM-dd"
              align="right"
              :picker-options="{ disabledDate(time) {
                return form.travelStartTime ? time.getTime() < new Date(form.travelStartTime).getTime() - 8.64e7 : false;
              }
              }"
              @change="checkTime"
            />
          </el-form-item>
          <el-form-item label="出差时长" prop="travelDuration">
            <el-input v-model="form.travelDuration" disabled style="width: 370px;">
              <template slot="append">{{ dict.label[dictLeaveTimeType][form.durationUnit] }}</template>
            </el-input>
          </el-form-item>
          <el-form-item label="出差原因">
            <el-input v-model="form.travelReason" type="textarea" rows="3" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="出发城市">
            <el-input v-model="form.departureCity" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="到达城市">
            <el-input v-model="form.arrivalCity" 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">{{ form.departureCity }}</div>
        </div>
        <div class="form-item">
          <div class="form-item-label">
            <label>到达城市:</label>
          </div>
          <div class="form-item-value">{{ form.arrivalCity }}</div>
        </div>
        <div class="form-item">
          <div class="form-item-label">
            <label>开始时间:</label>
          </div>
          <div class="form-item-value">{{ crud.toDate(form.travelStartTime) }}</div>
        </div>
        <div class="form-item">
          <div class="form-item-label">
            <label>结束时间:</label>
          </div>
          <div class="form-item-value">{{ crud.toDate(form.travelEndTime) }}</div>
        </div>
        <div class="form-item">
          <div class="form-item-label">
            <label>出差时长:</label>
          </div>
          <div class="form-item-value">{{ form.travelDuration + '(' + dict.label[dictLeaveTimeType][form.durationUnit] + ')' }}</div>
        </div>
        <div class="form-item">
          <div class="form-item-label">
            <label>出差原因:</label>
          </div>
          <div class="form-item-value">{{ form.travelReason }}</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 === dictGoOutReturn" 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 !== dictGoOutReturn" :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 prop="userName" label="员工" width="110" show-overflow-tooltip>
          <template slot-scope="scope">
            <el-tag>{{ scope.row.userName }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="appUserName" label="审批员工" width="110" show-overflow-tooltip>
          <template slot-scope="scope">
            <el-tag>{{ scope.row.appUserName }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="travelStartTime" label="出差开始时间" min-width="140" show-overflow-tooltip>
          <template slot-scope="scope">
            {{ crud.toDate(scope.row.travelStartTime) }}
          </template>
        </el-table-column>
        <el-table-column prop="travelEndTime" label="出差结束时间" min-width="140" show-overflow-tooltip>
          <template slot-scope="scope">
            {{ crud.toDate(scope.row.travelEndTime) }}
          </template>
        </el-table-column>
        <el-table-column prop="travelDuration" label="出差时长" show-overflow-tooltip>
          <template slot-scope="scope">
            {{ scope.row.travelDuration + '(' + dict.label[dictLeaveTimeType][scope.row.durationUnit] + ')' }}
          </template>
        </el-table-column>
        <el-table-column prop="travelReason" label="出差原因" show-overflow-tooltip />
        <el-table-column prop="departureCity" label="出发城市" show-overflow-tooltip />
        <el-table-column prop="arrivalCity" label="到达城市" show-overflow-tooltip />
        <el-table-column prop="approvalStatus" label="审批状态" show-overflow-tooltip>
          <template slot-scope="scope">
            <el-tag v-if="scope.row.approvalStatus === dictGoOutAppRev" type="warning">{{ dict.label[dictBussinessStatus][scope.row.approvalStatus] }}</el-tag>
            <el-tag v-if="scope.row.approvalStatus === dictGoOutAgree" type="success">{{ dict.label[dictBussinessStatus][scope.row.approvalStatus] }}</el-tag>
            <el-tag v-if="scope.row.approvalStatus === dictGoOutReturn" type="danger">{{ dict.label[dictBussinessStatus][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="创建时间" min-width="140" />
        <el-table-column label="审核操作" min-width="200px" 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 === dictGoOutAppRev ? false : true"
              @click="toApprove(scope.row)"
            >审核
            </el-button>
          </template>
        </el-table-column>
        <el-table-column v-if="checkPer(['admin','attendanceBusinessTravel:edit','attendanceBusinessTravel: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 crudAttendanceBusinessTravel from '@/api/attendance/attendanceBusinessTravel'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudUser from '@/api/system/user'
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, travelStartTime: null, travelEndTime: null, travelDuration: null, durationUnit: null, travelReason: null, departureCity: null, arrivalCity: null, approvalStatus: null, approvalDescription: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null }
export default {
  name: 'AttendanceBusinessTravel',
  components: { pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  cruds() {
    return CRUD({ title: '考勤出差', url: 'api/attendanceBusinessTravel', idField: 'id', sort: 'id,desc', crudMethod: { ...crudAttendanceBusinessTravel }})
  },
  // 数据字典constant
  dicts: [constant.BUSSINESS_APPROVE_STATUS, constant.LEAVE_TIME_TYPE],
  data() {
    return {
      permission: {
        add: ['admin', 'attendanceBusinessTravel:add'],
        edit: ['admin', 'attendanceBusinessTravel:edit'],
        del: ['admin', 'attendanceBusinessTravel:del'],
        download: ['admin', 'attendanceBusinessTravel:download']
      },
      rules: {
        userId: [
          { required: true, message: '用户id不能为空', trigger: 'blur' }
        ],
        approvalUserId: [
          { required: true, message: '审批用户id不能为空', trigger: 'blur' }
        ],
        travelStartTime: [
          { required: true, message: '出差开始时间不能为空', trigger: 'blur' }
        ],
        travelEndTime: [
          { required: true, message: '出差结束时间不能为空', trigger: 'blur' }
        ],
        travelDuration: [
          { required: true, message: '出差时长不能为空', trigger: 'blur' }
        ],
        durationUnit: [
          { required: true, message: '时长单位不能为空', trigger: 'blur' }
        ],
        approvalDescription: [
          { required: true, message: '退回原因不能为空', trigger: 'blur' }
        ],
        approvalStatus: [
          { required: true, message: '审批状态不能为空', trigger: 'blur' }
        ],
        createBy: [
          { required: true, message: '创建者不能为空', trigger: 'blur' }
        ],
        createTime: [
          { required: true, message: '创建时间不能为空', trigger: 'blur' }
        ]
      },
      users: [],
      dictBussinessStatus: constant.BUSSINESS_APPROVE_STATUS,
      dictGoOutAppRev: constant.BUSSINESS_APPROVE_STATUS_REVIEWED,
      dictGoOutAgree: constant.BUSSINESS_APPROVE_STATUS_AGREE,
      dictGoOutReturn: constant.BUSSINESS_APPROVE_STATUS_REFUSE,
      dictLeaveTimeTypeDay: constant.LEAVE_TIME_TYPE_DAY,
      dictLeaveTimeType: constant.LEAVE_TIME_TYPE,
      makeUpCardVisible: false,
      successLoading: false }
  },
  created() {
    this.getUsers()
  },
  methods: {
    // 钩子:在获取表格数据之前执行,false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    },
    // 查询员工
    getUsers() {
      crudUser.getAll().then(res => {
        this.users = res
      })
    },
    // 计算时长
    checkTime() {
      this.form.durationUnit = this.dictLeaveTimeTypeDay
      var data = JSON.stringify({
        'travelStartTime': this.form.travelStartTime,
        'travelEndTime': this.form.travelEndTime
      })
      crudAttendanceBusinessTravel.getRemainingTime(data).then(res => {
        this.form.travelDuration = res
      })
    },
    // 审批页面赋值
    toApprove(data) {
      this.makeUpCardVisible = true
      this.form.id = data.id
      this.form.userId = data.userId
      this.form.userName = data.userName
      this.form.travelStartTime = data.travelStartTime
      this.form.travelEndTime = data.travelEndTime
      this.form.departureCity = data.departureCity
      this.form.arrivalCity = data.arrivalCity
      this.form.travelDuration = data.travelDuration
      this.form.durationUnit = data.durationUnit
      this.form.approvalStatus = data.approvalStatus
      this.form.travelReason = data.travelReason
      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.dictGoOutAgree
        } else {
          // 退回改状态显示退回原因
          this.form.approvalStatus = this.dictGoOutReturn
          if (this.form.approvalDescription == null) {
            return
          }
        }
        crudAttendanceBusinessTravel.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
    },
    // 取消
    canel(data) {
      this.$refs[`popover_${data.id}`].showPopper = 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>
eladmin-web-master/src/views/attendance/attendanceCardReplacement/index.vue
@@ -143,9 +143,17 @@
        <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="申请人" show-overflow-tooltip />
        <el-table-column prop="appUserName" label="审批者" show-overflow-tooltip />
        <el-table-column prop="cardReplacementTime" label="补卡时间" show-overflow-tooltip />
        <el-table-column prop="userName" label="申请人" width="100" show-overflow-tooltip>
          <template slot-scope="scope">
            <el-tag>{{ scope.row.userName }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="appUserName" label="审批者" width="100" show-overflow-tooltip>
          <template slot-scope="scope">
            <el-tag>{{ scope.row.appUserName }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="cardReplacementTime" label="补卡时间" width="140" show-overflow-tooltip />
        <el-table-column prop="cardReplacementReason" label="补卡原因" show-overflow-tooltip />
        <el-table-column prop="approvalStatus" label="审批状态" show-overflow-tooltip>
          <template slot-scope="scope">
@@ -161,8 +169,8 @@
          </template>
        </el-table-column>
        <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">
        <el-table-column prop="createTime" label="创建时间" width="140" show-overflow-tooltip />
        <el-table-column label="审核操作" min-width="200px" align="center">
          <template slot-scope="scope">
            <el-button
              v-if="scope.row.approvalUserId === $store.state.user.user.id"
@@ -174,6 +182,25 @@
              @click="toApprove(scope.row)"
            >审核
            </el-button>
            <el-popover
              :ref="`popover_${scope.row.id}`"
              width="200"
            >
              <p>确定撤销该补卡?</p>
              <div style="text-align: right; margin: 0">
                <el-button size="mini" type="primary" @click="canel(scope.row)">取消</el-button>
                <el-button :loading="crud.status.cu === 2" type="primary" size="mini" @click="revoke(scope.row)">确定</el-button>
              </div>
              <el-button
                v-if="scope.row.approvalUserId === $store.state.user.user.id"
                slot="reference"
                type="danger"
                icon="el-icon-edit-outline"
                size="mini"
                :disabled="scope.row.approvalStatus === dictCardApproveStatusReviewed ? true : false"
              >撤销
              </el-button>
            </el-popover>
          </template>
        </el-table-column>
        <el-table-column v-if="checkPer(['admin','attendanceCardreplacement:edit','attendanceCardreplacement:del'])" label="操作" width="250px" align="center">
@@ -181,29 +208,7 @@
            <udOperation
              :data="scope.row"
              :permission="permission"
            >
              <template slot="left">
                <el-popover
                  :ref="`popover_${scope.row.id}`"
                  width="200"
                >
                  <p>确定撤销该补卡?</p>
                  <div style="text-align: right; margin: 0">
                    <el-button size="mini" type="primary" @click="canel(scope.row)">取消</el-button>
                    <el-button :loading="crud.status.cu === 2" type="primary" size="mini" @click="revoke(scope.row)">确定</el-button>
                  </div>
                  <el-button
                    v-if="scope.row.approvalUserId === $store.state.user.user.id"
                    slot="reference"
                    type="danger"
                    icon="el-icon-edit-outline"
                    size="mini"
                    :disabled="scope.row.approvalStatus === dictCardApproveStatusReviewed ? true : false"
                  >撤销
                  </el-button>
                </el-popover>
              </template>
            </udOperation>
            />
          </template>
        </el-table-column>
      </el-table>
eladmin-web-master/src/views/attendance/attendanceGoOut/index.vue
New file
@@ -0,0 +1,429 @@
<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-date-picker
          v-model="query.outStartTime"
          type="daterange"
          clearable
          class="filter-item"
          value-format="yyyy-MM-dd HH:mm:ss"
          placeholder="请选择开始时间"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="开始日期"
        />
        <el-date-picker
          v-model="query.outEndTime"
          type="daterange"
          clearable
          class="filter-item"
          value-format="yyyy-MM-dd HH:mm:ss"
          placeholder="请选择结束时间"
          range-separator="至"
          start-placeholder="结束日期"
          end-placeholder="结束日期"
        />
        <el-select v-model="query.outOfOfficeType" filterable clearable placeholder="请选择外出类型" style="width: 170px;" class="filter-item" @keyup.enter.native="crud.toQuery">
          <el-option
            v-for="item in dict[dictGoOutTypr]"
            :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>
        <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="outStartTime">
            <el-date-picker
              v-model="form.outStartTime"
              :type="'datetime'"
              placeholder="选择日期时间"
              style="width: 370px;"
              value-format="yyyy-MM-dd HH:mm:ss"
              align="right"
              :picker-options="{ disabledDate(time) {
                return form.outEndTime ? time.getTime() > new Date(form.outEndTime).getTime() - 8.64e7 : false;
              }
              }"
              default-time="09:00:00"
              @change="checkTime"
            />
          </el-form-item>
          <el-form-item label="结束时间" prop="outEndTime">
            <el-date-picker
              v-model="form.outEndTime"
              :type="'datetime'"
              placeholder="选择日期时间"
              style="width: 370px;"
              value-format="yyyy-MM-dd HH:mm:ss"
              align="right"
              :picker-options="{ disabledDate(time) {
                return form.outStartTime ? time.getTime() < new Date(form.outStartTime).getTime() - 8.64e7 : false;
              }
              }"
              default-time="18:00:00"
              @change="checkTime"
            />
          </el-form-item>
          <el-form-item label="外出时长" prop="outDuration">
            <el-input v-model="form.outDuration" disabled style="width: 370px;">
              <template slot="append">{{ dict.label[dictLeaveTimeType][form.durationUnit] }}</template>
            </el-input>
          </el-form-item>
          <el-form-item label="外出类型" prop="outOfOfficeType">
            <el-select v-model="form.outOfOfficeType" filterable clearable placeholder="请选择外出类型" style="width: 370px;">
              <el-option
                v-for="item in dict[dictGoOutTypr]"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="外出原因">
            <el-input v-model="form.outReason" 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[dictGoOutTypr][form.outOfOfficeType] }}</el-tag></div>
        </div>
        <div class="form-item">
          <div class="form-item-label">
            <label>开始时间:</label>
          </div>
          <div class="form-item-value">{{ form.outStartTime }}</div>
        </div>
        <div class="form-item">
          <div class="form-item-label">
            <label>结束时间:</label>
          </div>
          <div class="form-item-value">{{ form.outEndTime }}</div>
        </div>
        <div class="form-item">
          <div class="form-item-label">
            <label>外出时长:</label>
          </div>
          <div class="form-item-value">{{ form.outDuration + '(' + dict.label[dictLeaveTimeType][form.durationUnit] + ')' }}</div>
        </div>
        <div class="form-item">
          <div class="form-item-label">
            <label>外出原因:</label>
          </div>
          <div class="form-item-value">{{ form.outReason }}</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 === dictGoOutReturn" 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 !== dictGoOutReturn" :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 prop="userName" label="员工" width="110" show-overflow-tooltip>
          <template slot-scope="scope">
            <el-tag>{{ scope.row.userName }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="appUserName" label="审批员工" width="110" show-overflow-tooltip>
          <template slot-scope="scope">
            <el-tag>{{ scope.row.appUserName }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="outStartTime" label="外出开始时间" min-width="140" show-overflow-tooltip />
        <el-table-column prop="outEndTime" label="外出结束时间" min-width="140" show-overflow-tooltip />
        <el-table-column prop="outDuration" label="外出时长" show-overflow-tooltip>
          <template slot-scope="scope">
            {{ scope.row.outDuration + '(' + dict.label[dictLeaveTimeType][scope.row.durationUnit] + ')' }}
          </template>
        </el-table-column>
        <el-table-column prop="outOfOfficeType" label="外出类型" show-overflow-tooltip>
          <template slot-scope="scope">
            <el-tag>{{ dict.label[dictGoOutTypr][scope.row.outOfOfficeType] }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="outReason" label="外出原因" show-overflow-tooltip />
        <el-table-column prop="approvalStatus" label="审批状态" show-overflow-tooltip>
          <template slot-scope="scope">
            <el-tag v-if="scope.row.approvalStatus === dictGoOutAppRev" type="warning">{{ dict.label[dictApprovalStart][scope.row.approvalStatus] }}</el-tag>
            <el-tag v-if="scope.row.approvalStatus === dictGoOutAgree" type="success">{{ dict.label[dictApprovalStart][scope.row.approvalStatus] }}</el-tag>
            <el-tag v-if="scope.row.approvalStatus === dictGoOutReturn" 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="创建时间" min-width="140" 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 === dictGoOutAppRev ? false : true"
              @click="toApprove(scope.row)"
            >审核
            </el-button>
          </template>
        </el-table-column>
        <el-table-column v-if="checkPer(['admin','attendanceGoOut:edit','attendanceGoOut: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 crudAttendanceGoOut from '@/api/attendance/attendanceGoOut'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudUser from '@/api/system/user'
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, outStartTime: null, outEndTime: null, outDuration: null, durationUnit: null, outOfOfficeType: null, outReason: null, approvalStatus: null, approvalDescription: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null }
export default {
  name: 'AttendanceGoOut',
  components: { pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  cruds() {
    return CRUD({ title: '考勤外出', url: 'api/attendanceGoOut', idField: 'id', sort: 'id,desc', crudMethod: { ...crudAttendanceGoOut }})
  },
  // 数据字典
  dicts: [constant.LEAVE_TIME_TYPE, constant.GO_OUT_TYPE, constant.GO_OUT_APPROVE_STATUS],
  data() {
    return {
      permission: {
        add: ['admin', 'attendanceGoOut:add'],
        edit: ['admin', 'attendanceGoOut:edit'],
        del: ['admin', 'attendanceGoOut:del'],
        download: ['admin', 'attendanceGoOut:download']
      },
      rules: {
        userId: [
          { required: true, message: '用户id不能为空', trigger: 'change' }
        ],
        approvalUserId: [
          { required: true, message: '审批用户id不能为空', trigger: 'change' }
        ],
        outStartTime: [
          { required: true, message: '外出开始时间不能为空', trigger: 'change' }
        ],
        outEndTime: [
          { required: true, message: '外出结束时间不能为空', trigger: 'change' }
        ],
        outDuration: [
          { required: true, message: '外出时长不能为空', trigger: 'blur' }
        ],
        durationUnit: [
          { required: true, message: '时长单位不能为空', trigger: 'blur' }
        ],
        outOfOfficeType: [
          { required: true, message: '外出类型不能为空', trigger: 'change' }
        ],
        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: [],
      dictLeaveTimeType: constant.LEAVE_TIME_TYPE,
      dictLeaveTimeTypeHour: constant.LEAVE_TIME_TYPE_HOUR,
      dictGoOutTypr: constant.GO_OUT_TYPE,
      dictApprovalStart: constant.GO_OUT_APPROVE_STATUS,
      dictGoOutAppRev: constant.GO_OUT_APPROVE_STATUS_REVIEWED,
      dictGoOutAgree: constant.GO_OUT_APPROVE_STATUS_AGREE,
      dictGoOutReturn: constant.GO_OUT_APPROVE_STATUS_REFUSE,
      makeUpCardVisible: false,
      successLoading: false }
  },
  created() {
    this.getUsers()
  },
  methods: {
    // 钩子:在获取表格数据之前执行,false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    },
    // 查询员工
    getUsers() {
      crudUser.getAll().then(res => {
        this.users = res
      })
    },
    // 计算时长
    checkTime() {
      this.form.durationUnit = this.dictLeaveTimeTypeHour
      var data = JSON.stringify({
        'outStartTime': this.form.outStartTime,
        'outEndTime': this.form.outEndTime
      })
      crudAttendanceGoOut.getRemainingTime(data).then(res => {
        this.form.outDuration = res
      })
    },
    // 审批页面赋值
    toApprove(data) {
      this.makeUpCardVisible = true
      this.form.id = data.id
      this.form.userId = data.userId
      this.form.userName = data.userName
      this.form.outOfOfficeType = data.outOfOfficeType
      this.form.outStartTime = data.outStartTime
      this.form.outEndTime = data.outEndTime
      this.form.outDuration = data.outDuration
      this.form.durationUnit = data.durationUnit
      this.form.approvalStatus = data.approvalStatus
      this.form.outReason = data.outReason
      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.dictGoOutAgree
        } else {
          // 退回改状态显示退回原因
          this.form.approvalStatus = this.dictGoOutReturn
          if (this.form.approvalDescription == null) {
            return
          }
        }
        crudAttendanceGoOut.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>
eladmin-web-master/src/views/attendance/attendanceLeave/index.vue
@@ -29,17 +29,25 @@
        </el-select>
        <el-date-picker
          v-model="query.leaveStartTime"
          type="daterange"
          clearable
          class="filter-item"
          value-format="yyyy-MM-dd HH:mm:ss"
          placeholder="请选择开始时间"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="开始日期"
        />
        <el-date-picker
          v-model="query.leaveEndTime"
          type="daterange"
          clearable
          class="filter-item"
          value-format="yyyy-MM-dd HH:mm:ss"
          placeholder="请选择结束时间"
          range-separator="至"
          start-placeholder="结束日期"
          end-placeholder="结束日期"
        />
        <rrOperation />
      </div>
@@ -80,8 +88,8 @@
                return form.leaveEndTime ? time.getTime() > new Date(form.leaveEndTime).getTime() - 8.64e7 : false;
              }
              }"
              @change="checkLeaveTime"
              default-time="09:00:00"
              @change="checkLeaveTime"
            />
          </el-form-item>
          <el-form-item label="结束时间" prop="leaveEndTime">
@@ -92,8 +100,12 @@
              style="width: 370px;"
              value-format="yyyy-MM-dd HH:mm:ss"
              align="right"
              @change="checkLeaveTime"
              :picker-options="{ disabledDate(time) {
                return form.leaveStartTime ? time.getTime() < new Date(form.leaveStartTime).getTime() - 8.64e7 : false;
              }
              }"
              default-time="18:00:00"
              @change="checkLeaveTime"
            />
          </el-form-item>
          <el-form-item label="请假时长" prop="leaveDuration">
@@ -176,19 +188,27 @@
        <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="userName" label="员工" width="110" show-overflow-tooltip>
          <template slot-scope="scope">
            <el-tag>{{ scope.row.userName }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="appUserName" label="审批员工" width="110" show-overflow-tooltip>
          <template slot-scope="scope">
            <el-tag>{{ scope.row.appUserName }}</el-tag>
          </template>
        </el-table-column>
        <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>
        <el-table-column prop="leaveStartTime" min-width="140" 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>
        <el-table-column prop="leaveEndTime" min-width="140" label="请假结束时间" show-overflow-tooltip>
          <template slot-scope="scope">
            {{ scope.row.leaveDurationUnit === dictLeaveTimeTypeHour ? scope.row.leaveEndTime : crud.toDate(scope.row.leaveEndTime) }}
          </template>
@@ -208,7 +228,7 @@
        </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 prop="createTime" min-width="140" label="创建时间" show-overflow-tooltip />
        <el-table-column label="审核操作" min-width="120px" align="center">
          <template slot-scope="scope">
            <el-button