Преглед изворни кода

项目甘特图功能,按人员分组

seyason пре 3 година
родитељ
комит
f8fde5f50a
19 измењених фајлова са 842 додато и 110 уклоњено
  1. 6 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/DepartmentController.java
  2. 4 1
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ProjectController.java
  3. 237 78
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ReportController.java
  4. 20 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/vo/GanttDataItem.java
  5. 2 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/ProjectMapper.java
  6. 2 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/DepartmentService.java
  7. 2 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/ProjectService.java
  8. 3 1
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/ReportService.java
  9. 49 1
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/DepartmentServiceImpl.java
  10. 116 7
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java
  11. 18 6
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ReportServiceImpl.java
  12. 11 0
      fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ProjectMapper.xml
  13. 5 0
      fhKeeper/formulahousekeeper/timesheet/package-lock.json
  14. 1 0
      fhKeeper/formulahousekeeper/timesheet/package.json
  15. 9 0
      fhKeeper/formulahousekeeper/timesheet/src/routes.js
  16. 119 0
      fhKeeper/formulahousekeeper/timesheet/src/views/project/gantt.vue
  17. 5 0
      fhKeeper/formulahousekeeper/timesheet/src/views/project/list.vue
  18. 77 0
      fhKeeper/formulahousekeeper/timesheet/src/views/project/project_gantt.vue
  19. 156 16
      fhKeeper/formulahousekeeper/timesheet/src/views/workReport/daily.vue

+ 6 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/DepartmentController.java

@@ -38,6 +38,12 @@ public class DepartmentController {
         return departmentService.listAllMemb(request);
     }
 
+    //获取我可以管辖到的人员列表,进行代填时选择的人员列表用到
+    @RequestMapping("/listMyMembs")
+    public HttpRespMsg listMyMembs(HttpServletRequest request) {
+        return departmentService.listMyMembs(request);
+    }
+
     /**
      * 获取不带有层级的部门列表
      */

+ 4 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ProjectController.java

@@ -259,7 +259,10 @@ public class ProjectController {
         return projectService.importData(userId, file, request);
     }
 
-
+    @RequestMapping("/getGanttData")
+    public HttpRespMsg getGanttData(HttpServletRequest request) {
+        return projectService.getGanttData(request);
+    }
     //
 }
 

+ 237 - 78
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ReportController.java

@@ -1,6 +1,7 @@
 package com.management.platform.controller;
 
 
+import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.management.platform.entity.Report;
 import com.management.platform.entity.User;
@@ -9,6 +10,7 @@ import com.management.platform.service.ReportService;
 import com.management.platform.service.UserSalaryService;
 import com.management.platform.service.UserService;
 import com.management.platform.util.HttpRespMsg;
