public async Task <ActionResult> GetPermissionTree(string roleId)
        {
            var moduledata = await menuApp.GetList();

            var buttondata = await menuButtonApp.GetList();

            var authorizedata = new List <RoleAuthorizeEntity>();

            if (!string.IsNullOrEmpty(roleId))
            {
                authorizedata = await roleAuthorizeApp.GetListByObjectId(roleId);
            }
            var treeList = new List <TreeViewModel>();

            foreach (MenuEntity item in moduledata)
            {
                TreeViewModel tree        = new TreeViewModel();
                bool          hasChildren = moduledata.Count(t => t.ParentId == item.Id) == 0 ? false : true;
                tree.id          = item.Id;
                tree.text        = item.FullName;
                tree.value       = item.EnCode;
                tree.parentId    = item.ParentId;
                tree.isexpand    = true;
                tree.complete    = true;
                tree.showcheck   = true;
                tree.checkstate  = authorizedata.Count(t => t.ItemId == item.Id);
                tree.hasChildren = true;
                tree.img         = item.Icon == "" ? "" : item.Icon;
                treeList.Add(tree);
            }
            foreach (MenuButtonEntity item in buttondata)
            {
                TreeViewModel tree        = new TreeViewModel();
                bool          hasChildren = buttondata.Count(t => t.ParentId == item.Id) == 0 ? false : true;
                tree.id          = item.Id;
                tree.text        = item.FullName;
                tree.value       = item.EnCode;
                tree.parentId    = item.ParentId == "0" ? item.MenuId : item.ParentId;
                tree.isexpand    = true;
                tree.complete    = true;
                tree.showcheck   = true;
                tree.checkstate  = authorizedata.Count(t => t.ItemId == item.Id);
                tree.hasChildren = hasChildren;
                tree.img         = item.Icon == "" ? "" : item.Icon;
                treeList.Add(tree);
            }
            return(Content(treeList.TreeViewJson()));
        }
Exemple #2
0
        public async Task <ActionResult> GetCloneButtonTreeJson()
        {
            var menuData = await menuApp.GetList();

            var buttonData = await menuButtonApp.GetList();

            var treeList = new List <TreeViewModel>();

            foreach (MenuEntity item in menuData)
            {
                TreeViewModel tree        = new TreeViewModel();
                bool          hasChildren = menuData.Count(t => t.ParentId == item.Id) == 0 ? false : true;
                tree.id          = item.Id;
                tree.text        = item.FullName;
                tree.value       = item.EnCode;
                tree.parentId    = item.ParentId;
                tree.isexpand    = true;
                tree.complete    = true;
                tree.hasChildren = true;
                treeList.Add(tree);
            }
            foreach (MenuButtonEntity item in buttonData)
            {
                TreeViewModel tree        = new TreeViewModel();
                bool          hasChildren = buttonData.Count(t => t.ParentId == item.Id) == 0 ? false : true;
                tree.id          = item.Id;
                tree.text        = item.FullName;
                tree.value       = item.EnCode;
                tree.parentId    = item.ParentId == "0" ? item.MenuId : item.ParentId;
                tree.isexpand    = true;
                tree.complete    = true;
                tree.showcheck   = true;
                tree.hasChildren = hasChildren;
                if (item.Icon != "")
                {
                    tree.img = item.Icon;
                }
                treeList.Add(tree);
            }
            return(Content(treeList.TreeViewJson()));
        }