• EasyUi 菜单树形 列表显示


        $(function($) {
                $('#tg').treegrid({
                 url:'<%=request.getContextPath()%>/sysMenu/list',
                 rownumbers: false,
                 treeField: 'name',
                 checkbox:true,
            ascadeCheck:true,//结连显示 idField:
    'id', emptyMsg:'无数据', columns:[[ {title:'id',field:'id',160,hidden:true}, {field:'action',title:'操作',formatter:formatAction,'15%'}, {title:'菜单名称',field:'name','25%',align:'left'}, {title:'菜单路径',field:'url','25%',align:'left'}, {title:'菜单排序值',field:'displayorder','15%',align:'left'}, {title:'创建日期',field:'createdate','25%',align:'left'}, {title:'修改日期',field:'modifydate','25%',align:'left'} ]] }); }); function formatAction(val,row){ return '<a style="" href="#" onclick="javascript:editMenu('+row.id+')"> 编辑</a>'; }
        @RequestMapping("/list")
        public void list(HttpServletRequest request,HttpServletResponse response){
                
    
            List<SysMenu> list = null;
            Map<String,Object> params = new HashMap<String,Object>();
            
            gtSysUser user = (gtSysUser)request.getSession().getAttribute("user");
                list = this.sysMenuService.list(params);
                SysMenu tempMenu = sysMenuService.selectByPrimaryKey(1);
                
                if(!list.contains(tempMenu))
                {
                    list.add(0,tempMenu);
                    
                }
    
            List menuList = new ArrayList<Map>();
            //根菜单
            HashMap<String,Object> menuRootMap = new HashMap<>();
            for(SysMenu menu : list){
                    
                    if(menu.getParentid() == null || menu.getParentid() == 0){
                        menuRootMap.put("id", menu.getId());
                        menuRootMap.put("name", menu.getName());
                        menuRootMap.put("url", menu.getUrl());
                        menuRootMap.put("icon", menu.getIcon());
                        menuRootMap.put("displayorder", menu.getDisplayorder());
                        menuRootMap.put("createdate", menu.getCreatedate());
                        menuRootMap.put("modifydate", menu.getModifydate());
                    }
            };        
            ArrayList<Map<String,Object>> modalArray = new ArrayList<Map<String,Object>>();
              for(SysMenu menuParent : list){
                
                //二级模块
                if(menuParent.getParentid() == menuRootMap.get("id")){
                    HashMap<String,Object> menuParentMap = new HashMap<String,Object>();
                    ArrayList<Map<String,Object>> childrenList = new ArrayList<Map<String,Object>>() ;
                    menuParentMap.put("id", menuParent.getId());
                    menuParentMap.put("name", menuParent.getName());
                    menuParentMap.put("url", menuParent.getUrl());
                    menuParentMap.put("icon", menuParent.getIcon());
                    menuParentMap.put("displayorder", menuParent.getDisplayorder());
                    menuParentMap.put("createdate", menuParent.getCreatedate());
                    menuParentMap.put("modifydate", menuParent.getModifydate());
                    
                    //菜单
                    for(SysMenu menuChildren : list){
                        
                        if(menuChildren.getParentid().intValue() == menuParent.getId().intValue()){
                            HashMap<String,Object> menuChildrenMap = new HashMap<>();
                            menuChildrenMap.put("id", menuChildren.getId());
                            menuChildrenMap.put("name", menuChildren.getName());
                            menuChildrenMap.put("url", menuChildren.getUrl());
                            menuChildrenMap.put("icon", menuChildren.getIcon());
                            menuChildrenMap.put("displayorder", menuChildren.getDisplayorder());
                            menuChildrenMap.put("createdate", menuChildren.getCreatedate());
                            menuChildrenMap.put("modifydate", menuChildren.getModifydate());
                            childrenList.add(menuChildrenMap);
                            
                            ArrayList<Map<String,Object>> buttonChildrenList = new ArrayList<Map<String,Object>>();
                            //按钮
                            for(SysMenu menuButton : list){
                            
                                if(menuButton.getParentid().intValue() == menuChildren.getId().intValue()){
                                    HashMap<String,Object> buttonChildrenMap = new HashMap<>();
                                    buttonChildrenMap.put("id", menuButton.getId());
                                    buttonChildrenMap.put("name", menuButton.getName());
                                    buttonChildrenMap.put("url", menuButton.getUrl());
                                    buttonChildrenMap.put("icon", menuButton.getIcon());
                                    buttonChildrenMap.put("displayorder", menuButton.getDisplayorder());
                                    buttonChildrenMap.put("createdate", menuButton.getCreatedate());
                                    buttonChildrenMap.put("modifydate", menuButton.getModifydate());
                                    buttonChildrenList.add(buttonChildrenMap);    
                                }    
                            }
                            menuChildrenMap.put("children", buttonChildrenList);
                        }
                    }
                    menuParentMap.put("children", childrenList);
                    modalArray.add(menuParentMap);
                }
            }
            
            menuRootMap.put("children", modalArray);
            
            menuList.add(menuRootMap);
            
            //HashMap<String,Object> messageMap = new HashMap<String,Object>();
            //messageMap.put("rows", list);
            
            //this.out(response, messageMap);
            this.webOut(response, menuList);
            return;
        }
  • 相关阅读:
    C# 单点登录
    长度12的数组,要求对数据分为3组,每组数据对应位置的数字为前几位的和,并返回12位数组
    react项目初始化
    vue 过滤器的使用(解决forEach遇到的问题)
    nuxt中less使用
    vue项目less 使用
    Webpack中的sourceMap配置
    webpack 同一文件打包两次生成两个文件
    webpack---图片打包前和打包后名称一致的配置
    The computed property "userName" is already defined in data.
  • 原文地址:https://www.cnblogs.com/cuijinlong/p/7200268.html
Copyright © 2020-2023  润新知