+import com.management.platform.util.ListUtil;
 import org.apache.log4j.helpers.DateTimeDateFormat;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -101,34 +103,83 @@ public class ReportController {
                                   String[] createDate,
                                   Integer[] taskId,
                                   Integer[] isOvertime,
-                                  Integer[] progress) {
+                                  Integer[] progress,
+                                  String[] targetUids
+                                    ) {
         List<Report> reportList = new ArrayList<>();
         String token = request.getHeader("Token");
+        List<String> targetUidList = null;
+        List<User> targetUserList = null;
+        //代填
+        if (targetUids != null && targetUids.length > 0) {
+            String val = targetUids[0];
+            System.out.println("val===="+val);
+            String[] ids = val.split("@");
+            targetUidList = new ArrayList<>();
+            for (int i = 0; i < ids.length; i++) {
+                targetUidList.add(ids[i]);
+                System.out.println("用户ID=="+ids[i]);
+            }
+            targetUserList = userService.list(new QueryWrapper<User>().in("id", targetUidList));
+        }
         User user = userService.getById(token);
         LocalDate now = LocalDate.now();
         DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
         BigDecimal hourCost = null;
-        if (user.getCostApplyDate() != null) {
-            //检查有效期
-            if (user.getCostApplyDate().compareTo(dtf.format(now)) > 0) {
-                //取上一个历史成本
-                List<UserSalary> list = userSalaryService.list(new QueryWrapper<UserSalary>().eq("user_id", user.getId()).orderByDesc("indate").last("limit 2"));
-                if (list.size() > 1) {
-                    hourCost = list.get(1).getCost();
+        //自己填写的情况,计算个人自己的时薪
+        if (targetUidList == null) {
+            if (user.getCostApplyDate() != null) {
+                //检查有效期
+                if (user.getCostApplyDate().compareTo(dtf.format(now)) > 0) {
+                    //取上一个历史成本
+                    List<UserSalary> list = userSalaryService.list(new QueryWrapper<UserSalary>().eq("user_id", user.getId()).orderByDesc("indate").last("limit 2"));
+                    if (list.size() > 1) {
+                        hourCost = list.get(1).getCost();
+                    } else {
+                        //没有记录,又没有达到预设的起效时间,则默认为0
+                        hourCost = new BigDecimal(0);
+                    }
                 } else {
-                    //没有记录,又没有达到预设的起效时间,则默认为0
-                    hourCost = new BigDecimal(0);
+                    hourCost = user.getCost();
                 }
             } else {
                 hourCost = user.getCost();
             }
+
+            if (hourCost == null) {
+                hourCost = new BigDecimal(0);
+            }
         } else {
-            hourCost = user.getCost();
-        }
+            //代填的情况,计算每个人的时薪
+            for (User subsUser : targetUserList) {
+                BigDecimal tempCost = new BigDecimal(0);
+                if (subsUser.getCostApplyDate() != null) {
+                    //检查有效期
+                    if (subsUser.getCostApplyDate().compareTo(dtf.format(now)) > 0) {
+                        //取上一个历史成本
+                        List<UserSalary> list = userSalaryService.list(new QueryWrapper<UserSalary>().eq("user_id", subsUser.getId()).orderByDesc("indate").last("limit 2"));
+                        if (list.size() > 1) {
+                            tempCost = list.get(1).getCost();
+                        } else {
+                            //没有记录,又没有达到预设的起效时间,则默认为0
+                            tempCost = new BigDecimal(0);
+                        }
+                    } else {
+                        tempCost = subsUser.getCost();
+                    }
+                } else {
+                    tempCost = subsUser.getCost();
+                }
 
-        if (hourCost == null) {
-            hourCost = new BigDecimal(0);
+                if (tempCost == null) {
+                    tempCost = new BigDecimal(0);
+                }
+                //设置好时薪
+                System.out.println(subsUser.getName()+"的时薪是"+tempCost);
+                subsUser.setCost(tempCost);
+            }
         }
+
         SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
 
         try {
@@ -164,15 +215,172 @@ public class ReportController {
                         localStartDate = localStartDate.plusDays(daysOffset);
                         //跳过周末
                         if (localStartDate.getDayOfWeek() != DayOfWeek.SATURDAY && localStartDate.getDayOfWeek() != DayOfWeek.SUNDAY) {
+                            if (targetUserList == null) {
+                                Report report = new Report()
+                                        .setId(id[i] == -1 ? null : id[i])
+                                        .setProjectId(projectId[i])
+                                        .setSubProjectId(subProjectId[i] == 0?null:subProjectId[i])
+                                        .setReportTimeType(reportTimeType[i])
+                                        .setContent(content[i])
+                                        .setState(0)
+                                        .setCreateDate(localStartDate)
+                                        .setCreatorId(token);
+                                if (taskId != null && taskId[i] != null && taskId[i] != 0) {
+                                    report.setTaskId(taskId[i]);
+                                }
+                                if (isOvertime != null && isOvertime[i] != null) {
+                                    report.setIsOvertime(isOvertime[i]);
+                                }
+                                if (progress != null && progress[i] != null) {
+                                    report.setProgress(progress[i]);
+                                }
+                                if (report.getReportTimeType() == 0) {
+                                    report.setWorkingTime(workingTime[i])
+                                            .setCost(hourCost.multiply(new BigDecimal(workingTime[i])))
+                                            .setTimeType(timeType[i]);
+                                } else if (report.getReportTimeType() == 1) {
+                                    report.setWorkingTime(workingTime[i])
+                                            .setCost(hourCost.multiply(new BigDecimal(workingTime[i])));
+                                } else if (report.getReportTimeType() == 2) {
+                                    //时间范围填报, 计算一下时长
+                                    try {
+                                        report.setStartTime(startTime[i]).setEndTime(endTime[i]);
+                                        long time = sdf.parse(report.getEndTime()).getTime() - sdf.parse(report.getStartTime()).getTime();
+                                        int minutes = (int)time/1000/60;
+                                        double hours = minutes*1.0f/60;
+                                        report.setWorkingTime(hours);
+                                        report.setCost(hourCost.multiply(new BigDecimal(hours)));
+                                    } catch (ParseException e) {
+                                        e.printStackTrace();
+                                    }
+                                } else if (report.getReportTimeType() == 3) {
+                                    //计算时长
+                                    report.setWorkingTime(workingTime[i])
+                                            .setCost(hourCost.multiply(new BigDecimal(workingTime[i])));
+                                }
+                                reportList.add(report);
+                            } else {
+                                //批量代填报的
+                                for (User subsUser : targetUserList) {
+                                    Report report = new Report()
+                                            .setId(id[i] == -1 ? null : id[i])
+                                            .setProjectId(projectId[i])
+                                            .setSubProjectId(subProjectId[i] == 0?null:subProjectId[i])
+                                            .setReportTimeType(reportTimeType[i])
+                                            .setContent(content[i])
+                                            .setState(1)//代填,直接是审核通过状态
+                                            .setCreateDate(localStartDate)
+                                            .setCreatorId(subsUser.getId());
+                                    if (taskId != null && taskId[i] != null && taskId[i] != 0) {
+                                        report.setTaskId(taskId[i]);
+                                    }
+                                    if (isOvertime != null && isOvertime[i] != null) {
+                                        report.setIsOvertime(isOvertime[i]);
+                                    }
+                                    if (progress != null && progress[i] != null) {
+                                        report.setProgress(progress[i]);
+                                    }
+                                    if (report.getReportTimeType() == 0) {
+                                        report.setWorkingTime(workingTime[i])
+                                                .setCost(subsUser.getCost().multiply(new BigDecimal(workingTime[i])))
+                                                .setTimeType(timeType[i]);
+                                    } else if (report.getReportTimeType() == 1) {
+                                        report.setWorkingTime(workingTime[i])
+                                                .setCost(subsUser.getCost().multiply(new BigDecimal(workingTime[i])));
+                                    } else if (report.getReportTimeType() == 2) {
+                                        //时间范围填报, 计算一下时长
+                                        try {
+                                            report.setStartTime(startTime[i]).setEndTime(endTime[i]);
+                                            long time = sdf.parse(report.getEndTime()).getTime() - sdf.parse(report.getStartTime()).getTime();
+                                            int minutes = (int)time/1000/60;
+                                            double hours = minutes*1.0f/60;
+                                            report.setWorkingTime(hours);
+                                            report.setCost(subsUser.getCost().multiply(new BigDecimal(hours)));
+                                        } catch (ParseException e) {
+                                            e.printStackTrace();
+                                        }
+                                    } else if (report.getReportTimeType() == 3) {
+                                        //计算时长
+                                        report.setWorkingTime(workingTime[i])
+                                                .setCost(subsUser.getCost().multiply(new BigDecimal(workingTime[i])));
+                                    }
+                                    reportList.add(report);
+                                }
+                            }
+
+
+                        }
+
+                        //结束条件
+                        if (localStartDate.isEqual(localEndDate)) {
+                            break;
+                        }
+                        daysOffset = 1;
+                    }
+                } else {
+                    if (targetUidList == null) {
+                        Report report = new Report()
+                                .setId(id[i] == -1 ? null : id[i])
+                                .setProjectId(projectId[i])
+                                .setSubProjectId(subProjectId[i] == 0?null:subProjectId[i])
+                                .setReportTimeType(reportTimeType[i])
+                                .setContent(content[i])
+                                .setState(0)
+                                .setCreateDate(LocalDate.parse(createDate[i], DateTimeFormatter.ofPattern("yyyy-MM-dd")))
+                                .setCreatorId(token);
+                        if (taskId != null && taskId[i] != null && taskId[i] != 0) {
+                            report.setTaskId(taskId[i]);
+                        }
+                        if (isOvertime != null && isOvertime[i] != null) {
+                            report.setIsOvertime(isOvertime[i]);
+                        }
+                        if (progress != null && progress[i] != null) {
+                            report.setProgress(progress[i]);
+                        }
+                        if (report.getReportTimeType() == 0) {
+                            report.setWorkingTime(workingTime[i])
+                                    .setCost(hourCost.multiply(new BigDecimal(workingTime[i])))
+                                    .setTimeType(timeType[i]);
+                        } else if (report.getReportTimeType() == 1) {
+                            report.setWorkingTime(workingTime[i])
+                                    .setCost(hourCost.multiply(new BigDecimal(workingTime[i])));
+                        } else if (report.getReportTimeType() == 2) {
+                            //时间范围填报, 计算一下时长
+                            try {
+                                report.setStartTime(startTime[i]).setEndTime(endTime[i]);
+                                long time = sdf.parse(report.getEndTime()).getTime() - sdf.parse(report.getStartTime()).getTime();
+                                int minutes = (int)time/1000/60;
+                                double hours = minutes*1.0f/60;
+                                report.setWorkingTime(hours);
+                                report.setCost(hourCost.multiply(new BigDecimal(hours)));
+                            } catch (ParseException e) {
+                                e.printStackTrace();
+                            }
+                        } else if (report.getReportTimeType() == 3) {
+                            //计算时长
+                            report.setWorkingTime(workingTime[i])
+                                    .setCost(hourCost.multiply(new BigDecimal(workingTime[i])));
+                        }
+                        reportList.add(report);
+                        /*后续需要加入状态*/
+                        if (createDate[i] == null || projectId[i] == null) {
+                            HttpRespMsg httpRespMsg = new HttpRespMsg();
+                            httpRespMsg.setError("缺少数据");
+                            return httpRespMsg;
+                        }
+                    } else {
+                        //批量代填的情况
+                        for (User subsUser : targetUserList) {
+                            System.out.println("生成日报FOR=="+subsUser.getName()+", "+subsUser.getCost().toString());
                             Report report = new Report()
                                     .setId(id[i] == -1 ? null : id[i])
                                     .setProjectId(projectId[i])
                                     .setSubProjectId(subProjectId[i] == 0?null:subProjectId[i])
                                     .setReportTimeType(reportTimeType[i])
                                     .setContent(content[i])
-                                    .setState(0)
-                                    .setCreateDate(localStartDate)
-                                    .setCreatorId(token);
+                                    .setState(1)//代填的就直接审核通过了
+                                    .setCreateDate(LocalDate.parse(createDate[i], DateTimeFormatter.ofPattern("yyyy-MM-dd")))
+                                    .setCreatorId(subsUser.getId());
                             if (taskId != null && taskId[i] != null && taskId[i] != 0) {
                                 report.setTaskId(taskId[i]);
                             }
@@ -184,11 +392,11 @@ public class ReportController {
                             }
                             if (report.getReportTimeType() == 0) {
                                 report.setWorkingTime(workingTime[i])
-                                        .setCost(hourCost.multiply(new BigDecimal(workingTime[i])))
+                                        .setCost(subsUser.getCost().multiply(new BigDecimal(workingTime[i])))
                                         .setTimeType(timeType[i]);
                             } else if (report.getReportTimeType() == 1) {
                                 report.setWorkingTime(workingTime[i])
-                                        .setCost(hourCost.multiply(new BigDecimal(workingTime[i])));
+                                        .setCost(subsUser.getCost().multiply(new BigDecimal(workingTime[i])));
                             } else if (report.getReportTimeType() == 2) {
                                 //时间范围填报, 计算一下时长
                                 try {
@@ -197,74 +405,25 @@ public class ReportController {
                                     int minutes = (int)time/1000/60;
                                     double hours = minutes*1.0f/60;
                                     report.setWorkingTime(hours);
-                                    report.setCost(hourCost.multiply(new BigDecimal(hours)));
+                                    report.setCost(subsUser.getCost().multiply(new BigDecimal(hours)));
                                 } catch (ParseException e) {
                                     e.printStackTrace();
                                 }
                             } else if (report.getReportTimeType() == 3) {
                                 //计算时长
                                 report.setWorkingTime(workingTime[i])
-                                        .setCost(hourCost.multiply(new BigDecimal(workingTime[i])));
+                                        .setCost(subsUser.getCost().multiply(new BigDecimal(workingTime[i])));
                             }
                             reportList.add(report);
+                            /*后续需要加入状态*/
+                            if (createDate[i] == null || projectId[i] == null) {
+                                HttpRespMsg httpRespMsg = new HttpRespMsg();
+                                httpRespMsg.setError("缺少数据");
+                                return httpRespMsg;
+                            }
                         }
-
-                        //结束条件
-                        if (localStartDate.isEqual(localEndDate)) {
-                            break;
-                        }
-                        daysOffset = 1;
-                    }
-                } else {
-                    Report report = new Report()
-                            .setId(id[i] == -1 ? null : id[i])
-                            .setProjectId(projectId[i])
-                            .setSubProjectId(subProjectId[i] == 0?null:subProjectId[i])
-                            .setReportTimeType(reportTimeType[i])
-                            .setContent(content[i])
-                            .setState(0)
-                            .setCreateDate(LocalDate.parse(createDate[i], DateTimeFormatter.ofPattern("yyyy-MM-dd")))
-                            .setCreatorId(token);
-                    if (taskId != null && taskId[i] != null && taskId[i] != 0) {
-                        report.setTaskId(taskId[i]);
-                    }
-                    if (isOvertime != null && isOvertime[i] != null) {
-                        report.setIsOvertime(isOvertime[i]);
-                    }
-                    if (progress != null && progress[i] != null) {
-                        report.setProgress(progress[i]);
-                    }
-                    if (report.getReportTimeType() == 0) {
-                        report.setWorkingTime(workingTime[i])
-                                .setCost(hourCost.multiply(new BigDecimal(workingTime[i])))
-                                .setTimeType(timeType[i]);
-                    } else if (report.getReportTimeType() == 1) {
-                        report.setWorkingTime(workingTime[i])
-                                .setCost(hourCost.multiply(new BigDecimal(workingTime[i])));
-                    } else if (report.getReportTimeType() == 2) {
-                        //时间范围填报, 计算一下时长
-                        try {
-                            report.setStartTime(startTime[i]).setEndTime(endTime[i]);
-                            long time = sdf.parse(report.getEndTime()).getTime() - sdf.parse(report.getStartTime()).getTime();
-                            int minutes = (int)time/1000/60;
-                            double hours = minutes*1.0f/60;
-                            report.setWorkingTime(hours);
-                            report.setCost(hourCost.multiply(new BigDecimal(hours)));
-                        } catch (ParseException e) {
-                            e.printStackTrace();
-                        }
-                    } else if (report.getReportTimeType() == 3) {
-                        //计算时长
-                        report.setWorkingTime(workingTime[i])
-                                .setCost(hourCost.multiply(new BigDecimal(workingTime[i])));
-                    }
-                    reportList.add(report);
-                    /*后续需要加入状态*/
-                    if (createDate[i] == null || projectId[i] == null) {
-                        HttpRespMsg httpRespMsg = new HttpRespMsg();
-                        httpRespMsg.setError("缺少数据");
-                        return httpRespMsg;
                     }
+
                 }
             }
         } catch (NullPointerException e) {
@@ -273,7 +432,7 @@ public class ReportController {
             httpRespMsg.setError("验证失败");
             return httpRespMsg;
         }
-        return reportService.editReport(reportList, createDate.length > 0 ? createDate[0] : null);
+        return reportService.editReport(reportList, createDate.length > 0 ? createDate[0] : null, targetUserList, hourCost);
     }
 
     /**

+ 20 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/vo/GanttDataItem.java

@@ -0,0 +1,20 @@
+package com.management.platform.entity.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class GanttDataItem {
+    public String id;
+    public String userId;
+    public String text;
+    public Integer duration;
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    public Date start_date;
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    public Date end_date;
+    public String parent;
+}

+ 2 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/ProjectMapper.java

@@ -42,4 +42,6 @@ public interface ProjectMapper extends BaseMapper<Project> {
     Integer getCustomerProjectInAndOutCount(Integer companyId);
 
     List<CustomerProject> getProjectInAndOutByRange(Integer companyId, List<Integer> ids);
+
+    List<Map> getGanttData(@Param("userIds") List<String> userIds);
 }

+ 2 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/DepartmentService.java

@@ -32,4 +32,6 @@ public interface DepartmentService extends IService<Department> {
     HttpRespMsg exportUserStatistic(String startDate, String endDate, String userIds, HttpServletRequest request);
 
     HttpRespMsg listAllMemb(HttpServletRequest request);
+
+    HttpRespMsg listMyMembs(HttpServletRequest request);
 }

+ 2 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/ProjectService.java

@@ -76,4 +76,6 @@ public interface ProjectService extends IService<Project> {
     HttpRespMsg getCustomerProjectInAndOut(Integer pageIndex, Integer pageSize, HttpServletRequest request);
 
     HttpRespMsg exportCustomerProjectInAndOut(HttpServletRequest request);
+
+    HttpRespMsg getGanttData(HttpServletRequest request);
 }

+ 3 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/ReportService.java

@@ -2,10 +2,12 @@ package com.management.platform.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.management.platform.entity.Report;
+import com.management.platform.entity.User;
 import com.management.platform.util.HttpRespMsg;
 import org.springframework.web.bind.annotation.RequestParam;
 
 import javax.servlet.http.HttpServletRequest;
+import java.math.BigDecimal;
 import java.util.List;
 
 /**
@@ -23,7 +25,7 @@ public interface ReportService extends IService<Report> {
 
     HttpRespMsg getReport(String date, HttpServletRequest request);
 
-    HttpRespMsg editReport(List<Report> reportList, String date);
+    HttpRespMsg editReport(List<Report> reportList, String date, List<User> userList, BigDecimal hourCost);
 
     HttpRespMsg deleteReport(String userId, String date);
 

+ 49 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/DepartmentServiceImpl.java

@@ -3,10 +3,14 @@ package com.management.platform.service.impl;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.management.platform.entity.Department;
+import com.management.platform.entity.Participation;
+import com.management.platform.entity.Project;
 import com.management.platform.entity.User;
 import com.management.platform.entity.vo.DepartmentMasterVO;
 import com.management.platform.entity.vo.DepartmentVO;
 import com.management.platform.mapper.DepartmentMapper;
+import com.management.platform.mapper.ParticipationMapper;
+import com.management.platform.mapper.ProjectMapper;
 import com.management.platform.mapper.UserMapper;
 import com.management.platform.service.DepartmentService;
 import com.management.platform.util.ExcelUtil;
@@ -42,7 +46,10 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
     private DepartmentMapper departmentMapper;
     @Resource
     private DepartmentService departmentService;
-
+    @Resource
+    private ProjectMapper projectMapper;
+    @Resource
+    private ParticipationMapper participationMapper;
     //新增部门
     @Override
     public HttpRespMsg insertDepartment(String departmentName, Integer superiorId, String managerId, HttpServletRequest request) {
@@ -535,6 +542,47 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
         return msg;
     }
 
+    @Override
+    public HttpRespMsg listMyMembs(HttpServletRequest request) {
+        User currentUser = userMapper.selectById(request.getHeader("TOKEN"));
+        Integer companyId = currentUser.getCompanyId();
+        HttpRespMsg departmentList = departmentService.getDepartmentList(request);
+        List<DepartmentVO> list = (List<DepartmentVO>) departmentList.data;
+        //加上未分配的部门
+        DepartmentVO unAssignedDept = new DepartmentVO();
+        unAssignedDept.setId(0);
+        unAssignedDept.setLabel("未分配");
+        list.add(unAssignedDept);
+
+        //按照当前人员的权限,获取可管辖的人员列表
+        List<User> userList = new ArrayList<>();
+        if (currentUser.getRole() == 0) {
+            List<Project> projectList = projectMapper.selectList(new QueryWrapper<Project>().eq("incharger_id", currentUser.getId()));
+            if (projectList.size() > 0) {
+                List<Integer> collect = projectList.stream().map(Project::getId).collect(Collectors.toList());
+                List<Participation> participationList = participationMapper.selectList(new QueryWrapper<Participation>().in("project_id", collect));
+                List<String> userIds = participationList.stream().map(Participation::getUserId).collect(Collectors.toList());
+                userList = userMapper.selectList(new QueryWrapper<User>().in("id", userIds));
+            }
+        } else if (currentUser.getRole() == 1 || currentUser.getRole() == 2) {
+            userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId));
+        }
+
+        List<HashMap> userMapList = new ArrayList<>();
+        for (User u : userList) {
+            HashMap<String, Object> user = new HashMap<String, Object>();
+            user.put("id", u.getId());
+            user.put("name", u.getName());
+            user.put("departmentId", u.getDepartmentId());
+            userMapList.add(user);
+        }
+        fillDeptUser(list, userMapList);
+
+        HttpRespMsg msg = new HttpRespMsg();
+        msg.data = list;
+        return msg;
+    }
+
 
     private void fillDeptUser(List<DepartmentVO> list, List<HashMap> userList) {
         list.forEach(l->{

+ 116 - 7
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java

@@ -8,7 +8,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.management.platform.entity.*;
 import com.management.platform.entity.vo.CustomerProject;
-import com.management.platform.entity.vo.ProjectDataItem;
+import com.management.platform.entity.vo.GanttDataItem;
 import com.management.platform.entity.vo.ProjectVO;
 import com.management.platform.mapper.*;
 import com.management.platform.service.ProjectService;
@@ -22,7 +22,6 @@ import org.apache.poi.xssf.usermodel.XSSFSheet;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.assertj.core.util.Lists;
 import org.springframework.beans.BeanUtils;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -32,14 +31,11 @@ import org.springframework.web.multipart.MultipartFile;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.Part;
 import java.io.*;
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.time.LocalDate;
-import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
-import java.time.temporal.TemporalAccessor;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -985,6 +981,120 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         return httpRespMsg;
     }
 
+    @Override
+    public HttpRespMsg getGanttData(HttpServletRequest request) {
+        //根据人员权限来获取,
+        String token = request.getHeader("TOKEN");
+        User user = userMapper.selectById(token);
+        List<String> userIds = new ArrayList<>();
+        if (user.getRole() == 0) {
+            //看看是部门经理还是项目负责人
+            if (user.getManageDeptId() != null) {
+                List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("department_id", user.getManageDeptId()));
+                userIds = userList.stream().map(User::getId).collect(Collectors.toList());
+            } else {
+                //检查是否是项目负责人
+                List<Project> projectList = projectMapper.selectList(new QueryWrapper<Project>().eq("incharger_id", user.getId()));
+                if (projectList.size() > 0) {
+                    List<Integer> collect = projectList.stream().map(Project::getId).collect(Collectors.toList());
+                    List<Participation> participationList = participationMapper.selectList(new QueryWrapper<Participation>().in("project_id", collect));
+                    userIds = participationList.stream().map(Participation::getUserId).collect(Collectors.toList());
+                }
+            }
+        } else {
+            //查看全部
+            List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", user.getCompanyId()));
+            userIds = userList.stream().map(User::getId).collect(Collectors.toList());
+        }
+        HttpRespMsg msg = new HttpRespMsg();
+        List<GanttDataItem> itemList = new ArrayList<>();
+        if (userIds.size() > 0) {
+            List<Map> ganttData = projectMapper.getGanttData(userIds);
+            String lastUserId = null;
+
+            GanttDataItem lastUserItem = null;
+
+            for (int i=0;i<ganttData.size(); i++) {
+                Map map = ganttData.get(i);
+                String userId = (String) map.get("user_id");
+                Date start_date = (Date) map.get("start_date");
+                Date plan_end_date = (Date) map.get("plan_end_date");
+
+                if (!userId.equals(lastUserId)) {
+                    //新员工记录产生了
+                    lastUserItem = new GanttDataItem();
+                    lastUserItem.text = (String) map.get("name");
+                    lastUserItem.id = userId;
+                    lastUserItem.userId = (String) map.get("user_id");
+                    lastUserItem.start_date = start_date;
+                    lastUserItem.end_date = plan_end_date;
+                    if (plan_end_date != null && start_date != null) {
+                        lastUserItem.duration = (int)(plan_end_date.getTime() - start_date.getTime())/(24*3600*1000);
+                    }
+
+                    itemList.add(lastUserItem);
+                    lastUserId = userId;
+                    //项目也放进去
+                    GanttDataItem projectItem = new GanttDataItem();
+                    projectItem.text = (String) map.get("project_name");
+                    projectItem.id = lastUserId + "_" + (Integer) map.get("id");
+                    projectItem.userId = (String) map.get("user_id");
+                    projectItem.start_date = start_date;
+                    projectItem.end_date = plan_end_date;
+                    if (plan_end_date != null && start_date != null) {
+                        projectItem.duration = (int)(plan_end_date.getTime() - start_date.getTime())/24*3600*1000;
+                    }
+                    projectItem.parent = lastUserId;
+                    itemList.add(projectItem);
+                } else {
+                    //计算开始和结束日期
+                    GanttDataItem projectItem = new GanttDataItem();
+                    projectItem.text = (String) map.get("project_name");
+                    projectItem.id = lastUserId + "_" + (Integer) map.get("id");
+                    projectItem.userId = (String) map.get("user_id");
+                    projectItem.start_date = start_date;
+                    projectItem.end_date = plan_end_date;
+                    if (plan_end_date != null && start_date != null) {
+                        projectItem.duration = (int)((plan_end_date.getTime() - start_date.getTime())/(24*3600*1000));
+
+                        System.out.println("projectItem.duration ==" + projectItem.duration );
+                    }
+                    projectItem.parent = lastUserId;
+                    boolean userItemChanged = false;
+                    if (lastUserItem.start_date == null && start_date != null) {
+                        lastUserItem.start_date = start_date;
+                        userItemChanged = true;
+                    }
+                    if (lastUserItem.end_date == null && plan_end_date != null) {
+                        lastUserItem.end_date = plan_end_date;
+                        userItemChanged = true;
+                    }
+
+                    if (start_date != null && start_date.getTime() < lastUserItem.start_date.getTime()) {
+                        lastUserItem.start_date = start_date;
+                        userItemChanged = true;
+                    }
+                    if (plan_end_date != null && plan_end_date.getTime() > lastUserItem.end_date.getTime()) {
+                        lastUserItem.end_date = plan_end_date;
+                        userItemChanged = true;
+                    }
+
+                    //重新计算时长
+                    if (userItemChanged && lastUserItem.start_date != null && lastUserItem.end_date != null) {
+                        lastUserItem.duration = (int)(lastUserItem.start_date.getTime() - lastUserItem.end_date.getTime())/(24*3600*1000);
+                    }
+                    itemList.add(projectItem);
+                }
+            }
+        }
+
+        msg.data = itemList;
+
+        return msg;
+    }
+
+
+
     @Override
     public HttpRespMsg importData(String userId, MultipartFile multipartFile, HttpServletRequest request) {
         HttpRespMsg msg = new HttpRespMsg();
@@ -1065,9 +1175,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                         if (cnt > 0) {
                             throw new Exception("项目编码存在重复: " + code);
                         }
-                    } else {
-                        project.setProjectCode(code);
                     }
+                    project.setProjectCode(code);
                 }
 
                 String name = nameCell.getStringCellValue().trim().replaceAll("\\u00a0", "");

+ 18 - 6
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ReportServiceImpl.java

@@ -323,10 +323,10 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
 
     //新增或编辑报告
     @Override
-    public HttpRespMsg editReport(List<Report> reportList, String date) {
+    public HttpRespMsg editReport(List<Report> reportList, String date, List<User> userList, BigDecimal hourCost) {
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         List<Integer> idList = new ArrayList<>();
-        BigDecimal hourCost = userMapper.selectById(reportList.get(0).getCreatorId()).getCost();
+
         Integer companyId = userMapper.selectById(reportList.get(0).getCreatorId()).getCompanyId();
         TimeType timeType = timeTypeMapper.selectById(companyId);
         double totalWorkTime = 0;
@@ -344,8 +344,14 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                 if (!timeType.getPayOvertime()) {
                     //不能超过最多时间,超过的话,等比例核算
                     if (totalWorkTime > timeType.getAllday()) {
-                        BigDecimal cost = hourCost.multiply(new BigDecimal(timeType.getAllday()))
-                                .multiply(new BigDecimal(report.getWorkingTime())).divide(new BigDecimal(totalWorkTime), RoundingMode.HALF_UP);
+                        BigDecimal cost;
+                        if (hourCost == null) {
+                            cost = userList.stream().filter(u -> u.getId().equals(report.getCreatorId())).findFirst().get().getCost().multiply(new BigDecimal(timeType.getAllday()))
+                                    .multiply(new BigDecimal(report.getWorkingTime())).divide(new BigDecimal(totalWorkTime), RoundingMode.HALF_UP);
+                        } else {
+                            cost = hourCost.multiply(new BigDecimal(timeType.getAllday()))
+                                    .multiply(new BigDecimal(report.getWorkingTime())).divide(new BigDecimal(totalWorkTime), RoundingMode.HALF_UP);
+                        }
                         report.setCost(cost);
                     }
                 }
@@ -359,8 +365,14 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                     if (!timeType.getPayOvertime()) {
                         //不能超过最多时间,超过的话,等比例核算
                         if (totalWorkTime > timeType.getAllday()) {
-                            BigDecimal cost = hourCost.multiply(new BigDecimal(timeType.getAllday()))
-                                    .multiply(new BigDecimal(report.getWorkingTime())).divide(new BigDecimal(totalWorkTime), RoundingMode.HALF_UP);
+                            BigDecimal cost;
+                            if (hourCost == null) {
+                                cost = userList.stream().filter(u -> u.getId().equals(report.getCreatorId())).findFirst().get().getCost().multiply(new BigDecimal(timeType.getAllday()))
+                                        .multiply(new BigDecimal(report.getWorkingTime())).divide(new BigDecimal(totalWorkTime), RoundingMode.HALF_UP);
+                            } else {
+                                cost = hourCost.multiply(new BigDecimal(timeType.getAllday()))
+                                        .multiply(new BigDecimal(report.getWorkingTime())).divide(new BigDecimal(totalWorkTime), RoundingMode.HALF_UP);
+                            }
                             report.setCost(cost);
                         }
                     }

+ 11 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ProjectMapper.xml

@@ -173,4 +173,15 @@
         #{item}
     </foreach>
     </select>
+    <select id="getGanttData" resultType="java.util.Map">
+    SELECT participation.`user_id`, user.`name`,project.id, project.`project_name`, project.`plan_start_date` as start_date, project.`plan_end_date`,
+    TIMESTAMPDIFF(DAY,project.`plan_start_date`, project.`plan_end_date`) AS duration FROM participation
+    LEFT JOIN user ON user.id = participation.`user_id`
+    LEFT JOIN project ON project.`id` = participation.`project_id`
+    WHERE participation.`user_id` IN
+    <foreach collection="userIds" close=")" open="(" separator="," index="" item="item">
+        #{item}
+    </foreach> AND project.`status` = 1 and project.plan_start_date is not null and project.plan_end_date is not null
+        ORDER BY participation.user_id, project.`plan_start_date`
+    </select>
 </mapper>

+ 5 - 0
fhKeeper/formulahousekeeper/timesheet/package-lock.json

@@ -2932,6 +2932,11 @@
         "repeating": "^2.0.0"
       }
     },
+    "dhtmlx-gantt": {
+      "version": "7.1.6",
+      "resolved": "https://registry.nlark.com/dhtmlx-gantt/download/dhtmlx-gantt-7.1.6.tgz",
+      "integrity": "sha1-jNmOTlkDtKYDPrDZLFgk5bRyayk="
+    },
     "diffie-hellman": {
       "version": "5.0.3",
       "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz",

+ 1 - 0
fhKeeper/formulahousekeeper/timesheet/package.json

@@ -13,6 +13,7 @@
     "@tinymce/tinymce-vue": "^4.0.0",
     "axios": "^0.15.3",
     "dayjs": "^1.10.4",
+    "dhtmlx-gantt": "^7.1.6",
     "dingtalk-jsapi": "^2.13.42",
     "echarts": "^3.8.5",
     "element-ui": "^2.15.3",

+ 9 - 0
fhKeeper/formulahousekeeper/timesheet/src/routes.js

@@ -25,6 +25,7 @@ import depDetail from './views/project/detailDep.vue'
 import task from './views/task/list.vue'
 import projectInside from  './views/project/projectInside.vue'
 import info from './views/project/info.vue'
+import projectGantt from './views/project/project_gantt.vue'
 
 // 团队管理
 import team from './views/team/index.vue'
@@ -86,6 +87,12 @@ export const fixedRouter = [
             { path: '/earning/:id', component: projectInside, name: '挣值分析' },
         ]
     },
+    {
+        path: '/projectGantt',
+        component: projectGantt,
+        name: '项目甘特图',
+        hidden: true
+    },
     {
         path: '/viewonline',
         component: PdfView,
@@ -164,6 +171,8 @@ export const allRouters = [//组织架构
             { path: '/list', component: list, name: '项目管理' },
         ]
     },
+    
+    
     {
         path: '/',
         component: Home,

+ 119 - 0
fhKeeper/formulahousekeeper/timesheet/src/views/project/gantt.vue

@@ -0,0 +1,119 @@
+{{ src/components/Gantt.vue }}
+<template>
+    
+  <div ref="gantt">
+
+  </div>
+</template>
+
+<script>
+
+   
+import {gantt} from 'dhtmlx-gantt';
+// import 'dhtmlx-gantt/codebase/dhtmlxgantt.css'
+// import 'dhtmlx-gantt/codebase/locale/locale_cn'  // 本地化
+export default {
+  name: 'gantt',
+  props: {
+    tasks: {
+      type: Object,
+      default () {
+        return {data: [], links: []}
+      }
+    }
+  },
+ 
+  methods: {
+      
+  },
+  mounted: function () {
+    gantt.locale={
+    date: {
+        month_full: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
+        month_short: ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"],
+        day_full: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"],
+        day_short: ["日", "一", "二", "三", "四", "五", "六"]
+    },
+    labels: {
+        dhx_cal_today_button: "今天",
+        day_tab: "日",
+        week_tab: "周",
+        month_tab: "月",
+        new_event: "新建日程",
+        icon_save: "保存",
+        icon_cancel: "关闭",
+        icon_details: "详细",
+        icon_edit: "编辑",
+        icon_delete: "删除",
+        confirm_closing: "请确认是否撤销修改!", //Your changes will be lost, are your sure?
+        confirm_deleting: "是否删除日程?",
+        section_description: "描述",
+        section_time: "时间范围",
+        section_type: "类型",
+
+        /* grid columns */
+
+        column_text: "任务名",
+        column_start_date: "开始时间",
+        column_duration: "持续时间",
+        column_add: "",
+
+        /* link confirmation */
+
+        link: "关联",
+        confirm_link_deleting: "将被删除",
+        link_start: " (开始)",
+        link_end: " (结束)",
+
+        type_task: "任务",
+        type_project: "项目",
+        type_milestone: "里程碑",
+
+        minutes: "分钟",
+        hours: "小时",
+        days: "天",
+        weeks: "周",
+        months: "月",
+        years: "年"
+    }
+};
+      gantt.config.drag_move = false;
+    gantt.config.xml_date = "%Y-%m-%d";
+    gantt.config.columns=[
+        {name:"text",       label:"员工/项目名称",  tree:true, width:'*', align: "left" },
+        // {name:"start_date", label:"开始时间", width:'*' , align: "center" },
+        // {name:"duration",   label:"工时(天)", width:'*' ,   align: "center" }
+    ];
+    gantt.config.scale_unit = "month";	//按月显示
+	  gantt.config.date_scale = "%F, %Y";		//设置时间刻度的格式(X轴) 多个尺度
+
+	  gantt.config.scale_height = 50; //设置时间刻度的高度和网格的标题
+
+    gantt.config.subscales = [
+      {unit: "day", step: 1, date: "周%D,%d"}
+    ];
+    //设置任务条样式
+    gantt.templates.task_class = function (start, end, item) {
+      return item.parent == 0 ? "person_line" : ""
+    };
+
+    gantt.init(this.$refs.gantt);
+    gantt.parse(this.$props.tasks);
+    // gantt.groupBy({
+    //     relation_property: "owner",
+    //     groups: [{key:'seya', label: "seya"},{key:'tina', label: "tina"}],
+    //     group_id: "key",
+    //     group_text: "label"
+    // });
+    
+  }
+}
+</script>
+ 
+<style>
+    @import "~dhtmlx-gantt/codebase/dhtmlxgantt.css";
+    .person_line {
+      background:#8ecaf8;
+      border: #20a0ff 1px solid 
+    }
+</style>

