中扬CRM客户关系管理系统
#
luxiaotao1123
2022-11-08 1f653021b7c278f2e505101ce0364e2160be51d1
src/main/java/com/zy/crm/common/utils/TreeUtils.java
@@ -7,7 +7,6 @@
import com.zy.crm.manager.service.NodeService;
import com.zy.crm.manager.service.TagService;
import com.zy.crm.system.entity.Dept;
import com.zy.crm.system.entity.Role;
import com.zy.crm.system.entity.User;
import com.zy.crm.system.service.DeptService;
import com.zy.crm.system.service.RoleService;
@@ -189,7 +188,6 @@
        map.put("id", dept.getId());
        map.put("spread", true);
        map.put("key", "dept_id");
//        map.put("icon", "layui-icon layui-icon-star-fill");
        List<Map<String, Object>> childrens = new ArrayList<>();
        map.put("children", childrens);
        dealUserDept(dept, childrens, hostId, userId);
@@ -198,22 +196,8 @@
    }
    public void dealUserDept(Dept parent, List<Map<String, Object>> list, Long hostId, Long userId) {
        Wrapper<Dept> wrapper = new EntityWrapper<Dept>()
                .eq("parent_id", parent.getId())
                .eq("status", 1);
        if (hostId != null) {
            wrapper.eq("host_id", hostId);
        }
        List<Dept> depts = deptService.selectList(wrapper);
        List<User> users = new ArrayList<>();
        Role role = roleService.selectById(userService.selectById(userId).getRoleId());
        if (role.getCode().equals("salesman")) {
            users.add(userService.selectById(userId));
        } else {
            users = userService.getUserByDept(hostId, parent.getId());
        }
        // 人员
        List<User> users = roleService.getUserByRoleCode(hostId, parent.getId(), userId);
        for (User user : users) {
            Map<String, Object> map = new HashMap<>();
            map.put("title", user.getNickname());
@@ -222,14 +206,20 @@
            map.put("icon", "layui-icon layui-icon-friends");
            list.add(map);
        }
        // 部门
        Wrapper<Dept> wrapper = new EntityWrapper<Dept>()
                .eq("parent_id", parent.getId())
                .eq("status", 1);
        if (hostId != null) {
            wrapper.eq("host_id", hostId);
        }
        List<Dept> depts = deptService.selectList(wrapper);
        for (Dept dept : depts) {
            Map<String, Object> map = new HashMap<>();
            map.put("title", dept.getName());
            map.put("id", dept.getId());
            map.put("spread", true);
            map.put("key", "dept_id");
//            map.put("icon", "layui-icon layui-icon-star-fill");
            List<Map<String, Object>> childrens = new ArrayList<>();
            map.put("children", childrens);
            dealUserDept(dept, childrens, hostId, userId);