public ActionResult GetPermissionTree(string roleId)
        {
            var moduledata    = _moduleService.GetList();
            var buttondata    = _moduleButtonService.GetList();
            var authorizedata = new List <RoleAuthorizeBaseEntity>();

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

            foreach (ModuleBaseEntity item in moduledata)
            {
                TreeViewModel tree        = new TreeViewModel();
                bool          hasChildren = moduledata.Count(t => t.F_ParentId == item.F_Id) == 0 ? false : true;
                tree.id          = item.F_Id;
                tree.text        = item.F_FullName;
                tree.value       = item.F_EnCode;
                tree.parentId    = item.F_ParentId;
                tree.isexpand    = true;
                tree.complete    = true;
                tree.showcheck   = true;
                tree.checkstate  = authorizedata.Count(t => t.F_ItemId == item.F_Id);
                tree.hasChildren = true;
                tree.img         = item.F_Icon == "" ? "" : item.F_Icon;
                treeList.Add(tree);
            }
            foreach (ModuleButtonBaseEntity item in buttondata)
            {
                TreeViewModel tree        = new TreeViewModel();
                bool          hasChildren = buttondata.Count(t => t.F_ParentId == item.F_Id) == 0 ? false : true;
                tree.id          = item.F_Id;
                tree.text        = item.F_FullName;
                tree.value       = item.F_EnCode;
                tree.parentId    = item.F_ParentId == "0" ? item.F_ModuleId : item.F_ParentId;
                tree.isexpand    = true;
                tree.complete    = true;
                tree.showcheck   = true;
                tree.checkstate  = authorizedata.Count(t => t.F_ItemId == item.F_Id);
                tree.hasChildren = hasChildren;
                tree.img         = item.F_Icon == "" ? "" : item.F_Icon;
                treeList.Add(tree);
            }
            return(Content(treeList.TreeViewJson()));
        }
Пример #2
0
        public ActionResult Index(string roleId)
        {
            var listPerIds          = RoleAuthorizeService.GetList(roleId).Select(c => c.SRAModuleId).ToList();
            var listAllPers         = PermissionService.GetList();
            List <ZTreeNode> result = new List <ZTreeNode>();

            foreach (var item in listAllPers)
            {
                ZTreeNode model = new ZTreeNode();
                model.@checked = listPerIds.Contains(item.Id) ? model.@checked = true : model.@checked = false;
                model.id       = item.Id;
                model.pId      = item.SPParentId;
                model.name     = item.SPName;
                model.open     = true;
                result.Add(model);
            }
            return(Content(result.ToJson()));
        }