+ 5 - 0
fhKeeper/formulahousekeeper/timesheet/src/views/project/list.vue

@@ -42,6 +42,11 @@
                 <el-form-item style="float:right;" v-if="user.role == 1||user.role == 2||user.role == 5">
                     <el-link type="primary" :underline="false" @click="handleAdd(-1,null)">新增项目</el-link>
                 </el-form-item>
+                <el-form-item style="float:right;" v-if="user.company.packageProject==1">
+                    <router-link to="/projectGantt" >
+                    <el-link type="primary" :underline="false" >甘特图</el-link>
+                    </router-link>
+                </el-form-item>
             </el-form>
         </el-col>
 

Разлика између датотеке није приказан због своје велике величине
+ 77 - 0
fhKeeper/formulahousekeeper/timesheet/src/views/project/project_gantt.vue


+ 156 - 16
fhKeeper/formulahousekeeper/timesheet/src/views/workReport/daily.vue

@@ -1,17 +1,7 @@
 <template>
     <section>
-        <!--工具条-->
-        <!-- <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
-            <el-form :inline="true">
-                <el-form-item>
-                    <el-date-picker v-model="date" :editable="false" format="yyyy-MM" value-format="yyyy-MM" @change="changeMonthOut" :clearable="false" type="month" placeholder="选择月份"></el-date-picker>
-                </el-form-item>
-            </el-form>
-        </el-col> -->
-
         <!--列表-->
         <div>
