中扬CRM客户关系管理系统
#
luxiaotao1123
2022-09-19 f91e3a2507c6972fb15d7d91f0d0380dd4be0bef
#
4个文件已修改
36 ■■■■■ 已修改文件
src/main/java/com/zy/crm/common/utils/TreeUtils.java 21 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/crm/system/controller/DeptController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/static/js/cstmr/cstmr.js 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/views/cstmr/cstmr.html 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/crm/common/utils/TreeUtils.java
@@ -7,8 +7,10 @@
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;
import com.zy.crm.system.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
@@ -31,6 +33,8 @@
    private DeptService deptService;
    @Autowired
    private UserService userService;
    @Autowired
    private RoleService roleService;
    /******************************** 归类树 *********************************/
@@ -176,7 +180,7 @@
     * 获取树图数据结构
     */
    @Cacheable(cacheNames="deptUserTree",key="#id")
    public ArrayList<Map<String, Object>> getDeptUserTree(String id, Long hostId){
    public ArrayList<Map<String, Object>> getDeptUserTree(String id, Long hostId, Long userId){
        ArrayList<Map<String, Object>> result = new ArrayList<>();
        Dept dept = deptService.selectById(id);
        // 主节点
@@ -188,12 +192,12 @@
//        map.put("icon", "layui-icon layui-icon-star-fill");
        List<Map<String, Object>> childrens = new ArrayList<>();
        map.put("children", childrens);
        dealUserDept(dept, childrens, hostId);
        dealUserDept(dept, childrens, hostId, userId);
        result.add(map);
        return result;
    }
    public void dealUserDept(Dept parent, List<Map<String, Object>> list, Long hostId) {
    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);
@@ -202,7 +206,14 @@
        }
        List<Dept> depts = deptService.selectList(wrapper);
        List<User> users = userService.getUserByDept(hostId, parent.getId());
        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());
        }
        for (User user : users) {
            Map<String, Object> map = new HashMap<>();
            map.put("title", user.getNickname());
@@ -221,7 +232,7 @@
//            map.put("icon", "layui-icon layui-icon-star-fill");
            List<Map<String, Object>> childrens = new ArrayList<>();
            map.put("children", childrens);
            dealUserDept(dept, childrens, hostId);
            dealUserDept(dept, childrens, hostId, userId);
            list.add(map);
        }
    }
src/main/java/com/zy/crm/system/controller/DeptController.java
@@ -185,7 +185,7 @@
    @PostMapping(value = "/dept/user/tree/auth")
    @ManagerAuth
    public R deptUserTree(@RequestParam(required = false, defaultValue = "") String condition) throws IOException, ClassNotFoundException {
        ArrayList<Map<String, Object>> tree = treeUtils.getDeptUserTree(String.valueOf(getDeptId()), getHostId());
        ArrayList<Map<String, Object>> tree = treeUtils.getDeptUserTree(String.valueOf(getDeptId()), getHostId(), getUserId());
        // 深拷贝
        List<Map<String, Object>> result = ListUtils.deepCopy(tree);
        if (!Cools.isEmpty(condition)) {
src/main/webapp/static/js/cstmr/cstmr.js
@@ -64,9 +64,10 @@
                    break
                case 2:
                    // 导入 Excel
                    let arrFileHandle = await window.showOpenFilePicker()
                    let file = await arrFileHandle[0].getFile();
                    upload(file);
                    $("#importExcel").trigger("click");
                    // let arrFileHandle = await window.showOpenFilePicker()
                    // let file = await arrFileHandle[0].getFile();
                    // upload(file);
                    break
                case 3:
                    // 导出 Excel
@@ -385,10 +386,11 @@
    }
}
function upload(file){
    if(!file) {
function upload(obj){
    if(!obj.files) {
        return;
    }
    var file = obj.files[0];
    admin.confirm('确认同步 [' + file.name +'] 文件吗?', function (index) {
        layer.load(1, {shade: [0.1,'#fff']});
        var url = baseUrl + "/cstmr/excel/import/auth";
src/main/webapp/views/cstmr/cstmr.html
@@ -84,6 +84,7 @@
                </div>
            </div>
            <table class="layui-hide" id="cstmr" lay-filter="cstmr"></table>
            <input style="display:none" id="importExcel" type="file" onchange="upload(this)" >
        </div>
    </div>
    <div class="layui-card" style="margin-bottom: 0">