1 files added
18 files modified
| | |
| | | |
| | | /** |
| | | * 根据任务ID查询任务工时总和 |
| | | * @param taskId / |
| | | * @param id / |
| | | * @return / |
| | | */ |
| | | @Query(value = "SELECT COALESCE(SUM(project_cost), 0) AS totalLaborCost FROM project_cost WHERE project_id = ?1", nativeQuery = true) |
| | |
| | | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; |
| | | import org.springframework.data.jpa.repository.Query; |
| | | |
| | | import java.sql.Timestamp; |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | |
| | |
| | | public interface ProjectProgressRepository extends JpaRepository<ProjectProgress, Long>, JpaSpecificationExecutor<ProjectProgress> { |
| | | |
| | | |
| | | @Query(value = "SELECT * FROM project_progress WHERE project_id = ?1 ORDER BY create_time DESC", nativeQuery = true) |
| | | List<ProjectProgress> findByProjectId(Long id); |
| | | @Query(value = "SELECT * FROM project_progress WHERE project_id = ?1 AND belong_date < ?2 ORDER BY belong_date DESC", nativeQuery = true) |
| | | List<ProjectProgress> findByProjectId(Long id, Timestamp belongDate); |
| | | |
| | | /** |
| | | * 根据年度、周度、多项目ID查询 |
| | |
| | | @Query(value = "SELECT * FROM project_task WHERE project_id = ?1", nativeQuery = true) |
| | | List<ProjectTask> findByProjectId(Long id); |
| | | |
| | | @Query(value = "SELECT MIN(plan_start_time) AS taskStartDate, MAX(plan_end_time) AS taskEndDate, SUM(plan_hours) AS totalTaskTime FROM project_task WHERE project_id = ?1", nativeQuery = true) |
| | | @Query(value = "SELECT MIN(plan_start_time) AS taskStartDate, MAX(plan_end_time) AS taskEndDate, COALESCE(SUM(plan_hours), 0) AS totalTaskTime FROM project_task WHERE project_id = ?1", nativeQuery = true) |
| | | ProjectTaskSummary findSummaryByProjectId(Long id); |
| | | } |
| | |
| | | import me.zhengjie.modules.project.domain.ProjectCost; |
| | | import me.zhengjie.modules.project.service.dto.ProjectCostDto; |
| | | import me.zhengjie.modules.project.service.dto.ProjectCostQueryCriteria; |
| | | |
| | | import org.springframework.data.domain.Pageable; |
| | | |
| | | import java.text.ParseException; |
| | |
| | | import java.util.List; |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.sql.Timestamp; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | |
| | | */ |
| | | void download(List<ProjectCostDto> all, HttpServletResponse response) throws IOException; |
| | | |
| | | BigDecimal calcUserCostByDate(Long userId, String enterProjectTime, String exitProjectTime, Map<String, Double> costHoursMap) throws Exception; |
| | | BigDecimal calcUserCostByDate(Long userId, Timestamp enterProjectTime, Timestamp exitProjectTime, Map<String, Double> costHoursMap); |
| | | } |
| | |
| | | import java.util.Map; |
| | | import java.util.List; |
| | | import java.io.IOException; |
| | | import java.time.LocalDate; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | /** |
| | |
| | | * 生成周报 |
| | | * @param ids 项目ID |
| | | */ |
| | | void generateProjectProcess(Integer year, Integer weeks, Long[] ids); |
| | | void autoGenerateProjectProcess(LocalDate localDate, Integer year, Integer weeks); |
| | | |
| | | } |
| | |
| | | /** 预计进度 */ |
| | | private Double estimatedProgress; |
| | | |
| | | /** 上周预计进度 */ |
| | | private Double lastedProgress; |
| | | |
| | | /** 项目进度 */ |
| | | private Double projectProgress; |
| | | |
| | |
| | | /** 总消耗绩效工时 */ |
| | | private Double timeTotalCost; |
| | | |
| | | /** 本周消化绩效工时 */ |
| | | private Double timeLastCost; |
| | | |
| | | /** 实际消化工时 */ |
| | | private Double realLastCost; |
| | | |
| | |
| | | |
| | | /** 总消耗工作量 */ |
| | | private Double workTotalCost; |
| | | |
| | | /** 本周消化工作量 */ |
| | | private Double workLastCost; |
| | | |
| | | /** 计划总成本 */ |
| | | private BigDecimal moneyTotalInit; |
| | |
| | | @Data |
| | | public class ProjectProgressQueryCriteria { |
| | | |
| | | /** 模糊 */ |
| | | @Query(blurry = "project>name") |
| | | private String blurry; |
| | | /** 精确 */ |
| | | @Query(joinName = "project", propName = "id") |
| | | private Long projectId; |
| | | |
| | | /** 精确 */ |
| | | @Query(joinName = "project", propName = "projectDistinguish") |
| | |
| | | |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.sql.Timestamp; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.DayOfWeek; |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public ProjectCostDto create(ProjectCost resources) { |
| | | Project project = projectRepository.findByIdUpdate(resources.getProjectId()); |
| | | if(project.getApproveStatus().equals(Constant.APPROVE_STATUS_ACKNOWLEDGED)){ |
| | | throw new BadRequestException("项目已承认无法新增项目成本"); |
| | | } |
| | | return projectCostMapper.toDto(projectCostRepository.save(resources)); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void update(ProjectCost resources) { |
| | | Project project = projectRepository.findByIdUpdate(resources.getProjectId()); |
| | | if(project.getApproveStatus().equals(Constant.APPROVE_STATUS_ACKNOWLEDGED)){ |
| | | throw new BadRequestException("项目已承认无法修改项目成本"); |
| | | } |
| | | ProjectCost projectCost = projectCostRepository.findById(resources.getId()).orElseGet(ProjectCost::new); |
| | | ValidationUtil.isNull( projectCost.getId(),"ProjectCost","id",resources.getId()); |
| | | projectCost.copy(resources); |
| | |
| | | @Override |
| | | public void deleteAll(Long[] ids) { |
| | | for (Long id : ids) { |
| | | ProjectCost projectCost = projectCostRepository.findById(id).orElseGet(ProjectCost::new); |
| | | Project project = projectRepository.findByIdUpdate(projectCost.getProjectId()); |
| | | if(project.getApproveStatus().equals(Constant.APPROVE_STATUS_ACKNOWLEDGED)){ |
| | | throw new BadRequestException("项目已承认无法删除项目成本"); |
| | | } |
| | | projectCostRepository.deleteById(id); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public BigDecimal calcUserCostByDate(Long userId, String enterProjectTime, String exitProjectTime, Map<String, Double> costHoursMap) throws Exception { |
| | | public BigDecimal calcUserCostByDate(Long userId, Timestamp enterProjectTime, Timestamp exitProjectTime, Map<String, Double> costHoursMap) { |
| | | // 工资 |
| | | BigDecimal wageCost = BigDecimal.valueOf(0); |
| | | // 工作天数 |
| | | LocalDateTime enterProject = LocalDateTime.parse(enterProjectTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | | LocalDateTime exitProject = LocalDateTime.parse(exitProjectTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | | |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
| | | Date startDate = simpleDateFormat.parse(enterProjectTime); |
| | | Date endDate = simpleDateFormat.parse(exitProjectTime); |
| | | LocalDateTime enterProject = enterProjectTime.toLocalDateTime(); |
| | | LocalDateTime exitProject = exitProjectTime.toLocalDateTime(); |
| | | |
| | | // 通过id获取用户级别工资 |
| | | List<SysUserLevelWage> sysUserLevelWages = sysUserLevelWageRepository.findByUserId(userId) |
| | | .stream().filter(sysUserLevelWage -> !((sysUserLevelWage.getEndDate() != null && sysUserLevelWage.getEndDate().before(startDate)) || sysUserLevelWage.getStartDate().after(endDate))) |
| | | .stream().filter(sysUserLevelWage -> !((sysUserLevelWage.getEndDate() != null && sysUserLevelWage.getEndDate().before(enterProjectTime)) || sysUserLevelWage.getStartDate().after(exitProjectTime))) |
| | | .collect(Collectors.toList()); |
| | | // 通过id获取用户级别保险 |
| | | List<SysUserLevelInsurance> sysUserLevelInsurances = sysUserLevelInsuranceRepository.findByUserId(userId) |
| | | .stream().filter(sysUserLevelInsurance -> !((sysUserLevelInsurance.getEndDate() != null && sysUserLevelInsurance.getEndDate().before(startDate)) || sysUserLevelInsurance.getStartDate().after(endDate))) |
| | | .stream().filter(sysUserLevelInsurance -> !((sysUserLevelInsurance.getEndDate() != null && sysUserLevelInsurance.getEndDate().before(enterProjectTime)) || sysUserLevelInsurance.getStartDate().after(exitProjectTime))) |
| | | .collect(Collectors.toList()); |
| | | |
| | | // 判断是否有用户级别工资 |
| | |
| | | import java.time.LocalDate; |
| | | import java.time.temporal.WeekFields; |
| | | import java.util.ArrayList; |
| | | import java.util.Comparator; |
| | | import java.util.HashMap; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.List; |
| | |
| | | import me.zhengjie.modules.task.domain.Task; |
| | | import me.zhengjie.modules.task.domain.TaskDailyInterface; |
| | | import me.zhengjie.modules.task.domain.TaskDaliy; |
| | | import me.zhengjie.modules.task.domain.TaskInterface; |
| | | import me.zhengjie.modules.task.repository.TaskDaliyRepository; |
| | | import me.zhengjie.modules.task.repository.TaskRepository; |
| | | import me.zhengjie.utils.FileUtil; |
| | |
| | | public Map<String,Object> queryAll(ProjectProgressQueryCriteria criteria, Pageable pageable){ |
| | | Page<ProjectProgress> page = projectProgressRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder), pageable); |
| | | |
| | | // 当年第一周需满足四天。(例:2022年的第一周是从1月3号开始的,1号和2号并入到2021年度的最后一周里) |
| | | WeekFields wfs = WeekFields.of(DayOfWeek.MONDAY, 4); |
| | | |
| | | // 将实体类转换为DTO(重写) |
| | |
| | | public ProjectProgressDto apply(ProjectProgress projectProgress) { |
| | | // 将实体类转换成DTO |
| | | ProjectProgressDto projectProgressDto = projectProgressMapper.toDto(projectProgress); |
| | | // 根据项目ID查询项目信息 |
| | | // 获取前一周的周五 |
| | | LocalDate localDate = LocalDate.now() |
| | | .with(wfs.weekBasedYear(), projectProgress.getBelongYear()) |
| | | .with(wfs.weekOfWeekBasedYear(), projectProgress.getBelongWeek()) |
| | | .with(wfs.dayOfWeek(), 1L) |
| | | .with(wfs.dayOfWeek(), 5L) |
| | | .minusDays(7); |
| | | |
| | | // 获取前一周的项目进度信息 |
| | | Optional<ProjectProgress> projectProgressOpl = projectProgressRepository.findByBelongYearAndBelongWeekAndProjectId(localDate.get(wfs.weekBasedYear()), localDate.get(wfs.weekOfWeekBasedYear()), projectProgressDto.getProject().getId()); |
| | | projectProgressDto.setLastProjectProcess(projectProgressOpl.orElseGet(ProjectProgress::new)); |
| | | if (!projectProgressOpl.isPresent()) { |
| | | projectProgressDto.setTimeLastCost(projectProgressDto.getTimeTotalCost()); |
| | | projectProgressDto.setWorkLastCost(projectProgressDto.getWorkTotalCost()); |
| | | projectProgressDto.setLastedProgress(0.0); |
| | | } else { |
| | | if (projectProgressDto.getTimeTotalCost() != null) { |
| | | if (projectProgressOpl.get().getTimeTotalCost() != null) { |
| | | projectProgressDto.setTimeLastCost(projectProgressDto.getTimeTotalCost() - projectProgressOpl.get().getTimeTotalCost()); |
| | | } else { |
| | | projectProgressDto.setTimeLastCost(projectProgressDto.getTimeTotalCost()); |
| | | } |
| | | } |
| | | if (projectProgressDto.getWorkTotalCost() != null) { |
| | | if (projectProgressOpl.get().getWorkTotalCost() != null) { |
| | | projectProgressDto.setWorkLastCost(projectProgressDto.getWorkTotalCost() - projectProgressOpl.get().getWorkTotalCost()); |
| | | } else { |
| | | projectProgressDto.setWorkLastCost(projectProgressDto.getWorkTotalCost()); |
| | | } |
| | | } |
| | | projectProgressDto.setLastedProgress(projectProgressOpl.get().getEstimatedProgress() != null ? projectProgressOpl.get().getEstimatedProgress() : 0.0); |
| | | } |
| | | if (projectProgressDto.getProjectProgress() == null) { |
| | | projectProgressDto.setProjectProgress(0.0); |
| | | } |
| | |
| | | } |
| | | }; |
| | | return PageUtil.toPage(page.map(func)); |
| | | } |
| | | |
| | | @Override |
| | | public void generateProjectProcess(Integer year, Integer weeks, Long[] ids) { |
| | | |
| | | List<Project> projectList = null; |
| | | if (ids == null || ids.length == 0) { |
| | | projectList = projectRepository.findByProjectStatus(Constant.PROJECT_STATUS_UNDER_WAY); |
| | | } else { |
| | | projectList = projectRepository.findByProjectStatusAndIdIn(Constant.PROJECT_STATUS_UNDER_WAY, ids); |
| | | } |
| | | |
| | | WeekFields wfs = WeekFields.of(DayOfWeek.MONDAY, 4); |
| | | |
| | | // 根据项目ID查询项目信息 |
| | | LocalDate localDate = LocalDate.now() |
| | | .with(wfs.weekBasedYear(), year) |
| | | .with(wfs.weekOfWeekBasedYear(), weeks) |
| | | .with(wfs.dayOfWeek(), 1L) |
| | | .minusDays(7); |
| | | |
| | | projectList.forEach(project -> { |
| | | // 存在则更新,不存在则插入 |
| | | ProjectProgress projectProgress = projectProgressRepository.findByBelongYearAndBelongWeekAndProjectId(year, weeks, project.getId()).orElseGet(ProjectProgress::new); |
| | | if (projectProgress.getId() == null) { |
| | | projectProgress.setBelongYear(year); |
| | | projectProgress.setBelongWeek(weeks); |
| | | projectProgress.setBelongDate(Timestamp.valueOf(localDate.atStartOfDay())); |
| | | |
| | | projectProgress.setProject(project); |
| | | projectProgress.setApproveStatus(Constant.APPROVE_STATUS_UNRECOGNIZED); |
| | | } |
| | | |
| | | // 总工时 |
| | | Double timeTotalInit = 0.0; |
| | | // 总消化工时 |
| | | Double timeTotalCost = 0.0; |
| | | // 总工作量 |
| | | Double workTotalInit = 0.0; |
| | | // 总消耗工作量 |
| | | Double workTotalCost = 0.0; |
| | | // 真实时长 |
| | | Double realLastCost = 0.0; |
| | | List<Task> taskList = taskRepository.findByProjectIdUntilDate(project.getId(), projectProgress.getBelongDate()); |
| | | |
| | | List<TaskDaliy> taskDaliyList = taskDaliyRepository.findByProjectId(project.getId()); |
| | | Map<Long, List<TaskDaliy>> collectMap = taskDaliyList.stream().collect(Collectors.groupingBy(TaskDaliy::getUserId)); |
| | | |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | BigDecimal totalCost = BigDecimal.valueOf(0.0); |
| | | for (Entry<Long, List<TaskDaliy>> entry : collectMap.entrySet()) { |
| | | List<TaskDaliy> taskDaliyListSub = entry.getValue(); |
| | | Map<String, Double> costHourMap = new HashMap<String, Double>(); |
| | | taskDaliyListSub.forEach(taskDaliy -> { |
| | | costHourMap.put(sdf.format(taskDaliy.getFillDate()), taskDaliy.getConsumedHours()); |
| | | }); |
| | | String startDate = sdf.format(taskDaliyListSub.get(0).getFillDate()); |
| | | String endDate = sdf.format(taskDaliyListSub.get(taskDaliyListSub.size() - 1).getFillDate()); |
| | | try { |
| | | totalCost = totalCost.add(projectCostService.calcUserCostByDate(entry.getKey(), startDate + " 00:00:00", endDate + " 00:00:00", costHourMap)); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | for (Task task : taskList) { |
| | | timeTotalInit = timeTotalInit + task.getPlanHours(); |
| | | workTotalInit = workTotalInit + (task.getPlanWorkload() == null ? 0.0 : task.getPlanWorkload()); |
| | | TaskDailyInterface taskDailyInterface = taskDaliyRepository.collectTaskDaliyUntilDate(task.getId(), projectProgress.getBelongDate()); |
| | | if (Constant.TASK_STATUS_COMPLETED.equals(task.getTaskStatus())) { |
| | | timeTotalCost += BigDecimal.valueOf(task.getPlanHours()).multiply(BigDecimal.valueOf(taskDailyInterface.getTaskProgress())).divide(BigDecimal.valueOf(100), 2, BigDecimal.ROUND_CEILING).doubleValue(); |
| | | } else { |
| | | timeTotalCost += task.getPlanHours(); |
| | | } |
| | | workTotalCost += taskDailyInterface.getConsumedWorkload(); |
| | | realLastCost += taskDailyInterface.getConsumedHours(); |
| | | } |
| | | // 真实时长 |
| | | projectProgress.setRealLastCost(realLastCost); |
| | | // 总消化工时 |
| | | projectProgress.setTimeTotalCost(timeTotalCost); |
| | | // 总工时 |
| | | projectProgress.setTimeTotalInit(timeTotalInit); |
| | | // 总消耗工作量 |
| | | projectProgress.setWorkTotalCost(workTotalCost); |
| | | // 总工作量 |
| | | projectProgress.setWorkTotalInit(workTotalInit); |
| | | // 计划总成本 |
| | | projectProgress.setMoneyTotalInit(project.getPerformancePrice().multiply(BigDecimal.valueOf(timeTotalInit))); |
| | | // 总消耗成本 |
| | | projectProgress.setMoneyTotalCost(totalCost); |
| | | |
| | | // 存在则更新,不存在则插入 |
| | | projectProgressRepository.save(projectProgress); |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public ProjectProgressDto create(ProjectProgress resources) { |
| | | // 项目进度 check |
| | | checkProjectProgress(resources); |
| | | |
| | | // 项目是否已承认 |
| | | Project project = projectRepository.findByIdUpdate(resources.getProject().getId()); |
| | | if(project.getApproveStatus().equals(Constant.APPROVE_STATUS_UNRECOGNIZED)){ |
| | | throw new BadRequestException("项目未承认无法创建周报"); |
| | | } |
| | | resources.setProject(project); |
| | | |
| | | // 当年第一周需满足四天。(例:2022年的第一周是从1月3号开始的,1号和2号并入到2021年度的最后一周里) |
| | | WeekFields wfs = WeekFields.of(DayOfWeek.MONDAY, 4); |
| | | // 所属日未设定的场合,取对应周的周五 |
| | | if (resources.getBelongDate() == null) { |
| | | LocalDate localDate = LocalDate.now() |
| | | .with(wfs.weekBasedYear(), resources.getBelongYear()) |
| | | .with(wfs.weekOfWeekBasedYear(), resources.getBelongWeek()) |
| | | .with(wfs.dayOfWeek(), 1L); |
| | | .with(wfs.dayOfWeek(), 5L); |
| | | resources.setBelongDate(Timestamp.valueOf(localDate.atStartOfDay())); |
| | | } |
| | | return projectProgressMapper.toDto(projectProgressRepository.save(resources)); |
| | | return generalProjectProgress(resources); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void update(ProjectProgress resources) { |
| | | |
| | | ProjectProgress projectProgress = projectProgressRepository.findById(resources.getId()).orElseGet(ProjectProgress::new); |
| | | ValidationUtil.isNull( projectProgress.getId(),"ProjectProgress","id",resources.getId()); |
| | | |
| | | // 项目是否已承认 |
| | | Project project = projectRepository.findByIdUpdate(resources.getProject().getId()); |
| | | if(project.getApproveStatus().equals(Constant.APPROVE_STATUS_UNRECOGNIZED)){ |
| | | throw new BadRequestException("项目未承认无法创建周报"); |
| | | } |
| | | resources.setProject(project); |
| | | |
| | | // 周报是否已承认 |
| | | if(projectProgress.getApproveStatus().equals(Constant.APPROVE_STATUS_ACKNOWLEDGED)){ |
| | | throw new BadRequestException("周报已承认无法修改"); |
| | | } |
| | | |
| | | // 当年第一周需满足四天。(例:2022年的第一周是从1月3号开始的,1号和2号并入到2021年度的最后一周里) |
| | | WeekFields wfs = WeekFields.of(DayOfWeek.MONDAY, 4); |
| | | // 所属日未设定的场合,取对应周的周五 |
| | | if (resources.getBelongDate() == null) { |
| | | LocalDate localDate = LocalDate.now() |
| | | .with(wfs.weekBasedYear(), resources.getBelongYear()) |
| | | .with(wfs.weekOfWeekBasedYear(), resources.getBelongWeek()) |
| | | .with(wfs.dayOfWeek(), 5L); |
| | | resources.setBelongDate(Timestamp.valueOf(localDate.atStartOfDay())); |
| | | } |
| | | |
| | | projectProgress.copy(resources); |
| | | projectProgressRepository.save(projectProgress); |
| | | generalProjectProgress(resources); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void autoGenerateProjectProcess(LocalDate localDate, Integer year, Integer weeks) { |
| | | |
| | | // 获取所有的【进行中】的项目 |
| | | List<Project> projectList = projectRepository.findByProjectStatus(Constant.PROJECT_STATUS_UNDER_WAY); |
| | | |
| | | projectList.forEach(project -> { |
| | | // 存在则更新,不存在则插入 |
| | | ProjectProgress projectProgress = projectProgressRepository.findByBelongYearAndBelongWeekAndProjectId(year, weeks, project.getId()).orElseGet(ProjectProgress::new); |
| | | // 初始主键 |
| | | if (projectProgress.getId() == null) { |
| | | projectProgress.setBelongYear(year); |
| | | projectProgress.setBelongWeek(weeks); |
| | | projectProgress.setBelongDate(Timestamp.valueOf(localDate.atStartOfDay())); |
| | | |
| | | projectProgress.setProject(project); |
| | | projectProgress.setApproveStatus(Constant.APPROVE_STATUS_UNRECOGNIZED); |
| | | } |
| | | |
| | | // 如果已经承认则不需要更新 |
| | | if (Constant.APPROVE_STATUS_ACKNOWLEDGED.equals(projectProgress.getApproveStatus())) { |
| | | return; |
| | | } |
| | | |
| | | generalProjectProgress(projectProgress); |
| | | }); |
| | | } |
| | | |
| | | private ProjectProgressDto generalProjectProgress(ProjectProgress resources) { |
| | | |
| | | // 总消化工时 |
| | | Double timeTotalCost = 0.0; |
| | | // 总消耗工作量 |
| | | Double workTotalCost = 0.0; |
| | | // 真实时长 |
| | | Double realLastCost = 0.0; |
| | | List<TaskDailyInterface> taskDaliyWithTaskList = taskDaliyRepository.collectByProjectIdAndFillDateLessThanGroupByTaskIdJoinTask(resources.getProject().getId(), resources.getBelongDate()); |
| | | |
| | | for (TaskDailyInterface taskDaily : taskDaliyWithTaskList) { |
| | | // 总消化工时 |
| | | timeTotalCost += BigDecimal.valueOf(taskDaily.getPlanHours()).multiply(BigDecimal.valueOf(taskDaily.getTaskProgress())).divide(BigDecimal.valueOf(100), 2, BigDecimal.ROUND_CEILING).doubleValue(); |
| | | // 总消耗工作量 |
| | | workTotalCost += taskDaily.getConsumedWorkload(); |
| | | // 真实时长 |
| | | realLastCost += taskDaily.getConsumedHours(); |
| | | } |
| | | // 总消化工时 |
| | | resources.setTimeTotalCost(timeTotalCost); |
| | | // 总消耗工作量 |
| | | resources.setWorkTotalCost(workTotalCost); |
| | | // 真实时长 |
| | | resources.setRealLastCost(realLastCost); |
| | | |
| | | if (resources.getId() == null) { |
| | | // 根据项目ID取得任务信息 |
| | | TaskInterface taskTotal = taskRepository.collectByProjectId(resources.getProject().getId()); |
| | | // 总工时 |
| | | resources.setTimeTotalInit(taskTotal.getPlanHours()); |
| | | // 总工作量 |
| | | resources.setWorkTotalInit(taskTotal.getPlanWorkload()); |
| | | // 计划总成本 |
| | | resources.setMoneyTotalInit(resources.getProject().getPerformancePrice().multiply(BigDecimal.valueOf(taskTotal.getPlanHours()))); |
| | | } |
| | | |
| | | // 根据日期和项目ID取得日报信息 |
| | | List<TaskDailyInterface> taskDaliyList = taskDaliyRepository.collectByProjectIdAndFillDateLessThanGroupByUserIdAndFillDate(resources.getProject().getId(), resources.getBelongDate()); |
| | | Map<Long, List<TaskDailyInterface>> collectMap = taskDaliyList.stream().collect(Collectors.groupingBy(TaskDailyInterface::getUserId)); |
| | | |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | // 总消耗成本 |
| | | BigDecimal totalCost = BigDecimal.valueOf(0.0); |
| | | for (Entry<Long, List<TaskDailyInterface>> entry : collectMap.entrySet()) { |
| | | List<TaskDailyInterface> taskDaliyListSub = entry.getValue(); |
| | | // 最小日期 |
| | | TaskDailyInterface taskDaliyFirst = taskDaliyListSub.stream().min(Comparator.comparing(taskDaliy -> taskDaliy.getFillDate())).get(); |
| | | // 最大日期 |
| | | TaskDailyInterface taskDaliyLast = taskDaliyListSub.stream().max(Comparator.comparing(taskDaliy -> taskDaliy.getFillDate())).get(); |
| | | Map<String, Double> costHourMap = new HashMap<String, Double>(); |
| | | taskDaliyListSub.forEach(taskDaliy -> { |
| | | costHourMap.put(sdf.format(taskDaliy.getFillDate()), taskDaliy.getConsumedHours()); |
| | | }); |
| | | // 根据员工成本单金算出当前工作的成本 |
| | | totalCost = totalCost.add(projectCostService.calcUserCostByDate(entry.getKey(), new Timestamp(taskDaliyFirst.getFillDate().getTime()), new Timestamp(taskDaliyLast.getFillDate().getTime()), costHourMap)); |
| | | } |
| | | |
| | | // 总消耗成本 |
| | | resources.setMoneyTotalCost(totalCost); |
| | | |
| | | return projectProgressMapper.toDto(projectProgressRepository.save(resources)); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | map.put("总绩效工时", projectProgress.getTimeTotalInit()); |
| | | map.put("总消耗绩效工时", projectProgress.getTimeTotalCost()); |
| | | map.put("本周消化绩效工时", projectProgress.getTimeLastCost()); |
| | | map.put("实际消化工时", projectProgress.getRealLastCost()); |
| | | |
| | | map.put("总工作量", projectProgress.getWorkTotalInit()); |
| | | map.put("总消耗工作量", projectProgress.getWorkTotalCost()); |
| | | map.put("本周消化工作量", projectProgress.getWorkLastCost()); |
| | | list.add(map); |
| | | } |
| | | FileUtil.downloadExcel(list, response); |
| | | } |
| | | |
| | | public void checkProjectProgress(ProjectProgress resources){ |
| | | List<ProjectProgress> list = projectProgressRepository.findByProjectId(resources.getProject().getId()); |
| | | public void checkProjectProgress(ProjectProgress resources) { |
| | | // 获取前次月报的最大进度。 |
| | | List<ProjectProgress> list = projectProgressRepository.findByProjectId(resources.getProject().getId(), resources.getBelongDate()); |
| | | if (list.size() > 0 && list.get(0).getProjectProgress() != null) { |
| | | if (resources.getProjectProgress() <= list.get(0).getProjectProgress()) { |
| | | throw new BadRequestException("项目进度必须大于上一次的项目进度"); |
| | |
| | | */ |
| | | public void createWeekReport() throws Exception { |
| | | |
| | | // 当年第一周需满足四天。(例:2022年的第一周是从1月3号开始的,1号和2号并入到2021年度的最后一周里) |
| | | WeekFields wfs = WeekFields.of(DayOfWeek.MONDAY, 4); |
| | | LocalDate localDate = LocalDate.now().with(wfs.dayOfWeek(), 1L); |
| | | // 取得前一周的周五 |
| | | LocalDate localDate = LocalDate.now().with(wfs.dayOfWeek(), 5L).minusDays(7); |
| | | |
| | | int year = localDate.minusDays(7).get(wfs.weekBasedYear()); |
| | | int weeks = localDate.minusDays(7).get(wfs.weekOfWeekBasedYear()); |
| | | int year = localDate.get(wfs.weekBasedYear()); |
| | | int weeks = localDate.get(wfs.weekOfWeekBasedYear()); |
| | | |
| | | projectProgressService.generateProjectProcess(year, weeks, null); |
| | | projectProgressService.autoGenerateProjectProcess(localDate, year, weeks); |
| | | } |
| | | } |
| | |
| | | package me.zhengjie.modules.task.domain; |
| | | |
| | | import java.sql.Date; |
| | | import java.sql.Timestamp; |
| | | |
| | | import javax.persistence.Temporal; |
| | | import javax.persistence.TemporalType; |
| | | |
| | | |
| | | public interface TaskDailyInterface { |
| | | |
| | | /** |
| | |
| | | * @return |
| | | */ |
| | | Long getTaskId(); |
| | | |
| | | /** |
| | | * 日报日期 |
| | | */ |
| | | Date getFillDate(); |
| | | |
| | | /** |
| | | * 任务绩效工时 |
| | | */ |
| | | Double getPlanHours(); |
| | | } |
| New file |
| | |
| | | package me.zhengjie.modules.task.domain; |
| | | |
| | | import java.sql.Timestamp; |
| | | |
| | | public interface TaskInterface { |
| | | |
| | | /** |
| | | * 计划工时 |
| | | * @return |
| | | */ |
| | | Double getPlanHours(); |
| | | |
| | | /** |
| | | * 计划工作量 |
| | | * @return |
| | | */ |
| | | Double getPlanWorkload(); |
| | | |
| | | /** |
| | | * 任务ID |
| | | * @return |
| | | */ |
| | | Long getTaskId(); |
| | | |
| | | /** |
| | | * 项目ID |
| | | */ |
| | | Timestamp getProjectId(); |
| | | } |
| | |
| | | * @param projectId |
| | | * @return |
| | | */ |
| | | @Query(value = "SELECT * FROM task_daliy WHERE project_id = ?1 ORDER BY user_id, fill_date ASC", nativeQuery = true) |
| | | List<TaskDaliy> findByProjectId(Long projectId); |
| | | @Query(value = "SELECT COALESCE(SUM(consumed_hours), 0.0) AS consumedHours, COALESCE(sum(consumed_workload), 0.0) as consumedWorkload FROM task_daliy WHERE project_id = ?1 AND fill_date < ?2", nativeQuery = true) |
| | | TaskDailyInterface collectByProjectIdAndFillDateLessThan(Long projectId, Timestamp fillDate); |
| | | |
| | | /** |
| | | * 根据项目ID查询任务日报信息 |
| | | * @param projectId |
| | | * @return |
| | | */ |
| | | @Query(value = "SELECT td.task_id AS taskId, COALESCE(MAX(td.task_progress), 0) AS taskProgress, COALESCE(SUM(consumed_hours), 0) AS consumedHours, COALESCE(sum(consumed_workload), 0.0) as consumedWorkload, plan_hours AS planHours FROM task_daliy td INNER JOIN task t ON (td.task_id = t.id) WHERE td.project_id = ?1 AND td.fill_date < ?2 GROUP BY td.task_id", nativeQuery = true) |
| | | List<TaskDailyInterface> collectByProjectIdAndFillDateLessThanGroupByTaskIdJoinTask(Long projectId, Timestamp fillDate); |
| | | |
| | | /** |
| | | * 根据项目ID查询任务日报信息 |
| | | * @param projectId |
| | | * @return |
| | | */ |
| | | @Query(value = "SELECT user_id AS userId, fill_date AS fillDate, COALESCE(SUM(consumed_hours), 0) AS consumedHours FROM task_daliy WHERE project_id = ?1 AND fill_date < ?2 GROUP BY user_id, fill_date", nativeQuery = true) |
| | | List<TaskDailyInterface> collectByProjectIdAndFillDateLessThanGroupByUserIdAndFillDate(Long projectId, Timestamp fillDate); |
| | | |
| | | /** |
| | | * 根据项目ID、任务ID查询 |
| | |
| | | * @param taskId |
| | | * @return |
| | | */ |
| | | @Query(value = "SELECT user_id AS userId, task_id AS taskId, COALESCE(MAX(task_progress), 0) AS TaskProgress FROM task_daliy WHERE project_id = ?1 AND fill_date BETWEEN ?2 AND ?3 GROUP BY user_id, task_id", nativeQuery = true) |
| | | @Query(value = "SELECT user_id AS userId, task_id AS taskId, COALESCE(MAX(task_progress), 0) AS taskProgress FROM task_daliy WHERE project_id = ?1 AND fill_date BETWEEN ?2 AND ?3 GROUP BY user_id, task_id", nativeQuery = true) |
| | | List<TaskDailyInterface> collectCostByProjectIdAndFillDateBetweenGroupUserAndTaskId(Long projectId, Timestamp sdate, Timestamp edate); |
| | | |
| | | |
| | |
| | | package me.zhengjie.modules.task.repository; |
| | | |
| | | import me.zhengjie.modules.task.domain.Task; |
| | | import me.zhengjie.modules.task.domain.TaskInterface; |
| | | |
| | | import org.springframework.data.jpa.repository.JpaRepository; |
| | | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; |
| | | import org.springframework.data.jpa.repository.Query; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | */ |
| | | List<Task> findByProjectId(Long id); |
| | | |
| | | @Query(value = "SELECT * FROM task WHERE project_id = ?1 AND create_time < ?2", nativeQuery = true) |
| | | List<Task> findByProjectIdUntilDate(Long projectId, Date belongDate); |
| | | @Query(value = "SELECT COALESCE(SUM(plan_hours), 0.0) AS planHours, COALESCE(sum(plan_workload), 0.0) as planWorkload FROM task WHERE project_id = ?1", nativeQuery = true) |
| | | TaskInterface collectByProjectId(Long projectId); |
| | | } |
| | |
| | | <div class="head-container"> |
| | | <div v-if="crud.props.searchToggle"> |
| | | <!-- 搜索 --> |
| | | <el-input v-model="query.name" clearable placeholder="请输入名称" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" /> |
| | | <el-select v-model="query.projectTypeId" clearable filterable placeholder="请选择项目类型" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-input v-model="query.name" clearable placeholder="名称" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" /> |
| | | <el-select v-model="query.projectTypeId" clearable filterable placeholder="项目类型" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-option |
| | | v-for="item in projectTypeList" |
| | | :key="item.id" |
| | |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | <el-select v-model="query.liableUserId" clearable filterable placeholder="请选择责任人" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-select v-model="query.projectDistinguish" clearable filterable placeholder="项目区分" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-option |
| | | v-for="item in dict[projectDistinguish]" |
| | | :key="item.id" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | <el-select v-model="query.liableUserId" clearable filterable placeholder="责任人" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-option |
| | | v-for="item in userList" |
| | | :key="item.id" |
| | |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | <el-select v-model="query.projectStatus" clearable filterable placeholder="请选择项目状态" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-select v-model="query.projectStatus" clearable filterable placeholder="项目状态" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-option |
| | | v-for="item in dict[projectStatus]" |
| | | :key="item.id" |
| | |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | <date-range-picker v-model="query.planStartDate" class="date-item" @keyup.enter.native="crud.toQuery" /> |
| | | <date-range-picker v-model="query.planEndDate" class="date-item" @keyup.enter.native="crud.toQuery" /> |
| | | <el-select v-model="query.approveStatus" clearable filterable placeholder="批准状态" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-option |
| | | v-for="item in dict[approveStatus]" |
| | | :key="item.id" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | <rrOperation :crud="crud" /> |
| | | </div> |
| | | <!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'--> |
| | | |
| | | <crudOperation :permission="permission"> |
| | | <el-button |
| | | slot="right" |
| | |
| | | :disabled="crud.selections.length === 0" |
| | | @click="projectAdmit(crud.selections)" |
| | | >承认</el-button> |
| | | <el-button |
| | | slot="right" |
| | | v-permission="permission.seeTask" |
| | | class="filter-item" |
| | | size="mini" |
| | | type="primary" |
| | | icon="el-icon-view" |
| | | :disabled="crud.selections.length !== 1" |
| | | style="margin-left: 4px !important;" |
| | | @click="toSeeTask(crud.selections[0])" |
| | | > |
| | | 查看任务 |
| | | </el-button> |
| | | <el-button |
| | | slot="right" |
| | | v-permission="permission.seeCost" |
| | | class="filter-item" |
| | | size="mini" |
| | | type="primary" |
| | | icon="el-icon-view" |
| | | :disabled="crud.selections.length !== 1" |
| | | style="margin-left: 4px !important;" |
| | | @click="toSeeCost(crud.selections[0])" |
| | | > |
| | | 查看成本 |
| | | </el-button> |
| | | </crudOperation> |
| | | <!--表单组件--> |
| | | <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="690px"> |
| | | <el-form ref="form" :model="form" :rules="rules" :inline="true" size="small" label-width="110px"> |
| | | <el-divider>项目基本</el-divider> |
| | | <el-form-item label="名称" prop="name"> |
| | | <el-input v-model="form.name" maxlength="100" style="width: 523px;" /> |
| | | <el-input v-model="form.name" style="width: 523px;" /> |
| | | </el-form-item> |
| | | <el-form-item label="项目类型" prop="projectTypeId"> |
| | | <el-select v-model="form.projectTypeId" clearable filterable placeholder="请选择" style="width: 200px;" @change="projectTypeChange"> |
| | | <el-select v-model="form.projectTypeId" clearable filterable placeholder="请选择" style="width: 200px;" :disabled="disabledFlagByApprove" @change="projectTypeChange"> |
| | | <el-option |
| | | v-for="item in projectTypeList" |
| | | :key="item.id" |
| | |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="项目区分" prop="projectDistinguish"> |
| | | <el-select v-model="form.projectDistinguish" clearable filterable placeholder="请选择" style="width: 200px;"> |
| | | <el-select v-model="form.projectDistinguish" clearable filterable placeholder="请选择" style="width: 200px;" :disabled="disabledFlagByApprove"> |
| | | <el-option |
| | | v-for="item in dict[projectDistinguish]" |
| | | :key="item.id" |
| | |
| | | <el-form-item label="需求说明"> |
| | | <el-input v-model="form.requirement" :rows="3" type="textarea" style="width: 523px;" /> |
| | | </el-form-item> |
| | | <el-divider>金额</el-divider> |
| | | <el-form-item label="报价单金" prop="quotationPrice"> |
| | | <money-input :key="random" v-model="form.quotationPrice" :width="200" /> |
| | | <money-input :key="random" v-model="form.quotationPrice" :width="200" :disabled="disabledFlagByApprove" /> |
| | | </el-form-item> |
| | | <el-form-item label="报价币种" prop="unitCurrency"> |
| | | <el-select v-model="form.unitCurrency" clearable filterable placeholder="请选择" style="width: 200px;"> |
| | | <el-select v-model="form.unitCurrency" clearable filterable placeholder="请选择" style="width: 200px;" :disabled="disabledFlagByApprove"> |
| | | <el-option |
| | | v-for="item in dict[standardUnitCurrency]" |
| | | :key="item.id" |
| | |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="绩效单金" prop="performancePrice"> |
| | | <money-input :key="random" v-model="form.performancePrice" :width="200" /> |
| | | <money-input :key="random" v-model="form.performancePrice" :width="200" :disabled="disabledFlagByApprove" /> |
| | | </el-form-item> |
| | | <el-form-item label="绩效币种"> |
| | | <el-input value="人民币" maxlength="100" :disabled="true" style="width: 200px;" /> |
| | | <el-select v-model="standardUnitCurrencyRenminbi" clearable filterable placeholder="请选择" style="width: 200px;" disabled> |
| | | <el-option |
| | | v-for="item in dict[standardUnitCurrency]" |
| | | :key="item.id" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="绩效目标" prop="performanceObjectives"> |
| | | <el-input :key="random" v-model="form.performanceObjectives" style="width: 200px;"> |
| | | <el-input :key="random" v-model="form.performanceObjectives" style="width: 200px;" :disabled="disabledFlagByApprove"> |
| | | <template slot="append">%</template> |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item label="合同金额" prop="contractPrice"> |
| | | <money-input :key="random" v-model="form.contractPrice" :width="200" /> |
| | | <el-form-item label="合同总金额" prop="contractPrice"> |
| | | <money-input :key="random" v-model="form.contractPrice" :width="200" :disabled="disabledFlagByApprove" /> |
| | | </el-form-item> |
| | | <el-divider>项目其他</el-divider> |
| | | <el-form-item label="计划开始日期" prop="planStartDate"> |
| | | <el-date-picker v-model="form.planStartDate" style="width: 200px;" :picker-options="pickerOptionsStart" type="date" placeholder="选择日期" /> |
| | | <el-date-picker v-model="form.planStartDate" type="date" :picker-options="pickerOptionsStart" placeholder="选择日期" style="width: 200px;" /> |
| | | </el-form-item> |
| | | <el-form-item label="计划结束日期" prop="planEndDate"> |
| | | <el-date-picker v-model="form.planEndDate" type="date" :picker-options="pickerOptionsEnd" style="width: 200px;" placeholder="选择日期" /> |
| | | <el-date-picker v-model="form.planEndDate" type="date" :picker-options="pickerOptionsEnd" placeholder="选择日期" style="width: 200px;" /> |
| | | </el-form-item> |
| | | <el-form-item label="责任人"> |
| | | <el-select v-model="form.liableUserId" clearable filterable placeholder="请选择" style="width: 200px;"> |
| | |
| | | :key="item.id" |
| | | :label="item.nickName" |
| | | :value="item.id" |
| | | :disabled="!item.enabled" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | |
| | | <!--表格渲染--> |
| | | <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 150%;" @selection-change="crud.selectionChangeHandler"> |
| | | <el-table-column type="selection" width="55" fixed="left" /> |
| | | <el-table-column prop="name" label="名称" show-overflow-tooltip fixed="left" width="130" /> |
| | | <el-table-column prop="projectTypeName" label="项目类型" width="130"> |
| | | <el-table-column :show-overflow-tooltip="true" prop="name" label="名称" fixed="left" width="140" /> |
| | | <el-table-column :show-overflow-tooltip="true" prop="projectTypeName" label="项目类型" width="100"> |
| | | <template slot-scope="scope"> |
| | | <el-tag>{{ scope.row.projectTypeName }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="projectDistinguish" label="项目区分" width="130"> |
| | | <el-table-column :show-overflow-tooltip="true" prop="projectDistinguish" label="项目区分" width="100"> |
| | | <template slot-scope="scope"> |
| | | <el-tag>{{ dict.label[projectDistinguish][scope.row.projectDistinguish] }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="contractPrice" label="合同金额" width="120"> |
| | | <el-table-column :show-overflow-tooltip="true" prop="requirement" label="需求说明" width="140" /> |
| | | <el-table-column :show-overflow-tooltip="true" prop="contractPrice" label="合同总金额" width="100"> |
| | | <template slot-scope="scope"> |
| | | {{ scope.row.contractPrice != null && scope.row.contractPrice != '' ? crud.toMoney(scope.row.contractPrice) : '' }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="quotationPrice" label="报价金额" width="120"> |
| | | <template slot-scope="scope"> |
| | | <el-tooltip class="item" effect="dark" :content="scope.row.quotationPrice + ' * ' + scope.row.totalTaskTime" placement="top"> |
| | | <span>{{ scope.row.quotationPrice != null && scope.row.quotationPrice != '' ? crud.toMoney(scope.row.quotationPrice * scope.row.totalTaskTime) : 0 }}</span> |
| | | </el-tooltip> |
| | | </template> |
| | | <el-table-column :show-overflow-tooltip="true" prop="totalTaskTime" label="任务总工时" width="100" /> |
| | | <el-table-column label="报价"> |
| | | <el-table-column :show-overflow-tooltip="true" prop="quotationPrice" label="单金" width="100"> |
| | | <template slot-scope="scope"> |
| | | {{ crud.toMoney(scope.row.quotationPrice) }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="unitCurrency" label="币种" width="100"> |
| | | <template slot-scope="scope"> |
| | | <el-tag>{{ dict.label[standardUnitCurrency][scope.row.unitCurrency] }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" label="总金额" width="100"> |
| | | <template slot-scope="scope"> |
| | | {{ crud.toMoney(scope.row.quotationPrice * scope.row.totalTaskTime) }} |
| | | </template> |
| | | </el-table-column> |
| | | </el-table-column> |
| | | <el-table-column prop="performancePrice" label="绩效金额" width="120"> |
| | | <template slot-scope="scope"> |
| | | <el-tooltip class="item" effect="dark" :content="scope.row.performancePrice + ' * ' + scope.row.totalTaskTime" placement="top"> |
| | | <span>{{ scope.row.performancePrice != null && scope.row.performancePrice != '' ? crud.toMoney(scope.row.performancePrice * scope.row.totalTaskTime) : 0 }}</span> |
| | | </el-tooltip> |
| | | </template> |
| | | <el-table-column label="绩效"> |
| | | <el-table-column :show-overflow-tooltip="true" prop="performancePrice" label="单金" width="100"> |
| | | <template slot-scope="scope"> |
| | | {{ crud.toMoney(scope.row.performancePrice) }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" label="币种" width="100"> |
| | | <el-tag>{{ dict.label[standardUnitCurrency][standardUnitCurrencyRenminbi] }}</el-tag> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" label="总金额" width="100"> |
| | | <template slot-scope="scope"> |
| | | {{ crud.toMoney(scope.row.performancePrice * scope.row.totalTaskTime) }} |
| | | </template> |
| | | </el-table-column> |
| | | </el-table-column> |
| | | <el-table-column prop="totalLaborCost" label="项目成本" align="center" width="120"> |
| | | <el-table-column :show-overflow-tooltip="true" prop="performanceObjectives" label="绩效目标" width="80"> |
| | | <template slot-scope="scope"> |
| | | <el-tag v-if="scope.row.performancePrice * scope.row.totalTaskTime < scope.row.totalLaborCost" type="danger"> |
| | | {{ scope.row.totalLaborCost != null && scope.row.totalLaborCost != '' ? crud.toMoney(scope.row.totalLaborCost) : '' }} |
| | | </el-tag> |
| | | <span v-else> |
| | | {{ scope.row.totalLaborCost != null && scope.row.totalLaborCost != '' ? crud.toMoney(scope.row.totalLaborCost) : '' }} |
| | | </span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="performanceObjectives" label="绩效目标" align="center" width="120"> |
| | | <template slot-scope="scope"> |
| | | <el-tag v-if="scope.row.performancePrice * scope.row.totalTaskTime * (1 - scope.row.performanceObjectives / 100) < scope.row.totalLaborCost" type="warning"> |
| | | {{ (scope.row.performanceObjectives ? scope.row.performanceObjectives : 0) + '%' }} |
| | | </el-tag> |
| | | <span v-else> |
| | | <span :style="{ color: scope.row.performancePrice * scope.row.totalTaskTime * (1 - scope.row.performanceObjectives / 100) < scope.row.totalLaborCost ? 'red' : '' }"> |
| | | {{ (scope.row.performanceObjectives ? scope.row.performanceObjectives : 0) + '%' }} |
| | | </span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="liableUserName" label="责任人" width="80"> |
| | | <el-table-column :show-overflow-tooltip="true" prop="totalLaborCost" label="项目总成本" width="100"> |
| | | <template slot-scope="scope"> |
| | | <el-tag v-if="scope.row.liableUserName != null && scope.row.liableUserName != ''">{{ scope.row.liableUserName }}</el-tag> |
| | | <span :style="{ color: scope.row.performancePrice * scope.row.totalTaskTime < scope.row.totalLaborCost ? 'red' : '' }"> |
| | | {{ crud.toMoney(scope.row.totalLaborCost) }} |
| | | </span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="planStartDate" label="计划开始日期" width="120"> |
| | | <el-table-column :show-overflow-tooltip="true" prop="liableUserName" label="责任人" width="100"> |
| | | <template slot-scope="scope"> |
| | | <el-tag v-if="scope.row.liableUserName != null && scope.row.liableUserName != ''"> |
| | | {{ scope.row.liableUserName }} |
| | | </el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="planStartDate" label="计划开始日期" width="100"> |
| | | <template slot-scope="scope"> |
| | | {{ crud.toDate(scope.row.planStartDate) }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="planEndDate" label="计划结束日期" width="120"> |
| | | <el-table-column :show-overflow-tooltip="true" prop="planEndDate" label="计划结束日期" width="100"> |
| | | <template slot-scope="scope"> |
| | | {{ crud.toDate(scope.row.planEndDate) }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="projectStatus" label="项目状态" width="80"> |
| | | <el-table-column :show-overflow-tooltip="true" prop="projectStatus" label="项目状态" width="80"> |
| | | <template slot-scope="scope"> |
| | | <el-tag>{{ dict.label[projectStatus][scope.row.projectStatus] }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="approveStatus" label="批准状态" width="80"> |
| | | <el-table-column :show-overflow-tooltip="true" prop="approveStatus" label="批准状态" width="80"> |
| | | <template slot-scope="scope"> |
| | | <el-tag>{{ dict.label[approveStatus][scope.row.approveStatus] }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="createTime" label="创建时间" width="140" /> |
| | | <el-table-column :show-overflow-tooltip="true" prop="remarks" label="备注" width="140" /> |
| | | <el-table-column :show-overflow-tooltip="true" prop="createTime" label="创建时间" width="140" /> |
| | | <el-table-column v-if="checkPer(['admin','project:edit','project:del'])" label="操作" width="180px" align="center" fixed="right"> |
| | | <template slot-scope="scope"> |
| | | <udOperation |
| | |
| | | import pagination from '@crud/Pagination' |
| | | import moneyInput from '../../assembly/moneyInput/index.vue' |
| | | import constant from '../../../utils/constant' |
| | | import DateRangePicker from '@/components/DateRangePicker' |
| | | |
| | | const defaultForm = { id: null, name: null, projectTypeId: null, projectDistinguish: null, requirement: null, unitCurrency: null, performanceObjectives: null, quotationPrice: null, performancePrice: null, contractPrice: null, liableUserId: null, planStartDate: null, planEndDate: null, projectStatus: null, approveStatus: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null } |
| | | export default { |
| | | name: 'Project', |
| | | components: { pagination, crudOperation, rrOperation, udOperation, moneyInput, DateRangePicker }, |
| | | components: { pagination, crudOperation, rrOperation, udOperation, moneyInput }, |
| | | mixins: [presenter(), header(), form(defaultForm), crud()], |
| | | dicts: [constant.STANDARD_UNIT_CURRENCY, constant.PROJECT_DISTINGUISH, constant.PROJECT_STATUS, constant.APPROVE_STATUS], |
| | | cruds() { |
| | | return CRUD({ title: '项目', url: 'api/project', idField: 'id', sort: 'id,desc', crudMethod: { ...crudProject }}) |
| | | return CRUD({ title: '项目详情', url: 'api/project', idField: 'id', sort: 'id,desc', crudMethod: { ...crudProject }}) |
| | | }, |
| | | data() { |
| | | var quotationPrice = (rule, value, callback) => { |
| | | if (value !== null) { |
| | | if (isNaN(Number(value))) { |
| | | callback(new Error('报价单金必须是数字')) |
| | | } else { |
| | | if (value <= 0) { |
| | | callback(new Error('报价单金必须大于0')) |
| | | } else if (value >= 10000000000) { |
| | | callback(new Error('报价单金必须小于1百亿')) |
| | | } else { |
| | | callback() |
| | | } |
| | | } |
| | | } else { |
| | | callback(new Error('单价金额不能为空')) |
| | | } |
| | | } |
| | | var performancePrice = (rule, value, callback) => { |
| | | if (value !== null) { |
| | | if (isNaN(Number(value))) { |
| | | callback(new Error('绩效单金必须是数字')) |
| | | } else { |
| | | if (value < 0) { |
| | | callback(new Error('绩效单金必须大于0')) |
| | | } else if (value >= 10000000000) { |
| | | callback(new Error('绩效单金必须小于1百亿')) |
| | | } else { |
| | | callback() |
| | | } |
| | | } |
| | | // 指针重指向 |
| | | const _this = this |
| | | // 金额(十亿内)验证 |
| | | var priceValidate = (rule, value, callback) => { |
| | | if (value != null && value !== '' && (isNaN(value) || Number(value) < 0 || Number(value) > 1000000000)) { |
| | | callback(new Error('请输入 十亿 以内的正整数或两位小数')) |
| | | } else { |
| | | callback() |
| | | } |
| | |
| | | edit: ['admin', 'project:edit'], |
| | | del: ['admin', 'project:del'], |
| | | download: ['admin', 'project:download'], |
| | | admit: ['admin', 'project:admit'] |
| | | admit: ['admin', 'project:admit'], |
| | | seeTask: ['admin', 'project:seeTask'], |
| | | seeCost: ['admin', 'project:seeCost'] |
| | | }, |
| | | rules: { |
| | | name: [ |
| | | { required: true, message: '名称不能为空', trigger: 'blur' }, |
| | | { min: 1, max: 100, message: '最大长度 100 个字符', trigger: 'blur' } |
| | | { max: 100, message: '最大长度 100 个字符', trigger: 'blur' } |
| | | ], |
| | | projectTypeId: [ |
| | | { required: true, message: '项目类型不能为空', trigger: 'change' } |
| | |
| | | { required: true, message: '单价币种不能为空', trigger: 'change' } |
| | | ], |
| | | quotationPrice: [ |
| | | { required: true, validator: quotationPrice, trigger: 'blur' } |
| | | { required: true, message: '报价单金不能为空', trigger: 'blur' }, |
| | | { validator: priceValidate, trigger: 'blur' } |
| | | ], |
| | | performancePrice: [ |
| | | { required: true, validator: performancePrice, trigger: 'blur' } |
| | | { required: true, message: '绩效单金不能为空', trigger: 'blur' }, |
| | | { validator: priceValidate, trigger: 'blur' } |
| | | ], |
| | | performanceObjectives: [ |
| | | { required: true, validator: proportionValidate, trigger: 'blur' } |
| | | { required: true, message: '绩效目标不能为空', trigger: 'blur' }, |
| | | { validator: proportionValidate, trigger: 'blur' } |
| | | ], |
| | | projectStatus: [ |
| | | { required: true, message: '项目状态不能为空', trigger: 'change' } |
| | |
| | | { key: 'name', display_name: '名称' }, |
| | | { key: 'projectTypeId', display_name: '项目类型' }, |
| | | { key: 'projectDistinguish', display_name: '项目区分' }, |
| | | { key: 'unitCurrency', display_name: '单价币种' }, |
| | | { key: 'liableUserId', display_name: '责任人' }, |
| | | { key: 'planStartDate', display_name: '计划开始日期' }, |
| | | { key: 'planEndDate', display_name: '计划结束日期' }, |
| | | { key: 'projectStatus', display_name: '项目状态' }, |
| | | { key: 'approveStatus', display_name: '批准状态' } |
| | | ], |
| | | // 标准单价币种 |
| | | standardUnitCurrency: constant.STANDARD_UNIT_CURRENCY, |
| | | // 标准单价币种:人民币 |
| | | standardUnitCurrencyRenminbi: constant.STANDARD_UNIT_CURRENCY_RENMINBI, |
| | | // 项目状态 |
| | | projectStatus: constant.PROJECT_STATUS, |
| | | // 批准状态 |
| | |
| | | // 选中结束时间之后不可选 |
| | | pickerOptionsStart: { |
| | | disabledDate: (time) => { |
| | | if (this.form.planEndDate) { |
| | | return time.getTime() > Date.now() || time.getTime() > this.form.planEndDate |
| | | } |
| | | return _this.form.planEndDate != null && _this.form.planEndDate !== '' ? time.getTime() > new Date(_this.form.planEndDate).getTime() : false |
| | | } |
| | | }, |
| | | // 选中开始时间之后不可选 |
| | | pickerOptionsEnd: { |
| | | disabledDate: (time) => { |
| | | return time.getTime() < this.form.planStartDate |
| | | return _this.form.planStartDate != null && _this.form.planStartDate !== '' ? time.getTime() < new Date(_this.form.planStartDate).getTime() : false |
| | | } |
| | | } |
| | | }, |
| | | // 表单禁用标记(承认状态) |
| | | disabledFlagByApprove: false |
| | | } |
| | | }, |
| | | methods: { |
| | | // 钩子:在获取表格数据之前执行,false 则代表不获取数据 |
| | | [CRUD.HOOK.beforeRefresh]() { |
| | | // 获取项目类型 |
| | | this.getPackageTypeAll() |
| | | // 获取责任人 |
| | | this.getUserListAll() |
| | | return true |
| | | }, |
| | | // 新增与编辑前做的操作 |
| | | [CRUD.HOOK.afterToCU](crud, form) { |
| | | // 判断表单承认状态 |
| | | if (this.form.approveStatus === constant.APPROVE_STATUS_ACKNOWLEDGED) { |
| | | // 表单禁用标记(承认状态) |
| | | this.disabledFlagByApprove = true |
| | | } else { |
| | | // 表单禁用标记(承认状态) |
| | | this.disabledFlagByApprove = false |
| | | } |
| | | // 随机数 |
| | | this.random = Math.random() |
| | | }, |
| | | // 获取项目类型 |
| | | getPackageTypeAll() { |
| | | // 获取项目类型 |
| | | crudProjectType.getAll().then(res => { |
| | | // 项目类型列表 |
| | | this.projectTypeList = res |
| | | }).catch(() => { |
| | | |
| | |
| | | }, |
| | | // 获取责任人 |
| | | getUserListAll() { |
| | | // 获取责任人 |
| | | crudUser.getAll().then(res => { |
| | | // 用户列表 |
| | | this.userList = res |
| | | }).catch(() => { |
| | | |
| | |
| | | this.form.quotationPrice = res[0].standardQuotationPrice |
| | | // 单价金额赋值 |
| | | this.form.performancePrice = res[0].standardPerformancePrice |
| | | // |
| | | // 绩效目标赋值 |
| | | this.form.performanceObjectives = res[0].standardPerformanceObjectives |
| | | // 随机数 |
| | | this.random = Math.random() |
| | | }) |
| | | }, |
| | |
| | | }, |
| | | // 项目承认 |
| | | projectAdmit(row) { |
| | | // 选中的id |
| | | this.ids = [] |
| | | // 判断是多个项目承认还是单个项目承认 |
| | | if (row.id !== undefined) { |
| | | this.$refs[`popover_${row.id}`].showPopper = false |
| | | // 选中的id |
| | | this.ids.push(row.id) |
| | | // 项目承认 |
| | | crudProject.editAdmit(this.ids).then(res => { |
| | |
| | | this.crud.refresh() |
| | | }) |
| | | } else { |
| | | // 确认框 |
| | | this.$confirm('此操作将承认' + row.length + '个项目, 是否继续?', '提示', { |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | | type: 'success' |
| | | }).then(() => { |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '项目已承认!' |
| | | }) |
| | | // 循环选中数据 |
| | | for (let i = 0; i < row.length; i++) { |
| | | // 选中的id |
| | | this.ids.push(row[i].id) |
| | | // 判断循环是否结束 |
| | | if (i === row.length - 1) { |
| | | // 项目承认 |
| | | crudProject.editAdmit(this.ids).then(res => { |
| | | // 消息提示 |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '项目已承认!' |
| | | }) |
| | | // 刷新数据 |
| | | this.crud.refresh() |
| | | }) |
| | | } |
| | | } |
| | | // 项目承认 |
| | | crudProject.editAdmit(this.ids).then(res => { |
| | | // 刷新数据 |
| | | this.crud.refresh() |
| | | }) |
| | | }).catch(() => { |
| | | // 消息提示 |
| | | this.$message({ |
| | | type: 'info', |
| | | message: '已取消项目承认' |
| | | }) |
| | | }) |
| | | } |
| | | }, |
| | | // 查看任务 |
| | | toSeeTask(data) { |
| | | // 跳转页面 |
| | | this.$router.push({ |
| | | name: 'ProjectTask', |
| | | params: { |
| | | projectId: data.id |
| | | } |
| | | }) |
| | | }, |
| | | // 查看成本 |
| | | toSeeCost(data) { |
| | | // 跳转页面 |
| | | this.$router.push({ |
| | | name: 'ProjectCost', |
| | | params: { |
| | | projectId: data.id |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | } |
| | |
| | | <div class="head-container"> |
| | | <div v-if="crud.props.searchToggle"> |
| | | <!-- 搜索 --> |
| | | <el-select v-model="query.projectId" clearable filterable placeholder="请选择项目" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-select v-model="query.projectId" clearable filterable placeholder="所属项目" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-option |
| | | v-for="item in projectList" |
| | | :key="item.id" |
| | |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | <el-select v-model="query.userId" clearable filterable placeholder="请选择用户" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-select v-model="query.userId" clearable filterable placeholder="所属员工" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-option |
| | | v-for="item in userList" |
| | | :key="item.id" |
| | |
| | | <!--表单组件--> |
| | | <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="110px"> |
| | | <el-form-item label="项目" prop="projectId"> |
| | | <el-select v-model="form.projectId" clearable filterable placeholder="请选择" style="width: 340px;"> |
| | | <el-form-item label="所属项目" prop="projectId"> |
| | | <el-select v-model="form.projectId" clearable filterable placeholder="请选择" style="width: 340px;" :disabled="disabledFlagByApprove"> |
| | | <el-option |
| | | v-for="item in projectList" |
| | | :key="item.id" |
| | | :label="item.name" |
| | | :value="item.id" |
| | | :disabled="item.approveStatus == approveStatusAcknowledged" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="用户" prop="userId"> |
| | | <el-select v-model="form.userId" clearable filterable placeholder="请选择" style="width: 340px;" @change="timeChange"> |
| | | <el-form-item label="所属员工" prop="userId"> |
| | | <el-select v-model="form.userId" clearable filterable placeholder="请选择" style="width: 340px;" :disabled="disabledFlagByApprove" @change="getProjectCost"> |
| | | <el-option |
| | | v-for="item in userList" |
| | | :key="item.id" |
| | | :label="item.nickName" |
| | | :value="item.id" |
| | | :disabled="!item.enabled" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="进入项目时间" prop="enterProjectTime"> |
| | | <el-date-picker v-model="form.enterProjectTime" value-format="yyyy-MM-dd HH:mm:ss" type="datetime" style="width: 340px;" @change="timeChange" /> |
| | | <el-date-picker v-model="form.enterProjectTime" type="datetime" :picker-options="pickerOptionsStart" style="width: 340px;" :disabled="disabledFlagByApprove" @change="getProjectCost" /> |
| | | </el-form-item> |
| | | <el-form-item label="退出项目时间" prop="exitProjectTime"> |
| | | <el-date-picker v-model="form.exitProjectTime" value-format="yyyy-MM-dd HH:mm:ss" type="datetime" style="width: 340px;" @change="timeChange" /> |
| | | <el-date-picker v-model="form.exitProjectTime" type="datetime" :picker-options="pickerOptionsEnd" style="width: 340px;" :disabled="disabledFlagByApprove" @change="getProjectCost" /> |
| | | </el-form-item> |
| | | <el-form-item label="项目成本" prop="projectCost"> |
| | | <!-- <el-input v-model="form.projectCost" style="width: 340px;" /> --> |
| | | <money-input :key="random" v-model="form.projectCost" :width="340" /> |
| | | <money-input :key="random" v-model="form.projectCost" :width="340" :disabled="disabledFlagByApprove" /> |
| | | </el-form-item> |
| | | <el-form-item label="备注"> |
| | | <el-input v-model="form.remarks" :rows="3" type="textarea" style="width: 340px;" /> |
| | | <el-input v-model="form.remarks" :rows="3" type="textarea" style="width: 340px;" :disabled="disabledFlagByApprove" /> |
| | | </el-form-item> |
| | | </el-form> |
| | | <div slot="footer" class="dialog-footer"> |
| | |
| | | <!--表格渲染--> |
| | | <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="projectName" label="项目" show-overflow-tooltip> |
| | | <el-table-column prop="projectName" label="所属项目" show-overflow-tooltip> |
| | | <template slot-scope="scope"> |
| | | <el-tag>{{ scope.row.projectName }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="userName" label="用户" show-overflow-tooltip> |
| | | <el-table-column prop="userName" label="所属员工" show-overflow-tooltip> |
| | | <template slot-scope="scope"> |
| | | <el-tag>{{ scope.row.userName }}</el-tag> |
| | | </template> |
| | |
| | | import udOperation from '@crud/UD.operation' |
| | | import pagination from '@crud/Pagination' |
| | | import moneyInput from '../../assembly/moneyInput/index.vue' |
| | | import constant from '../../../utils/constant' |
| | | |
| | | const defaultForm = { id: null, projectId: null, userId: null, enterProjectTime: null, exitProjectTime: null, projectCost: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null } |
| | | export default { |
| | |
| | | return CRUD({ title: '项目成本', url: 'api/projectCost', idField: 'id', sort: 'id,desc', crudMethod: { ...crudProjectCost }}) |
| | | }, |
| | | data() { |
| | | // 指针重指向 |
| | | const _this = this |
| | | return { |
| | | permission: { |
| | | add: ['admin', 'projectCost:add'], |
| | |
| | | }, |
| | | rules: { |
| | | projectId: [ |
| | | { required: true, message: '项目不能为空', trigger: 'blur' } |
| | | { required: true, message: '所属项目不能为空', trigger: 'blur' } |
| | | ], |
| | | userId: [ |
| | | { required: true, message: '用户不能为空', trigger: 'blur' } |
| | | { required: true, message: '所属员工不能为空', trigger: 'blur' } |
| | | ], |
| | | enterProjectTime: [ |
| | | { required: true, message: '进入项目时间不能为空', trigger: 'blur' } |
| | |
| | | ] |
| | | }, |
| | | queryTypeOptions: [ |
| | | { key: 'projectId', display_name: '项目' }, |
| | | { key: 'userId', display_name: '用户' }, |
| | | { key: 'projectId', display_name: '所属项目' }, |
| | | { key: 'userId', display_name: '所属员工' }, |
| | | { key: 'enterProjectTime', display_name: '进入项目时间' }, |
| | | { key: 'exitProjectTime', display_name: '退出项目时间' } |
| | | ], |
| | | // 承认状态:已承认 |
| | | approveStatusAcknowledged: constant.APPROVE_STATUS_ACKNOWLEDGED, |
| | | // 用户列表 |
| | | userList: [], |
| | | // 项目列表 |
| | | projectList: [], |
| | | // 随机数 |
| | | random: 0, |
| | | // 选中结束时间之后不可选 |
| | | pickerOptionsStart: { |
| | | disabledDate: (time) => { |
| | | if (this.form.exitProjectTime) { |
| | | return time.getTime() > this.form.exitProjectTime |
| | | } |
| | | return _this.form.exitProjectTime != null && _this.form.exitProjectTime !== '' ? time.getTime() > new Date(_this.form.exitProjectTime).getTime() : false |
| | | } |
| | | }, |
| | | // 选中开始时间之后不可选 |
| | | pickerOptionsEnd: { |
| | | disabledDate: (time) => { |
| | | return time.getTime() < this.form.enterProjectTime |
| | | return _this.form.enterProjectTime != null && _this.form.enterProjectTime !== '' ? time.getTime() < new Date(_this.form.enterProjectTime).getTime() - (86400000 - 1) : false |
| | | } |
| | | } |
| | | }, |
| | | // 表单禁用标记(承认状态) |
| | | disabledFlagByApprove: false |
| | | } |
| | | }, |
| | | methods: { |
| | | // 钩子:在获取表格数据之前执行,false 则代表不获取数据 |
| | | [CRUD.HOOK.beforeRefresh]() { |
| | | // 判断传参是否为空 |
| | | if (this.$route.params.projectId != null && this.$route.params.projectId !== '' && this.crud.query.projectId === undefined) { |
| | | // 检索条件赋值 |
| | | this.$set(this.crud.query, 'projectId', Number(this.$route.params.projectId)) |
| | | } |
| | | // 获取用户列表 |
| | | this.getUserList() |
| | | // 获取项目列表 |
| | | this.getProjectList() |
| | | return true |
| | | }, |
| | | // 新增与编辑前做的操作 |
| | | [CRUD.HOOK.afterToCU](crud, form) { |
| | | // 表单禁用标记(承认状态) |
| | | this.disabledFlagByApprove = false |
| | | // 循环项目列表 |
| | | for (let i = 0; i < this.projectList.length; i++) { |
| | | // 判断是否为同一项目 |
| | | if (this.form.projectId === this.projectList[i].id && this.projectList[i].approveStatus === constant.APPROVE_STATUS_ACKNOWLEDGED) { |
| | | // 表单禁用标记(承认状态) |
| | | this.disabledFlagByApprove = true |
| | | } |
| | | } |
| | | // 随机数 |
| | | this.random = Math.random() |
| | | }, |
| | | // 获取用户列表 |
| | | getUserList() { |
| | | // 获取用户列表 |
| | | crudUser.getAll().then(res => { |
| | | // 用户列表 |
| | | this.userList = res |
| | | }).catch(() => { |
| | | |
| | | }) |
| | | }, |
| | | // 获取项目列表 |
| | | getProjectList() { |
| | | // 获取项目列表 |
| | | crudProject.getAll().then(res => { |
| | | // 项目列表 |
| | | this.projectList = res |
| | | }) |
| | | }, |
| | | timeChange() { |
| | | if (this.form.enterProjectTime != null && this.form.exitProjectTime != null) { |
| | | this.getProjectCost() |
| | | } |
| | | }, |
| | | // 获取项目成本 |
| | | getProjectCost() { |
| | | if (this.form.userId != null) { |
| | | // 判断所属员工、进入项目时间、离开项目时间是否为空 |
| | | if (this.form.userId != null && this.form.enterProjectTime != null && this.form.exitProjectTime != null) { |
| | | // 获取项目成本 |
| | | crudProjectCost.getCost({ |
| | | userId: this.form.userId, |
| | | enterProjectTime: this.form.enterProjectTime, |
| | | exitProjectTime: this.form.exitProjectTime |
| | | }).then(res => { |
| | | // 项目成本 |
| | | this.form.projectCost = res.projectCost |
| | | // 随机数 |
| | | this.random = Math.random() |
| | | }) |
| | | } |
| | |
| | | <div class="head-container"> |
| | | <div v-if="crud.props.searchToggle"> |
| | | <!-- 搜索 --> |
| | | <el-input v-model="query.blurry" clearable placeholder="请输入项目名" style="width: 185px" class="filter-item" @keyup.enter.native="crud.toQuery" /> |
| | | <el-select v-model="query.distinguish" filterable clearable placeholder="请选择项目区分" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-option |
| | | v-for="item in dict[projectDistinguish]" |
| | | :key="item.id" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | <el-select v-model="query.belongYear" filterable clearable placeholder="请选择年度" style="width: 185px;" class="filter-item"> |
| | | <el-select v-model="query.belongYear" filterable clearable placeholder="年度" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-option |
| | | v-for="item in belongYearList" |
| | | :key="item" |
| | |
| | | :value="item" |
| | | /> |
| | | </el-select> |
| | | <el-select v-model="query.belongWeek" filterable clearable placeholder="请选择周数" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-select v-model="query.belongWeek" filterable clearable placeholder="周数" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-option |
| | | v-for="item in belongWeekList" |
| | | :key="item" |
| | | :label="item" |
| | | :value="item" |
| | | /> |
| | | </el-select> |
| | | <el-select v-model="query.projectId" filterable clearable placeholder="所属项目" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-option |
| | | v-for="item in projectList" |
| | | :key="item.id" |
| | | :label="item.name" |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | <el-select v-model="query.distinguish" filterable clearable placeholder="项目区分" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-option |
| | | v-for="item in dict[projectDistinguish]" |
| | | :key="item.id" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | <rrOperation :crud="crud" /> |
| | |
| | | <!--表单组件--> |
| | | <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px"> |
| | | <el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px"> |
| | | <el-form-item label="项目" prop="project.id"> |
| | | <el-form-item label="所属项目" prop="project.id"> |
| | | <el-select v-model="form.project.id" filterable clearable placeholder="请选择" style="width: 370px;" :disabled="disabled || crud.status.add !== 1"> |
| | | <el-option |
| | | v-for="item in projectList" |
| | |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="年度" prop="belongYear"> |
| | | <el-select v-model="form.belongYear" filterable clearable placeholder="请选择" style="width: 370px;" :disabled="disabled || crud.status.add !== 1"> |
| | | <el-option |
| | | v-for="item in belongYearList" |
| | | :key="item" |
| | | :label="item" |
| | | :value="item" |
| | | /> |
| | | </el-select> |
| | | <el-input v-model.number="form.belongYear" style="width: 370px;" :disabled="disabled || crud.status.add !== 1" /> |
| | | </el-form-item> |
| | | <el-form-item label="周数" prop="belongWeek"> |
| | | <el-select v-model="form.belongWeek" filterable clearable placeholder="请选择" style="width: 370px;" :disabled="disabled || crud.status.add !== 1"> |
| | | <el-option |
| | | v-for="item in belongWeekList2" |
| | | :key="item" |
| | | :label="item" |
| | | :value="item" |
| | | :disabled="item.approveStatus == approveStatusUnsettled" |
| | | /> |
| | | </el-select> |
| | | <el-input v-model.number="form.belongWeek" style="width: 370px;" :disabled="disabled || crud.status.add !== 1" /> |
| | | </el-form-item> |
| | | <el-form-item label="项目进度" prop="projectProgress"> |
| | | <el-form-item v-if="crud.status.add !== 1" label="本周预计" prop="lastedProgress"> |
| | | <el-input v-model="form.lastProjectProcess.estimatedProgress" style="width: 370px;" :disabled="true"> |
| | | <template slot="append">%</template> |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item label="本周实际" prop="projectProgress"> |
| | | <el-input v-model="form.projectProgress" style="width: 370px;" :disabled="disabled"> |
| | | <template slot="append">%</template> |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item label="批准状态" prop="approveStatus"> |
| | | <el-form-item label="下周预计" prop="estimatedProgress"> |
| | | <el-input v-model="form.estimatedProgress" style="width: 370px;" :disabled="disabled"> |
| | | <template slot="append">%</template> |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item label="承认状态" prop="approveStatus"> |
| | | <el-select v-model="form.approveStatus" filterable clearable :disabled="disabled" placeholder="请选择" style="width: 370px;"> |
| | | <el-option |
| | | v-for="item in dict[approveStatus]" |
| | |
| | | <!--表格渲染--> |
| | | <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="belongYear" label="年度" width="70" /> |
| | | <el-table-column prop="belongWeek" label="周数" width="50" /> |
| | | <el-table-column prop="projectName" label="项目" show-overflow-tooltip width="170"> |
| | | <el-table-column show-overflow-tooltip prop="belongYear" label="年度" /> |
| | | <el-table-column show-overflow-tooltip prop="belongWeek" label="周数" /> |
| | | <el-table-column show-overflow-tooltip prop="projectName" label="所属项目" width="140"> |
| | | <template slot-scope="scope"> |
| | | <el-tag>{{ scope.row.project.name }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="lastedProgress" label="预计进度" show-overflow-tooltip width="70"> |
| | | <el-table-column show-overflow-tooltip prop="lastedProgress" label="本周预计"> |
| | | <template slot-scope="scope"> |
| | | {{ (scope.row.lastedProgress ? scope.row.lastedProgress : 0) + '%' }} |
| | | {{ (scope.row.lastProjectProcess.estimatedProgress ? scope.row.lastProjectProcess.estimatedProgress : 0) + '%' }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="projectProgress" label="实际进度" show-overflow-tooltip width="70"> |
| | | <el-table-column show-overflow-tooltip prop="projectProgress" label="本周实际"> |
| | | <template slot-scope="scope"> |
| | | <el-tag v-if="scope.row.lastedProgress > scope.row.projectProgress" type="danger">{{ (scope.row.projectProgress ? scope.row.projectProgress : 0) + '%' }}</el-tag> |
| | | <el-tag v-else>{{ (scope.row.projectProgress ? scope.row.projectProgress : 0) + '%' }}</el-tag> |
| | | <span :style="{ color: scope.row.lastedProgress > scope.row.projectProgress ? 'red' : '' }">{{ (scope.row.projectProgress ? scope.row.projectProgress + '%' : '') }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="approveStatus" label="批准状态" width="80"> |
| | | <el-table-column show-overflow-tooltip prop="estimatedProgress" label="下周预计"> |
| | | <template slot-scope="scope"> |
| | | <el-tag>{{ dict.label[approveStatus][scope.row.approveStatus] }}</el-tag> |
| | | {{ (scope.row.estimatedProgress ? scope.row.estimatedProgress + '%' : '') }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="moneyTotalInit" label="计划总成本" align="center" width="100"> |
| | | <el-table-column show-overflow-tooltip prop="moneyTotalInit" label="计划总成本"> |
| | | <template slot-scope="scope"> |
| | | {{ scope.row.moneyTotalInit != null && scope.row.moneyTotalInit != '' ? crud.toMoney(scope.row.moneyTotalInit) : 0 }} |
| | | ({{ scope.row.lastProjectProcess.moneyTotalInit != null && scope.row.lastProjectProcess.moneyTotalInit != '' ? crud.toMoney(scope.row.moneyTotalInit - scope.row.lastProjectProcess.moneyTotalInit) : 0 }}) |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="moneyTotalCost" label="总消耗成本" align="center" width="100"> |
| | | <el-table-column show-overflow-tooltip prop="moneyTotalCost" label="总消耗成本"> |
| | | <template slot-scope="scope"> |
| | | {{ scope.row.moneyTotalCost != null && scope.row.moneyTotalCost != '' ? crud.toMoney(scope.row.moneyTotalCost) : 0 }} |
| | | ({{ scope.row.lastProjectProcess.moneyTotalCost != null && scope.row.lastProjectProcess.moneyTotalCost != '' ? crud.toMoney(scope.row.moneyTotalCost - scope.row.lastProjectProcess.moneyTotalCost) : 0 }}) |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="realLastCost" label="本周消化工时" align="center" width="100" /> |
| | | <el-table-column prop="workTotalInit" label="总工作量" align="center" width="100"> |
| | | <el-table-column show-overflow-tooltip prop="realLastCost" label="本周消化工时"> |
| | | <template slot-scope="scope"> |
| | | {{ scope.row.lastProjectProcess.realLastCost != null ? scope.row.realLastCost - scope.row.lastProjectProcess.realLastCost : 0 }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column show-overflow-tooltip prop="workTotalInit" label="总工作量"> |
| | | <template slot-scope="scope"> |
| | | {{ scope.row.workTotalInit != null && scope.row.workTotalInit != '' ? crud.toMoney(scope.row.workTotalInit) : 0 }} |
| | | ({{ scope.row.lastProjectProcess.workTotalInit != null && scope.row.lastProjectProcess.workTotalInit != '' ? crud.toMoney(scope.row.workTotalInit - scope.row.lastProjectProcess.workTotalInit) : 0 }}) |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="workTotalCost" label="总消耗工作量" align="center" width="100"> |
| | | <el-table-column show-overflow-tooltip prop="workTotalCost" label="总消耗工作量"> |
| | | <template slot-scope="scope"> |
| | | {{ scope.row.workTotalCost != null && scope.row.workTotalCost != '' ? crud.toMoney(scope.row.workTotalCost) : 0 }} |
| | | ({{ scope.row.lastProjectProcess.workTotalCost != null && scope.row.lastProjectProcess.workTotalCost != '' ? crud.toMoney(scope.row.workTotalCost - scope.row.lastProjectProcess.workTotalCost) : 0 }}) |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="remarks" label="备注" show-overflow-tooltip /> |
| | | <el-table-column show-overflow-tooltip prop="approveStatus" label="承认状态"> |
| | | <template slot-scope="scope"> |
| | | <el-tag>{{ dict.label[approveStatus][scope.row.approveStatus] }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column show-overflow-tooltip prop="remarks" label="备注" width="140" /> |
| | | <el-table-column show-overflow-tooltip prop="createTime" label="创建时间" width="140" /> |
| | | <el-table-column v-if="checkPer(['admin','projectProgress:edit','projectProgress:del'])" label="操作" width="150px" align="center"> |
| | | <template slot-scope="scope"> |
| | | <udOperation |
| | |
| | | import pagination from '@crud/Pagination' |
| | | import constant from '../../../utils/constant' |
| | | |
| | | const defaultForm = { id: null, project: { id: null }, belongYear: null, belongWeek: null, approveStatus: null, projectProgress: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null } |
| | | const defaultForm = { id: null, project: { id: null }, belongYear: null, belongWeek: null, approveStatus: null, projectProgress: null, estimatedProgress: null, lastProjectProcess: {}, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null } |
| | | export default { |
| | | name: 'ProjectProgress', |
| | | components: { pagination, crudOperation, rrOperation, udOperation }, |
| | |
| | | return CRUD({ title: '项目进度', url: 'api/projectProgress', idField: 'id', sort: ['belongYear,desc', 'belongWeek,desc'], crudMethod: { ...crudProjectProgress }}) |
| | | }, |
| | | data() { |
| | | var checkProjectProgress = (rule, value, callback) => { |
| | | // 年度(2020~2099)验证 |
| | | var yearValidate = (rule, value, callback) => { |
| | | if (value != null && value !== '' && (isNaN(value) || !Number.isInteger(value) || Number(value) <= 2020 || Number(value) >= 2099)) { |
| | | callback(new Error('请输入 2020 到 2099 以内的正整数')) |
| | | } else { |
| | | callback() |
| | | } |
| | | } |
| | | // 周数(1~53)验证 |
| | | var weekValidate = (rule, value, callback) => { |
| | | if (value != null && value !== '' && (isNaN(value) || !Number.isInteger(value) || Number(value) < 1 || Number(value) > 53)) { |
| | | callback(new Error('请输入 1 到 53 以内的正整数')) |
| | | } else { |
| | | callback() |
| | | } |
| | | } |
| | | // 进度(百内)验证 |
| | | var progressValidate = (rule, value, callback) => { |
| | | const reg = /^([0-9]|[1-9]\d)(\.\d{1,2})?$|100$/ |
| | | if (value != null && value !== '' && !reg.test(value)) { |
| | | callback(new Error('请输入 一百 以内的正整数或两位小数')) |
| | |
| | | }, |
| | | rules: { |
| | | 'project.id': [ |
| | | { required: true, message: '项目不能为空', trigger: 'onblur' } |
| | | { required: true, message: '所属项目不能为空', trigger: 'change' } |
| | | ], |
| | | belongYear: [ |
| | | { required: true, message: '年度不能为空', trigger: 'blur' }, |
| | | { validator: yearValidate, trigger: 'blur' } |
| | | ], |
| | | belongWeek: [ |
| | | { required: true, message: '周数不能为空', trigger: 'blur' }, |
| | | { validator: weekValidate, trigger: 'blur' } |
| | | ], |
| | | projectProgress: [ |
| | | { required: true, message: '进度不能为空', trigger: 'onblur' }, |
| | | { required: true, validator: checkProjectProgress, trigger: 'onblur' } |
| | | { required: true, message: '本周实际不能为空', trigger: 'blur' }, |
| | | { validator: progressValidate, trigger: 'blur' } |
| | | ], |
| | | estimatedProgress: [ |
| | | { required: true, message: '下周预计不能为空', trigger: 'blur' }, |
| | | { validator: progressValidate, trigger: 'blur' } |
| | | ], |
| | | approveStatus: [ |
| | | { required: true, message: '进度不能为空', trigger: 'onblur' } |
| | | { required: true, message: '承认状态不能为空', trigger: 'blur' } |
| | | ] |
| | | }, |
| | | queryTypeOptions: [ |
| | | { key: 'projectId', display_name: '项目' }, |
| | | { key: 'projectDistinguish', display_name: '项目区分' }, |
| | | { key: 'belongYear', display_name: '年度' }, |
| | | { key: 'belongWeek', display_name: '周数' } |
| | | { key: 'belongWeek', display_name: '周数' }, |
| | | { key: 'projectId', display_name: '所属项目' }, |
| | | { key: 'projectDistinguish', display_name: '项目区分' } |
| | | ], |
| | | // 项目 |
| | | projectList: [], |
| | | // 年度 |
| | | belongYearList: [], |
| | | // 周数 |
| | | belongWeekList: [], |
| | | // 周数 |
| | | belongWeekList2: [], |
| | | // 禁用状态 |
| | | disabled: false, |
| | | // 项目区分 |
| | | projectDistinguish: constant.PROJECT_DISTINGUISH, |
| | | // 承认状态 |
| | | approveStatus: constant.APPROVE_STATUS, |
| | | // 未承认 |
| | | // 承认状态:未承认 |
| | | approveStatusUnsettled: constant.APPROVE_STATUS_UNRECOGNIZED, |
| | | // 已承认 |
| | | approveStatusAcknowledged: constant.APPROVE_STATUS_ACKNOWLEDGED |
| | | // 承认状态:已承认 |
| | | approveStatusAcknowledged: constant.APPROVE_STATUS_ACKNOWLEDGED, |
| | | // 项目列表 |
| | | projectList: [], |
| | | // 年度列表 |
| | | belongYearList: [], |
| | | // 周数列表 |
| | | belongWeekList: [], |
| | | // 禁用状态 |
| | | disabled: false |
| | | } |
| | | }, |
| | | watch: { |
| | | // 检索条件:年度 |
| | | 'query.belongYear'(newValue) { |
| | | // 年度变更后,周数初始化 |
| | | if (this.query.belongWeek) { |
| | | this.query.belongWeek = null |
| | | } |
| | | // 周数列表 |
| | | this.belongWeekList = [] |
| | | |
| | | // 年度清空后不需要查询数据 |
| | | if (!newValue) { |
| | | return |
| | |
| | | // 查询年度对应的周数 |
| | | crudProjectProgress.getBelongWeek(newValue).then(res => { |
| | | res.forEach(item => { |
| | | // 周数列表 |
| | | this.belongWeekList.push(item) |
| | | }) |
| | | }) |
| | | }, |
| | | 'form.belongYear'(newValue, oldValue) { |
| | | if (this.disabled || this.crud.status.add !== 1) { |
| | | return |
| | | } |
| | | // 年度变更后,周数初始化 |
| | | if (this.form.belongWeek) { |
| | | this.form.belongWeek = null |
| | | } |
| | | this.belongWeekList2 = [] |
| | | |
| | | // 年度清空后不需要查询数据 |
| | | if (!newValue) { |
| | | return |
| | | } |
| | | // 查询年度对应的周数 |
| | | crudProjectProgress.getBelongWeek(newValue).then(res => { |
| | | res.forEach(item => { |
| | | this.belongWeekList2.push(item) |
| | | }) |
| | | }) |
| | | } |
| | |
| | | methods: { |
| | | // 钩子:在获取表格数据之前执行,false 则代表不获取数据 |
| | | [CRUD.HOOK.beforeRefresh]() { |
| | | // 获取项目信息 |
| | | this.getProject() |
| | | // 获取年度信息 |
| | | this.getBelongYear() |
| | | return true |
| | | }, |
| | | // 新增与编辑前做的操作 |
| | | [CRUD.HOOK.afterToCU](crud, form) { |
| | | // 是否可以修改 |
| | | this.getDisabled() |
| | | this.belongWeekList2.splice(0, this.belongWeekList2.length) |
| | | }, |
| | | // 获取项目信息 |
| | | getProject() { |
| | | // 获取项目信息 |
| | | crudProject.getAll().then(res => { |
| | | // 项目列表 |
| | | this.projectList = res |
| | | }) |
| | | }, |
| | | // 获取年度信息 |
| | | getBelongYear() { |
| | | // 获取年度信息 |
| | | crudProjectProgress.getBelongYear().then(res => { |
| | | // 年度列表 |
| | | this.belongYearList = res |
| | | }) |
| | | }, |
| | | // 是否可以修改 |
| | | getDisabled() { |
| | | // 禁用状态 |
| | | this.disabled = false |
| | | // 判断表单承认状态 |
| | | if (this.form.approveStatus === this.approveStatusAcknowledged) { |
| | | // 禁用状态 |
| | | this.disabled = true |
| | | } else if (this.form.approveStatus === this.approveStatusUnsettled) { |
| | | // 禁用状态 |
| | | this.disabled = false |
| | | } |
| | | this.rules['project.id'].forEach(element => { |
| | | element.required = !(this.disabled || this.crud.status.add !== 1) |
| | | }) |
| | | this.rules.projectProgress.forEach(element => { |
| | | element.required = !(this.disabled) |
| | | }) |
| | | this.rules.approveStatus.forEach(element => { |
| | | element.required = !(this.disabled) |
| | | }) |
| | | } |
| | | } |
| | | } |
| | |
| | | <div class="head-container"> |
| | | <div v-if="crud.props.searchToggle"> |
| | | <!-- 搜索 --> |
| | | <!-- <el-input v-model="query.projectId" clearable placeholder="项目ID" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" /> --> |
| | | <el-input v-model="query.name" clearable placeholder="名称" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" /> |
| | | <el-select v-model="query.projectId" filterable placeholder="项目名称" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-select v-model="query.projectId" clearable filterable placeholder="所属项目" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-option |
| | | v-for="item in projectList" |
| | | :key="item.id" |
| | |
| | | <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="110px"> |
| | | <el-form-item label="名称" prop="name"> |
| | | <el-input v-model="form.name" maxlength="100" style="width: 340px;" /> |
| | | <el-input v-model="form.name" style="width: 340px;" :disabled="disabledFlagByApprove" /> |
| | | </el-form-item> |
| | | <el-form-item label="项目名称" prop="projectId"> |
| | | <el-select v-model="form.projectId" filterable placeholder="请选择" style="width: 340px;"> |
| | | <el-form-item label="所属项目" prop="projectId"> |
| | | <el-select v-model="form.projectId" clearable filterable placeholder="请选择" style="width: 340px;" :disabled="disabledFlagByApprove"> |
| | | <el-option |
| | | v-for="item in projectList" |
| | | :key="item.id" |
| | |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="任务分类" prop="taskClassification"> |
| | | <el-select v-model="form.taskClassification" filterable placeholder="请选择" style="width: 340px;"> |
| | | <el-select v-model="form.taskClassification" clearable filterable placeholder="请选择" style="width: 340px;" :disabled="disabledFlagByApprove"> |
| | | <el-option |
| | | v-for="item in dict[taskClassification]" |
| | | :key="item.id" |
| | |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="描述"> |
| | | <el-input v-model="form.description" :rows="3" type="textarea" style="width: 340px;" /> |
| | | <el-input v-model="form.description" :rows="3" type="textarea" style="width: 340px;" :disabled="disabledFlagByApprove" /> |
| | | </el-form-item> |
| | | <el-form-item label="计划开始时间"> |
| | | <el-date-picker v-model="form.planStartTime" type="datetime" :picker-options="pickerOptionsStart" style="width: 340px;" /> |
| | | <el-date-picker v-model="form.planStartTime" type="datetime" :picker-options="pickerOptionsStart" style="width: 340px;" :disabled="disabledFlagByApprove" /> |
| | | </el-form-item> |
| | | <el-form-item label="计划结束时间"> |
| | | <el-date-picker v-model="form.planEndTime" type="datetime" :picker-options="pickerOptionsEnd" style="width: 340px;" /> |
| | | <el-date-picker v-model="form.planEndTime" type="datetime" :picker-options="pickerOptionsEnd" style="width: 340px;" :disabled="disabledFlagByApprove" /> |
| | | </el-form-item> |
| | | <el-form-item label="计划工时" prop="planHours"> |
| | | <el-input v-model="form.planHours" style="width: 340px;" /> |
| | | <el-input v-model="form.planHours" style="width: 340px;" :disabled="disabledFlagByApprove" /> |
| | | </el-form-item> |
| | | <el-form-item label="计划工作量" prop="planWorkload"> |
| | | <el-input v-model="form.planWorkload" style="width: 340px;" /> |
| | | <el-input v-model="form.planWorkload" style="width: 340px;" :disabled="disabledFlagByApprove" /> |
| | | </el-form-item> |
| | | <el-form-item label="计划工作量单位"> |
| | | <el-select v-model="form.planWorkloadUnit" filterable placeholder="请选择" style="width: 340px;"> |
| | | <el-select v-model="form.planWorkloadUnit" filterable placeholder="请选择" style="width: 340px;" :disabled="disabledFlagByApprove"> |
| | | <el-option |
| | | v-for="item in dict[standardWorkloadUnit]" |
| | | :key="item.id" |
| | |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="备注"> |
| | | <el-input v-model="form.remarks" :rows="3" type="textarea" style="width: 340px;" /> |
| | | <el-input v-model="form.remarks" :rows="3" type="textarea" style="width: 340px;" :disabled="disabledFlagByApprove" /> |
| | | </el-form-item> |
| | | </el-form> |
| | | <div slot="footer" class="dialog-footer"> |
| | |
| | | <!--表格渲染--> |
| | | <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="name" label="名称" width="180" show-overflow-tooltip /> |
| | | <el-table-column prop="projectName" label="项目名称" width="180" show-overflow-tooltip> |
| | | <el-table-column show-overflow-tooltip prop="name" label="名称" width="180" /> |
| | | <el-table-column show-overflow-tooltip prop="projectName" label="所属项目" width="180"> |
| | | <template slot-scope="scope"> |
| | | <el-tag>{{ scope.row.projectName }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="taskClassification" label="任务分类" width="80" show-overflow-tooltip> |
| | | <el-table-column show-overflow-tooltip prop="taskClassification" label="任务分类" width="80"> |
| | | <template slot-scope="scope"> |
| | | <el-tag>{{ dict.label[taskClassification][scope.row.taskClassification] }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="description" label="描述" width="140" show-overflow-tooltip /> |
| | | <el-table-column prop="planStartTime" label="计划开始时间" show-overflow-tooltip /> |
| | | <el-table-column prop="planEndTime" label="计划结束时间" show-overflow-tooltip /> |
| | | <el-table-column prop="planHours" label="计划工时" width="100" show-overflow-tooltip /> |
| | | <el-table-column prop="planWorkload" label="计划工作量" width="100" show-overflow-tooltip /> |
| | | <el-table-column prop="planWorkloadUnit" label="计划工作量单位" width="120" show-overflow-tooltip> |
| | | <el-table-column show-overflow-tooltip prop="description" label="描述" width="140" /> |
| | | <el-table-column show-overflow-tooltip prop="planStartTime" label="计划开始时间" /> |
| | | <el-table-column show-overflow-tooltip prop="planEndTime" label="计划结束时间" /> |
| | | <el-table-column show-overflow-tooltip prop="planHours" label="计划工时" width="100" /> |
| | | <el-table-column show-overflow-tooltip prop="planWorkload" label="计划工作量" width="100" /> |
| | | <el-table-column show-overflow-tooltip prop="planWorkloadUnit" label="计划工作量单位" width="120"> |
| | | <template slot-scope="scope"> |
| | | <el-tag v-if="dict.label[standardWorkloadUnit][scope.row.planWorkloadUnit]!=null">{{ dict.label[standardWorkloadUnit][scope.row.planWorkloadUnit] }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="remarks" label="备注" width="140" show-overflow-tooltip /> |
| | | <el-table-column prop="createTime" label="创建时间" width="140" /> |
| | | <el-table-column show-overflow-tooltip prop="remarks" label="备注" width="140" /> |
| | | <el-table-column show-overflow-tooltip prop="createTime" label="创建时间" width="140" /> |
| | | <el-table-column v-if="checkPer(['admin','projectTask:edit','projectTask:del'])" label="操作" width="150px" align="center"> |
| | | <template slot-scope="scope"> |
| | | <udOperation |
| | |
| | | return CRUD({ title: '项目任务', url: 'api/projectTask', idField: 'id', sort: 'id,desc', crudMethod: { ...crudProjectTask }}) |
| | | }, |
| | | data() { |
| | | var planTime = (rule, value, callback) => { |
| | | const reg = /^([0-9]|[1-9]\d{1,2})(\.\d{1,2})?$|1000$/ |
| | | if (value != null && value !== '' && !reg.test(value)) { |
| | | callback(new Error('请输入 一千 以内的正整数或两位小数')) |
| | | } else { |
| | | callback() |
| | | } |
| | | } |
| | | var planWorkload = (rule, value, callback) => { |
| | | // 指针重指向 |
| | | const _this = this |
| | | // 时长(千内)验证 |
| | | var durationValidate = (rule, value, callback) => { |
| | | const reg = /^([0-9]|[1-9]\d{1,2})(\.\d{1,2})?$|1000$/ |
| | | if (value != null && value !== '' && !reg.test(value)) { |
| | | callback(new Error('请输入 一千 以内的正整数或两位小数')) |
| | |
| | | rules: { |
| | | name: [ |
| | | { required: true, message: '名称不能为空', trigger: 'blur' }, |
| | | { min: 1, max: 100, message: '最大长度 100 个字符', trigger: 'blur' } |
| | | { max: 100, message: '最大长度 100 个字符', trigger: 'blur' } |
| | | ], |
| | | projectId: [ |
| | | { required: true, message: '项目名称不能为空', trigger: 'blur' } |
| | | { required: true, message: '所属项目不能为空', trigger: 'change' } |
| | | ], |
| | | taskClassification: [ |
| | | { required: true, message: '任务分类不能为空', trigger: 'blur' } |
| | | { required: true, message: '任务分类不能为空', trigger: 'change' } |
| | | ], |
| | | planHours: [ |
| | | { required: true, validator: planTime, trigger: 'blur' } |
| | | { required: true, message: '计划工时不能为空', trigger: 'blur' }, |
| | | { validator: durationValidate, trigger: 'blur' } |
| | | ], |
| | | planWorkload: [ |
| | | { validator: planWorkload, trigger: 'blur' } |
| | | { validator: durationValidate, trigger: 'blur' } |
| | | ] |
| | | }, |
| | | queryTypeOptions: [ |
| | | { key: 'projectId', display_name: '项目名称' }, |
| | | { key: 'name', display_name: '名称' }, |
| | | { key: 'taskClassification', display_name: '任务分类' }, |
| | | { key: 'planStartTime', display_name: '计划开始时间' }, |
| | | { key: 'planEndTime', display_name: '计划结束时间' } |
| | | { key: 'projectId', display_name: '所属项目' }, |
| | | { key: 'taskClassification', display_name: '任务分类' } |
| | | ], |
| | | // 字典:任务分类 |
| | | taskClassification: constant.TAST_CLASSIFICATION, |
| | |
| | | approveStatusAcknowledged: constant.APPROVE_STATUS_ACKNOWLEDGED, |
| | | // 项目列表 |
| | | projectList: [], |
| | | // 计划开始时间选项 |
| | | pickerOptionsStart: { |
| | | disabledDate: (time) => { |
| | | if (this.form.planEndTime) { |
| | | return time.getTime() > this.form.planEndTime |
| | | return _this.form.planEndTime != null && _this.form.planEndTime !== '' ? time.getTime() > new Date(_this.form.planEndTime).getTime() : false |
| | | } |
| | | } |
| | | }, |
| | | // 计划结束时间选项 |
| | | pickerOptionsEnd: { |
| | | disabledDate: (time) => { |
| | | return time.getTime() < this.form.planStartTime |
| | | return _this.form.planStartTime != null && _this.form.planStartTime !== '' ? time.getTime() < new Date(_this.form.planStartTime).getTime() - (86400000 - 1) : false |
| | | } |
| | | } |
| | | }, |
| | | // 表单禁用标记(承认状态) |
| | | disabledFlagByApprove: false |
| | | } |
| | | }, |
| | | methods: { |
| | | // 钩子:在获取表格数据之前执行,false 则代表不获取数据 |
| | | [CRUD.HOOK.beforeRefresh]() { |
| | | // 判断传参是否为空 |
| | | if (this.$route.params.projectId != null && this.$route.params.projectId !== '' && this.crud.query.projectId === undefined) { |
| | | // 检索条件赋值 |
| | | this.$set(this.crud.query, 'projectId', Number(this.$route.params.projectId)) |
| | | } |
| | | // 获取信息项目列表 |
| | | this.getprojectAll() |
| | | return true |
| | | }, |
| | | // 新增与编辑前做的操作 |
| | | [CRUD.HOOK.afterToCU](crud, form) { |
| | | // 表单禁用标记(承认状态) |
| | | this.disabledFlagByApprove = false |
| | | // 循环项目列表 |
| | | for (let i = 0; i < this.projectList.length; i++) { |
| | | // 判断是否为同一项目 |
| | | if (this.form.projectId === this.projectList[i].id && this.projectList[i].approveStatus === constant.APPROVE_STATUS_ACKNOWLEDGED) { |
| | | // 表单禁用标记(承认状态) |
| | | this.disabledFlagByApprove = true |
| | | } |
| | | } |
| | | // 随机数 |
| | | this.random = Math.random() |
| | | }, |
| | | // 获取信息项目列表 |
| | | getprojectAll() { |
| | | // 获取信息项目列表 |
| | | crudProject.getAll().then(res => { |
| | | // 项目列表 |
| | | this.projectList = res |
| | | }) |
| | | } |
| | |
| | | <div class="head-container"> |
| | | <div v-if="crud.props.searchToggle"> |
| | | <!-- 搜索 --> |
| | | <el-input v-model="query.name" clearable placeholder="请输入名称" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" /> |
| | | <el-input v-model="query.name" clearable placeholder="名称" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" /> |
| | | <rrOperation /> |
| | | </div> |
| | | <!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'--> |
| | |
| | | <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="120px"> |
| | | <el-form-item label="名称" prop="name"> |
| | | <el-input v-model="form.name" maxlength="100" style="width: 330px;" /> |
| | | <el-input v-model="form.name" style="width: 330px;" /> |
| | | </el-form-item> |
| | | <el-form-item label="标准单价币种" prop="standardUnitCurrency"> |
| | | <el-form-item label="标准报价单金" prop="standardQuotationPrice"> |
| | | <money-input :key="random" v-model="form.standardQuotationPrice" :width="330" /> |
| | | </el-form-item> |
| | | <el-form-item label="标准报价币种" prop="standardUnitCurrency"> |
| | | <el-select v-model="form.standardUnitCurrency" filterable placeholder="请选择" style="width: 330px;"> |
| | | <el-option |
| | | v-for="item in dict[standardUnitCurrency]" |
| | |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="标准报价单金" prop="standardQuotationPrice"> |
| | | <money-input :key="random" v-model="form.standardQuotationPrice" :width="330" /> |
| | | </el-form-item> |
| | | <el-form-item label="标准绩效单金" prop="standardPerformancePrice"> |
| | | <money-input :key="random" v-model="form.standardPerformancePrice" :width="330" /> |
| | | </el-form-item> |
| | | <el-form-item label="标准绩效币种"> |
| | | <el-select v-model="standardUnitCurrencyRenminbi" filterable placeholder="请选择" style="width: 330px;" disabled> |
| | | <el-option |
| | | v-for="item in dict[standardUnitCurrency]" |
| | | :key="item.id" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="标准绩效目标" prop="standardPerformanceObjectives"> |
| | | <el-input v-model="form.standardPerformanceObjectives" filterable placeholder="请输入绩效目标" style="width: 330px;"> |
| | | <el-input v-model="form.standardPerformanceObjectives" style="width: 330px;"> |
| | | <template slot="append">%</template> |
| | | </el-input> |
| | | </el-form-item> |
| | |
| | | <!--表格渲染--> |
| | | <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="name" label="名称" show-overflow-tooltip /> |
| | | <el-table-column prop="standardUnitCurrency" label="标准单价币种"> |
| | | <template slot-scope="scope"> |
| | | <el-tag>{{ dict.label[standardUnitCurrency][scope.row.standardUnitCurrency] }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="standardQuotationPrice" label="标准报价单金"> |
| | | <el-table-column show-overflow-tooltip prop="name" label="名称" /> |
| | | <el-table-column show-overflow-tooltip prop="standardQuotationPrice" label="标准报价单金"> |
| | | <template slot-scope="scope"> |
| | | {{ crud.toMoney(scope.row.standardQuotationPrice) }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="standardPerformancePrice" label="标准绩效单金"> |
| | | <el-table-column show-overflow-tooltip prop="standardUnitCurrency" label="标准报价币种"> |
| | | <template slot-scope="scope"> |
| | | <el-tag>{{ dict.label[standardUnitCurrency][scope.row.standardUnitCurrency] }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column show-overflow-tooltip prop="standardPerformancePrice" label="标准绩效单金"> |
| | | <template slot-scope="scope"> |
| | | {{ crud.toMoney(scope.row.standardPerformancePrice) }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="standardPerformanceObjectives" label="标准绩效目标"> |
| | | <el-table-column show-overflow-tooltip label="标准绩效币种"> |
| | | <el-tag>{{ dict.label[standardUnitCurrency][standardUnitCurrencyRenminbi] }}</el-tag> |
| | | </el-table-column> |
| | | <el-table-column show-overflow-tooltip prop="standardPerformanceObjectives" label="标准绩效目标"> |
| | | <template slot-scope="scope"> |
| | | {{ scope.row.standardPerformanceObjectives }}% |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="standardWorkloadUnit" label="标准工作量单位"> |
| | | <el-table-column show-overflow-tooltip prop="standardWorkloadUnit" label="标准工作量单位"> |
| | | <template slot-scope="scope"> |
| | | <el-tag>{{ dict.label[standardWorkloadUnit][scope.row.standardWorkloadUnit] }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="remarks" label="备注" show-overflow-tooltip /> |
| | | <el-table-column prop="createTime" label="创建时间" /> |
| | | <el-table-column show-overflow-tooltip prop="remarks" label="备注" /> |
| | | <el-table-column show-overflow-tooltip prop="createTime" label="创建时间" /> |
| | | <el-table-column v-if="checkPer(['admin','projectType:edit','projectType:del'])" label="操作" width="150px" align="center"> |
| | | <template slot-scope="scope"> |
| | | <udOperation |
| | |
| | | return CRUD({ title: '项目类型', url: 'api/projectType', idField: 'id', sort: 'id,desc', crudMethod: { ...crudProjectType }}) |
| | | }, |
| | | data() { |
| | | var checkStandardQuotationPrice = (rule, value, callback) => { |
| | | if (value !== null) { |
| | | if (isNaN(Number(value))) { |
| | | callback(new Error('标准报价单金必须是数字')) |
| | | } else { |
| | | if (value <= 0) { |
| | | callback(new Error('标准报价单金必须大于0')) |
| | | } else if (value >= 10000000000) { |
| | | callback(new Error('标准报价单金必须小于1百亿')) |
| | | } else { |
| | | callback() |
| | | } |
| | | } |
| | | // 金额(十亿内)验证 |
| | | var priceValidate = (rule, value, callback) => { |
| | | if (value != null && value !== '' && (isNaN(value) || Number(value) < 0 || Number(value) > 1000000000)) { |
| | | callback(new Error('请输入 十亿 以内的正整数或两位小数')) |
| | | } else { |
| | | callback(new Error('标准报价单金不能为空')) |
| | | } |
| | | } |
| | | var checkStandardPerformancePrice = (rule, value, callback) => { |
| | | if (value !== null) { |
| | | if (isNaN(Number(value))) { |
| | | callback(new Error('标准绩效单金必须是数字')) |
| | | } else { |
| | | if (value <= 0) { |
| | | callback(new Error('标准绩效单金必须大于0')) |
| | | } else if (value >= 10000000000) { |
| | | callback(new Error('标准绩效单金必须小于1百亿')) |
| | | } else { |
| | | callback() |
| | | } |
| | | } |
| | | } else { |
| | | callback(new Error('标准绩效单金不能为空')) |
| | | callback() |
| | | } |
| | | } |
| | | // 比例(百内)验证 |
| | |
| | | rules: { |
| | | name: [ |
| | | { required: true, message: '名称不能为空', trigger: 'blur' }, |
| | | { min: 1, max: 100, message: '最大长度 100 个字符', trigger: 'blur' } |
| | | ], |
| | | standardUnitCurrency: [ |
| | | { required: true, message: '标准单价币种不能为空', trigger: 'blur' } |
| | | { max: 100, message: '最大长度 100 个字符', trigger: 'blur' } |
| | | ], |
| | | standardQuotationPrice: [ |
| | | { required: true, validator: checkStandardQuotationPrice, trigger: 'blur' } |
| | | { required: true, message: '标准报价单金不能为空', trigger: 'blur' }, |
| | | { validator: priceValidate, trigger: 'blur' } |
| | | ], |
| | | standardUnitCurrency: [ |
| | | { required: true, message: '标准报价币种不能为空', trigger: 'change' } |
| | | ], |
| | | standardPerformancePrice: [ |
| | | { required: true, validator: checkStandardPerformancePrice, trigger: 'blur' } |
| | | { required: true, message: '标准绩效单金不能为空', trigger: 'blur' }, |
| | | { validator: priceValidate, trigger: 'blur' } |
| | | ], |
| | | standardPerformanceObjectives: [ |
| | | { required: true, validator: proportionValidate, trigger: 'blur' } |
| | | { required: true, message: '标准绩效目标不能为空', trigger: 'blur' }, |
| | | { validator: proportionValidate, trigger: 'blur' } |
| | | ], |
| | | standardWorkloadUnit: [ |
| | | { required: true, message: '标准工作量单位不能为空', trigger: 'blur' } |
| | | { required: true, message: '标准工作量单位不能为空', trigger: 'change' } |
| | | ] |
| | | }, |
| | | queryTypeOptions: [ |
| | |
| | | ], |
| | | // 标准单价币种 |
| | | standardUnitCurrency: constant.STANDARD_UNIT_CURRENCY, |
| | | // 标准单价币种:人民币 |
| | | standardUnitCurrencyRenminbi: constant.STANDARD_UNIT_CURRENCY_RENMINBI, |
| | | // 标准工作量单位 |
| | | standardWorkloadUnit: constant.STANDARD_WORKLOAD_UNIT, |
| | | // 随机数 |