-
             <el-card class="box-card daily" shadow="never">
                 <div slot="header" class="clearfix" id="clearfix" style="padding-left: 195px;">
                     <div class="jjk" style="display:inline-block;position:fixed;top:70px;background:#fff;left:250px;">
@@ -77,8 +67,10 @@
                     未填写<el-link :underline="false" @click="showMembList(0)"><span style="margin-left:5px;margin-right:5px;color:red;">{{(depData == null?data[0].membCount:(depData.isUser == 1?1:depData.membCount))-reportList.length}}</span></el-link>人
                         </span>
                         <span style="float:right;">
-                            <el-link type="primary" style="margin-right:10px;" :underline="false" @click="fillInReport(-1,0)">填写日报</el-link>
-                            <el-link type="primary" style="margin-right:10px;" :underline="false" @click="fillInReport(-1,1)">批量填报</el-link>
+                            <el-link type="primary" style="margin-right:10px;" :underline="false" @click="isSubstitude=false;fillInReport(-1,0)">填写日报</el-link>
+                            <el-link type="primary" style="margin-right:10px;" :underline="false" @click="isSubstitude=true; fillInReport(-1,0)">代填日报</el-link>
+                            <el-link type="primary" style="margin-right:10px;" :underline="false" @click="isSubstitude=false;fillInReport(-1,1)">批量填报</el-link>
+                            <!-- <el-link type="primary" style="margin-right:10px;" :underline="false" @click="isSubstitude=true; fillInReport(-1,1)">批量代填</el-link> -->
                             <el-link type="primary" style="margin-right:10px;" :underline="false" @click="showExportDialog">导出日报</el-link>
                             <el-link type="primary" style="margin-right:10px;" :underline="false" @click="batchApprove" >批量审核</el-link>
                         </span>
