layui 弹框加载树

html部分:

    js部分:

    后台代码:

    /**
     * 角色权限树
     */
    @ResponseBody
    @GetMapping("/authTree")
    public List> authTree(Integer roleId) {
        List roleAuths = authoritiesService.listByRoleId(roleId);
        List allAuths = authoritiesService.list();
        List> authTrees = new ArrayList<>();
        for (Authorities one : allAuths) {
            Map authTree = new HashMap<>();
            authTree.put("id", one.getAuthorityId());
            authTree.put("name", one.getAuthorityName() + " " + StringUtil.getStr(one.getAuthority()));
            authTree.put("pId", one.getParentId());
            authTree.put("open", true);
            authTree.put("checked", false);
            for (Authorities temp : roleAuths) {
                if (temp.getAuthorityId().equals(one.getAuthorityId())) {
                    authTree.put("checked", true);
                    break;
                }
            }
            authTrees.add(authTree);
        }
        return authTrees;
    }

    页面展示:

    layui 弹框加载树_第1张图片

     

    你可能感兴趣的:(layui)