10 files added
5 files modified
| | |
| | | */ |
| | | String blurry() default ""; |
| | | |
| | | //wcd加 |
| | | String isOr() default ""; |
| | | // |
| | | |
| | | enum Type { |
| | | // jie 2019/6/4 相等 |
| | | EQUAL |
| | |
| | | String propName = q.propName(); |
| | | String joinName = q.joinName(); |
| | | String blurry = q.blurry(); |
| | | // wcd加 |
| | | String isOr = q.isOr(); |
| | | // |
| | | String attributeName = isBlank(propName) ? field.getName() : propName; |
| | | Class<?> fieldType = field.getType(); |
| | | Object val = field.get(query); |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | // wcd加 |
| | | if (ObjectUtil.isNotEmpty(isOr)) { |
| | | String[] isOrs = isOr.split(","); |
| | | List<Predicate> orP = new ArrayList<>(); |
| | | for (String s : isOrs) { |
| | | orP.add(cb.equal(root.get(s) |
| | | .as(String.class), val)); |
| | | } |
| | | Predicate[] orpr = new Predicate[orP.size()]; |
| | | list.add(cb.or(orP.toArray(orpr))); |
| | | continue; |
| | | } |
| | | // |
| | | |
| | | switch (q.type()) { |
| | | case EQUAL: |
| | | list.add(cb.equal(getExpression(attributeName,join,root) |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.attendance.domain; |
| | | |
| | | import lombok.Data; |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import cn.hutool.core.bean.copier.CopyOptions; |
| | | import me.zhengjie.base.BaseEntity; |
| | | |
| | | import javax.persistence.*; |
| | | import javax.validation.constraints.*; |
| | | import java.sql.Timestamp; |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @description / |
| | | * @author wcd |
| | | * @date 2022-12-21 |
| | | **/ |
| | | @Entity |
| | | @Data |
| | | @Table(name="attendance_cardreplacement") |
| | | public class AttendanceCardreplacement 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 = "`card_replacement_time`",nullable = false) |
| | | @NotNull |
| | | @ApiModelProperty(value = "补卡时间") |
| | | private Timestamp cardReplacementTime; |
| | | |
| | | @Column(name = "`card_replacement_reason`") |
| | | @ApiModelProperty(value = "补卡原因") |
| | | private String cardReplacementReason; |
| | | |
| | | @Column(name = "`approval_status`",nullable = false) |
| | | @NotBlank |
| | | @ApiModelProperty(value = "审批状态") |
| | | private String approvalStatus; |
| | | |
| | | @Column(name = "`approval_description`") |
| | | @ApiModelProperty(value = "审批说明") |
| | | private String approvalDescription; |
| | | |
| | | @Column(name = "`card_replacement_distinguish`") |
| | | @ApiModelProperty(value = "补卡区分") |
| | | private String cardReplacementDistinguish; |
| | | |
| | | @Column(name = "`remarks`") |
| | | @ApiModelProperty(value = "备注") |
| | | private String remarks; |
| | | |
| | | |
| | | public void copy(AttendanceCardreplacement source){ |
| | | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * 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.AttendanceCardreplacement; |
| | | import org.springframework.data.jpa.repository.JpaRepository; |
| | | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; |
| | | import org.springframework.data.jpa.repository.Query; |
| | | |
| | | import java.sql.Timestamp; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @author wcd |
| | | * @date 2022-12-21 |
| | | **/ |
| | | public interface AttendanceCardreplacementRepository extends JpaRepository<AttendanceCardreplacement, Long>, JpaSpecificationExecutor<AttendanceCardreplacement> { |
| | | |
| | | //查询补卡记录是否存 |
| | | @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); |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.attendance.rest; |
| | | |
| | | import me.zhengjie.annotation.Log; |
| | | import me.zhengjie.modules.attendance.domain.AttendanceCardreplacement; |
| | | import me.zhengjie.modules.attendance.service.AttendanceCardreplacementService; |
| | | import me.zhengjie.modules.attendance.service.dto.AttendanceCardreplacementQueryCriteria; |
| | | 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 2022-12-21 |
| | | **/ |
| | | @RestController |
| | | @RequiredArgsConstructor |
| | | @Api(tags = "补卡管理") |
| | | @RequestMapping("/api/attendanceCardreplacement") |
| | | public class AttendanceCardreplacementController { |
| | | |
| | | private final AttendanceCardreplacementService attendanceCardreplacementService; |
| | | |
| | | @Log("导出数据") |
| | | @ApiOperation("导出数据") |
| | | @GetMapping(value = "/download") |
| | | @PreAuthorize("@el.check('attendanceCardreplacement:download')") |
| | | public void exportAttendanceCardreplacement(HttpServletResponse response, AttendanceCardreplacementQueryCriteria criteria) throws IOException { |
| | | attendanceCardreplacementService.download(attendanceCardreplacementService.queryAll(criteria), response); |
| | | } |
| | | |
| | | @GetMapping |
| | | @Log("查询补卡") |
| | | @ApiOperation("查询补卡") |
| | | @PreAuthorize("@el.check('attendanceCardreplacement:list')") |
| | | public ResponseEntity<Object> queryAttendanceCardreplacement(AttendanceCardreplacementQueryCriteria criteria, Pageable pageable){ |
| | | return new ResponseEntity<>(attendanceCardreplacementService.queryAll(criteria,pageable),HttpStatus.OK); |
| | | } |
| | | |
| | | @GetMapping(value = "/all") |
| | | @Log("查询补卡") |
| | | @ApiOperation("查询补卡") |
| | | @PreAuthorize("@el.check('attendanceCardreplacement:list')") |
| | | public ResponseEntity<Object> queryAttendanceCardreplacement(AttendanceCardreplacementQueryCriteria criteria){ |
| | | return new ResponseEntity<>(attendanceCardreplacementService.queryAll(criteria),HttpStatus.OK); |
| | | } |
| | | |
| | | @PostMapping |
| | | @Log("新增补卡") |
| | | @ApiOperation("新增补卡") |
| | | @PreAuthorize("@el.check('attendanceCardreplacement:add')") |
| | | public ResponseEntity<Object> createAttendanceCardreplacement(@Validated @RequestBody AttendanceCardreplacement resources) throws Exception { |
| | | return new ResponseEntity<>(attendanceCardreplacementService.create(resources),HttpStatus.CREATED); |
| | | } |
| | | |
| | | @PutMapping |
| | | @Log("修改补卡") |
| | | @ApiOperation("修改补卡") |
| | | @PreAuthorize("@el.check('attendanceCardreplacement:edit')") |
| | | public ResponseEntity<Object> updateAttendanceCardreplacement(@Validated @RequestBody AttendanceCardreplacement resources){ |
| | | attendanceCardreplacementService.update(resources); |
| | | return new ResponseEntity<>(HttpStatus.NO_CONTENT); |
| | | } |
| | | |
| | | @DeleteMapping |
| | | @Log("删除补卡") |
| | | @ApiOperation("删除补卡") |
| | | @PreAuthorize("@el.check('attendanceCardreplacement:del')") |
| | | public ResponseEntity<Object> deleteAttendanceCardreplacement(@RequestBody Long[] ids) { |
| | | attendanceCardreplacementService.deleteAll(ids); |
| | | return new ResponseEntity<>(HttpStatus.OK); |
| | | } |
| | | |
| | | @PutMapping(value = "/approve") |
| | | @Log("审核功能") |
| | | @ApiOperation("审核功能") |
| | | public ResponseEntity<Object> checkApprove(@Validated @RequestBody AttendanceCardreplacement resources){ |
| | | attendanceCardreplacementService.updateApprove(resources); |
| | | return new ResponseEntity<>(HttpStatus.NO_CONTENT); |
| | | } |
| | | |
| | | @PutMapping(value = "/revoke") |
| | | @Log("补卡撤销") |
| | | @ApiOperation("补卡撤销") |
| | | public ResponseEntity<Object> checkInApplicationPass(@Validated @RequestBody AttendanceCardreplacement resources){ |
| | | attendanceCardreplacementService.cardRevoke(resources); |
| | | return new ResponseEntity<>(HttpStatus.NO_CONTENT); |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.attendance.service; |
| | | |
| | | import me.zhengjie.modules.attendance.domain.AttendanceCardreplacement; |
| | | import me.zhengjie.modules.attendance.service.dto.AttendanceCardreplacementDto; |
| | | import me.zhengjie.modules.attendance.service.dto.AttendanceCardreplacementQueryCriteria; |
| | | 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 2022-12-21 |
| | | **/ |
| | | public interface AttendanceCardreplacementService { |
| | | |
| | | /** |
| | | * 查询数据分页 |
| | | * @param criteria 条件 |
| | | * @param pageable 分页参数 |
| | | * @return Map<String,Object> |
| | | */ |
| | | Map<String,Object> queryAll(AttendanceCardreplacementQueryCriteria criteria, Pageable pageable); |
| | | |
| | | /** |
| | | * 查询所有数据不分页 |
| | | * @param criteria 条件参数 |
| | | * @return List<AttendanceCardreplacementDto> |
| | | */ |
| | | List<AttendanceCardreplacementDto> queryAll(AttendanceCardreplacementQueryCriteria criteria); |
| | | |
| | | /** |
| | | * 根据ID查询 |
| | | * @param id ID |
| | | * @return AttendanceCardreplacementDto |
| | | */ |
| | | AttendanceCardreplacementDto findById(Long id); |
| | | |
| | | /** |
| | | * 创建 |
| | | * @param resources / |
| | | * @return AttendanceCardreplacementDto |
| | | */ |
| | | AttendanceCardreplacementDto create(AttendanceCardreplacement resources) throws Exception; |
| | | |
| | | /** |
| | | * 编辑 |
| | | * @param resources / |
| | | */ |
| | | void update(AttendanceCardreplacement resources); |
| | | |
| | | /** |
| | | * 多选删除 |
| | | * @param ids / |
| | | */ |
| | | void deleteAll(Long[] ids); |
| | | |
| | | /** |
| | | * 导出数据 |
| | | * @param all 待导出的数据 |
| | | * @param response / |
| | | * @throws IOException / |
| | | */ |
| | | void download(List<AttendanceCardreplacementDto> all, HttpServletResponse response) throws IOException; |
| | | |
| | | /** |
| | | * 审核 |
| | | * @param resources / |
| | | */ |
| | | void updateApprove(AttendanceCardreplacement resources); |
| | | |
| | | /** |
| | | * 补卡撤销 |
| | | * @param resources |
| | | */ |
| | | void cardRevoke(AttendanceCardreplacement resources); |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.attendance.service.dto; |
| | | |
| | | import lombok.Data; |
| | | import me.zhengjie.base.BaseDTO; |
| | | |
| | | import java.sql.Timestamp; |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @description / |
| | | * @author wcd |
| | | * @date 2022-12-21 |
| | | **/ |
| | | @Data |
| | | public class AttendanceCardreplacementDto extends BaseDTO implements Serializable { |
| | | |
| | | /** 主键id */ |
| | | private Long id; |
| | | |
| | | /** 用户id */ |
| | | private Long userId; |
| | | |
| | | /** 审批用户id */ |
| | | private Long approvalUserId; |
| | | |
| | | /** 补卡时间 */ |
| | | private Timestamp cardReplacementTime; |
| | | |
| | | /** 补卡原因 */ |
| | | private String cardReplacementReason; |
| | | |
| | | /** 审批状态 */ |
| | | private String approvalStatus; |
| | | |
| | | /** 审批说明 */ |
| | | private String approvalDescription; |
| | | |
| | | /** 补卡区分 */ |
| | | private String cardReplacementDistinguish; |
| | | |
| | | /** 备注 */ |
| | | private String remarks; |
| | | |
| | | /** 申请人 */ |
| | | private String userName; |
| | | |
| | | /** 审批人 */ |
| | | private String appUserName; |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.attendance.service.dto; |
| | | |
| | | import lombok.Data; |
| | | import java.util.List; |
| | | import me.zhengjie.annotation.Query; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @author wcd |
| | | * @date 2022-12-21 |
| | | **/ |
| | | @Data |
| | | public class AttendanceCardreplacementQueryCriteria{ |
| | | |
| | | //员工查询 |
| | | @Query |
| | | private Long userId; |
| | | |
| | | //日期查询 |
| | | @Query(type = Query.Type.INNER_LIKE, propName = "cardReplacementTime") |
| | | private String cardReplacementTime; |
| | | |
| | | //审批查询 |
| | | @Query |
| | | private String approvalStatus; |
| | | |
| | | //区分查询 |
| | | @Query |
| | | private String cardReplacementDistinguish; |
| | | |
| | | @Query(isOr = "userId,approvalUserId") |
| | | private Long approver; |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.attendance.service.impl; |
| | | |
| | | import me.zhengjie.exception.BadRequestException; |
| | | import me.zhengjie.modules.attendance.domain.Attendance; |
| | | import me.zhengjie.modules.attendance.domain.AttendanceCardreplacement; |
| | | import me.zhengjie.modules.attendance.repository.AttendanceRepository; |
| | | 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.User; |
| | | import me.zhengjie.modules.system.repository.RoleRepository; |
| | | import me.zhengjie.modules.system.repository.UserRepository; |
| | | import me.zhengjie.utils.*; |
| | | import lombok.RequiredArgsConstructor; |
| | | import me.zhengjie.modules.attendance.repository.AttendanceCardreplacementRepository; |
| | | import me.zhengjie.modules.attendance.service.AttendanceCardreplacementService; |
| | | import me.zhengjie.modules.attendance.service.dto.AttendanceCardreplacementDto; |
| | | import me.zhengjie.modules.attendance.service.dto.AttendanceCardreplacementQueryCriteria; |
| | | import me.zhengjie.modules.attendance.service.mapstruct.AttendanceCardreplacementMapper; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.data.domain.Page; |
| | | import org.springframework.data.domain.Pageable; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.io.IOException; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.ArrayList; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.function.Function; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @description 服务实现 |
| | | * @author wcd |
| | | * @date 2022-12-21 |
| | | **/ |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class AttendanceCardreplacementServiceImpl implements AttendanceCardreplacementService { |
| | | |
| | | private final AttendanceCardreplacementRepository attendanceCardreplacementRepository; |
| | | private final AttendanceCardreplacementMapper attendanceCardreplacementMapper; |
| | | private final UserRepository userRepository; |
| | | private final OpaiDingTalkService opaiDingTalkService; |
| | | private final RoleRepository roleRepository; |
| | | private final AttendanceRepository attendanceRepository; |
| | | |
| | | @Override |
| | | 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 >(){ |
| | | |
| | | @Override |
| | | public AttendanceCardreplacementDto apply(AttendanceCardreplacement attendanceCardreplacement) { |
| | | // 将实体类转换成DTO |
| | | AttendanceCardreplacementDto attendanceCardreplacementDto = attendanceCardreplacementMapper.toDto(attendanceCardreplacement); |
| | | //查询申请人信息 |
| | | User user = userRepository.findById(attendanceCardreplacementDto.getUserId()).orElseGet(User::new); |
| | | attendanceCardreplacementDto.setUserName(user.getNickName()); |
| | | //查询申请人信息 |
| | | User appUser = userRepository.findById(attendanceCardreplacementDto.getApprovalUserId()).orElseGet(User::new); |
| | | attendanceCardreplacementDto.setAppUserName(appUser.getNickName()); |
| | | return attendanceCardreplacementDto; |
| | | } |
| | | }; |
| | | return PageUtil.toPage(page.map(func)); |
| | | } |
| | | |
| | | @Override |
| | | public List<AttendanceCardreplacementDto> queryAll(AttendanceCardreplacementQueryCriteria criteria){ |
| | | return attendanceCardreplacementMapper.toDto(attendanceCardreplacementRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public AttendanceCardreplacementDto findById(Long id) { |
| | | AttendanceCardreplacement attendanceCardreplacement = attendanceCardreplacementRepository.findById(id).orElseGet(AttendanceCardreplacement::new); |
| | | ValidationUtil.isNull(attendanceCardreplacement.getId(),"AttendanceCardreplacement","id",id); |
| | | return attendanceCardreplacementMapper.toDto(attendanceCardreplacement); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public AttendanceCardreplacementDto create(AttendanceCardreplacement resources) throws Exception { |
| | | //查询补卡记录是否存在 |
| | | AttendanceCardreplacement attendanceCardreplacement = attendanceCardreplacementRepository.findByUserIdAndCardReplacementTime(resources.getUserId(),resources.getCardReplacementTime()); |
| | | if(ObjectUtils.isNotEmpty(attendanceCardreplacement)) { |
| | | throw new BadRequestException("补卡记录已存在"); |
| | | } |
| | | //查询考勤表是否有记录 |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | String attDate = sdf.format(resources.getCardReplacementTime()); |
| | | Attendance attendance = attendanceRepository.findAllByUserIdAndAttendanceDate(resources.getUserId(),attDate.substring(0,10)); |
| | | if(ObjectUtils.isEmpty(attendance)){ |
| | | throw new BadRequestException("考勤记录不存在"); |
| | | } |
| | | |
| | | resources.setApprovalStatus(Constant.CARD_APPROVE_STATUS_REVIEWED); |
| | | //查询补卡次数(待加入)? |
| | | |
| | | //发送给审批者 |
| | | List<String> sendList = new ArrayList<>(); |
| | | //查询申请人信息 |
| | | User user = userRepository.getOne(resources.getUserId()); |
| | | //查询审批者信息 |
| | | User appUser = userRepository.getOne(resources.getApprovalUserId()); |
| | | sendList.add(appUser.getDingding()); |
| | | opaiDingTalkService.sendNotice(sendList, "审批提醒", "### 审批提示 \n >" + user.getNickName() + " 提交了补卡审批,请登录PMS系统处理", "card"); |
| | | return attendanceCardreplacementMapper.toDto(attendanceCardreplacementRepository.save(resources)); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void update(AttendanceCardreplacement resources) { |
| | | AttendanceCardreplacement attendanceCardreplacement = attendanceCardreplacementRepository.findById(resources.getId()).orElseGet(AttendanceCardreplacement::new); |
| | | ValidationUtil.isNull( attendanceCardreplacement.getId(),"AttendanceCardreplacement","id",resources.getId()); |
| | | attendanceCardreplacement.copy(resources); |
| | | |
| | | //查询考勤表是否有记录 |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | String attDate = sdf.format(resources.getCardReplacementTime()); |
| | | Attendance attendance = attendanceRepository.findAllByUserIdAndAttendanceDate(resources.getUserId(),attDate.substring(0,10)); |
| | | if(ObjectUtils.isEmpty(attendance)){ |
| | | throw new BadRequestException("考勤记录不存在"); |
| | | } |
| | | |
| | | attendanceCardreplacementRepository.save(attendanceCardreplacement); |
| | | } |
| | | |
| | | /** |
| | | * 审核功能 |
| | | * @param resources |
| | | */ |
| | | @Override |
| | | public void updateApprove(AttendanceCardreplacement resources) { |
| | | AttendanceCardreplacement attendanceCardreplacement = attendanceCardreplacementRepository.findById(resources.getId()).orElseGet(AttendanceCardreplacement::new); |
| | | ValidationUtil.isNull(attendanceCardreplacement.getId(), "AttendanceCardreplacement", "id", resources.getId()); |
| | | attendanceCardreplacement.copy(resources); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | String attDate = sdf.format(resources.getCardReplacementTime()); |
| | | // 根据userId和日期查询考勤记录表 |
| | | Attendance attendance = attendanceRepository.findAllByUserIdAndAttendanceDate(resources.getUserId(), attDate.substring(0, 10)); |
| | | // 判断是上班补卡还是下班补卡 |
| | | if (resources.getCardReplacementDistinguish().equals(Constant.CARD_REPLACEMENT_DIFFERENTIATION_GOON)) { |
| | | // 通过 |
| | | if (resources.getApprovalStatus().equals(Constant.CARD_APPROVE_STATUS_AGREE)) { |
| | | // set考勤打卡时间和打卡状态 |
| | | attendance.setActualWorkStartTime(resources.getCardReplacementTime()); |
| | | attendance.setStartClockResults(Constant.ATTENDANCE_STATE_NORMAL); |
| | | attendance.setStartLocationResults(Constant.LOCATION_RESULTS_NORMAL); |
| | | // 减少补卡次数待加入? |
| | | } |
| | | } else { |
| | | // 通过 |
| | | if (resources.getApprovalStatus().equals(Constant.CARD_APPROVE_STATUS_AGREE)) { |
| | | // set考勤打卡时间和打卡状态 |
| | | attendance.setActualWorkEndTime(resources.getCardReplacementTime()); |
| | | attendance.setEndClockResults(Constant.ATTENDANCE_STATE_NORMAL); |
| | | attendance.setEndLocationResults(Constant.LOCATION_RESULTS_NORMAL); |
| | | // 减少补卡次数待加入? |
| | | } |
| | | } |
| | | attendanceRepository.save(attendance); |
| | | attendanceCardreplacementRepository.save(attendanceCardreplacement); |
| | | } |
| | | |
| | | /** |
| | | * 补卡撤销 |
| | | * @param resources |
| | | */ |
| | | @Override |
| | | public void cardRevoke(AttendanceCardreplacement resources) { |
| | | AttendanceCardreplacement attendanceCardreplacement = attendanceCardreplacementRepository.findById(resources.getId()).orElseGet(AttendanceCardreplacement::new); |
| | | ValidationUtil.isNull( attendanceCardreplacement.getId(),"AttendanceCardreplacement","id",resources.getId()); |
| | | attendanceCardreplacement.copy(resources); |
| | | //如果审批状态为已通过,补卡次数加回来? |
| | | if(resources.getApprovalStatus().equals(Constant.CARD_APPROVE_STATUS_AGREE)) { |
| | | } |
| | | attendanceCardreplacement.setApprovalStatus(Constant.CARD_APPROVE_STATUS_REVIEWED); |
| | | attendanceCardreplacementRepository.save(attendanceCardreplacement); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteAll(Long[] ids) { |
| | | for (Long id : ids) { |
| | | attendanceCardreplacementRepository.deleteById(id); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void download(List<AttendanceCardreplacementDto> all, HttpServletResponse response) throws IOException { |
| | | List<Map<String, Object>> list = new ArrayList<>(); |
| | | for (AttendanceCardreplacementDto attendanceCardreplacement : all) { |
| | | Map<String,Object> map = new LinkedHashMap<>(); |
| | | map.put("用户id", attendanceCardreplacement.getUserId()); |
| | | map.put("审批用户id", attendanceCardreplacement.getApprovalUserId()); |
| | | map.put("补卡时间", attendanceCardreplacement.getCardReplacementTime()); |
| | | map.put("补卡原因", attendanceCardreplacement.getCardReplacementReason()); |
| | | map.put("审批状态", attendanceCardreplacement.getApprovalStatus()); |
| | | map.put("审批说明", attendanceCardreplacement.getApprovalDescription()); |
| | | map.put("补卡区分", attendanceCardreplacement.getCardReplacementDistinguish()); |
| | | map.put("备注", attendanceCardreplacement.getRemarks()); |
| | | map.put("创建者", attendanceCardreplacement.getCreateBy()); |
| | | map.put("创建时间", attendanceCardreplacement.getCreateTime()); |
| | | map.put("更新者", attendanceCardreplacement.getUpdateBy()); |
| | | map.put("更新时间", attendanceCardreplacement.getUpdateTime()); |
| | | list.add(map); |
| | | } |
| | | FileUtil.downloadExcel(list, response); |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * 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.AttendanceCardreplacement; |
| | | import me.zhengjie.modules.attendance.service.dto.AttendanceCardreplacementDto; |
| | | import org.mapstruct.Mapper; |
| | | import org.mapstruct.ReportingPolicy; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @author wcd |
| | | * @date 2022-12-21 |
| | | **/ |
| | | @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) |
| | | public interface AttendanceCardreplacementMapper extends BaseMapper<AttendanceCardreplacementDto, AttendanceCardreplacement> { |
| | | |
| | | } |
| | |
| | | |
| | | 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 String DATE_TYPE = "date_type"; |
| | | // 日期类型:工作日 |
| | |
| | | |
| | | // 固定时间(12:30) |
| | | public static final String DATE_TIME_NOON = "12:30:00"; |
| | | |
| | | //补卡区分 |
| | | public static final String CARD_REPLACEMENT_DIFFERENTIATION = "card_replacement_differentiation"; |
| | | // 补卡区分: 上班补卡 |
| | | public static final String CARD_REPLACEMENT_DIFFERENTIATION_GOON = "card_replacement_differentiation_goOn"; |
| | | // 补卡区分: 下班补卡 |
| | | public static final String CARD_REPLACEMENT_DIFFERENTIATION_GOOFF = "card_replacement_differentiation_goOff"; |
| | | |
| | | //补卡审批状态 |
| | | public static final String CARD_APPROVE_STATUS = "card_approve_status"; |
| | | // 补卡审批状态: 待审核 |
| | | public static final String CARD_APPROVE_STATUS_REVIEWED = "card_approve_status_reviewed"; |
| | | // 补卡审批状态: 已同意 |
| | | public static final String CARD_APPROVE_STATUS_AGREE = "card_approve_status_agree"; |
| | | // 补卡审批状态: 已拒绝 |
| | | public static final String CARD_APPROVE_STATUS_REFUSE = "card_approve_status_refuse"; |
| | | |
| | | } |
| New file |
| | |
| | | import request from '@/utils/request' |
| | | |
| | | export function getAll(params) { |
| | | return request({ |
| | | url: 'api/attendanceCardreplacement/all', |
| | | method: 'get', |
| | | params |
| | | }) |
| | | } |
| | | |
| | | export function add(data) { |
| | | return request({ |
| | | url: 'api/attendanceCardreplacement', |
| | | method: 'post', |
| | | data |
| | | }) |
| | | } |
| | | |
| | | export function del(ids) { |
| | | return request({ |
| | | url: 'api/attendanceCardreplacement/', |
| | | method: 'delete', |
| | | data: ids |
| | | }) |
| | | } |
| | | |
| | | export function edit(data) { |
| | | return request({ |
| | | url: 'api/attendanceCardreplacement', |
| | | method: 'put', |
| | | data |
| | | }) |
| | | } |
| | | |
| | | export function approve(data) { |
| | | return request({ |
| | | url: 'api/attendanceCardreplacement/approve', |
| | | method: 'put', |
| | | data |
| | | }) |
| | | } |
| | | |
| | | export function revoke(data) { |
| | | return request({ |
| | | url: 'api/attendanceCardreplacement/revoke', |
| | | method: 'put', |
| | | data |
| | | }) |
| | | } |
| | | |
| | | export default { add, edit, del, getAll, revoke, approve } |
| | |
| | | // 日期类型: 节假日(串休) |
| | | export const DATE_TYPE_HOLIDAYS = 'date_type_holidays' |
| | | // 日期类型: 双休 |
| | | export const DATE_TYPE_WEEKEND = 'date_type_weekend' |
| | | export const DATE_TYPE_WEEKEND = 'date_type_weekend' |
| | | |
| | | // 标准单价币种 |
| | | export const STANDARD_UNIT_CURRENCY = 'standard_unit_currency' |
| | |
| | | // 请假时间单位: (天) |
| | | export const LEAVE_TIME_TYPE_DAY = 'leave_time_type_day' |
| | | |
| | | // 考勤补卡区分 |
| | | export const CARD_REPLACEMENT_DIFFERENTIATION = 'card_replacement_differentiation' |
| | | // 考勤补卡区分: 上班补卡 |
| | | export const CARD_REPLACEMENT_DIFFERENTIATION_GOON = 'card_replacement_differentiation_goOn' |
| | | // 考勤补卡区分:下班补卡 |
| | | export const CARD_REPLACEMENT_DIFFERENTIATION_GOOFF = 'card_replacement_differentiation_goOff' |
| | | |
| | | // 考勤补卡审核状态 |
| | | export const CARD_APPROVE_STATUS = 'card_approve_status' |
| | | // 考勤补卡审核状态: 待审核 |
| | | export const CARD_APPROVE_STATUS_REVIEWED = 'card_approve_status_reviewed' |
| | | // 考勤补卡审核状态: 已同意 |
| | | export const CARD_APPROVE_STATUS_AGREE = 'card_approve_status_agree' |
| | | // 考勤补卡审核状态: 已拒绝 |
| | | export const CARD_APPROVE_STATUS_REFUSE = 'card_approve_status_refuse' |
| | | |
| | | export default { |
| | | CONFIG_PROPORTION_BASIC_WAGE, |
| | | CONFIG_PROPORTION_MERIT_WAGE, |
| | |
| | | APPROVAL_STATUS_RETURNED, |
| | | LEAVE_TIME_TYPE, |
| | | LEAVE_TIME_TYPE_HOUR, |
| | | LEAVE_TIME_TYPE_DAY |
| | | LEAVE_TIME_TYPE_DAY, |
| | | CARD_REPLACEMENT_DIFFERENTIATION, |
| | | CARD_REPLACEMENT_DIFFERENTIATION_GOON, |
| | | CARD_REPLACEMENT_DIFFERENTIATION_GOOFF, |
| | | CARD_APPROVE_STATUS, |
| | | CARD_APPROVE_STATUS_REVIEWED, |
| | | CARD_APPROVE_STATUS_AGREE, |
| | | CARD_APPROVE_STATUS_REFUSE |
| | | } |
| | |
| | | <rrOperation /> |
| | | </div> |
| | | <!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'--> |
| | | <crudOperation :permission="permission" /> |
| | | <crudOperation :permission="permission"> |
| | | <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 !== 1" |
| | | @click="makeUpCardOnDuty(crud.selections[0],1)" |
| | | >上班补卡 |
| | | </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 !== 1" |
| | | @click="makeUpCardOnDuty(crud.selections[0],2)" |
| | | >下班补卡 |
| | | </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"> |
| | | <el-form ref="form" :model="form" :rules="rules" size="small" label-width="140px"> |
| | | <el-form-item label="员工" prop="userId"> |
| | | <el-select v-model="form.userId" clearable filterable placeholder="请选择" @change="getRosteTime(form)" style="width: 310px;"> |
| | | <el-select v-model="form.userId" clearable filterable placeholder="请选择" style="width: 310px;" @change="getRosteTime(form)"> |
| | | <el-option |
| | | v-for="item in users" |
| | | :key="item.id" |
| | |
| | | value-format="yyyy-MM-dd HH:mm:ss" |
| | | align="right" |
| | | :picker-options="{ disabledDate(time) { |
| | | return form.rosteringWorkStartTime ? time.getTime() < new Date(form.rosteringWorkStartTime).getTime() - 8.64e7 : false; |
| | | return form.rosteringWorkStartTime ? time.getTime() < new Date(form.rosteringWorkStartTime).getTime() - 8.64e7 : false; |
| | | } |
| | | }" |
| | | default-time="18:00:00" |
| | |
| | | value-format="yyyy-MM-dd HH:mm:ss" |
| | | align="right" |
| | | :picker-options="{ disabledDate(time) { |
| | | return form.actualWorkStartTime ? time.getTime() < new Date(form.actualWorkStartTime).getTime() - 8.64e7 : false; |
| | | return form.actualWorkStartTime ? time.getTime() < new Date(form.actualWorkStartTime).getTime() - 8.64e7 : false; |
| | | } |
| | | }" |
| | | default-time="18:00:00" |
| | |
| | | <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="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-form-item label="基准时间"> |
| | | <span>{{ makeUpCardForm.rosterTime }}</span> |
| | | </el-form-item> |
| | | <el-form-item label="补卡时间" prop="cardReplacementTime"> |
| | | <div> |
| | | <label style="margin-right: 5px">日期:</label> |
| | | <span>{{ makeUpCardForm.checkDate }}</span> |
| | | </div> |
| | | <div> |
| | | <label style="margin-right: 5px">时间:</label> |
| | | <el-time-picker |
| | | v-model="makeUpCardForm.cardReplacementTime" |
| | | format="HH:mm:ss" |
| | | value-format="HH:mm:ss" |
| | | style="width: 195px;" |
| | | /> |
| | | </div> |
| | | </el-form-item> |
| | | <el-form-item label="审批人" prop="approvalUserId"> |
| | | <el-select v-model="makeUpCardForm.approvalUserId" clearable filterable placeholder="请选择" style="width: 240px;"> |
| | | <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="makeUpCardForm.cardReplacementReason" type="textarea" :rows="6" resize="none" style="width: 325px;" /> |
| | | </el-form-item> |
| | | </el-form> |
| | | <div slot="footer" class="dialog-footer"> |
| | | <el-button type="text" @click="closeCard">取消</el-button> |
| | | <el-button :loading="makeUpCardLoading" type="primary" @click="submitMakeUpCard">确认</el-button> |
| | | </div> |
| | | </el-dialog> |
| | | <!--表格渲染--> |
| | |
| | | |
| | | <script> |
| | | import crudAttendance from '@/api/attendance/attendance' |
| | | import crudAttendanceCardreplacement from '@/api/attendance/attendanceCardreplacement' |
| | | import crudUser from '@/api/system/user' |
| | | import CRUD, { presenter, header, form, crud } from '@crud/crud' |
| | | import rrOperation from '@crud/RR.operation' |
| | |
| | | return CRUD({ title: '考勤记录', url: 'api/attendance', idField: 'id', sort: 'id,desc', crudMethod: { ...crudAttendance }}) |
| | | }, |
| | | // 数据字典 |
| | | dicts: [constant.ATTENDANCE_STATE, constant.DATE_TYPE, constant.LOCATION_RESULTS], |
| | | dicts: [constant.ATTENDANCE_STATE, constant.DATE_TYPE, constant.LOCATION_RESULTS, constant.CARD_REPLACEMENT_DIFFERENTIATION, constant.CARD_APPROVE_STATUS], |
| | | data() { |
| | | return { |
| | | permission: { |
| | |
| | | ], |
| | | dateType: [ |
| | | { required: true, message: '日期类型不能为空', trigger: 'change' } |
| | | ] |
| | | }, |
| | | makeRules: { |
| | | cardReplacementTime: [ |
| | | { required: true, message: '补卡时间不能为空', trigger: 'change' } |
| | | ], |
| | | createBy: [ |
| | | { required: true, message: '创建者不能为空', trigger: 'blur' } |
| | | ], |
| | | createTime: [ |
| | | { required: true, message: '创建时间不能为空', trigger: 'blur' } |
| | | approvalUserId: [ |
| | | { required: true, message: '审批人不能为空', trigger: 'change' } |
| | | ] |
| | | }, |
| | | attendanceState: constant.ATTENDANCE_STATE, |
| | |
| | | dictAttendanceStateBusiness: constant.ATTENDANCE_STATE_BUSINESS, |
| | | dictAttendanceStateLeave: constant.ATTENDANCE_STATE_LEAVE, |
| | | dictAttendanceStateRest: constant.ATTENDANCE_STATE_REST, |
| | | users: [] } |
| | | users: [], |
| | | makeUpCardVisible: false, |
| | | makeUpCardLoading: false, |
| | | makeUpCardTitle: '', |
| | | makeUpCardForm: { |
| | | id: null, |
| | | userId: null, |
| | | approvalUserId: null, |
| | | cardReplacementTime: null, |
| | | cardReplacementReason: null, |
| | | approvalStatus: null, |
| | | approvalDescription: null, |
| | | cardReplacementDistinguish: null, |
| | | remarks: null, |
| | | rosterTime: null, |
| | | timeResult: null, |
| | | checkDate: null |
| | | }, |
| | | dictCardReplacementGoOn: constant.CARD_REPLACEMENT_DIFFERENTIATION_GOON, |
| | | dictCardReplacementOffOn: constant.CARD_REPLACEMENT_DIFFERENTIATION_GOOFF, |
| | | dictCardApproveStatusReviewed: constant.CARD_APPROVE_STATUS_REVIEWED } |
| | | }, |
| | | methods: { |
| | | // 钩子:在获取表格数据之前执行,false 则代表不获取数据 |
| | |
| | | }) |
| | | }, |
| | | // 获取表格上下班排班时间 |
| | | getRosteTime(data){ |
| | | if(data.userId !== null && data.attendanceDate !== null) { |
| | | getRosteTime(data) { |
| | | if (data.userId !== null && data.attendanceDate !== null) { |
| | | // 根据用户id查询排班时间 |
| | | crudUser.getAll({id: data.userId}).then(res => { |
| | | this.form.rosteringWorkStartTime = new Date(this.crud.toDate(data.attendanceDate) + ' ' + res[0].sysRostering.workStartTime) |
| | | this.form.rosteringWorkEndTime = new Date(this.crud.toDate(data.attendanceDate) + ' ' + res[0].sysRostering.workEndTime) |
| | | crudUser.getAll({ id: data.userId }).then(res => { |
| | | this.form.rosteringWorkStartTime = new Date(this.crud.toDate(data.attendanceDate) + ' ' + res[0].sysRostering.workStartTime) |
| | | this.form.rosteringWorkEndTime = new Date(this.crud.toDate(data.attendanceDate) + ' ' + res[0].sysRostering.workEndTime) |
| | | }) |
| | | } |
| | | }, |
| | | // 补卡页面 |
| | | makeUpCardOnDuty(data, Number) { |
| | | 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: '上班无需补卡' |
| | | }) |
| | | } |
| | | } |
| | | // 判断下班打卡状态,给提示 |
| | | 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: '下班无需补卡' |
| | | }) |
| | | } |
| | | } |
| | | }, |
| | | // 补卡提交 |
| | | submitMakeUpCard() { |
| | | this.$refs['makeUpCardForm'].validate(valid => { |
| | | if (!valid) { |
| | | return |
| | | } |
| | | this.makeUpCardLoading = true |
| | | this.makeUpCardForm.cardReplacementTime = this.makeUpCardForm.checkDate + ' ' + this.makeUpCardForm.cardReplacementTime |
| | | crudAttendanceCardreplacement.add(this.makeUpCardForm).then(res => { |
| | | this.makeUpCardVisible = false |
| | | this.makeUpCardLoading = false |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '补卡申请成功' |
| | | }) |
| | | }).catch(() => { |
| | | this.makeUpCardVisible = false |
| | | this.makeUpCardLoading = false |
| | | }) |
| | | }) |
| | | if (this.$refs['makeUpCardForm']) { |
| | | this.$refs['makeUpCardForm'].resetFields() |
| | | } |
| | | }, |
| | | // 关闭 |
| | | closeCard() { |
| | | if (this.$refs['makeUpCardForm']) { |
| | | this.$refs['makeUpCardForm'].resetFields() |
| | | } |
| | | this.crud.cancelCU() |
| | | this.makeUpCardVisible = false |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | <template> |
| | | <div class="app-container"> |
| | | <!--工具栏--> |
| | | <div class="head-container"> |
| | | <div> |
| | | <el-select v-model="query.userId" filterable clearable placeholder="请选择员工" style="width: 185px;" 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.cardReplacementTime" |
| | | clearable |
| | | class="filter-item" |
| | | value-format="yyyy-MM-dd" |
| | | placeholder="请选择补卡时间" |
| | | /> |
| | | <el-select v-model="query.approvalStatus" filterable clearable placeholder="请选择审批状态" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-option |
| | | v-for="item in dict[dictCardApproveStatus]" |
| | | :key="item.value" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | <el-select v-model="query.cardReplacementDistinguish" filterable clearable placeholder="请选择补卡区分" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-option |
| | | v-for="item in dict[dictCardReplacement]" |
| | | :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="userId"> |
| | | <el-select v-model="form.userId" clearable filterable placeholder="请选择申请人" style="width: 310px;"> |
| | | <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="approvalUserId"> |
| | | <el-select v-model="form.approvalUserId" clearable filterable placeholder="请选择审批者" style="width: 310px;"> |
| | | <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="cardReplacementTime"> |
| | | <el-date-picker |
| | | v-model="form.cardReplacementTime" |
| | | type="datetime" |
| | | placeholder="选择补卡时间" |
| | | style="width: 310px;" |
| | | value-format="yyyy-MM-dd HH:mm:ss" |
| | | align="right" |
| | | default-time="09:00:00" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="补卡原因"> |
| | | <el-input v-model="form.cardReplacementReason" type="textarea" rows="3" style="width: 370px;" /> |
| | | </el-form-item> |
| | | <el-form-item v-if="form.id !== null" label="审批状态" prop="approvalStatus"> |
| | | <el-select v-model="form.approvalStatus" style="width: 370px;"> |
| | | <el-option |
| | | v-for="item in dict[dictCardApproveStatus]" |
| | | :key="item.value" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | </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="补卡区分" prop="cardReplacementDistinguish"> |
| | | <el-select v-model="form.cardReplacementDistinguish" style="width: 370px;"> |
| | | <el-option |
| | | v-for="item in dict[dictCardReplacement]" |
| | | :key="item.value" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | </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.cardReplacementTime }}</div> |
| | | </div> |
| | | <div class="form-item" style="margin: 0px"> |
| | | <div class="form-item-label"> |
| | | <label>补卡原因:</label> |
| | | </div> |
| | | <div class="form-item-value">{{ form.cardReplacementReason }}</div> |
| | | </div> |
| | | <el-form ref="form" :model="form" :rules="rules" size="small" label-width="92px"> |
| | | <el-form-item v-if="form.approvalStatus === dictCardApproveStatusRefuse" 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 !== dictCardApproveStatusRefuse" :loading="successLoading" type="success" @click="approveFunction(2,form)">审核通过</el-button> |
| | | </div> |
| | | </el-dialog> |
| | | <!--表格渲染--> |
| | | <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler"> |
| | | <el-table-column type="selection" width="55" /> |
| | | <el-table-column v-if="false" prop="id" label="id" show-overflow-tooltip /> |
| | | <el-table-column v-if="false" prop="userId" label="申请人ID" show-overflow-tooltip /> |
| | | <el-table-column prop="userName" label="申请人" 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="cardReplacementReason" label="补卡原因" show-overflow-tooltip /> |
| | | <el-table-column prop="approvalStatus" label="审批状态" show-overflow-tooltip> |
| | | <template slot-scope="scope"> |
| | | <el-tag v-if="scope.row.approvalStatus === dictCardApproveStatusReviewed" type="warning">{{ dict.label[dictCardApproveStatus][scope.row.approvalStatus] }}</el-tag> |
| | | <el-tag v-if="scope.row.approvalStatus === dictCardApproveStatusAgree" type="success">{{ dict.label[dictCardApproveStatus][scope.row.approvalStatus] }}</el-tag> |
| | | <el-tag v-if="scope.row.approvalStatus === dictCardApproveStatusRefuse" type="danger">{{ dict.label[dictCardApproveStatus][scope.row.approvalStatus] }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="approvalDescription" label="审批说明" show-overflow-tooltip /> |
| | | <el-table-column prop="cardReplacementDistinguish" label="补卡区分" show-overflow-tooltip> |
| | | <template slot-scope="scope"> |
| | | <el-tag>{{ dict.label[dictCardReplacement][scope.row.cardReplacementDistinguish] }}</el-tag> |
| | | </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"> |
| | | <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 === dictCardApproveStatusReviewed ? false : true" |
| | | @click="toApprove(scope.row)" |
| | | >审核 |
| | | </el-button> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column v-if="checkPer(['admin','attendanceCardreplacement:edit','attendanceCardreplacement:del'])" label="操作" width="250px" align="center"> |
| | | <template slot-scope="scope"> |
| | | <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> |
| | | <!--分页组件--> |
| | | <pagination /> |
| | | </div> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import crudAttendanceCardreplacement from '@/api/attendance/attendanceCardreplacement' |
| | | import CRUD, { presenter, header, form, crud } from '@crud/crud' |
| | | import crudUser from '@/api/system/user' |
| | | import rrOperation from '@crud/RR.operation' |
| | | import crudOperation from '@crud/CRUD.operation' |
| | | import udOperation from '@crud/UD.operation' |
| | | import pagination from '@crud/Pagination' |
| | | import constant from '../../../utils/constant' |
| | | |
| | | const defaultForm = { id: null, userId: null, userName: null, approvalUserId: null, cardReplacementTime: null, cardReplacementReason: null, approvalStatus: null, approvalDescription: null, cardReplacementDistinguish: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null } |
| | | export default { |
| | | name: 'AttendanceCardreplacement', |
| | | components: { pagination, crudOperation, rrOperation, udOperation }, |
| | | mixins: [presenter(), header(), form(defaultForm), crud()], |
| | | // 数据字典 |
| | | dicts: [constant.CARD_REPLACEMENT_DIFFERENTIATION, constant.CARD_APPROVE_STATUS], |
| | | cruds() { |
| | | return CRUD({ title: '补卡', url: 'api/attendanceCardreplacement', idField: 'id', sort: 'id,desc', crudMethod: { ...crudAttendanceCardreplacement }}) |
| | | }, |
| | | data() { |
| | | return { |
| | | permission: { |
| | | add: ['admin', 'attendanceCardreplacement:add'], |
| | | edit: ['admin', 'attendanceCardreplacement:edit'], |
| | | del: ['admin', 'attendanceCardreplacement:del'], |
| | | download: ['admin', 'attendanceCardreplacement:download'] |
| | | }, |
| | | rules: { |
| | | userId: [ |
| | | { required: true, message: '员工不能为空', trigger: 'change' } |
| | | ], |
| | | approvalUserId: [ |
| | | { required: true, message: '审批者不能为空', trigger: 'change' } |
| | | ], |
| | | cardReplacementTime: [ |
| | | { required: true, message: '补卡时间不能为空', trigger: 'blur' } |
| | | ], |
| | | approvalStatus: [ |
| | | { required: true, message: '审批状态不能为空', trigger: 'change' } |
| | | ], |
| | | |
| | | approvalDescription: [ |
| | | { required: true, message: '审批说明不能为空', trigger: 'change' } |
| | | ], |
| | | cardReplacementDistinguish: [ |
| | | { required: true, message: '补卡区分不能为空', trigger: 'change' } |
| | | ] |
| | | }, |
| | | users: [], |
| | | makeUpCardVisible: false, |
| | | successLoading: false, |
| | | dictCardApproveStatus: constant.CARD_APPROVE_STATUS, |
| | | dictCardApproveStatusReviewed: constant.CARD_APPROVE_STATUS_REVIEWED, |
| | | dictCardApproveStatusAgree: constant.CARD_APPROVE_STATUS_AGREE, |
| | | dictCardApproveStatusRefuse: constant.CARD_APPROVE_STATUS_REFUSE, |
| | | dictCardReplacement: constant.CARD_REPLACEMENT_DIFFERENTIATION } |
| | | }, |
| | | methods: { |
| | | // 钩子:在获取表格数据之前执行,false 则代表不获取数据 |
| | | [CRUD.HOOK.beforeRefresh]() { |
| | | this.getUsers() |
| | | return true |
| | | }, |
| | | // 查询员工 |
| | | getUsers() { |
| | | crudUser.getAll().then(res => { |
| | | this.users = res |
| | | }) |
| | | }, |
| | | // 审批页面赋值 |
| | | toApprove(data) { |
| | | this.makeUpCardVisible = true |
| | | this.form.id = data.id |
| | | this.form.userId = data.userId |
| | | this.form.userName = data.userName |
| | | this.form.cardReplacementTime = data.cardReplacementTime |
| | | this.form.cardReplacementReason = data.cardReplacementReason |
| | | this.form.cardReplacementDistinguish = data.cardReplacementDistinguish |
| | | }, |
| | | // 审核功能 |
| | | 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.dictCardApproveStatusAgree |
| | | } else { |
| | | // 退回改状态显示退回原因 |
| | | this.form.approvalStatus = this.dictCardApproveStatusRefuse |
| | | if (this.form.approvalDescription == null) { |
| | | return |
| | | } |
| | | } |
| | | crudAttendanceCardreplacement.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() |
| | | } |
| | | }) |
| | | }, |
| | | // 撤消功能 |
| | | revoke(data) { |
| | | crudAttendanceCardreplacement.revoke(data).then(res => { |
| | | this.crud.refresh() |
| | | this.$message({ type: 'success', message: '撤销成功' }) |
| | | this.$refs[`popover_${data.id}`].showPopper = false |
| | | }).catch((error) => { |
| | | this.$message({ type: 'error', message: error.response.data.message }) |
| | | }) |
| | | if (this.$refs['form']) { |
| | | this.$refs['form'].resetFields() |
| | | } |
| | | this.crud.cancelCU() |
| | | }, |
| | | // 关闭 |
| | | 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> |