@@ -86,8 +78,10 @@
                     <!--普通员工,含项目经理 -->
                     <div class="report_title" v-if="(user.role==0||user.role==5) && user.manageDeptId == 0"><span>日报列表</span>
                     <span style="float:right;" v-if="(user.role==0||user.role==5) && user.manageDeptId == 0">
-                            <el-link type="primary" style="margin-right:10px;" :underline="false" @click="fillInReport(-1,0)">填写日报</el-link>
-                            <el-link type="primary" style="margin-right:10px;" :underline="false" @click="fillInReport(-1,1)">批量填报</el-link>
+                            <el-link type="primary" style="margin-right:10px;" :underline="false" @click="isSubstitude=false;fillInReport(-1,0)">填写日报</el-link>
+                            <el-link type="primary" v-if="user.leader" style="margin-right:10px;" :underline="false" @click="isSubstitude=true; fillInReport(-1,0)">代填日报</el-link>
+                            <el-link type="primary" style="margin-right:10px;" :underline="false" @click="isSubstitude=false;fillInReport(-1,1)">批量填报</el-link>
+                            <!-- <el-link type="primary" v-if="user.leader" style="margin-right:10px;" :underline="false" @click="isSubstitude=true; fillInReport(-1,1)">批量代填</el-link> -->
                             <el-link type="primary" v-if="user.leader" style="margin-right:10px;" :underline="false" @click="batchApprove">批量审核</el-link>
                     </span>
                     </div>
