eladmin-master/eladmin-common/src/main/java/me/zhengjie/utils/ElAdminConstant.java
@@ -107,16 +107,28 @@ public static final String TEMPLATE_CONTROL_TYPE_ATTENDANCE = "Attendance"; // 审批模版时长粒度:小时 public static final String TEMPLATE_DATE_TYPE_HOUR = "hour"; public static final String TEMPLATE_DATE_RANGE_TYPE_HOUR = "hour"; // 审批模版时长粒度:天 public static final String TEMPLATE_DATE_TYPE_HALFDAY = "halfday"; // 审批模版选择类型:单选 public static final String TEMPLATE_SELECTOR_TYPE_SINGLE = "single"; // 审批模版选择类型:多选 public static final String TEMPLATE_SELECTOR_TYPE_MULTI = "multi"; // 审批模版成员对象:成员 public static final String TEMPLATE_CONTACT_MODE_USER = "user"; // 审批模版成员对象:部门 public static final String TEMPLATE_CONTACT_MODE_DEPARTMENT = "department"; // 审批模版日期类型:日期 public static final String TEMPLATE_DATE_TYPE_DATE = "date"; // 审批模版日期类型:日期+时间 public static final String TEMPLATE_DATE_TYPE_HOUR = "hour"; } /** eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/listener/ChangeApprovalStatusEventListener.java
@@ -15,6 +15,10 @@ import me.zhengjie.modules.attendance.service.*; import me.zhengjie.modules.attendance.service.dto.*; import me.zhengjie.modules.constant.Constant; import me.zhengjie.modules.project.domain.ProjectReimburse; import me.zhengjie.modules.project.repository.ProjectReimburseRepository; import me.zhengjie.modules.project.service.ProjectReimburseService; import me.zhengjie.modules.project.service.dto.ProjectReimburseQueryCriteria; import me.zhengjie.modules.temp.domain.WechatSendHistory; import me.zhengjie.modules.temp.event.ChangeApprovalStatusEvent; import me.zhengjie.modules.temp.repository.WechatSendHistoryRepository; @@ -49,6 +53,8 @@ private final AttendanceOvertimeRepository attendanceOvertimeRepository; private final AttendanceCardreplacementService attendanceCardreplacementService; private final AttendanceCardreplacementRepository attendanceCardreplacementRepository; private final ProjectReimburseService projectReimburseService; private final ProjectReimburseRepository projectReimburseRepository; @EventListener @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW) @@ -169,6 +175,23 @@ } else { System.out.println("企微状态下发数据对应数据(补卡)未找到:下发数据ID为" + event.getHistoryId()); } } else if (fieldList.get(0).getFieldTable().equals("ProjectReimburse")) { // 补卡 ProjectReimburseQueryCriteria reimburseQueryCriteria = new ProjectReimburseQueryCriteria(); reimburseQueryCriteria.setWecomSpNo(approvalSend.getApprovalInfo().getSpNo()); List<ProjectReimburse> reimburseList = projectReimburseRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, reimburseQueryCriteria, criteriaBuilder), Sort.by(Sort.Direction.DESC, "id")); if (reimburseList.size() > 0) { ProjectReimburse reimburse = reimburseList.get(0); reimburse.setApprovalStatus(switchSpStatusToSysStatus("报销", approvalSend.getApprovalInfo().getSpStatus())); reimburse.setWecomEventId(approveEventSaved.getEventId()); try { projectReimburseService.updateApprove(reimburse); } catch (Exception e) { System.out.println("企微状态下发数据对应数据(报销)更新失败:下发数据ID为" + event.getHistoryId()); } } else { System.out.println("企微状态下发数据对应数据(报销)未找到:下发数据ID为" + event.getHistoryId()); } } else { System.out.println("企微状态下发数据对应模板绑定表名未找到:下发数据ID为" + event.getHistoryId()); } @@ -261,6 +284,21 @@ // 已支付 case "补卡-10": finalStatus = Constant.CARD_APPROVE_STATUS_REVIEWED; break; // 审批中 case "报销-1": finalStatus = Constant.REIMBURSE_APPROVE_STATUS_REVIEWED; break; // 已通过 case "报销-2": finalStatus = Constant.REIMBURSE_APPROVE_STATUS_AGREE; break; // 已驳回 case "报销-3": finalStatus = Constant.REIMBURSE_APPROVE_STATUS_REFUSE; break; // 已撤销 case "报销-4": finalStatus = Constant.REIMBURSE_APPROVE_STATUS_REFUSE; break; // 通过后撤销 case "报销-6": finalStatus = Constant.REIMBURSE_APPROVE_STATUS_REFUSE; break; // 已删除 case "报销-7": finalStatus = Constant.REIMBURSE_APPROVE_STATUS_REFUSE; break; // 已支付 case "报销-10": finalStatus = Constant.REIMBURSE_APPROVE_STATUS_REVIEWED; break; // 默认 default: finalStatus = Constant.APPROVAL_STATUS_UNDER_APPROVAL; break; } eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/service/TemplateControlFieldService.java
@@ -108,4 +108,14 @@ * 提交微信审批 */ <R> Map<String, String> createWecomApproval(R data, String userWxId); /** * 提交微信微盘文件上传 */ List<String> uploadWecomDriveFile(List<String> filePaths, String spaceId, String fatherId); /** * 提交微信临时素材文件上传 */ List<String> uploadWecomMediaFile(List<String> filePaths); } eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/service/impl/TemplateControlFieldServiceImpl.java
@@ -1,21 +1,22 @@ /* * 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. */ * 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.approval.service.impl; import com.alibaba.fastjson.JSONObject; import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.cp.bean.oa.WxCpCorpConfInfo; @@ -23,6 +24,8 @@ import me.chanjar.weixin.cp.bean.oa.WxCpOaApprovalTemplateResult; import me.chanjar.weixin.cp.bean.oa.applydata.ApplyDataContent; import me.chanjar.weixin.cp.bean.oa.applydata.ContentValue; import me.chanjar.weixin.cp.bean.oa.wedrive.WxCpFileUpload; import me.chanjar.weixin.cp.bean.oa.wedrive.WxCpFileUploadRequest; import me.zhengjie.exception.BadRequestException; import me.zhengjie.modules.approval.domain.Template; import me.zhengjie.modules.approval.domain.TemplateControl; @@ -51,8 +54,11 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import java.io.File; import java.lang.reflect.Field; import java.math.BigDecimal; import java.nio.file.Files; import java.nio.file.Paths; import java.sql.Timestamp; import java.util.*; import java.io.IOException; @@ -60,11 +66,11 @@ import java.util.stream.Collectors; /** * @website https://eladmin.vip * @description 服务实现 * @author baolh * @date 2025-03-17 **/ * @website https://eladmin.vip * @description 服务实现 * @author baolh * @date 2025-03-17 **/ @Service @RequiredArgsConstructor public class TemplateControlFieldServiceImpl implements TemplateControlFieldService { @@ -253,10 +259,62 @@ criteria.setFieldTable(data.getClass().getSimpleName()); criteria.setDelStatus(ElAdminConstant.Constant.TEMPLATE_DEL_STATUS_NORMAL); List<TemplateControlField> templateControlFields = templateControlFieldRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)); return this.sendApplyevent(data, templateControlFields, userWxId); return this.sendApplyEvent(data, templateControlFields, userWxId); } private <R> Map<String, String> sendApplyevent(R data, List<TemplateControlField> bindData, String userWxId) { @Override public List<String> uploadWecomDriveFile(List<String> filePaths, String spaceId, String fatherId) { try { return filePaths.stream().map(path -> { WxCpFileUploadRequest uploadRequest = new WxCpFileUploadRequest(); uploadRequest.setSpaceId(spaceId); uploadRequest.setFatherId(fatherId); uploadRequest.setFileName(Arrays.stream(path.split("/")).reduce((first, second) -> Optional.ofNullable(second).orElse(first)).orElse("")); try { // 读取文件字节 byte[] fileContent = Files.readAllBytes(Paths.get(path)); // 转换为Base64字符串 String base64String = Base64.getEncoder().encodeToString(fileContent); uploadRequest.setFileBase64Content(base64String); } catch (IOException e) { throw new BadRequestException("文件转换异常"); } try { WxCpFileUpload upload = wxCpService.getOaWeDriveService().fileUpload(uploadRequest); return upload.getFileId(); } catch (WxErrorException e) { e.printStackTrace(); throw new BadRequestException("文件上传异常"); } }).collect(Collectors.toList()); } catch (Exception e) { e.printStackTrace(); throw new BadRequestException("文件上传准备异常"); } } @Override public List<String> uploadWecomMediaFile(List<String> filePaths) { try { return filePaths.stream().map(path -> { File file = new File(path); try { WxMediaUploadResult uploadResult = wxCpService.getMediaService().upload("file", file); return uploadResult.getMediaId(); } catch (WxErrorException e) { e.printStackTrace(); throw new BadRequestException("文件上传异常"); } }).collect(Collectors.toList()); } catch (Exception e) { e.printStackTrace(); throw new BadRequestException("文件上传准备异常"); } } private <R> Map<String, String> sendApplyEvent(R data, List<TemplateControlField> bindData, String userWxId) { Map<String, String> resultMap = new HashMap<>(2); try { @@ -347,9 +405,19 @@ // 日期/日期+时间 ContentValue.Date date = Optional.ofNullable(value.getDate()).orElse(new ContentValue.Date()); if (control.getControlParam().equals("date.type")) { date.setType(String.valueOf(object)); } else if (control.getControlParam().equals("date.s_timestamp")) { if (control.getControlParam().equals("date.s_timestamp")) { // 时间展示类型 if (StringUtils.isNotBlank(control.getContentConfig())) { WxCpOaApprovalTemplateResult.TemplateConfig config = JSONObject.parseObject(control.getContentConfig(), WxCpOaApprovalTemplateResult.TemplateConfig.class); if (StringUtils.isNotBlank(config.getDate().getType())) { date.setType(config.getDate().getType()); } else { date.setType(ElAdminConstant.Constant.TEMPLATE_DATE_TYPE_DATE); } } else { date.setType(ElAdminConstant.Constant.TEMPLATE_DATE_TYPE_DATE); } // 时间戳 if (field.getType().equals(String.class) || field.getType().equals(Integer.class) || field.getType().equals(Long.class)) { date.setTimestamp(String.valueOf(object)); } else if (field.getType().equals(Timestamp.class)) { @@ -359,7 +427,7 @@ } value.setDate(date); } else if (control.getControlType().equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_TYPE_SELECTOR)) { // 单选/多选 TODO:暂时设定只支持单选 // 单选/多选 TODO:暂时设定只支持单选,250421添加多选 ContentValue.Selector selector = Optional.ofNullable(value.getSelector()).orElse(new ContentValue.Selector()); if (control.getControlParam().equals("selector.options[].key")) { @@ -370,12 +438,32 @@ .flatMap(opt -> opt.getValue().stream().map(val -> new AbstractMap.SimpleEntry<>(val.getText(), opt.getKey()))) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (existing, replacement) -> existing)); selector.setType("single"); ContentValue.Selector.Option option = new ContentValue.Selector.Option(); option.setKey(optionMap.containsKey(String.valueOf(object)) ? optionMap.get(String.valueOf(object)) : String.valueOf(object)); selector.setOptions(Arrays.asList(option)); if (config.getSelector().getType().equals(ElAdminConstant.Constant.TEMPLATE_SELECTOR_TYPE_MULTI)) { // 多选 List<String> optionValList; if (object instanceof Collection<?>) { optionValList = ((Collection<?>) object).stream().map(i -> String.valueOf(i)).collect(Collectors.toList()); } else { optionValList = Arrays.stream(String.valueOf(object).split(",")).collect(Collectors.toList()); } // 填充多选数据 selector.setType(ElAdminConstant.Constant.TEMPLATE_SELECTOR_TYPE_MULTI); selector.setOptions(optionValList.stream().map(s -> { ContentValue.Selector.Option option = new ContentValue.Selector.Option(); option.setKey(optionMap.containsKey(s) ? optionMap.get(s) : s); return option; }).collect(Collectors.toList())); } else { // 单选 selector.setType(ElAdminConstant.Constant.TEMPLATE_SELECTOR_TYPE_SINGLE); ContentValue.Selector.Option option = new ContentValue.Selector.Option(); option.setKey(optionMap.containsKey(String.valueOf(object)) ? optionMap.get(String.valueOf(object)) : String.valueOf(object)); selector.setOptions(Arrays.asList(option)); } } else { selector.setType("single"); // 默认单选 selector.setType(ElAdminConstant.Constant.TEMPLATE_SELECTOR_TYPE_SINGLE); ContentValue.Selector.Option option = new ContentValue.Selector.Option(); option.setKey(String.valueOf(object)); selector.setOptions(Arrays.asList(option)); @@ -417,17 +505,50 @@ value.setMembers(Arrays.asList(member)); } } else if (control.getControlType().equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_TYPE_FILE)) { // 附件 TODO:暂时设定只支持一条。 ContentValue.File file = Optional.ofNullable(value.getFiles()).map(i -> i.get(0)).orElse(new ContentValue.File()); // 附件 TODO:暂时设定只支持一条。250421添加多条 List<ContentValue.File> fileList = Optional.ofNullable(value.getFiles()).orElse(new ArrayList<>()); if (control.getControlParam().equals("files[].file_id")) { file.setFileId(String.valueOf(object)); List<String> fileIdList = Arrays.stream(String.valueOf(object).split("\\|")).collect(Collectors.toList()); if (fileList.size() > 0) { for (int i = 0; i < fileList.size(); i++) { fileList.get(i).setFileId(Optional.ofNullable(fileIdList.get(i)).orElse(null)); } } else { fileList = fileIdList.stream().map(s -> { ContentValue.File file = new ContentValue.File(); file.setFileId(s); return file; }).collect(Collectors.toList()); } } else if (control.getControlParam().equals("files[].file_name")) { file.setFileName(String.valueOf(object)); List<String> fileNameList = Arrays.stream(String.valueOf(object).split("|")).collect(Collectors.toList()); if (fileList.size() > 0) { for (int i = 0; i < fileList.size(); i++) { fileList.get(i).setFileName(Optional.ofNullable(fileNameList.get(i)).orElse(null)); } } else { fileList = fileNameList.stream().map(s -> { ContentValue.File file = new ContentValue.File(); file.setFileName(s); return file; }).collect(Collectors.toList()); } } else if (control.getControlParam().equals("files[].file_url")) { file.setFileUrl(String.valueOf(object)); List<String> fileUrlList = Arrays.stream(String.valueOf(object).split("|")).collect(Collectors.toList()); if (fileList.size() > 0) { for (int i = 0; i < fileList.size(); i++) { fileList.get(i).setFileUrl(Optional.ofNullable(fileUrlList.get(i)).orElse(null)); } } else { fileList = fileUrlList.stream().map(s -> { ContentValue.File file = new ContentValue.File(); file.setFileUrl(s); return file; }).collect(Collectors.toList()); } } value.setFiles(Arrays.asList(file)); value.setFiles(fileList); } else if (control.getControlType().equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_TYPE_TABLE)) { // 明细 TODO:因结构复杂,暂时设定不提供支持 value.setChildren(null); @@ -503,7 +624,7 @@ if (control.getControlParam().equals("vacation.selector.options[].key")) { ContentValue.Selector selector = Optional.ofNullable(vacation.getSelector()).orElse(new ContentValue.Selector()); // 假勤组件固定单选 selector.setType("single"); selector.setType(ElAdminConstant.Constant.TEMPLATE_SELECTOR_TYPE_SINGLE); ContentValue.Selector.Option option = new ContentValue.Selector.Option(); option.setKey(String.valueOf(object)); selector.setOptions(Arrays.asList(option)); eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/approval/service/impl/TemplateServiceImpl.java
@@ -184,12 +184,12 @@ TemplateControlDto newMoneySaved = templateControlMapper.toDto(templateControlRepository.save(newMoney)); templateControlDtos.add(newMoneySaved); } else if (controls.getProperty().getControl().equals(ElAdminConstant.Constant.TEMPLATE_CONTROL_TYPE_DATE)) { // 时间展示类型:day-日期;hour-日期+时间 TemplateControl dateType = makeDefaultTemplateControl(savedTemplateDto.getId(), controls); dateType.setControlParam("date.type"); dateType.setControlParamName("时间展示类型"); TemplateControlDto dateTypeSaved = templateControlMapper.toDto(templateControlRepository.save(dateType)); templateControlDtos.add(dateTypeSaved); // // 时间展示类型:day-日期;hour-日期+时间 TODO:250425修改为按照config设定传值 // TemplateControl dateType = makeDefaultTemplateControl(savedTemplateDto.getId(), controls); // dateType.setControlParam("date.type"); // dateType.setControlParamName("时间展示类型"); // TemplateControlDto dateTypeSaved = templateControlMapper.toDto(templateControlRepository.save(dateType)); // templateControlDtos.add(dateTypeSaved); // 时间戳-字符串类型 TemplateControl dateSTimestamp = makeDefaultTemplateControl(savedTemplateDto.getId(), controls); dateSTimestamp.setControlParam("date.s_timestamp"); eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceCardreplacementServiceImpl.java
@@ -154,7 +154,7 @@ // 企微申请时审批人需要默认值 resources.setApprovalUserId(0L); // 添加企微申请参数 resources.setWecomDateType(ElAdminConstant.Constant.TEMPLATE_DATE_TYPE_HOUR); resources.setWecomDateType(ElAdminConstant.Constant.TEMPLATE_DATE_RANGE_TYPE_HOUR); Map<String, String> cardTypeMap = dictDetailRepository.findByDictName(Constant.CARD_REPLACEMENT_DIFFERENTIATION).stream().collect(Collectors.toMap(DictDetail::getValue, DictDetail::getLabel)); resources.setWecomTypeOptionVal(cardTypeMap.get(resources.getCardReplacementDistinguish())); // 提交申请 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceGoOutServiceImpl.java
@@ -201,7 +201,7 @@ // 添加企微申请参数 resources.setWecomType(dictDetailRepository.findByDictNameAndValue("go_out_type", resources.getOutOfOfficeType()).getLabel()); resources.setWecomLocation("暂无"); resources.setWecomDateType(ElAdminConstant.Constant.TEMPLATE_DATE_TYPE_HOUR); resources.setWecomDateType(ElAdminConstant.Constant.TEMPLATE_DATE_RANGE_TYPE_HOUR); resources.setWecomDuration(String.valueOf(new BigDecimal(resources.getOutDuration()).multiply(new BigDecimal(3600)).longValue())); resources.setWecomAttendanceType("4"); resources.setWecomApproveWecomId(approvalUser.getWeComId()); eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceLeaveServiceImpl.java
@@ -196,7 +196,7 @@ if (siteTypes.size() > 0) { // 添加企微申请参数 if (resources.getLeaveDurationUnit().equals(Constant.LEAVE_TIME_TYPE_HOUR)) { attendanceLeave.setWecomDateType(ElAdminConstant.Constant.TEMPLATE_DATE_TYPE_HOUR); attendanceLeave.setWecomDateType(ElAdminConstant.Constant.TEMPLATE_DATE_RANGE_TYPE_HOUR); attendanceLeave.setWecomDuration(String.valueOf(new BigDecimal(attendanceLeave.getLeaveDuration()).multiply(new BigDecimal(3600)).longValue())); } else { attendanceLeave.setWecomDateType(ElAdminConstant.Constant.TEMPLATE_DATE_TYPE_HALFDAY); eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/attendance/service/impl/AttendanceOvertimeServiceImpl.java
@@ -151,7 +151,7 @@ if (siteTypes.size() > 0) { String approvalWeComId = userRepository.findById(resources.getApprovalUserId()).orElse(new User()).getWeComId(); // 添加企微申请参数 resources.setWecomDateType(ElAdminConstant.Constant.TEMPLATE_DATE_TYPE_HOUR); resources.setWecomDateType(ElAdminConstant.Constant.TEMPLATE_DATE_RANGE_TYPE_HOUR); resources.setWecomDuration(String.valueOf(new BigDecimal(resources.getOvertimeDuration()).multiply(new BigDecimal(3600)).longValue())); resources.setWecomAttendanceType("5"); resources.setWecomApproveWecomId(approvalWeComId); eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/constant/Constant.java
@@ -399,4 +399,18 @@ public static final String WECOM_MESSAGE_URL = "http://pms-upgrade.yhzhg.cn/"; // 企微消息:按钮文字(最多4个字,超出自动截断) public static final String WECOM_MESSAGE_BTNTXT = "前往查看"; // 报销审批状态 public static final String REIMBURSE_APPROVE_STATUS = "reimburse_approve_status"; // 报销审批状态:待审核 public static final String REIMBURSE_APPROVE_STATUS_REVIEWED = "reimburse_approve_status_reviewed"; // 报销审批状态:已同意 public static final String REIMBURSE_APPROVE_STATUS_AGREE = "reimburse_approve_status_agree"; // 报销审批状态:已拒绝 public static final String REIMBURSE_APPROVE_STATUS_REFUSE = "reimburse_approve_status_refuse"; // 报销类型 public static final String REIMBURSE_TYPE = "reimburse_type"; // 报销费用类型 public static final String REIMBURSE_EXPENSE_TYPE = "reimburse_expense_type"; } eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/project/domain/ProjectReimburse.java
New file @@ -0,0 +1,132 @@ /* * 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.project.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.math.BigDecimal; import java.io.Serializable; /** * @website https://eladmin.vip * @description / * @author baolh * @date 2025-04-22 **/ @Entity @Data @Table(name="project_reimburse") public class ProjectReimburse 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 = "`project_id`") @ApiModelProperty(value = "项目ID") private Long projectId; @Column(name = "`reimburse_type`") @ApiModelProperty(value = "报销类型(多个用,分隔)") private String reimburseType; @Column(name = "`reimburse_reason`") @ApiModelProperty(value = "报销原因") private String reimburseReason; @Column(name = "`expense_type`") @ApiModelProperty(value = "费用类型(多个用,分隔)") private String expenseType; @Column(name = "`start_time`") @ApiModelProperty(value = "开始时间") private Timestamp startTime; @Column(name = "`end_time`") @ApiModelProperty(value = "结束时间") private Timestamp endTime; @Column(name = "`expense_amount`") @ApiModelProperty(value = "费用金额") private BigDecimal expenseAmount; @Column(name = "`expense_comment`") @ApiModelProperty(value = "费用说明") private String expenseComment; @Column(name = "`origin_file_name`") @ApiModelProperty(value = "附件源文件名") private String originFileName; @Column(name = "`file_path`") @ApiModelProperty(value = "附件路径") private String filePath; @Column(name = "`approval_status`") @ApiModelProperty(value = "审批状态") private String approvalStatus; @Column(name = "`approval_description`") @ApiModelProperty(value = "审批说明") private String approvalDescription; @Column(name = "`wecom_sp_no`") @ApiModelProperty(value = "企微审批单号") private String wecomSpNo; @Column(name = "`wecom_event_id`") @ApiModelProperty(value = "企微最新审批变化") private Long wecomEventId; @Column(name = "`wecom_file_ids`") @ApiModelProperty(value = "企微附件ID(多个用|分隔,最多6个,每个最大10M)") private String wecomFileIds; @Column(name = "`wecom_reimburse_type`") @ApiModelProperty(value = "企微报销类型(多个用,分隔)") private String wecomReimburseType; @Column(name = "`wecom_expense_type`") @ApiModelProperty(value = "企微费用类型(多个用,分隔)") private String wecomExpenseType; @Column(name = "`wecom_project_name`") @ApiModelProperty(value = "企微项目名称") private String wecomProjectName; public void copy(ProjectReimburse source){ BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); } } eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/project/repository/ProjectReimburseRepository.java
New file @@ -0,0 +1,28 @@ /* * 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.project.repository; import me.zhengjie.modules.project.domain.ProjectReimburse; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; /** * @website https://eladmin.vip * @author baolh * @date 2025-04-22 **/ public interface ProjectReimburseRepository extends JpaRepository<ProjectReimburse, Long>, JpaSpecificationExecutor<ProjectReimburse> { } eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/project/rest/ProjectReimburseController.java
New file @@ -0,0 +1,96 @@ /* * 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.project.rest; import me.zhengjie.annotation.Log; import me.zhengjie.modules.project.domain.ProjectReimburse; import me.zhengjie.modules.project.service.ProjectReimburseService; import me.zhengjie.modules.project.service.dto.ProjectReimburseQueryCriteria; 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 baolh * @date 2025-04-22 **/ @RestController @RequiredArgsConstructor @Api(tags = "projectReimburse管理") @RequestMapping("/api/projectReimburse") public class ProjectReimburseController { private final ProjectReimburseService projectReimburseService; @Log("导出数据") @ApiOperation("导出数据") @GetMapping(value = "/download") @PreAuthorize("@el.check('projectReimburse:list')") public void exportProjectReimburse(HttpServletResponse response, ProjectReimburseQueryCriteria criteria) throws IOException { projectReimburseService.download(projectReimburseService.queryAll(criteria), response); } @GetMapping @Log("查询projectReimburse") @ApiOperation("查询projectReimburse") @PreAuthorize("@el.check('projectReimburse:list')") public ResponseEntity<Object> queryProjectReimburse(ProjectReimburseQueryCriteria criteria, Pageable pageable){ return new ResponseEntity<>(projectReimburseService.queryAll(criteria,pageable),HttpStatus.OK); } @PostMapping @Log("新增projectReimburse") @ApiOperation("新增projectReimburse") @PreAuthorize("@el.check('projectReimburse:add')") public ResponseEntity<Object> createProjectReimburse(@Validated @RequestBody ProjectReimburse resources){ return new ResponseEntity<>(projectReimburseService.create(resources),HttpStatus.CREATED); } @PutMapping @Log("修改projectReimburse") @ApiOperation("修改projectReimburse") @PreAuthorize("@el.check('projectReimburse:edit')") public ResponseEntity<Object> updateProjectReimburse(@Validated @RequestBody ProjectReimburse resources){ projectReimburseService.update(resources); return new ResponseEntity<>(HttpStatus.NO_CONTENT); } @DeleteMapping @Log("删除projectReimburse") @ApiOperation("删除projectReimburse") @PreAuthorize("@el.check('projectReimburse:del')") public ResponseEntity<Object> deleteProjectReimburse(@RequestBody Long[] ids) { projectReimburseService.deleteAll(ids); return new ResponseEntity<>(HttpStatus.OK); } @PutMapping(value = "/approve") @Log("审核报销") @ApiOperation("审核功能") @PreAuthorize("@el.check('projectReimburse:approve')") public ResponseEntity<Object> approveProjectReimburse(@Validated @RequestBody ProjectReimburse resources) { projectReimburseService.updateApprove(resources); return new ResponseEntity<>(HttpStatus.NO_CONTENT); } } eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/project/service/ProjectReimburseService.java
New file @@ -0,0 +1,89 @@ /* * 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.project.service; import me.zhengjie.modules.project.domain.ProjectReimburse; import me.zhengjie.modules.project.service.dto.ProjectReimburseDto; import me.zhengjie.modules.project.service.dto.ProjectReimburseQueryCriteria; 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 baolh * @date 2025-04-22 **/ public interface ProjectReimburseService { /** * 查询数据分页 * @param criteria 条件 * @param pageable 分页参数 * @return Map<String,Object> */ Map<String,Object> queryAll(ProjectReimburseQueryCriteria criteria, Pageable pageable); /** * 查询所有数据不分页 * @param criteria 条件参数 * @return List<ProjectReimburseDto> */ List<ProjectReimburseDto> queryAll(ProjectReimburseQueryCriteria criteria); /** * 根据ID查询 * @param id ID * @return ProjectReimburseDto */ ProjectReimburseDto findById(Long id); /** * 创建 * @param resources / * @return ProjectReimburseDto */ ProjectReimburseDto create(ProjectReimburse resources); /** * 编辑 * @param resources / */ void update(ProjectReimburse resources); /** * 多选删除 * @param ids / */ void deleteAll(Long[] ids); /** * 导出数据 * @param all 待导出的数据 * @param response / * @throws IOException / */ void download(List<ProjectReimburseDto> all, HttpServletResponse response) throws IOException; /** * 审核报销 * @param resources / */ void updateApprove(ProjectReimburse resources); } eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/project/service/dto/ProjectReimburseDto.java
New file @@ -0,0 +1,94 @@ /* * 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.project.service.dto; import lombok.Data; import me.zhengjie.base.BaseDTO; import me.zhengjie.modules.approval.service.dto.ApproveEventDto; import java.sql.Timestamp; import java.math.BigDecimal; import java.io.Serializable; /** * @website https://eladmin.vip * @description / * @author baolh * @date 2025-04-22 **/ @Data public class ProjectReimburseDto extends BaseDTO implements Serializable { /** 主键ID */ private Long id; /** 用户ID */ private Long userId; /** 审批用户ID */ private Long approvalUserId; /** 项目ID */ private Long projectId; /** 报销类型(多个用,分隔) */ private String reimburseType; /** 报销原因 */ private String reimburseReason; /** 费用类型(多个用,分隔) */ private String expenseType; /** 开始时间 */ private Timestamp startTime; /** 结束时间 */ private Timestamp endTime; /** 费用金额 */ private BigDecimal expenseAmount; /** 费用说明 */ private String expenseComment; /** 附件源文件名 */ private String originFileName; /** 附件路径 */ private String filePath; /** 审批状态 */ private String approvalStatus; /** 审批说明 */ private String approvalDescription; /** 企微审批单号 */ private String wecomSpNo; /** 企微最新审批变化 */ private ApproveEventDto event; /** 申请用户名 */ private String userName; /** 审批用户名 */ private String appUserName; /** 所属项目 */ private String projectName; } eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/project/service/dto/ProjectReimburseQueryCriteria.java
New file @@ -0,0 +1,54 @@ /* * 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.project.service.dto; import lombok.Data; import java.sql.Timestamp; import java.util.List; import me.zhengjie.annotation.Query; /** * @website https://eladmin.vip * @author baolh * @date 2025-04-22 **/ @Data public class ProjectReimburseQueryCriteria{ /** 精确 */ @Query private Long projectId; /** 精确 */ @Query(type = Query.Type.EQUAL) private String wecomSpNo; /** 模糊 */ @Query(type = Query.Type.INNER_LIKE) private String reimburseType; /** 模糊 */ @Query(type = Query.Type.INNER_LIKE) private String expenseType; /** BETWEEN */ @Query(type = Query.Type.BETWEEN) private List<Timestamp> startTime; /** BETWEEN */ @Query(type = Query.Type.BETWEEN) private List<Timestamp> endTime; } eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/project/service/impl/ProjectReimburseServiceImpl.java
New file @@ -0,0 +1,219 @@ /* * 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.project.service.impl; import me.zhengjie.config.FileProperties; import me.zhengjie.exception.BadRequestException; import me.zhengjie.modules.approval.domain.ApproveEvent; import me.zhengjie.modules.approval.repository.ApproveEventRepository; import me.zhengjie.modules.approval.service.TemplateControlFieldService; import me.zhengjie.modules.approval.service.mapstruct.ApproveEventMapper; import me.zhengjie.modules.constant.Constant; import me.zhengjie.modules.project.domain.Project; import me.zhengjie.modules.project.domain.ProjectReimburse; import me.zhengjie.modules.project.repository.ProjectRepository; import me.zhengjie.modules.system.domain.Dict; import me.zhengjie.modules.system.domain.DictDetail; import me.zhengjie.modules.system.domain.User; import me.zhengjie.modules.system.repository.DictDetailRepository; import me.zhengjie.modules.system.repository.UserRepository; import me.zhengjie.utils.*; import lombok.RequiredArgsConstructor; import me.zhengjie.modules.project.repository.ProjectReimburseRepository; import me.zhengjie.modules.project.service.ProjectReimburseService; import me.zhengjie.modules.project.service.dto.ProjectReimburseDto; import me.zhengjie.modules.project.service.dto.ProjectReimburseQueryCriteria; import me.zhengjie.modules.project.service.mapstruct.ProjectReimburseMapper; 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.util.*; import java.io.IOException; import javax.servlet.http.HttpServletResponse; import java.util.function.Function; import java.util.stream.Collectors; /** * @website https://eladmin.vip * @description 服务实现 * @author baolh * @date 2025-04-22 **/ @Service @RequiredArgsConstructor public class ProjectReimburseServiceImpl implements ProjectReimburseService { private final ProjectReimburseRepository projectReimburseRepository; private final UserRepository userRepository; private final ApproveEventRepository approveEventRepository; private final ProjectRepository projectRepository; private final DictDetailRepository dictDetailRepository; private final ProjectReimburseMapper projectReimburseMapper; private final ApproveEventMapper approveEventMapper; private final TemplateControlFieldService templateControlFieldService; private final FileProperties properties; @Override public Map<String,Object> queryAll(ProjectReimburseQueryCriteria criteria, Pageable pageable){ Page<ProjectReimburse> page = projectReimburseRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); Function<ProjectReimburse, ProjectReimburseDto> func = new Function<ProjectReimburse, ProjectReimburseDto>() { @Override public ProjectReimburseDto apply(ProjectReimburse projectReimburse) { // 将实体类转换成DTO ProjectReimburseDto projectReimburseDto = projectReimburseMapper.toDto(projectReimburse); // 查询用户信息 User user = userRepository.findById(projectReimburseDto.getUserId()).orElseGet(User::new); projectReimburseDto.setUserName(user.getNickName()); // 查询审批用户名 User appUser = userRepository.findById(projectReimburseDto.getApprovalUserId()).orElseGet(User::new); projectReimburseDto.setAppUserName(appUser.getNickName()); // 获取所属项目名 Project project = projectRepository.findById(projectReimburseDto.getProjectId()).orElseGet(Project::new); projectReimburseDto.setProjectName(project.getName()); // 查询企微最新审批变化记录 if (ObjectUtils.isNotEmpty(projectReimburse.getWecomEventId())) { ApproveEvent event = approveEventRepository.findById(projectReimburse.getWecomEventId()).orElseGet(ApproveEvent::new); projectReimburseDto.setEvent(approveEventMapper.toDto(event)); } return projectReimburseDto; } }; return PageUtil.toPage(page.map(func)); } @Override public List<ProjectReimburseDto> queryAll(ProjectReimburseQueryCriteria criteria){ List<ProjectReimburseDto> projectReimburseDtoList = projectReimburseMapper.toDto(projectReimburseRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); projectReimburseDtoList.forEach(projectReimburseDto -> { // 查询申请用户名 User user = userRepository.findById(projectReimburseDto.getUserId()).orElseGet(User::new); projectReimburseDto.setUserName(user.getNickName()); // 查询审批用户名 User appUser = userRepository.findById(projectReimburseDto.getApprovalUserId()).orElseGet(User::new); projectReimburseDto.setAppUserName(appUser.getNickName()); // 获取所属项目名 Project project = projectRepository.findById(projectReimburseDto.getProjectId()).orElseGet(Project::new); projectReimburseDto.setProjectName(project.getName()); }); return projectReimburseDtoList; } @Override @Transactional public ProjectReimburseDto findById(Long id) { ProjectReimburse projectReimburse = projectReimburseRepository.findById(id).orElseGet(ProjectReimburse::new); ValidationUtil.isNull(projectReimburse.getId(),"ProjectReimburse","id",id); return projectReimburseMapper.toDto(projectReimburse); } @Override @Transactional(rollbackFor = Exception.class) public ProjectReimburseDto create(ProjectReimburse resources) { resources.setApprovalStatus(Constant.REIMBURSE_APPROVE_STATUS_REVIEWED); // 判断是否提交企微审批 List<DictDetail> siteTypes = dictDetailRepository.findByDictName(Constant.APPROVAL_SITE_TYPE).stream().filter(siteType -> siteType.getValue().toLowerCase().equals("wecom")).collect(Collectors.toList()); if (siteTypes.size() > 0) { // 添加企微申请参数 String weComId = userRepository.findById(resources.getUserId()).orElse(new User()).getWeComId(); Map<String, String> reimburseTypeMap = dictDetailRepository.findByDictName(Constant.REIMBURSE_TYPE).stream().collect(Collectors.toMap(DictDetail::getValue, DictDetail::getLabel)); Map<String, String> expenseTypeMap = dictDetailRepository.findByDictName(Constant.REIMBURSE_EXPENSE_TYPE).stream().collect(Collectors.toMap(DictDetail::getValue, DictDetail::getLabel)); resources.setWecomReimburseType(Arrays.stream(resources.getReimburseType().split(",")).map(rt -> Optional.ofNullable(reimburseTypeMap.get(rt)).orElse(rt)).collect(Collectors.joining(","))); resources.setWecomExpenseType(Arrays.stream(resources.getExpenseType().split(",")).map(et -> Optional.ofNullable(expenseTypeMap.get(et)).orElse(et)).collect(Collectors.joining(","))); resources.setWecomProjectName(projectRepository.findById(resources.getProjectId()).orElseGet(Project::new).getName()); if (StringUtils.isNotBlank(resources.getFilePath())) { // 文件上传至企微临时素材 FileProperties.ElPath elPath = properties.getPath(); resources.setWecomFileIds(templateControlFieldService.uploadWecomMediaFile(Arrays.stream(resources.getFilePath().split(",")).map(p -> { p = elPath.getPath().concat(p.replace("file/", "")).replace("\\","/"); return p; }).collect(Collectors.toList())).stream().collect(Collectors.joining("|"))); } // 提交申请 Map<String, String> approvalResultMap = templateControlFieldService.createWecomApproval(resources, weComId); if (approvalResultMap.containsKey("spNo")) { resources.setWecomSpNo(approvalResultMap.get("spNo")); } else { throw new BadRequestException(approvalResultMap.containsKey("error") ? approvalResultMap.get("error") : "企微申请提交失败"); } } return projectReimburseMapper.toDto(projectReimburseRepository.save(resources)); } @Override @Transactional(rollbackFor = Exception.class) public void update(ProjectReimburse resources) { ProjectReimburse projectReimburse = projectReimburseRepository.findById(resources.getId()).orElseGet(ProjectReimburse::new); ValidationUtil.isNull( projectReimburse.getId(),"ProjectReimburse","id",resources.getId()); projectReimburse.copy(resources); projectReimburseRepository.save(projectReimburse); } @Override public void deleteAll(Long[] ids) { for (Long id : ids) { projectReimburseRepository.deleteById(id); } } @Override public void download(List<ProjectReimburseDto> all, HttpServletResponse response) throws IOException { List<Map<String, Object>> list = new ArrayList<>(); Map<String, String> reimburseApproveStatusDict = dictDetailRepository.findByDictName(Constant.REIMBURSE_APPROVE_STATUS).stream().collect(Collectors.toMap(DictDetail::getValue, DictDetail::getLabel)); Map<String, String> reimburseTypeDict = dictDetailRepository.findByDictName(Constant.REIMBURSE_TYPE).stream().collect(Collectors.toMap(DictDetail::getValue, DictDetail::getLabel)); Map<String, String> reimburseExpenseTypeDict = dictDetailRepository.findByDictName(Constant.REIMBURSE_EXPENSE_TYPE).stream().collect(Collectors.toMap(DictDetail::getValue, DictDetail::getLabel)); for (ProjectReimburseDto projectReimburse : all) { Map<String,Object> map = new LinkedHashMap<>(); map.put("申请人", projectReimburse.getUserName()); map.put("审批者", projectReimburse.getAppUserName()); map.put("所属项目", projectReimburse.getProjectName()); map.put("报销类型", Arrays.stream(projectReimburse.getReimburseType().split(",")).map(s -> Optional.ofNullable(reimburseTypeDict.get(s)).orElse(s)).collect(Collectors.joining(","))); map.put("报销原因", projectReimburse.getReimburseReason()); map.put("费用类型", Arrays.stream(projectReimburse.getExpenseType().split(",")).map(s -> Optional.ofNullable(reimburseExpenseTypeDict.get(s)).orElse(s)).collect(Collectors.joining(","))); map.put("开始时间", projectReimburse.getStartTime()); map.put("结束时间", projectReimburse.getEndTime()); map.put("费用金额", projectReimburse.getExpenseAmount()); map.put("费用说明", projectReimburse.getExpenseComment()); map.put("审批状态", Optional.ofNullable(reimburseApproveStatusDict.get(projectReimburse.getApprovalStatus())).orElse(projectReimburse.getApprovalStatus())); map.put("审批说明", projectReimburse.getApprovalDescription()); map.put("创建时间", projectReimburse.getCreateTime()); map.put("创建人", projectReimburse.getCreateBy()); map.put("更新时间", projectReimburse.getUpdateTime()); map.put("更新人", projectReimburse.getUpdateBy()); list.add(map); } FileUtil.downloadExcel(list, response); } /** * 审核报销 * * @param resources / */ @Override public void updateApprove(ProjectReimburse resources) { ProjectReimburse projectReimburse = projectReimburseRepository.findById(resources.getId()).orElseGet(ProjectReimburse::new); ValidationUtil.isNull( projectReimburse.getId(),"ProjectReimburse","id",resources.getId()); projectReimburse.copy(resources); projectReimburseRepository.save(projectReimburse); } } eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/project/service/mapstruct/ProjectReimburseMapper.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.project.service.mapstruct; import me.zhengjie.base.BaseMapper; import me.zhengjie.modules.project.domain.ProjectReimburse; import me.zhengjie.modules.project.service.dto.ProjectReimburseDto; import org.mapstruct.Mapper; import org.mapstruct.ReportingPolicy; /** * @website https://eladmin.vip * @author baolh * @date 2025-04-22 **/ @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) public interface ProjectReimburseMapper extends BaseMapper<ProjectReimburseDto, ProjectReimburse> { } eladmin-web-master/src/api/project/projectReimburse.js
New file @@ -0,0 +1,35 @@ import request from '@/utils/request' export function add(data) { return request({ url: 'api/projectReimburse', method: 'post', data }) } export function del(ids) { return request({ url: 'api/projectReimburse/', method: 'delete', data: ids }) } export function edit(data) { return request({ url: 'api/projectReimburse', method: 'put', data }) } export function approve(data) { return request({ url: 'api/projectReimburse/approve', method: 'put', data }) } export default { add, edit, del, approve } eladmin-web-master/src/utils/constant.js
@@ -395,8 +395,24 @@ export const WECOM_BIND_OVERTIME = 'AttendanceOvertime' // 企微审批字段绑定:补卡字段绑定 export const WECOM_BIND_REPLACEMENT = 'AttendanceCardreplacement' // 企微审批字段绑定:补卡字段绑定 export const WECOM_BIND_REIMBURSE = 'ProjectReimburse' // 申请审核站点 export const APPROVAL_SITE_TYPE = 'approval_site_type' // 报销审批状态 export const REIMBURSE_APPROVE_STATUS = 'reimburse_approve_status' // 报销审批状态:审核中 export const REIMBURSE_APPROVE_STATUS_REVIEWED = 'reimburse_approve_status_reviewed' // 报销审批状态:已通过 export const REIMBURSE_APPROVE_STATUS_AGREE = 'reimburse_approve_status_agree' // 报销审批状态:已退回 export const REIMBURSE_APPROVE_STATUS_REFUSE = 'reimburse_approve_status_refuse' // 报销类型 export const REIMBURSE_TYPE = 'reimburse_type' // 报销费用类型 export const REIMBURSE_EXPENSE_TYPE = 'reimburse_expense_type' export default { ROLE_LEVEL_SUPER, @@ -578,5 +594,12 @@ WECOM_BIND_TRAVEL, WECOM_BIND_OVERTIME, WECOM_BIND_REPLACEMENT, APPROVAL_SITE_TYPE WECOM_BIND_REIMBURSE, APPROVAL_SITE_TYPE, REIMBURSE_APPROVE_STATUS, REIMBURSE_APPROVE_STATUS_REVIEWED, REIMBURSE_APPROVE_STATUS_AGREE, REIMBURSE_APPROVE_STATUS_REFUSE, REIMBURSE_TYPE, REIMBURSE_EXPENSE_TYPE } eladmin-web-master/src/views/project/projectReimburse/index.vue
New file @@ -0,0 +1,686 @@ <template> <div class="app-container"> <!-- 工具栏 --> <div class="head-container"> <div v-if="crud.props.searchToggle"> <!-- 搜索 --> <!-- <label class="el-form-item-label">所属项目</label> --> <el-input v-model="query.projectId" clearable placeholder="所属项目" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" /> <!-- <label class="el-form-item-label">报销类型</label> --> <el-input v-model="query.reimburseType" clearable placeholder="报销类型" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" /> <!-- <label class="el-form-item-label">费用类型</label> --> <el-input v-model="query.expenseType" clearable placeholder="费用类型" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" /> <el-date-picker v-model="query.startTime" type="daterange" clearable range-separator=" ~ " start-placeholder="开始时间" end-placeholder="结束时间" style="width: 285px;" class="filter-item" /> <el-date-picker v-model="query.endTime" type="daterange" clearable range-separator=" ~ " start-placeholder="开始时间" end-placeholder="结束时间" style="width: 285px;" class="filter-item" /> <rrOperation :crud="crud" /> </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="主键ID"> <el-input v-model="form.id" style="width: 370px;" /> </el-form-item> --> <el-form-item label="申请人" prop="userId"> <!-- <el-input v-model="form.userId" style="width: 370px;" /> --> <el-select v-model="form.userId" filterable clearable placeholder="请选择" style="width: 370px;" :disabled="disabledUser(form) || form.wecomSpNo !== null"> <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" :hidden="form.wecomSpNo !== null || (form.id == null && wecomApprovalVisible)"> <el-select v-model="form.approvalUserId" filterable clearable placeholder="请选择" style="width: 370px;" :disabled="form.approvalStatus == dictReimburseApproveStatusAgree || form.approvalStatus == dictReimburseApproveStatusRefuse || form.wecomSpNo !== null"> <el-option v-for="item in approvalUsers" :key="item.id" :label="item.nickName" :value="item.id" /> </el-select> </el-form-item> <el-form-item label="所属项目" prop="projectId"> <el-select v-model="form.projectId" filterable clearable placeholder="请选择" style="width: 370px;" :disabled="form.approvalStatus == dictReimburseApproveStatusAgree || form.approvalStatus == dictReimburseApproveStatusRefuse || form.wecomSpNo !== null"> <el-option v-for="item in projects" :key="`project_${item.id}`" :label="item.name" :value="item.id" /> </el-select> </el-form-item> <el-form-item label="报销类型" prop="reimburseTypes"> <el-select v-model="form.reimburseTypes" multiple filterable clearable placeholder="请选择" style="width: 370px;" :disabled="form.approvalStatus == dictReimburseApproveStatusAgree || form.approvalStatus == dictReimburseApproveStatusRefuse || form.wecomSpNo !== null"> <el-option v-for="item in dict[dictReimburseType]" :key="item.value" :label="item.label" :value="item.value" /> </el-select> </el-form-item> <el-form-item label="报销原因" prop="reimburseReason"> <el-input v-model="form.reimburseReason" placeholder="请输入" type="textarea" rows="3" style="width: 370px;" :disabled="form.approvalStatus == dictReimburseApproveStatusAgree || form.approvalStatus == dictReimburseApproveStatusRefuse || form.wecomSpNo !== null" /> </el-form-item> <el-form-item label="费用类型" prop="expenseTypes"> <el-select v-model="form.expenseTypes" multiple filterable clearable placeholder="请选择" style="width: 370px;" :disabled="form.approvalStatus == dictReimburseApproveStatusAgree || form.approvalStatus == dictReimburseApproveStatusRefuse || form.wecomSpNo !== null"> <el-option v-for="item in dict[dictReimburseExpenseType]" :key="item.value" :label="item.label" :value="item.value" /> </el-select> </el-form-item> <el-form-item label="开始时间" prop="startTime"> <el-date-picker v-model="form.startTime" type="date" placeholder="选择日期" value-format="yyyy-MM-dd 00:00:00" style="width: 370px;" align="right" :picker-options="{ disabledDate(time) { return form.endTime ? time.getTime() > new Date(form.endTime).getTime() - 8.64e7 : false; } }" :disabled="form.approvalStatus == dictReimburseApproveStatusAgree || form.approvalStatus == dictReimburseApproveStatusRefuse || form.wecomSpNo !== null" /> </el-form-item> <el-form-item label="结束时间" prop="endTime"> <el-date-picker v-model="form.endTime" type="date" placeholder="选择日期" style="width: 370px;" value-format="yyyy-MM-dd 23:59:59" align="right" :picker-options="{ disabledDate(time) { return form.startTime ? time.getTime() < new Date(form.startTime).getTime() - 8.64e7 : false; } }" :disabled="form.approvalStatus == dictReimburseApproveStatusAgree || form.approvalStatus == dictReimburseApproveStatusRefuse || form.wecomSpNo !== null" /> </el-form-item> <el-form-item label="费用金额" prop="expenseAmount"> <el-input-number v-model="form.expenseAmount" placeholder="请输入" style="width: 370px;" :disabled="form.approvalStatus == dictReimburseApproveStatusAgree || form.approvalStatus == dictReimburseApproveStatusRefuse || form.wecomSpNo !== null" /> </el-form-item> <el-form-item label="费用说明" prop="expenseComment"> <el-input v-model="form.expenseComment" placeholder="请输入" type="textarea" rows="3" style="width: 370px;" :disabled="form.approvalStatus == dictReimburseApproveStatusAgree || form.approvalStatus == dictReimburseApproveStatusRefuse || form.wecomSpNo !== null" /> </el-form-item> <el-form-item label="附件"> <file-upload key="file_key" ref="fileUpload" :file-url="form.filePath == null || form.filePath === '' ? null : form.filePath" :limit="6" :disabled="form.approvalStatus == dictReimburseApproveStatusAgree || form.approvalStatus == dictReimburseApproveStatusRefuse || form.wecomSpNo !== null" @fileInfo="getFileInfo" /> </el-form-item> <!-- <el-form-item label="附件源文件名"> <el-input v-model="form.originFileName" style="width: 370px;" /> </el-form-item> <el-form-item label="附件路径"> <el-input v-model="form.filePath" style="width: 370px;" /> </el-form-item> <el-form-item label="审批状态" prop="approvalStatus"> <el-input v-model="form.approvalStatus" style="width: 370px;" /> </el-form-item> --> <el-form-item label="审批说明" prop="approvalDescription"> <el-input v-model="form.approvalDescription" type="textarea" rows="3" disabled style="width: 370px;" /> </el-form-item> <!-- <el-form-item label="创建时间"> <el-input v-model="form.createTime" style="width: 370px;" /> </el-form-item> <el-form-item label="创建人"> <el-input v-model="form.createBy" style="width: 370px;" /> </el-form-item> <el-form-item label="更新时间"> <el-input v-model="form.updateTime" style="width: 370px;" /> </el-form-item> <el-form-item label="更新人"> <el-input v-model="form.updateBy" style="width: 370px;" /> </el-form-item> <el-form-item label="企微审批单号"> <el-input v-model="form.wecomSpNo" style="width: 370px;" /> </el-form-item> <el-form-item label="企微最新审批变化"> <el-input v-model="form.wecomEventId" style="width: 370px;" /> </el-form-item> <el-form-item label="企微附件ID(多个用|分隔,最多6个,每个最大10M)"> <el-input v-model="form.wecomFileIds" style="width: 370px;" /> </el-form-item> <el-form-item label="企微报销类型(多个用,分隔)"> <el-input v-model="form.wecomReimburseType" style="width: 370px;" /> </el-form-item> <el-form-item label="企微费用类型(多个用,分隔)"> <el-input v-model="form.wecomExpenseType" style="width: 370px;" /> </el-form-item> <el-form-item label="企微项目名称"> <el-input v-model="form.wecomProjectName" 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 || fileUploadLoading" type="primary" @click="formSubmit">确认</el-button> </div> </el-dialog> <!-- 审批组件 --> <el-dialog :close-on-click-modal="false" :before-close="cancelApprove" :visible.sync="approveModal.visible" :title="approveModal.title" width="500px"> <el-form ref="approveForm" :model="form" :rules="approveRules" size="small" label-width="80px"> <el-form-item label="申请人"> {{ form.userName }} </el-form-item> <el-form-item label="所属项目"> {{ form.projectName }} </el-form-item> <el-form-item label="报销类型"> {{ batchConversion(form.reimburseType, dict.label[dictReimburseType]) }} </el-form-item> <el-form-item label="报销原因"> {{ form.reimburseReason }} </el-form-item> <el-form-item label="费用类型"> {{ batchConversion(form.expenseType, dict.label[dictReimburseExpenseType]) }} </el-form-item> <el-form-item label="开始时间"> {{ form.startTime }} </el-form-item> <el-form-item label="结束时间"> {{ form.endTime }} </el-form-item> <el-form-item label="费用金额"> {{ form.expenseAmount }} </el-form-item> <el-form-item label="费用说明"> {{ form.expenseComment }} </el-form-item> <el-form-item v-if="form.approvalStatus === dictReimburseApproveStatusRefuse" 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;" :loading="approveModal.approveLoading" @click="handleApprove(1, form)">审核退回</el-button> <el-button v-if="form.approvalStatus !== dictReimburseApproveStatusRefuse" :loading="approveModal.approveLoading" type="success" @click="handleApprove(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="申请人"> <template slot-scope="scope"> <el-tag>{{ scope.row.userName }}</el-tag> </template> </el-table-column> <el-table-column prop="appUserName" label="审批者"> <template slot-scope="scope"> <el-popover v-if="scope.row.wecomSpNo && scope.row.event" placement="right-start" width="600" trigger="click" > <approvalLine :event-data="scope.row.event" :user-list="users" /> <el-tag slot="reference" effect="dark"> <i class="el-icon-search" /> <span>详细</span> </el-tag> </el-popover> <el-tag v-else-if="scope.row.appUserName">{{ scope.row.appUserName }}</el-tag> <el-tag v-else>暂无</el-tag> </template> </el-table-column> <el-table-column prop="projectName" label="所属项目" min-width="140"> <template slot-scope="scope"> <el-tag>{{ scope.row.projectName }}</el-tag> </template> </el-table-column> <el-table-column prop="reimburseType" label="报销类型" min-width="140" show-overflow-tooltip> <template slot-scope="scope"> {{ batchConversion(scope.row.reimburseType, dict.label[dictReimburseType]) }} </template> </el-table-column> <!-- <el-table-column prop="reimburseReason" label="报销原因" show-overflow-tooltip /> --> <el-table-column prop="expenseType" label="费用类型" min-width="140" show-overflow-tooltip> <template slot-scope="scope"> {{ batchConversion(scope.row.expenseType, dict.label[dictReimburseExpenseType]) }} </template> </el-table-column> <el-table-column prop="startTime" label="开始时间" min-width="100"> <template slot-scope="scope"> {{ crud.toDate(scope.row.startTime) }} </template> </el-table-column> <el-table-column prop="endTime" label="结束时间" min-width="100"> <template slot-scope="scope"> {{ crud.toDate(scope.row.endTime) }} </template> </el-table-column> <el-table-column prop="expenseAmount" label="费用金额" /> <!-- <el-table-column prop="expenseComment" label="费用说明" show-overflow-tooltip /> <el-table-column prop="originFileName" label="附件文件名" /> <el-table-column prop="filePath" label="附件路径" /> --> <el-table-column prop="approvalStatus" label="审批状态"> <template slot-scope="scope"> <el-tag v-if="scope.row.approvalStatus === dictReimburseApproveStatusReviewed" type="warning">{{ dict.label[dictReimburseApproveStatus][scope.row.approvalStatus] }}</el-tag> <el-tag v-if="scope.row.approvalStatus === dictReimburseApproveStatusAgree" type="success">{{ dict.label[dictReimburseApproveStatus][scope.row.approvalStatus] }}</el-tag> <el-tag v-if="scope.row.approvalStatus === dictReimburseApproveStatusRefuse" type="danger">{{ dict.label[dictReimburseApproveStatus][scope.row.approvalStatus] }}</el-tag> </template> </el-table-column> <el-table-column prop="approvalDescription" label="审批说明" show-overflow-tooltip /> <el-table-column prop="createTime" label="创建时间" min-width="140" /> <!-- <el-table-column prop="createBy" label="创建人" /> <el-table-column prop="updateTime" label="更新时间" /> <el-table-column prop="updateBy" label="更新人" /> <el-table-column prop="wecomSpNo" label="企微审批单号" /> <el-table-column prop="wecomEventId" label="企微最新审批变化" /> <el-table-column prop="wecomFileIds" label="企微附件ID(多个用|分隔,最多6个,每个最大10M)" /> <el-table-column prop="wecomReimburseType" label="企微报销类型(多个用,分隔)" /> <el-table-column prop="wecomExpenseType" label="企微费用类型(多个用,分隔)" /> <el-table-column prop="wecomProjectName" label="企微项目名称" /> --> <el-table-column v-if="checkPer(permission.approve)" label="审核操作" width="180px" align="center" fixed="right"> <template slot-scope="scope"> <el-button v-if="scope.row.approvalUserId === $store.state.user.user.id && !scope.row.wecomSpNo" v-permission="permission.approve" :loading="crud.status.cu === 2" size="mini" type="primary" icon="el-icon-s-check" :disabled="!(scope.row.approvalStatus === dictReimburseApproveStatusReviewed)" @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="handleCanel(scope.row.id)">取消</el-button> <el-button :loading="revokeLoading" type="primary" size="mini" @click="handleRevoke(scope.row)">确定</el-button> </div> <el-button v-if="scope.row.approvalUserId === $store.state.user.user.id && !scope.row.wecomSpNo" slot="reference" v-permission="permission.approve" type="danger" icon="el-icon-edit-outline" size="mini" :disabled="scope.row.approvalStatus === dictReimburseApproveStatusReviewed" > 撤销 </el-button> </el-popover> <el-link v-if="scope.row.wecomSpNo" type="primary">请前往企微审核</el-link> </template> </el-table-column> <el-table-column v-if="checkPer(['admin','projectReimburse:edit','projectReimburse:del'])" label="操作" width="150px" align="center" fixed="right"> <template slot-scope="scope"> <udOperation :data="scope.row" :permission="permission" /> </template> </el-table-column> </el-table> <!--分页组件--> <pagination /> </div> </div> </template> <script> import crudProjectReimburse from '@/api/project/projectReimburse' import crudUser from '@/api/system/user' import crudProject from '@/api/project/project' import CRUD, { presenter, header, form, crud } from '@crud/crud' import rrOperation from '@crud/RR.operation' import crudOperation from '@crud/CRUD.operation' import udOperation from '@crud/UD.operation' import pagination from '@crud/Pagination' import approvalLine from '@/components/ApprovalLine' import fileUpload from '@/views/assembly/fileUpload' import { mapGetters } from 'vuex' import constant from '@/utils/constant' const defaultForm = { id: null, userId: null, approvalUserId: null, projectId: null, reimburseType: null, reimburseReason: null, expenseType: null, startTime: null, endTime: null, expenseAmount: null, expenseComment: null, originFileName: null, filePath: null, approvalStatus: null, approvalDescription: null, createTime: null, createBy: null, updateTime: null, updateBy: null, wecomSpNo: null, event: null, userName: null, appUserName: null, projectName: null, reimburseTypes: null, expenseTypes: null } export default { name: 'ProjectReimburse', components: { pagination, crudOperation, rrOperation, udOperation, approvalLine, fileUpload }, mixins: [presenter(), header(), form(defaultForm), crud()], dicts: [constant.REIMBURSE_APPROVE_STATUS, constant.REIMBURSE_TYPE, constant.REIMBURSE_EXPENSE_TYPE, constant.APPROVAL_SITE_TYPE], cruds() { return CRUD({ title: '项目报销', url: 'api/projectReimburse', idField: 'id', sort: 'id,desc', crudMethod: { ...crudProjectReimburse }}) }, data() { return { permission: { add: ['admin', 'projectReimburse:add'], edit: ['admin', 'projectReimburse:edit'], del: ['admin', 'projectReimburse:del'], download: ['admin', 'projectReimburse:download'], approve: ['admin', 'projectReimburse:approve'] }, rules: { userId: [ { required: true, message: '申请人不能为空', trigger: 'change' } ], approvalUserId: [ { required: true, message: '审批者不能为空', trigger: 'change' } ], projectId: [ { required: true, message: '所属项目不能为空', trigger: 'change' } ], reimburseTypes: [ { required: true, message: '报销类型不能为空', trigger: 'blur' } ], expenseTypes: [ { required: true, message: '费用类型不能为空', trigger: 'blur' } ], startTime: [ { required: true, message: '开始时间不能为空', trigger: 'blur' } ], endTime: [ { required: true, message: '结束时间不能为空', trigger: 'blur' } ], expenseAmount: [ { required: true, message: '费用金额不能为空', trigger: 'blur' } ] }, approveRules: { approvalDescription: [ { required: true, message: '退回原因不能为空', trigger: 'blur' } ] }, queryTypeOptions: [ { key: 'projectId', display_name: '所属项目' }, { key: 'reimburseType', display_name: '报销类型' }, { key: 'expenseType', display_name: '费用类型' } ], approveModal: { title: '报销审批', visible: false, approveLoading: false }, // 撤销Loading revokeLoading: false, dictReimburseApproveStatus: constant.REIMBURSE_APPROVE_STATUS, dictReimburseApproveStatusReviewed: constant.REIMBURSE_APPROVE_STATUS_REVIEWED, dictReimburseApproveStatusAgree: constant.REIMBURSE_APPROVE_STATUS_AGREE, dictReimburseApproveStatusRefuse: constant.REIMBURSE_APPROVE_STATUS_REFUSE, dictReimburseType: constant.REIMBURSE_TYPE, dictReimburseExpenseType: constant.REIMBURSE_EXPENSE_TYPE, users: [], approvalUsers: [], projects: [], userRolesLevelMin: null, // 角色级别: 总经理 roleLevelGenerl: constant.ROLE_LEVEL_GENERAL, // 企微审核判断 wecomApprovalVisible: false, fileUploadLoading: false } }, computed: { ...mapGetters([ 'user' ]) }, created() { const that = this that.getUsers() that.getApprovalUsers() that.getProjects() that.$on('dictReady', () => { const dictData = { ...that.dict } const filterData = dictData[constant.APPROVAL_SITE_TYPE].filter(item => item.value.toLowerCase() === 'wecom') if (filterData.length > 0) { that.wecomApprovalVisible = true } }) }, methods: { // 钩子:在获取表格数据之前执行,false 则代表不获取数据 [CRUD.HOOK.beforeRefresh]() { const that = this // 用户角色级别数组 const userRolesLevel = that.user.roles.map(({ level }) => level) // 用户最大角色级别 that.userRolesLevelMin = Math.min(...userRolesLevel) return true }, // 钩子:新建 - 之前 [CRUD.HOOK.beforeToAdd]() { const that = this // 转换报销类型和费用类型 that.$set(that.form, 'reimburseTypes', []) that.$set(that.form, 'expenseTypes', []) // 判断用户最大角色级别是否大于总经理角色:赋值 if (that.userRolesLevelMin > that.roleLevelGenerl) { // 表单赋值 that.form.userId = that.user.id } if (that.wecomApprovalVisible) { that.form.approvalUserId = 0 } return true }, // 钩子:编辑 - 之前 [CRUD.HOOK.beforeToEdit]() { const that = this // 转换报销类型和费用类型 that.$set(that.form, 'reimburseTypes', that.form.reimburseType.split(',')) that.$set(that.form, 'expenseTypes', that.form.expenseType.split(',')) return true }, // 钩子:提交 - 之前 [CRUD.HOOK.beforeSubmit]() { const that = this // 解除文件上传Loading that.fileUploadLoading = false // 转换报销类型和费用类型 that.$set(that.form, 'reimburseType', that.form.reimburseTypes.join(',')) that.$set(that.form, 'expenseType', that.form.expenseTypes.join(',')) return true }, // 钩子:提交 - 之后 [CRUD.HOOK.afterSubmit]() { const that = this that.$set(that.form, 'reimburseTypes', undefined) that.$set(that.form, 'expenseTypes', undefined) return true }, // 查询员工 getUsers() { const that = this crudUser.getAll().then(res => { that.users = res }) }, // 查询审核人 getApprovalUsers() { const that = this crudUser.getApprovalUsers().then(res => { that.approvalUsers = res }) }, // 获取项目列表 getProjects() { const that = this // 获取项目列表 crudProject.getAll().then(res => { that.projects = res }) }, // 提交数据 formSubmit() { const that = this that.$refs['form'].validate(valid => { if (!valid) { return } that.fileUploadLoading = true that.$refs.fileUpload.submit() }) }, // 禁用 disabledUser(data) { const that = this if (that.userRolesLevelMin > that.roleLevelGenerl) { return true } if (data.approvalStatus !== null && data.approvalStatus === that.dictReimburseApproveStatusAgree || data.approvalStatus === that.dictReimburseApproveStatusRefuse) { return true } }, // 批量转换字符串 batchConversion(str, dictData) { const finalStrArr = [] str && str.split(',').forEach(item => { finalStrArr.push(dictData[item] || item) }) return finalStrArr.join(',') }, // 启动审批 toApprove(data) { const that = this const form = JSON.parse(JSON.stringify(data)) const approveFrom = that.form for (const key in form) { if (approveFrom.hasOwnProperty(key)) { approveFrom[key] = form[key] } else { that.$set(approveFrom, key, form[key]) } } if (that.$refs['approveForm']) { that.$refs['approveForm'].clearValidate() } that.approveModal.visible = true }, // 执行审批 handleApprove(type, data) { const that = this const msg = type === 2 ? '通过' : '拒绝' that.$refs['approveForm'].validate(valid => { if (!valid) { return } // 判断通过状态 if (type === 2) { that.form.approvalStatus = that.dictReimburseApproveStatusAgree } else { // 退回改状态显示退回原因 that.form.approvalStatus = that.dictReimburseApproveStatusRefuse if (that.form.approvalDescription == null) { return } } that.approveModal.approveLoading = true that.crud.crudMethod.approve(that.form).then(() => { that.crud.refresh() that.$message({ type: 'success', message: '审核' + msg + '成功' }) that.cancelApprove() }).catch(() => { that.approveModal.approveLoading = false }) }) }, // 取消撤销 handleCanel(id) { const that = this that.$refs[`popover_${id}`].showPopper = false }, // 取消撤销 handleRevoke(data) { const that = this that.revokeLoading = true const form = JSON.parse(JSON.stringify(data)) form.approvalStatus = that.dictReimburseApproveStatusReviewed that.crud.crudMethod.approve(form).then(() => { that.crud.refresh() that.revokeLoading = false that.$message({ type: 'success', message: '撤销成功' }) that.$refs[`popover_${data.id}`].showPopper = false }).catch(err => { that.$message({ type: 'error', message: err.response.data.message }) }) }, // 取消审批 cancelApprove() { const that = this that.approveModal.approveLoading = false if (that.$refs['approveForm']) { that.$refs['approveForm'].resetFields() } that.crud.resetForm() that.approveModal.visible = false }, // 获取文件信息 getFileInfo(info) { const that = this // 判断返回数据 if (info.length === 0) { // 表单文件路径赋值 that.crud.form.filePath = null // 解除附件上传Loading that.fileUploadLoading = false // 表单提交 that.crud.submitCU() // 终止 return } // 循环返回数据 for (let i = 0; i < info.length; i++) { // 判断循环下标 if (i === 0) { // 表单文件路径赋值 that.crud.form.filePath = info[i].response == null || info[i].response === '' ? info[i].url.substring(info[i].url.indexOf('/file/'), info[i].url.length) : '/file/' + info[i].response.type + '/' + info[i].response.realName } else { // 表单文件路径赋值 that.crud.form.filePath += info[i].response == null || info[i].response === '' ? ',' + info[i].url.substring(info[i].url.indexOf('/file/'), info[i].url.length) : ',/file/' + info[i].response.type + '/' + info[i].response.realName } // 判断循环是否结束 if (i === info.length - 1) { // 解除附件上传Loading that.fileUploadLoading = false // 表单提交 that.crud.submitCU() return } } } } } </script> <style scoped> </style> eladmin-web-master/src/views/template/bind/index.vue
@@ -155,7 +155,7 @@ rules: {} } }, dicts: [constant.WECOM_BIND_LEAVE, constant.WECOM_BIND_GOOUT, constant.WECOM_BIND_TRAVEL, constant.WECOM_BIND_OVERTIME, constant.WECOM_BIND_REPLACEMENT, constant.APPROVAL_SITE_TYPE], dicts: [constant.WECOM_BIND_LEAVE, constant.WECOM_BIND_GOOUT, constant.WECOM_BIND_TRAVEL, constant.WECOM_BIND_OVERTIME, constant.WECOM_BIND_REPLACEMENT, constant.WECOM_BIND_REIMBURSE, constant.APPROVAL_SITE_TYPE], created() { const that = this that.queryLoading = true @@ -187,7 +187,12 @@ dictData[constant.WECOM_BIND_REPLACEMENT].forEach(replacement => { replacementTableDate.fieldNames.push({ label: replacement.label, propName: replacement.value }) }) that.tableInfoData.push(leaveTableDate, goOutTableDate, travelTableDate, overtimeTableDate, replacementTableDate) // 报销字段绑定信息制作 const reimburseTableDate = { name: '报销', fieldTable: constant.WECOM_BIND_REIMBURSE, fieldNames: [] } dictData[constant.WECOM_BIND_REIMBURSE].forEach(reimburse => { reimburseTableDate.fieldNames.push({ label: reimburse.label, propName: reimburse.value }) }) that.tableInfoData.push(leaveTableDate, goOutTableDate, travelTableDate, overtimeTableDate, replacementTableDate, reimburseTableDate) that.queryLoading = false