This commit is contained in:
2026-04-22 18:01:23 +08:00
25 changed files with 1262 additions and 121 deletions

View File

@@ -6,6 +6,7 @@ import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.helper.LoginHelper;
import com.ruoyi.hrm.domain.bo.HrmAppropriationReqBo;
import com.ruoyi.hrm.domain.vo.HrmAppropriationReqVo;
import com.ruoyi.hrm.service.IHrmAppropriationReqService;
@@ -31,6 +32,7 @@ public class HrmAppropriationReqController extends BaseController {
@GetMapping("/list")
public TableDataInfo<HrmAppropriationReqVo> list(HrmAppropriationReqBo bo, PageQuery pageQuery) {
bo.setCreateBy(LoginHelper.getUsername());
return service.queryPageList(bo, pageQuery);
}
@@ -59,6 +61,7 @@ public class HrmAppropriationReqController extends BaseController {
@GetMapping("/all")
public R<List<HrmAppropriationReqVo>> all(HrmAppropriationReqBo bo) {
bo.setCreateBy(String.valueOf(LoginHelper.getUserId()));
return R.ok(service.queryList(bo));
}
}

View File

@@ -64,11 +64,9 @@ public class HrmEmployeeController extends BaseController {
*/
@GetMapping("/byUserId/{userId}")
public R<HrmEmployeeVo> getByUserId(@PathVariable @NotNull Long userId) {
HrmEmployeeBo bo = new HrmEmployeeBo();
bo.setUserId(userId);
List<HrmEmployeeVo> list = service.queryList(bo);
if (list != null && !list.isEmpty()) {
return R.ok(list.get(0));
HrmEmployeeVo vo = service.queryByUserId(userId);
if (vo != null) {
return R.ok(vo);
}
return R.fail("未找到该用户对应的员工信息");
}

View File

@@ -6,7 +6,7 @@ import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.hrm.domain.HrmLeaveReq;
import com.ruoyi.common.helper.LoginHelper;
import com.ruoyi.hrm.domain.bo.HrmLeaveReqBo;
import com.ruoyi.hrm.domain.vo.HrmLeaveReqVo;
import com.ruoyi.hrm.domain.vo.HrmLeaveStatsVo;
@@ -30,6 +30,7 @@ public class HrmLeaveReqController extends BaseController {
@GetMapping("/list")
public TableDataInfo<HrmLeaveReqVo> list(HrmLeaveReqBo bo, PageQuery pageQuery) {
bo.setCreateBy(LoginHelper.getUsername());
return service.queryPageList(bo, pageQuery);
}
@@ -58,6 +59,7 @@ public class HrmLeaveReqController extends BaseController {
@GetMapping("/all")
public R<List<HrmLeaveReqVo>> all(HrmLeaveReqBo bo) {
bo.setCreateBy(LoginHelper.getUsername());
return R.ok(service.queryList(bo));
}

View File

@@ -0,0 +1,127 @@
package com.ruoyi.hrm.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.helper.LoginHelper;
import com.ruoyi.hrm.domain.HrmEmployee;
import com.ruoyi.hrm.domain.bo.HrmAppropriationReqBo;
import com.ruoyi.hrm.domain.bo.HrmLeaveReqBo;
import com.ruoyi.hrm.domain.bo.HrmReimburseReqBo;
import com.ruoyi.hrm.domain.bo.HrmSealReqBo;
import com.ruoyi.hrm.domain.bo.HrmTravelReqBo;
import com.ruoyi.hrm.domain.vo.HrmAppropriationReqVo;
import com.ruoyi.hrm.domain.vo.HrmLeaveReqVo;
import com.ruoyi.hrm.domain.vo.HrmMyApplyVo;
import com.ruoyi.hrm.domain.vo.HrmReimburseReqVo;
import com.ruoyi.hrm.domain.vo.HrmSealReqVo;
import com.ruoyi.hrm.domain.vo.HrmTravelReqVo;
import com.ruoyi.hrm.mapper.HrmAppropriationReqMapper;
import com.ruoyi.hrm.mapper.HrmEmployeeMapper;
import com.ruoyi.hrm.mapper.HrmLeaveReqMapper;
import com.ruoyi.hrm.mapper.HrmReimburseReqMapper;
import com.ruoyi.hrm.mapper.HrmSealReqMapper;
import com.ruoyi.hrm.mapper.HrmTravelReqMapper;
import com.ruoyi.system.mapper.SysUserMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
@RequiredArgsConstructor
@RestController
@RequestMapping("/hrm/my-apply")
public class HrmMyApplyController extends BaseController {
private final HrmEmployeeMapper employeeMapper;
private final SysUserMapper sysUserMapper;
private final HrmLeaveReqMapper leaveReqMapper;
private final HrmTravelReqMapper travelReqMapper;
private final HrmSealReqMapper sealReqMapper;
private final HrmReimburseReqMapper reimburseReqMapper;
private final HrmAppropriationReqMapper appropriationReqMapper;
@GetMapping("/list")
public TableDataInfo<HrmMyApplyVo> list(String bizType, String status, String keyword, PageQuery pageQuery) {
Long currentUserId = LoginHelper.getUserId();
if (currentUserId == null) {
return TableDataInfo.build();
}
HrmEmployee emp = employeeMapper.selectOne(new com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<HrmEmployee>()
.eq(HrmEmployee::getUserId, currentUserId));
if (emp == null) {
return TableDataInfo.build();
}
SysUser sysUser = sysUserMapper.selectUserById(emp.getUserId());
String nickName = sysUser != null ? sysUser.getNickName() : null;
List<HrmMyApplyVo> all = new ArrayList<>();
if (bizType == null || bizType.isEmpty() || "leave".equals(bizType)) {
all.addAll(mapLeave(leaveReqMapper.selectVoWithProjectList(buildLeaveBo(emp.getEmpId(), status)), nickName));
}
if (bizType == null || bizType.isEmpty() || "travel".equals(bizType)) {
all.addAll(mapTravel(travelReqMapper.selectVoWithProjectList(buildTravelBo(emp.getEmpId(), status)), nickName));
}
if (bizType == null || bizType.isEmpty() || "seal".equals(bizType)) {
all.addAll(mapSeal(sealReqMapper.selectVoWithProjectList(buildSealBo(emp.getEmpId(), status)), nickName));
}
if (bizType == null || bizType.isEmpty() || "reimburse".equals(bizType)) {
all.addAll(mapReimburse(reimburseReqMapper.selectVoWithProjectList(buildReimburseBo(emp.getEmpId(), status)), nickName));
}
if (bizType == null || bizType.isEmpty() || "appropriation".equals(bizType)) {
all.addAll(mapAppropriation(appropriationReqMapper.selectVoWithProjectList(buildAppropriationBo(emp.getEmpId(), status)), nickName));
}
if (keyword != null && !keyword.isEmpty()) {
String lower = keyword.toLowerCase();
all = all.stream().filter(v -> contains(v, lower)).collect(Collectors.toList());
}
all.sort(Comparator.comparing(HrmMyApplyVo::getCreateTime, Comparator.nullsLast(Comparator.naturalOrder())).reversed());
long start = (pageQuery.getPageNum() - 1L) * pageQuery.getPageSize();
long end = Math.min(start + pageQuery.getPageSize(), all.size());
Page<HrmMyApplyVo> page = new Page<>(pageQuery.getPageNum(), pageQuery.getPageSize(), all.size());
page.setRecords(start >= all.size() ? new ArrayList<>() : all.subList((int) start, (int) end));
return TableDataInfo.build(page);
}
private boolean contains(HrmMyApplyVo v, String lower) {
return Objects.toString(v.getTitle(), "").toLowerCase().contains(lower)
|| Objects.toString(v.getRemark(), "").toLowerCase().contains(lower)
|| Objects.toString(v.getNickName(), "").toLowerCase().contains(lower)
|| Objects.toString(v.getEmpName(), "").toLowerCase().contains(lower)
|| Objects.toString(v.getBizId(), "").contains(lower);
}
private HrmLeaveReqBo buildLeaveBo(Long empId, String status) { HrmLeaveReqBo bo = new HrmLeaveReqBo(); bo.setEmpId(empId); bo.setStatus(status); return bo; }
private HrmTravelReqBo buildTravelBo(Long empId, String status) { HrmTravelReqBo bo = new HrmTravelReqBo(); bo.setEmpId(empId); bo.setStatus(status); return bo; }
private HrmSealReqBo buildSealBo(Long empId, String status) { HrmSealReqBo bo = new HrmSealReqBo(); bo.setEmpId(empId); bo.setStatus(status); return bo; }
private HrmReimburseReqBo buildReimburseBo(Long empId, String status) { HrmReimburseReqBo bo = new HrmReimburseReqBo(); bo.setEmpId(empId); bo.setStatus(status); return bo; }
private HrmAppropriationReqBo buildAppropriationBo(Long empId, String status) { HrmAppropriationReqBo bo = new HrmAppropriationReqBo(); bo.setEmpId(empId); bo.setStatus(status); return bo; }
private List<HrmMyApplyVo> mapLeave(List<HrmLeaveReqVo> list, String nickName) { return list.stream().map(v -> toVo("leave", v.getBizId(), v.getEmpId(), nickName, v.getReason(), v.getStatus(), v.getCreateTime())).collect(Collectors.toList()); }
private List<HrmMyApplyVo> mapTravel(List<HrmTravelReqVo> list, String nickName) { return list.stream().map(v -> toVo("travel", v.getBizId(), v.getEmpId(), nickName, v.getReason(), v.getStatus(), v.getCreateTime())).collect(Collectors.toList()); }
private List<HrmMyApplyVo> mapSeal(List<HrmSealReqVo> list, String nickName) { return list.stream().map(v -> toVo("seal", v.getBizId(), v.getEmpId(), nickName, v.getRemark(), v.getStatus(), v.getCreateTime())).collect(Collectors.toList()); }
private List<HrmMyApplyVo> mapReimburse(List<HrmReimburseReqVo> list, String nickName) { return list.stream().map(v -> toVo("reimburse", v.getBizId(), v.getEmpId(), nickName, v.getReason(), v.getStatus(), v.getCreateTime())).collect(Collectors.toList()); }
private List<HrmMyApplyVo> mapAppropriation(List<HrmAppropriationReqVo> list, String nickName) { return list.stream().map(v -> toVo("appropriation", v.getBizId(), v.getEmpId(), nickName, v.getReason(), v.getStatus(), v.getCreateTime())).collect(Collectors.toList()); }
private HrmMyApplyVo toVo(String bizType, Long bizId, Long empId, String nickName, String title, String status, java.util.Date createTime) {
HrmMyApplyVo vo = new HrmMyApplyVo();
vo.setBizType(bizType);
vo.setBizId(bizId);
vo.setEmpId(empId);
vo.setNickName(nickName);
vo.setTitle(title);
vo.setStatus(status);
vo.setCreateTime(createTime);
return vo;
}
}

View File

@@ -6,6 +6,7 @@ import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.helper.LoginHelper;
import com.ruoyi.hrm.domain.bo.HrmReimburseReqBo;
import com.ruoyi.hrm.domain.vo.HrmReimburseReqVo;
import com.ruoyi.hrm.service.IHrmReimburseReqService;
@@ -31,6 +32,7 @@ public class HrmReimburseReqController extends BaseController {
@GetMapping("/list")
public TableDataInfo<HrmReimburseReqVo> list(HrmReimburseReqBo bo, PageQuery pageQuery) {
bo.setCreateBy(LoginHelper.getUsername());
return service.queryPageList(bo, pageQuery);
}
@@ -59,6 +61,7 @@ public class HrmReimburseReqController extends BaseController {
@GetMapping("/all")
public R<List<HrmReimburseReqVo>> all(HrmReimburseReqBo bo) {
bo.setCreateBy(LoginHelper.getUsername());
return R.ok(service.queryList(bo));
}
}

View File

@@ -6,6 +6,7 @@ import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.helper.LoginHelper;
import com.ruoyi.hrm.domain.bo.HrmSealReqBo;
import com.ruoyi.hrm.domain.bo.HrmSealStampBo;
import com.ruoyi.hrm.domain.vo.HrmSealReqVo;
@@ -32,6 +33,7 @@ public class HrmSealReqController extends BaseController {
@GetMapping("/list")
public TableDataInfo<HrmSealReqVo> list(HrmSealReqBo bo, PageQuery pageQuery) {
bo.setCreateBy(LoginHelper.getUsername());
return service.queryPageList(bo, pageQuery);
}

View File

@@ -1,12 +1,12 @@
package com.ruoyi.hrm.controller;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.AjaxResult;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.helper.LoginHelper;
import com.ruoyi.hrm.domain.bo.HrmTravelReqBo;
import com.ruoyi.hrm.domain.vo.HrmTravelReqVo;
import com.ruoyi.hrm.service.IHrmTravelReqService;
@@ -40,6 +40,7 @@ public class HrmTravelReqController extends BaseController {
@GetMapping("/list")
public TableDataInfo<HrmTravelReqVo> list(HrmTravelReqBo bo, PageQuery pageQuery) {
bo.setCreateBy(LoginHelper.getUsername());
return service.queryPageList(bo, pageQuery);
}
@@ -82,6 +83,7 @@ public class HrmTravelReqController extends BaseController {
@GetMapping("/all")
public R<List<HrmTravelReqVo>> all(HrmTravelReqBo bo) {
bo.setCreateBy(LoginHelper.getUsername());
return R.ok(service.queryList(bo));
}
}

View File

@@ -0,0 +1,24 @@
package com.ruoyi.hrm.domain.vo;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@Data
public class HrmMyApplyVo implements Serializable {
private static final long serialVersionUID = 1L;
private String bizType;
private Long bizId;
private Long empId;
private String empName;
private Long userId;
private String nickName;
private String title;
private String status;
private Date createTime;
private Date endTime;
private Date actualEndTime;
private String remark;
}

View File

@@ -15,6 +15,8 @@ public interface IHrmEmployeeService {
List<HrmEmployeeVo> queryList(HrmEmployeeBo bo);
HrmEmployeeVo queryByUserId(Long userId);
Boolean insertByBo(HrmEmployeeBo bo);
Boolean updateByBo(HrmEmployeeBo bo);

View File

@@ -0,0 +1,9 @@
package com.ruoyi.hrm.service;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.hrm.domain.vo.HrmMyApplyVo;
public interface IHrmMyApplyService {
TableDataInfo<HrmMyApplyVo> queryPageList(String bizType, String status, String keyword, PageQuery pageQuery);
}

View File

@@ -29,6 +29,11 @@ public class HrmEmployeeServiceImpl implements IHrmEmployeeService {
return baseMapper.selectVoById(empId);
}
@Override
public HrmEmployeeVo queryByUserId(Long userId) {
return baseMapper.selectVoOne(Wrappers.<HrmEmployee>lambdaQuery().eq(HrmEmployee::getUserId, userId));
}
@Override
public TableDataInfo<HrmEmployeeVo> queryPageList(HrmEmployeeBo bo, PageQuery pageQuery) {
LambdaQueryWrapper<HrmEmployee> lqw = buildQueryWrapper(bo);

View File

@@ -73,6 +73,12 @@
<artifactId>xxl-job-core</artifactId>
</dependency>
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>fad-hrm</artifactId>
</dependency>
</dependencies>

View File

@@ -12,6 +12,7 @@ import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.oa.domain.bo.OaProjectReportBo;
import com.ruoyi.oa.domain.vo.OaProjectReportVo;
import com.ruoyi.oa.domain.vo.OaProjectTravelCompareVo;
import com.ruoyi.oa.domain.vo.ProjectReportCardVo;
import com.ruoyi.oa.domain.vo.ProjectReportPieVo;
import com.ruoyi.oa.domain.vo.ProjectReportTrendVo;
@@ -51,6 +52,15 @@ public class OaProjectReportController extends BaseController {
return iOaProjectReportService.queryPageList(bo, pageQuery);
}
@GetMapping("/travel-compare")
public TableDataInfo<OaProjectTravelCompareVo> travelCompare(@RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate start,
@RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate end,
@RequestParam(required = false) String nickName,
@RequestParam(required = false) String workPlace,
PageQuery pageQuery) {
return iOaProjectReportService.getTravelCompareList(start, end, nickName, workPlace, pageQuery);
}
/**
* 查询项目报工列表
*/

View File

@@ -0,0 +1,47 @@
package com.ruoyi.oa.domain.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDate;
/**
* 报工出差比对结果
*/
@Data
public class OaProjectTravelCompareVo implements Serializable {
private static final long serialVersionUID = 1L;
/** 用户昵称 */
private String nickName;
/** 比对日期(一天) */
@JsonFormat(pattern = "yyyy-MM-dd")
private LocalDate compareDate;
/** 是否出差 */
private Long isTrip;
/** 是否出差(中文) */
private String trip;
/** 报工地点 */
private String workPlace;
/** 实际出差地点 */
private String travelPlace;
/** 机器比对结果 */
private String compareResult;
/** 是否通过 */
private Boolean pass;
/** 出差记录ID */
private Long travelBizId;
/** 报工ID */
private Long reportId;
}

View File

@@ -52,5 +52,11 @@ public interface OaProjectReportMapper extends BaseMapperPlus<OaProjectReportMap
List<OaProjectReportVo> getClearList(@Param("start") LocalDate start, @Param("end") LocalDate end);
Page<OaProjectReportVo> selectTravelCompareReportPage(@Param("page") Page<OaProjectReportVo> page,
@Param("start") LocalDate start,
@Param("end") LocalDate end,
@Param("nickName") String nickName,
@Param("workPlace") String workPlace);
List<OaProjectReportVo> getSummaryData(@Param("start") LocalDate start, @Param("end") LocalDate end);
}

View File

@@ -1,78 +1,48 @@
package com.ruoyi.oa.service;
import com.ruoyi.oa.domain.vo.OaProjectReportVo;
import com.ruoyi.oa.domain.bo.OaProjectReportBo;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.oa.domain.bo.OaProjectReportBo;
import com.ruoyi.oa.domain.vo.OaProjectReportVo;
import com.ruoyi.oa.domain.vo.OaProjectTravelCompareVo;
import com.ruoyi.oa.domain.vo.ProjectReportCardVo;
import com.ruoyi.oa.domain.vo.ProjectReportPieVo;
import com.ruoyi.oa.domain.vo.ProjectReportTrendVo;
import java.time.LocalDate;
import java.util.Collection;
import java.util.List;
/**
* 项目报工Service接口
*
* @author hdka
* @date 2025-06-16
*/
public interface IOaProjectReportService {
/**
* 查询项目报工
*/
OaProjectReportVo queryById(Long reportId);
/**
* 查询项目报工列表
*/
TableDataInfo<OaProjectReportVo> queryPageList(OaProjectReportBo bo, PageQuery pageQuery);
/**
* 查询项目报工列表
*/
List<OaProjectReportVo> queryList(OaProjectReportBo bo);
/**
* 新增项目报工
*/
Boolean insertByBo(OaProjectReportBo bo);
/**
* 修改项目报工
*/
Boolean updateByBo(OaProjectReportBo bo);
/**
* 校验并批量删除项目报工信息
*/
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
/**
* 报工数据看板
* @return
*/
ProjectReportCardVo getCardData();
public List<ProjectReportTrendVo> getTrend(LocalDate start, LocalDate end);
public List<ProjectReportPieVo> getDistribution(LocalDate start, LocalDate end);
List<OaProjectReportVo> getRankData(LocalDate start, LocalDate end);
List<OaProjectReportVo> getProjects(LocalDate start, LocalDate end);
List<OaProjectReportVo> clearList(LocalDate start, LocalDate end);
OaProjectReportVo queryById(Long reportId);
Boolean insertByBo(OaProjectReportBo bo);
Boolean updateByBo(OaProjectReportBo bo);
Boolean deleteWithValidByIds(List<Long> ids, Boolean isValid);
List<OaProjectReportVo> getRankData(LocalDate start, LocalDate end);
ProjectReportCardVo getCardData();
List<ProjectReportTrendVo> getTrend(LocalDate start, LocalDate end);
List<ProjectReportPieVo> getDistribution(LocalDate start, LocalDate end);
List<OaProjectReportVo> getProjects(LocalDate start, LocalDate end);
List<OaProjectReportVo> getSummaryData(LocalDate start, LocalDate end);
/**
* 查询当前登录用户今日的报工记录
*/
OaProjectReportVo getTodayReportByCurrentUser();
Boolean insertReportSupplement(OaProjectReportBo bo);
TableDataInfo<OaProjectTravelCompareVo> getTravelCompareList(LocalDate start, LocalDate end, String nickName, String workPlace, PageQuery pageQuery);
}

View File

@@ -1,30 +1,35 @@
package com.ruoyi.oa.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.helper.LoginHelper;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.domain.PageQuery;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.hrm.domain.bo.HrmTravelReqBo;
import com.ruoyi.hrm.domain.vo.HrmTravelReqVo;
import com.ruoyi.hrm.service.IHrmTravelReqService;
import com.ruoyi.oa.domain.OaProjectReport;
import com.ruoyi.oa.domain.bo.OaProjectReportBo;
import com.ruoyi.oa.domain.vo.OaProjectReportVo;
import com.ruoyi.oa.domain.vo.OaProjectTravelCompareVo;
import com.ruoyi.oa.domain.vo.ProjectReportCardVo;
import com.ruoyi.oa.domain.vo.ProjectReportPieVo;
import com.ruoyi.oa.domain.vo.ProjectReportTrendVo;
import lombok.RequiredArgsConstructor;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;
import com.ruoyi.oa.domain.bo.OaProjectReportBo;
import com.ruoyi.oa.domain.vo.OaProjectReportVo;
import com.ruoyi.oa.domain.OaProjectReport;
import com.ruoyi.oa.mapper.OaProjectReportMapper;
import com.ruoyi.oa.service.IOaProjectReportService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* 项目报工Service业务层处理
@@ -37,6 +42,7 @@ import java.util.*;
public class OaProjectReportServiceImpl implements IOaProjectReportService {
private final OaProjectReportMapper baseMapper;
private final IHrmTravelReqService hrmTravelReqService;
/**
* 查询项目报工
@@ -64,6 +70,77 @@ public class OaProjectReportServiceImpl implements IOaProjectReportService {
return baseMapper.selectAll(bo);
}
@Override
public TableDataInfo<OaProjectTravelCompareVo> getTravelCompareList(LocalDate start, LocalDate end, String nickName, String workPlace, PageQuery pageQuery) {
int pageNum = pageQuery.getPageNum() == null || pageQuery.getPageNum() <= 0 ? 1 : pageQuery.getPageNum();
int pageSize = pageQuery.getPageSize() == null || pageQuery.getPageSize() <= 0 ? 50 : pageQuery.getPageSize();
Page<OaProjectReportVo> page = new Page<>(pageNum, pageSize);
Page<OaProjectReportVo> reportPage = baseMapper.selectTravelCompareReportPage(page, start, end, nickName, workPlace);
List<OaProjectReportVo> reportList = reportPage.getRecords();
List<OaProjectTravelCompareVo> rows = new ArrayList<>();
List<HrmTravelReqVo> travelList = hrmTravelReqService.queryList(new HrmTravelReqBo());
for (OaProjectReportVo report : reportList) {
OaProjectTravelCompareVo vo = new OaProjectTravelCompareVo();
vo.setNickName(report.getNickName());
vo.setCompareDate(toLocalDate(report.getCreateTime()));
vo.setWorkPlace(safeString(report.getWorkPlace()));
vo.setReportId(report.getReportId());
vo.setIsTrip(report.getIsTrip());
vo.setTrip(report.getTrip());
if (report.getIsTrip() == null || report.getIsTrip() != 1) {
vo.setTravelPlace("无出差记录");
vo.setPass(false);
vo.setCompareResult("该员工未出差");
rows.add(vo);
continue;
}
HrmTravelReqVo matchedTravel = null;
LocalDate reportDate = vo.getCompareDate();
if (reportDate != null) {
for (HrmTravelReqVo travel : travelList) {
if (travel.getEmpId() == null || report.getUserId() == null || !travel.getEmpId().equals(report.getUserId())) {
continue;
}
if (travel.getStartTime() == null) {
continue;
}
LocalDate travelStart = toLocalDate(travel.getStartTime());
LocalDate travelEnd = toLocalDate(travel.getActualEndTime() != null ? travel.getActualEndTime() : travel.getEndTime());
if (travelStart == null || travelEnd == null) {
continue;
}
if (!reportDate.isBefore(travelStart) && !reportDate.isAfter(travelEnd)) {
matchedTravel = travel;
break;
}
}
}
if (matchedTravel == null) {
vo.setTravelPlace("无出差记录");
vo.setPass(false);
vo.setCompareResult("该员工未出差");
} else {
String travelPlace = safeString(matchedTravel.getDestination());
boolean pass = isLocationMatched(vo.getWorkPlace(), travelPlace);
vo.setTravelPlace(travelPlace);
vo.setPass(pass);
vo.setCompareResult(pass ? "通过" : "异常");
vo.setTravelBizId(matchedTravel.getBizId());
}
rows.add(vo);
}
TableDataInfo<OaProjectTravelCompareVo> table = TableDataInfo.build();
table.setRows(rows);
table.setTotal(reportPage.getTotal());
return table;
}
private QueryWrapper<OaProjectReport> buildQueryWrapper(OaProjectReportBo bo) {
Map<String, Object> params = bo.getParams();
@@ -110,6 +187,45 @@ public class OaProjectReportServiceImpl implements IOaProjectReportService {
return lqw;
}
private LocalDate toLocalDate(Date date) {
if (date == null) return null;
return date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
}
private String safeString(String value) {
return value == null ? "" : value.trim();
}
private boolean isLocationMatched(String a, String b) {
if (StringUtils.isBlank(a) || StringUtils.isBlank(b)) {
return false;
}
String left = normalizeLocation(a);
String right = normalizeLocation(b);
return !left.isEmpty() && left.equals(right);
}
private String normalizeLocation(String value) {
String normalized = value.trim();
if (normalized.length() >= 2) {
normalized = normalized.substring(0, 2);
}
return normalized;
}
private <T> TableDataInfo<T> toPage(List<T> list, PageQuery pageQuery) {
int pageNum = pageQuery.getPageNum() == null || pageQuery.getPageNum() <= 0 ? 1 : pageQuery.getPageNum();
int pageSize = pageQuery.getPageSize() == null || pageQuery.getPageSize() <= 0 ? 50 : pageQuery.getPageSize();
long total = list.size();
int fromIndex = Math.min((pageNum - 1) * pageSize, list.size());
int toIndex = Math.min(fromIndex + pageSize, list.size());
List<T> records = list.subList(fromIndex, toIndex);
TableDataInfo<T> tableDataInfo = TableDataInfo.build();
tableDataInfo.setRows(records);
tableDataInfo.setTotal(total);
return tableDataInfo;
}
/**
* 新增项目报工
*/
@@ -168,7 +284,7 @@ public class OaProjectReportServiceImpl implements IOaProjectReportService {
* 批量删除项目报工
*/
@Override
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
public Boolean deleteWithValidByIds(List<Long> ids, Boolean isValid) {
if(isValid){
//TODO 做一些业务上的校验,判断是否需要校验
}

View File

@@ -195,11 +195,54 @@
left join sys_user su on su.user_id = opr.user_id
left join sys_dept sd on su.dept_id = sd.dept_id
WHERE opr.del_flag = 0
AND DATE(opr.create_time)
BETWEEN DATE_FORMAT(#{start}, '%Y-%m-%d')
AND DATE_FORMAT(#{end}, '%Y-%m-%d')
<if test="start != null">
AND DATE(opr.create_time) &gt;= DATE_FORMAT(#{start}, '%Y-%m-%d')
</if>
<if test="end != null">
AND DATE(opr.create_time) &lt;= DATE_FORMAT(#{end}, '%Y-%m-%d')
</if>
ORDER BY opr.create_time DESC
</select>
<select id="selectTravelCompareReportPage" resultType="com.ruoyi.oa.domain.vo.OaProjectReportVo">
select opr.report_id,
opr.user_id,
opr.is_trip,
opr.work_place,
opr.project_id,
opr.content,
opr.create_time,
opr.create_by,
opr.update_time,
opr.update_by,
opr.del_flag,
opr.remark,
op.project_name,
op.project_num,
op.project_code,
su.nick_name,
opr.work_type,
sd.dept_name
from oa_project_report opr
left join sys_oa_project op on opr.project_id = op.project_id
left join sys_user su on su.user_id = opr.user_id
left join sys_dept sd on su.dept_id = sd.dept_id
<where>
opr.del_flag = 0
<if test="start != null">
AND DATE(opr.create_time) &gt;= DATE_FORMAT(#{start}, '%Y-%m-%d')
</if>
<if test="end != null">
AND DATE(opr.create_time) &lt;= DATE_FORMAT(#{end}, '%Y-%m-%d')
</if>
<if test="nickName != null and nickName != ''">
AND su.nick_name LIKE CONCAT('%', #{nickName}, '%')
</if>
<if test="workPlace != null and workPlace != ''">
AND opr.work_place LIKE CONCAT('%', #{workPlace}, '%')
</if>
</where>
ORDER BY opr.create_time DESC
LIMIT 20
</select>
<select id="getSummaryData" resultType="com.ruoyi.oa.domain.vo.OaProjectReportVo">

View File

@@ -0,0 +1,9 @@
import request from '@/utils/request'
export function listMyApply(query) {
return request({
url: '/hrm/my-apply/list',
method: 'get',
params: query
})
}

View File

@@ -0,0 +1,18 @@
import request from '@/utils/request'
export function listTravelCompare (start, end, nickName, workPlace, pageNum, pageSize) {
return request({
url: '/oa/projectReport/travel-compare',
method: 'get',
params: {
...(start ? { start } : {}),
...(end ? { end } : {}),
...(nickName ? { nickName } : {}),
...(workPlace ? { workPlace } : {}),
pageNum,
pageSize,
orderByColumn: 'compareDate',
isAsc: 'desc'
}
})
}

View File

@@ -0,0 +1,323 @@
<template>
<div class="my-apply-page">
<section class="stats-strip">
<el-card shadow="never" class="stat-card">
<div class="stat-label">总申请</div>
<div class="stat-value">{{ summary.total }}</div>
</el-card>
<el-card shadow="never" class="stat-card">
<div class="stat-label">审批中</div>
<div class="stat-value warning">{{ summary.running }}</div>
</el-card>
<el-card shadow="never" class="stat-card">
<div class="stat-label">已通过</div>
<div class="stat-value success">{{ summary.approved }}</div>
</el-card>
</section>
<section class="filters">
<el-card shadow="never" class="filter-card">
<div class="filter-row">
<el-select v-model="query.bizType" placeholder="申请类型" clearable size="small" style="width: 130px" @change="handleFilterChange">
<el-option label="全部" value="" />
<el-option label="请假" value="leave" />
<el-option label="出差" value="travel" />
<el-option label="用印" value="seal" />
<el-option label="报销" value="reimburse" />
<el-option label="拨款" value="appropriation" />
</el-select>
<el-select v-model="query.status" placeholder="状态" clearable size="small" style="width: 130px" @change="handleFilterChange">
<el-option label="全部" value="" />
<el-option label="草稿" value="draft" />
<el-option label="审批中" value="running" />
<el-option label="已通过" value="approved" />
<el-option label="已驳回" value="rejected" />
<el-option label="已撤销" value="revoked" />
</el-select>
<el-input v-model="query.keyword" placeholder="输入申请标题/备注关键词" size="small" clearable style="width: 260px" @keyup.enter.native="handleFilterChange" />
<el-button type="primary" size="small" icon="el-icon-search" @click="handleFilterChange">查询</el-button>
<el-button size="small" icon="el-icon-refresh" @click="resetQuery">重置</el-button>
</div>
</el-card>
</section>
<section class="content">
<el-card shadow="never" class="table-card">
<div slot="header" class="card-header">
<span>申请列表</span>
<el-button size="mini" icon="el-icon-refresh" @click="loadList">刷新</el-button>
</div>
<el-table :data="list" v-loading="loading" stripe @row-dblclick="goDetail" empty-text="暂无申请记录">
<el-table-column label="申请类型" min-width="100">
<template slot-scope="scope">
<el-tag :type="getTypeTagType(scope.row.bizType)">{{ getTypeText(scope.row.bizType) }}</el-tag>
</template>
</el-table-column>
<el-table-column label="申请名称" min-width="240" show-overflow-tooltip>
<template slot-scope="scope">
{{ getRowTitle(scope.row) }}
</template>
</el-table-column>
<el-table-column label="发起人" min-width="140" show-overflow-tooltip>
<template slot-scope="scope">
{{ scope.row.nickName || '-' }}
</template>
</el-table-column>
<el-table-column label="状态" min-width="110">
<template slot-scope="scope">
<el-tag :type="statusType(scope.row)" size="small">{{ statusText(scope.row) }}</el-tag>
</template>
</el-table-column>
<el-table-column label="发起时间" prop="createTime" min-width="160">
<template slot-scope="scope">{{ formatDate(scope.row.createTime) }}</template>
</el-table-column>
<el-table-column label="操作" min-width="180" fixed="right">
<template slot-scope="scope">
<el-button type="text" size="mini" @click="goDetail(scope.row)">详情</el-button>
<el-button
v-if="showEarlyEndButton(scope.row)"
type="text"
size="mini"
style="color: #e6a23c"
:loading="earlyEndLoadingId === scope.row.bizId"
@click.stop="handleEarlyEnd(scope.row)"
>
提前结束
</el-button>
</template>
</el-table-column>
</el-table>
<div class="pagination-wrapper">
<el-pagination
:current-page="query.pageNum"
:page-size="query.pageSize"
:page-sizes="[10, 20, 50, 100]"
:total="total"
layout="total, sizes, prev, pager, next, jumper"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
/>
</div>
</el-card>
</section>
</div>
</template>
<script>
import { listMyApply } from '@/api/hrm/myApply'
import { earlyEndTravel } from '@/api/hrm/travel'
import applyTypeMinix from '@/views/hrm/minix/applyTypeMinix.js'
export default {
name: 'HrmMyApply',
mixins: [applyTypeMinix],
data () {
return {
loading: false,
earlyEndLoadingId: null,
list: [],
total: 0,
summary: {
total: 0,
running: 0,
approved: 0
},
query: {
pageNum: 1,
pageSize: 50,
bizType: '',
status: '',
keyword: ''
}
}
},
created () {
this.loadList()
},
methods: {
getRowTitle (row) {
return row.title || row.remark || '-'
},
isTravelCompleted (row) {
if (!row || row.bizType !== 'travel') return false
const endTime = row.endTime ? new Date(row.endTime).getTime() : 0
const now = Date.now()
return Boolean(row.actualEndTime) || (endTime && endTime <= now)
},
showEarlyEndButton (row) {
if (!row || row.bizType !== 'travel') return false
if (row.actualEndTime) return false
const endTime = row.endTime ? new Date(row.endTime).getTime() : 0
return row.status === 'approved' && endTime > Date.now()
},
statusText (row) {
const status = row?.status
if (row?.bizType === 'travel' && status === 'approved') {
return this.isTravelCompleted(row) ? '已完成' : '进行中'
}
const map = { draft: '草稿', running: '审批中', pending: '审批中', approved: '已通过', rejected: '已驳回', revoked: '已撤销', finished: '已完成' }
return map[status] || status || '-'
},
statusType (row) {
const status = row?.status
if (row?.bizType === 'travel' && status === 'approved') {
return this.isTravelCompleted(row) ? 'success' : 'warning'
}
const map = { draft: 'info', running: 'warning', pending: 'warning', approved: 'success', rejected: 'danger', revoked: 'danger', finished: 'success' }
return map[status] || 'info'
},
formatDate (val) {
if (!val) return ''
const d = new Date(val)
const p = n => (n < 10 ? `0${n}` : n)
return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}`
},
handleFilterChange () {
this.query.pageNum = 1
this.loadList()
},
resetQuery () {
this.query = { pageNum: 1, pageSize: 10, bizType: '', status: '', keyword: '' }
this.loadList()
},
async loadList () {
this.loading = true
try {
const res = await listMyApply({
pageNum: this.query.pageNum,
pageSize: this.query.pageSize,
bizType: this.query.bizType || undefined,
status: this.query.status || undefined,
keyword: this.query.keyword || undefined
})
this.list = res.rows || []
this.total = res.total || 0
this.summary.total = res.total || 0
this.summary.running = (res.rows || []).filter(i => ['running', 'pending'].includes(i.status) || (i.bizType === 'travel' && i.status === 'approved' && !this.isTravelCompleted(i))).length
this.summary.approved = (res.rows || []).filter(i => i.status === 'approved' && !(i.bizType === 'travel' && !this.isTravelCompleted(i))).length
} catch (err) {
console.error('加载我的申请失败:', err)
this.$message.error('加载我的申请失败')
this.list = []
this.total = 0
} finally {
this.loading = false
}
},
handleSizeChange (val) {
this.query.pageSize = val
this.query.pageNum = 1
this.loadList()
},
handleCurrentChange (val) {
this.query.pageNum = val
this.loadList()
},
async handleEarlyEnd (row) {
this.$confirm('确认提前结束本次出差吗?结束后的实际时间将记录为当前时间。', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(async () => {
this.earlyEndLoadingId = row.bizId
try {
await earlyEndTravel(row.bizId)
this.$message.success('提前结束成功')
await this.loadList()
} catch (error) {
this.$message.error(error.message || '提前结束失败')
} finally {
this.earlyEndLoadingId = null
}
}).catch(() => {})
},
goDetail (row) {
if (!row) return
const routeMap = {
leave: '/hrm/HrmLeaveDetail',
travel: '/hrm/HrmTravelDetail',
seal: '/hrm/HrmSealDetail',
reimburse: '/hrm/HrmReimburseDetail',
appropriation: '/hrm/HrmAppropriationDetail'
}
const path = routeMap[row.bizType]
if (!path) {
this.$message.warning('暂不支持该申请类型的详情页')
return
}
this.$router.push({ path, query: { bizId: row.bizId } })
}
}
}
</script>
<style lang="scss" scoped>
.my-apply-page {
padding: 16px 20px 32px;
background: #f8f9fb;
}
.stats-strip {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 12px;
margin-bottom: 16px;
}
.stat-card {
border: 1px solid #e6e8ed;
border-radius: 10px;
background: #fff;
text-align: center;
}
.stat-label {
font-size: 12px;
color: #8a8f99;
}
.stat-value {
margin-top: 4px;
font-size: 22px;
font-weight: 800;
color: #2b2f36;
}
.warning { color: #e6a23c; }
.success { color: #67c23a; }
.filter-card,
.table-card {
border: 1px solid #d7d9df;
border-radius: 10px;
}
.filter-row {
display: flex;
gap: 10px;
align-items: center;
flex-wrap: wrap;
}
.card-header {
display: flex;
align-items: center;
justify-content: space-between;
font-weight: 700;
color: #2b2f36;
}
.pagination-wrapper {
margin-top: 16px;
display: flex;
justify-content: flex-end;
}
@media (max-width: 1200px) {
.stats-strip {
grid-template-columns: 1fr;
}
}
</style>

View File

@@ -15,7 +15,6 @@
</el-button>
<span class="hint-text">提前结束将把当前时间记录为实际结束时间</span>
</div>
<!-- ===== 新增显示已提前结束的信息 ===== -->
<div v-if="detail.actualEndTime" class="early-end-info">
<el-alert
type="info"
@@ -26,6 +25,16 @@
</template>
</el-alert>
</div>
<div v-else-if="isTravelCompleted(detail)" class="early-end-info">
<el-alert
type="success"
:closable="false"
show-icon>
<template slot="default">
该出差已完成
</template>
</el-alert>
</div>
<!-- 出差时间与行程 -->
<div class="block-title">出差时间与行程</div>
<el-card class="inner-card" shadow="never">
@@ -95,14 +104,19 @@ export default {
const p = n => (n < 10 ? `0${n}` : n)
return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}`
},
// 新增:处理提前结束
showEarlyEndButton(detail) {
isTravelCompleted (detail) {
if (!detail) return false
const endTime = detail.endTime ? new Date(detail.endTime).getTime() : 0
const now = Date.now()
return Boolean(detail.actualEndTime) || (endTime && endTime <= now)
},
showEarlyEndButton(detail) {
if (!detail) return false
// 已经提前结束的不显示
if (detail.actualEndTime) return false
// 只有已通过或进行中状态才显示
const status = detail.status
return status === 'approved' || status === 'in_progress'
const endTime = detail.endTime ? new Date(detail.endTime).getTime() : 0
const now = Date.now()
return status === 'approved' && endTime > now
},
handleEarlyEnd() {
@@ -116,10 +130,8 @@ export default {
const bizId = this.currentBizId
await earlyEndTravel(bizId)
this.$message.success('提前结束成功')
// 刷新页面
setTimeout(() => {
location.reload()
}, 1000)
this.$emit('refresh')
this.$forceUpdate()
} catch (error) {
this.$message.error(error.message || '提前结束失败')
} finally {

View File

@@ -158,9 +158,47 @@
</div>
</div>
<!-- 进度板块 Tab1 进度明细表默认Tab2 原思维导图 + 图例 -->
<!-- 进度板块 与进度中心(step) 同款的简要信息条 + Tab -->
<div class="panel schedule-panel">
<el-tabs v-model="scheduleViewTab" class="schedule-panel-tabs">
<div v-if="currentProjectId" class="schedule-board-summary schedule-board-summary--pace-like">
<el-row>
<div>
<el-row>
<el-col :span="12">
<div style="font-size: small;">
<span style="color:#d0d0d0 ">项目名</span>
<el-popover placement="bottom" trigger="hover" width="800">
<template slot="reference">
<span style="color: #409eff;">{{ projectDisplayName }}</span>
</template>
<ProjectInfo :info="projectDetail || {}" />
</el-popover>
</div>
</el-col>
<el-col :span="12">
<div style="font-size: small;">
<span style="color:#d0d0d0 ">项目负责人</span>
<span>{{ projectManagerName }}</span>
</div>
</el-col>
<el-col :span="12">
<div style="font-size: small;">
<span style="color:#d0d0d0 ">当前进度</span>
<span>{{ dashboardScheduleSummary }}</span>
</div>
</el-col>
<el-col :span="12">
<div style="font-size: small;">
<span style="color:#d0d0d0 ">项目状态</span>
<span v-if="projectIsTop" style="color: #ff4d4f;">重点关注</span>
<span v-else>一般项目</span>
</div>
</el-col>
</el-row>
</div>
</el-row>
</div>
<el-tabs v-model="scheduleViewTab" class="schedule-panel-tabs" @tab-click="onScheduleTabClick">
<el-tab-pane label="进度明细" name="list">
<!-- 进度数据表格自然撑开高度 .progress-table-scroll 单独承担纵向/横向滚动 -->
<div class="progress-table-pane" v-loading="xmindLoading">
@@ -206,6 +244,7 @@
<el-empty :image-size="80" description="暂无进度步骤数据"></el-empty>
</div>
<xmind
ref="dashboardMindXmind"
v-else-if="scheduleViewTab === 'mind'"
:list="stepList"
height="100%"
@@ -243,10 +282,11 @@
<script>
import { mapState } from 'vuex'
import Xmind from '@/views/oa/project/pace/components/xmind.vue'
import ProjectInfo from '@/components/fad-service/ProjectInfo/index.vue'
export default {
name: 'OaProjectDashboard2',
components: { Xmind },
components: { Xmind, ProjectInfo },
dicts: ['sys_work_type', 'sys_sort_grade'],
data () {
return {
@@ -265,8 +305,31 @@ export default {
'projectTotal',
'taskQuery',
'taskList',
'stepList'
'stepList',
'projectDetail'
]),
projectDisplayName () {
const p = this.projectDetail
return (p && p.projectName) ? String(p.projectName) : ''
},
projectManagerName () {
const p = this.projectDetail
return (p && p.functionary) ? String(p.functionary) : ''
},
projectIsTop () {
const p = this.projectDetail
if (!p) return false
const top = p.isTop
return top === true || top === 1 || top === '1'
},
/** 与 pace/step 中 scheduleSummary 文案规则一致 */
dashboardScheduleSummary () {
const list = this.stepList || []
const totalCount = list.length
const completedCount = list.filter((item) => item.status === 2).length
const pendingCount = list.filter((item) => item.status === 1).length
return `已完成(${completedCount}+ 待验收(${pendingCount} / 总节点数(${totalCount}`
},
filteredTaskList () {
const list = this.taskList || []
const code = (this.taskQuery.projectCode || '').trim().toLowerCase()
@@ -304,6 +367,19 @@ export default {
this.getProjectList()
},
methods: {
/** 进度导图挂在 Tab 内,切换为可见后触发 ECharts 重新测量,避免线上画布宽/高为 0 */
onScheduleTabClick (tab) {
if (!tab || tab.name !== 'mind') return;
this.$nextTick(() => {
requestAnimationFrame(() => {
const comp = this.$refs.dashboardMindXmind;
if (comp && typeof comp.scheduleResize === 'function') {
comp.scheduleResize();
}
});
});
},
async getProjectList () {
this.projectLoading = true
try {
@@ -360,6 +436,16 @@ export default {
} finally {
this.pageLoading = false
this.xmindLoading = false
if (this.scheduleViewTab === 'mind') {
this.$nextTick(() => {
requestAnimationFrame(() => {
const comp = this.$refs.dashboardMindXmind
if (comp && typeof comp.scheduleResize === 'function') {
comp.scheduleResize()
}
})
})
}
}
},
@@ -666,16 +752,18 @@ export default {
padding: 0;
}
.schedule-panel-tabs {
flex: 1 1 0%;
min-height: 0;
display: flex;
flex-direction: column;
.schedule-board-summary--pace-like {
flex-shrink: 0;
padding: 10px 12px 8px;
border-bottom: 1px solid #ebeef5;
}
/* Element Tabs 根节点参与纵向 flex才能把剩余高度交给内容区 */
.schedule-panel-tabs :deep(.el-tabs) {
/*
* schedule-panel-tabs 与 .el-tabs 在同一 DOM 节点上,不能用「.schedule-panel-tabs :deep(.el-tabs)」后代选择器(永远匹配不到)。
* 生产包合并 CSS 后Element 全局 .el-tabs 可能后加载并盖住单独的 .schedule-panel-tabs导致 flex 丢失。
* 使用双类选择器提高命中与优先级。
*/
.schedule-panel-tabs.el-tabs {
flex: 1 1 0%;
min-height: 0;
display: flex;
@@ -683,13 +771,13 @@ export default {
height: 100%;
}
.schedule-panel-tabs :deep(.el-tabs__header) {
.schedule-panel-tabs.el-tabs :deep(.el-tabs__header) {
margin-bottom: 0;
padding: 0 12px;
flex-shrink: 0;
}
.schedule-panel-tabs :deep(.el-tabs__content) {
.schedule-panel-tabs.el-tabs :deep(.el-tabs__content) {
flex: 1 1 0%;
min-height: 0;
overflow: hidden;
@@ -699,9 +787,11 @@ export default {
}
/* 当前激活的 pane 占满内容区高度,子元素才能算出可滚动区域 */
.schedule-panel-tabs :deep(.el-tab-pane) {
.schedule-panel-tabs.el-tabs :deep(.el-tab-pane) {
flex: 1 1 0%;
min-height: 0;
min-width: 0;
width: 100%;
overflow: hidden;
display: flex;
flex-direction: column;
@@ -710,6 +800,8 @@ export default {
.schedule-tab-pane-inner {
flex: 1 1 0%;
min-height: 0;
min-width: 0;
width: 100%;
height: 100%;
box-sizing: border-box;
display: flex;
@@ -719,19 +811,24 @@ export default {
.schedule-tab-pane-inner--mind {
min-height: 280px;
overflow: hidden;
width: 100%;
min-width: 0;
}
/* 进度明细 Tab占满下方板块;内部仅滚动区参与滚动 */
/* 进度明细 Tab表格与面板四边留白,避免贴边 */
.progress-table-pane {
flex: 1 1 0%;
min-height: 0;
width: 100%;
height:300px;
height: 300px;
box-sizing: border-box;
display: flex;
flex-direction: column;
padding: 8px 12px 10px;
padding: 14px 18px 18px;
}
.progress-table-pane :deep(.el-empty) {
padding: 24px 8px;
}
.progress-table-scroll {
@@ -740,6 +837,8 @@ export default {
min-width: 0;
overflow: auto;
-webkit-overflow-scrolling: touch;
/* 表格与滚动容器边缘再留一线间距,滚动条不压表格边框 */
padding: 2px 4px 4px 2px;
}
.progress-step-el-table {
@@ -751,7 +850,10 @@ export default {
flex-direction: row;
align-items: stretch;
flex: 1;
flex-basis: 0;
min-height: 0;
min-width: 0;
width: 100%;
}
.task-table-wrap {
@@ -804,7 +906,7 @@ export default {
}
.xmind-wrap {
flex: 1;
flex: 1 1 0%;
min-width: 0;
position: relative;
padding: 0;

View File

@@ -106,7 +106,9 @@ export default {
return {
width: '100%',
height: this.height,
minHeight: this.dashboardMode ? '300px' : '240px'
minHeight: this.dashboardMode ? '300px' : '240px',
/* 看板嵌在横向 flex 内,避免 min-width:auto 把可用宽压成 0 */
...(this.dashboardMode ? { minWidth: 0, boxSizing: 'border-box' } : {})
}
}
},
@@ -118,37 +120,92 @@ export default {
clickEvent: null, // 新增:存储点击事件句柄,用于销毁解绑
users: [],
supplierList: [],
chartResizeObserver: null,
chartResizeObserverRaf: null
};
},
watch: {
// 监听列表数据变化,自动更新图表
list: {
deep: true,
handler () {
if (this.chartInstance) {
this.$nextTick(() => {
this.initChart();
}
});
}
}
},
mounted () {
this.initChart();
this.$nextTick(() => this.resizeChart());
this.deferResizeChart();
window.addEventListener('resize', this.resizeChart);
this.$nextTick(() => {
this.bindChartResizeObserver();
});
},
beforeDestroy () {
window.removeEventListener('resize', this.resizeChart);
// 新增解绑Echarts点击事件防止内存泄漏
this.unbindChartResizeObserver();
if (this.chartInstance && this.clickEvent) {
this.chartInstance.off('click', this.clickEvent);
}
// 销毁图表实例,防止内存泄漏
this.chartInstance?.dispose();
},
methods: {
// 优化:增加防抖处理-窗口自适应,避免频繁触发
resizeChart () {
this.chartInstance?.resize()
this.chartInstance?.resize();
},
/**
* 供综合看板在切换 Tab 后调用Tab 从 display:none 变为可见后需重新测量画布。
*/
scheduleResize () {
this.deferResizeChart();
},
/**
* el-tab / flex 布局下首帧常为 0 宽高,生产环境更明显;延迟到布局稳定后再 resize。
*/
deferResizeChart () {
this.$nextTick(() => {
this.$nextTick(() => {
requestAnimationFrame(() => {
this.resizeChart();
requestAnimationFrame(() => this.resizeChart());
});
});
});
},
bindChartResizeObserver () {
if (!this.dashboardMode || typeof ResizeObserver === 'undefined') {
return;
}
const el = this.$refs.chart;
if (!el) {
return;
}
this.unbindChartResizeObserver();
this.chartResizeObserver = new ResizeObserver(() => {
if (this.chartResizeObserverRaf != null) {
cancelAnimationFrame(this.chartResizeObserverRaf);
}
this.chartResizeObserverRaf = requestAnimationFrame(() => {
this.chartResizeObserverRaf = null;
this.resizeChart();
});
});
this.chartResizeObserver.observe(el);
},
unbindChartResizeObserver () {
if (this.chartResizeObserverRaf != null) {
cancelAnimationFrame(this.chartResizeObserverRaf);
this.chartResizeObserverRaf = null;
}
if (this.chartResizeObserver) {
this.chartResizeObserver.disconnect();
this.chartResizeObserver = null;
}
},
handleSubmit () {
@@ -288,11 +345,13 @@ export default {
};
},
// 初始化图表
initChart () {
// 初始化图表实例
const dom = this.$refs.chart;
if (!dom) {
return;
}
if (!this.chartInstance) {
this.chartInstance = echarts.init(this.$refs.chart);
this.chartInstance = echarts.init(dom);
}
// 重要:先解绑已有点击事件,防止多次绑定导致弹窗多次触发
if (this.clickEvent) {
@@ -422,8 +481,8 @@ export default {
}
]
};
// 渲染图表
this.chartInstance?.setOption(option, true);
this.deferResizeChart();
this.clickEvent = (params) => {
const data = params.data;
@@ -461,12 +520,16 @@ export default {
flex-direction: column;
height: 100%;
min-height: 0;
width: 100%;
min-width: 0;
}
/* 与综合看板折线图区域一致:白底、细边框、轻圆角 */
.xmind-box--dashboard .xmind-container {
flex: 1;
min-height: 0;
min-width: 0;
width: 100%;
background: #fff;
border: 1px solid #ebeef5;
border-radius: 6px;

View File

@@ -0,0 +1,239 @@
<template>
<div class="travel-compare-page">
<el-card shadow="never" class="filter-card">
<div class="filter-row">
<div class="filter-item">
<span class="filter-label">姓名</span>
<el-input
v-model="queryParams.nickName"
clearable
size="small"
placeholder="请输入姓名"
style="width: 180px"
/>
</div>
<div class="filter-item">
<span class="filter-label">地点</span>
<el-input
v-model="queryParams.workPlace"
clearable
size="small"
placeholder="请输入报工地点"
style="width: 200px"
/>
</div>
<div class="filter-item">
<span class="filter-label">时间</span>
<el-date-picker
v-model="dateRange"
type="daterange"
range-separator=""
start-placeholder="开始日期"
end-placeholder="结束日期"
value-format="yyyy-MM-dd"
size="small"
clearable
/>
</div>
<el-button type="primary" size="small" icon="el-icon-search" @click="handleQuery">查询</el-button>
<el-button size="small" icon="el-icon-refresh" @click="resetQuery">重置</el-button>
</div>
</el-card>
<el-card shadow="never" class="table-card">
<div slot="header" class="card-header">
<span>报工审核</span>
<el-button size="mini" icon="el-icon-refresh" @click="loadList">刷新</el-button>
</div>
<el-table :data="list" v-loading="loading" stripe empty-text="暂无比对记录">
<el-table-column label="姓名" prop="nickName" min-width="140" />
<el-table-column label="日期" prop="compareDate" min-width="120">
<template slot-scope="scope">{{ formatDate(scope.row.compareDate) }}</template>
</el-table-column>
<el-table-column label="是否出差" min-width="120">
<template slot-scope="scope">
{{ scope.row.isTrip === 1 ? '是' : '否' }}
</template>
</el-table-column>
<el-table-column label="报工地点" prop="workPlace" min-width="180" show-overflow-tooltip />
<el-table-column label="实际出差地点" prop="travelPlace" min-width="180" show-overflow-tooltip />
<el-table-column label="机器比对结果" min-width="140">
<template slot-scope="scope">
<span
:class="[
'result-tag',
scope.row.compareResult === '通过' ? 'pass' : (scope.row.compareResult === '异常' ? 'fail' : 'neutral')
]"
>
{{ scope.row.compareResult }}
</span>
</template>
</el-table-column>
</el-table>
<div class="pagination-wrap">
<el-pagination
background
:current-page="pageNum"
:page-size="pageSize"
:total="total"
layout="total, prev, pager, next, sizes, jumper"
:page-sizes="[10, 20, 50, 100]"
@current-change="handleCurrentChange"
@size-change="handleSizeChange"
/>
</div>
</el-card>
</div>
</template>
<script>
import { listTravelCompare } from '@/api/oa/projectCompare'
export default {
name: 'OaProjectTravelCompare',
data () {
return {
loading: false,
list: [],
total: 0,
pageNum: 1,
pageSize: 50,
dateRange: [],
queryParams: {
nickName: '',
workPlace: ''
}
}
},
created () {
this.loadList()
},
methods: {
formatDateOnly (date) {
const p = n => (n < 10 ? `0${n}` : `${n}`)
return `${date.getFullYear()}-${p(date.getMonth() + 1)}-${p(date.getDate())}`
},
formatDate (val) {
if (!val) return '-'
const d = new Date(val)
if (Number.isNaN(d.getTime())) return '-'
return this.formatDateOnly(d)
},
handleQuery () {
this.pageNum = 1
this.loadList()
},
async loadList () {
this.loading = true
try {
const [start, end] = this.dateRange || []
const res = await listTravelCompare(
start || null,
end || null,
this.queryParams.nickName,
this.queryParams.workPlace,
this.pageNum,
this.pageSize
)
this.list = res?.rows || []
this.total = res?.total || 0
} catch (err) {
console.error('加载报工审核失败:', err)
this.$message.error('加载报工审核失败')
this.list = []
this.total = 0
} finally {
this.loading = false
}
},
handleCurrentChange (pageNum) {
this.pageNum = pageNum
this.loadList()
},
handleSizeChange (pageSize) {
this.pageSize = pageSize
this.pageNum = 1
this.loadList()
},
resetQuery () {
this.pageNum = 1
this.pageSize = 50
this.queryParams.nickName = ''
this.queryParams.workPlace = ''
this.dateRange = []
this.loadList()
}
}
}
</script>
<style lang="scss" scoped>
.travel-compare-page {
padding: 16px 20px 32px;
}
.filter-card,
.table-card {
border: 1px solid #d7d9df;
border-radius: 10px;
margin-bottom: 16px;
}
.filter-row {
display: flex;
gap: 16px;
align-items: center;
flex-wrap: wrap;
}
.filter-item {
display: flex;
align-items: center;
gap: 8px;
}
.filter-label {
color: #606266;
font-size: 14px;
white-space: nowrap;
}
.card-header {
display: flex;
align-items: center;
justify-content: space-between;
font-weight: 700;
color: #2b2f36;
}
.pagination-wrap {
display: flex;
justify-content: flex-end;
margin-top: 16px;
}
.result-tag {
display: inline-block;
padding: 4px 10px;
border-radius: 4px;
font-size: 12px;
line-height: 1;
}
.pass {
background: #e8f7ee;
color: #1f8b4c;
}
.fail {
background: #fdecec;
color: #d93026;
}
.neutral {
background: #eef2f7;
color: #5c6b7a;
}
</style>