@@ -110,7 +104,7 @@
                                 <!--自己可以撤回待审核状态的报告 -->
                                 <el-button v-if="(user.id == item1.id) && item1.state == 0" type="normal" :loading="logining" size="small" @click="cancel(item1)">撤回</el-button>
                                 <el-button v-if="(user.role == 1 || user.role == 2 || user.id == item1.data[0].inchargerId) && item1.state == 1" type="normal" :loading="logining" size="small" @click="deny(item1.id,1, item1)">撤销</el-button>
-                                <el-button v-if="item1.state >= 2 && user.id == item1.id" type="primary" size="small" @click="fillInReport(index1,0)">编辑日报</el-button>
+                                <el-button v-if="item1.state >= 2 && user.id == item1.id" type="primary" size="small" @click="isSubstitude=false; fillInReport(index1,0)">编辑日报</el-button>
                             </div>
                             <div class="one_daily_body">
                                 <el-timeline>
@@ -149,6 +143,11 @@
         <!-- 填写日报的dialog -->
         <el-dialog :title="isBatch==0?'填写日报':'批量填报'" :visible.sync="dialogVisible" width="60%" :close-on-click-modal="false">
             <el-form ref="workForm" :model="workForm" :rules="workRules" label-width="100px">
+                <el-form-item label="选择人员" prop="userNames" v-if="isSubstitude" 
+                :rules="{ required: true, message: '请选择代填人员', trigger: 'change' }">
+                    <el-input @focus="showChooseMembTree" v-model="workForm.userNames"
+                    placeholder="请选择代填人员" ></el-input>
+                </el-form-item>
                 <el-form-item label="工作日期" prop="createDate">
                     <el-date-picker v-model="workForm.createDate" :editable="false" format="yyyy-MM-dd" value-format="yyyy-MM-dd" 
                     :style="'width:'+(isBatch==0?'200':'280')+'px;'" :type="isBatch==0?'date':'daterange'"
@@ -315,6 +314,25 @@
                 <el-button type="default" @click="exportMemb"  :disabled="fillMembList == 0">导出</el-button>
             </div>
         </el-dialog>
+
+        
+        <!-- 按部门选择人员 -->
+        <el-dialog title="选择需要代填报的人员"  v-if="chooseParticipVisible" :visible.sync="chooseParticipVisible" :close-on-click-modal="false" customClass="customWidth" width="500px">
+            <!-- <el-input style="width:100%" v-model="filterName" placeholder="请输入姓名搜索" @change="findUserInTree"></el-input> -->
+            <div class="tree" style="height:400px">
+                <el-scrollbar style="height:100%">
+                <el-tree :data="deptMembData" show-checkbox :props="defaultProps" node-key="id"
+                    ref="chooseMembTree" @check-change="onTreeItemChange" :default-checked-keys="workForm.userId"
+                    highlight-current ></el-tree>
+                </el-scrollbar>
+            </div>
+            <div>已选中&nbsp;{{chosenMembCount}}&nbsp;人</div>
+            <div slot="footer" class="dialog-footer">
+                <el-button  @click="chooseParticipVisible = false" >取消</el-button>
+                <el-button type="primary" @click="chooseParticip()" >确定</el-button>
+            </div>
+        </el-dialog>
+
     </section>
 </template>
 
@@ -324,6 +342,7 @@
     export default {
         data() {
             return {
+                isSubstitude:false,
                 isFill:false,
                 unFillList:[],
                 fillList:[],
@@ -378,10 +397,14 @@
                 workRules: {
                     createDate: [{ required: true, message: "请选择工作日期", trigger: "change" }],
                 },
-
+                chooseParticipVisible: false,
                 logining: false,
                 isDisable: false,
                 timeType:[],
+
+                deptMembData: [
+                    
+                ],
                 //部门人员树状结构
                 data: [
                     {
@@ -409,9 +432,67 @@
                 selected: false,
                 valuet: new Date(),
                 domObj: null,
+                participator:[],
+                chosenMembCount:0,
             };
         },
         methods: {
+            showChooseMembTree() {
+                this.chosenMembCount = this.participator.length;
+                this.chooseParticipVisible = true;
+            },
+            onTreeItemChange() {
+                var chosenList = this.$refs.chooseMembTree.getCheckedNodes();
+                var list = chosenList.filter(item=>item.isUser == 1);
+                this.chosenMembCount = list.length;
+            },
+            findUserInTree() {
+                if (this.filterName == '') {
+                    this.deptMembData = this.allMembData;
+                } else {
+                    var list = this.findRecursively(this.filterName, this.allMembData);
+                    this.deptMembData = list;
+                }
+            },
+
+            findRecursively(username, list) {
+                var filterList = [];
+                for (var i=0;i<list.length; i++) {
+                    if (list[i].isUser == 1) {
+                        if (list[i].label.indexOf(username) >= 0) {
+                            //匹配上了
+                            filterList.push(list[i]);
+                        }
+                    } else if (list[i].children != null && list[i].children.length > 0) {
+                        var subList = this.findRecursively(username, list[i].children);
+                        if (subList.length > 0) {
+                            subList.forEach(s=>filterList.push(s));
+                        }
+                    }
+                }
+                return filterList;
+            },
+
+            //确定选择参与人
+            chooseParticip() {
+                this.chooseParticipVisible = false;
+                var chosenList = this.$refs.chooseMembTree.getCheckedNodes();
+                this.chosenMembList = chosenList.filter(item=>item.isUser == 1);
+                this.workForm.userNames = '';
+                this.workForm.userId = [];
+                this.participator = [];
+                for (var i=0;i<this.chosenMembList.length; i++) {
+                    this.workForm.userId.push(this.chosenMembList[i].id);
+                    this.workForm.userNames += this.chosenMembList[i].label+',';
+                    var item = {id:this.chosenMembList[i].id, name:this.chosenMembList[i].label};
+                    this.participator.push(item);
+                }
+                if (this.workForm.userNames.length > 0) {
+                    this.workForm.userNames = this.workForm.userNames.substring(0, this.workForm.userNames.length-1);
+                }
+                
+            },
+
             //微信通知人员填写
             weixinNotify() {
                 if (this.fillMembList.length == 0) return;
@@ -803,6 +884,36 @@
                 } 
                 
             },
+
+            //获取可以选择的代填的人员列表
+            getSubstitudeUserDeptList() {
+                if (this.deptMembData.length == 0) {
+                    this.http.post("/department/listMyMembs", {},
+                        res => {
+                            if (res.code == "ok") {
+                                let noAllData = JSON.parse(JSON.stringify(res.data));
+                                if (noAllData.length > 0) {
+                                    if (noAllData[0].label == '全部人员') {
+                                        noAllData.splice(0,1);
+                                    }
+                                }
+                                this.setUserToDept(noAllData);
+                                this.deptMembData = noAllData;
+                            } else {
+                                this.$message({
+                                    message: res.msg,
+                                    type: "error"
+                                });
+                            }
+                        },
+                        error => {
+                            this.$message({
+                                message: error,
+                                type: "error"
+                            });
+                        });
+                }
+            },
             
             // 获取部门列表
             getDepartment() {
@@ -815,6 +926,7 @@
                 res => {
                     if (res.code == "ok") {
                         var list = res.data , list1 = JSON.parse(JSON.stringify(res.data));
+                        // let noAllData = JSON.parse(JSON.stringify(res.data));
                         if (this.user.role > 0) {
                             list.splice(0,0,{
                                 id: -1,
@@ -827,6 +939,15 @@
                         this.setUserToDept(list);
                         this.data = list;
                         this.allData = list;
+                        
+                        // if (noAllData.length > 0) {
+                        //     if (noAllData[0].label == '全部人员') {
+                        //         noAllData.splice(0,1);
+                        //     }
+                        // }
+                        // this.setUserToDept(noAllData);
+                        // this.deptMembData = noAllData;
+
                         this.option = this.changeArr(list1);
                         list[0].membCount = this.membCount;
                         if (this.depData.id == -1) {
@@ -1216,6 +1337,8 @@
                             this.workForm = {
                                 createDate: this.workForm.createDate,
                                 domains: arr,
+                                userNames:null,
+                                userId:null,
                             }
                         } else {
                             this.workForm = {
@@ -1229,6 +1352,8 @@
                                     state: 2,
                                     timeType:0,
                                 }],
+                                userId:null,
+                                userNames:null,
                             }
                             this.canEdit = true;
                         }
@@ -1249,6 +1374,9 @@
 
             // 打开日报填写
             fillInReport(i, isBatch) {
+                if (this.isSubstitude) {
+                    this.getSubstitudeUserDeptList();
+                }
                 if(i == -1) {
                     this.isDisable = false;
                 } else {
@@ -1457,6 +1585,18 @@
                                 this.workForm.domains[i].isOvertime = '1'
                                 formData.append("isOvertime", this.workForm.domains[i].isOvertime);
                             }
+                            //代填的情况
+                            console.log('===@@===');
+                            if (this.workForm.userId != null) {
+                                var targetUids = '';
+                                this.workForm.userId.forEach(u=>{
+                                    targetUids += u + '@';
+                                });
+                                if (targetUids.length > 0) {
+                                    targetUids = targetUids.substring(0, targetUids.length -1);
+                                    formData.append("targetUids", targetUids);
+                                }
+                            }
                         }
                         this.http.uploadFile( this.port.report.editPort, formData,
                         res => {