Пример #1
0
        public ActionResult ModuleButtonTreeJson(string roleId)
        {
            var existModuleButton = permissionBLL.GetModuleButtonList(roleId);

            var moduleButtonData = authorizeBLL.GetModuleButtonList(SystemInfo.CurrentUserId);
            var moduleData       = authorizeBLL.GetModuleListByModuleButton(SystemInfo.CurrentUserId, moduleButtonData);
            var treeList         = new List <TreeEntity>();

            foreach (ModuleEntity item in moduleData)
            {
                TreeEntity tree = new TreeEntity();
                tree.id             = item.F_ModuleId;
                tree.text           = item.F_FullName;
                tree.value          = item.F_ModuleId;
                tree.checkstate     = existModuleButton.Count(t => t.F_ItemId == item.F_ModuleId);
                tree.showcheck      = true;
                tree.isexpand       = true;
                tree.complete       = true;
                tree.hasChildren    = true;
                tree.parentId       = item.F_ParentId;
                tree.img            = item.F_Icon;
                tree.AttributeValue = item.F_IsMenu.ToString();
                treeList.Add(tree);
            }

            foreach (ModuleButtonEntity item in moduleButtonData)
            {
                TreeEntity tree        = new TreeEntity();
                bool       hasChildren = moduleButtonData.Count(t => t.F_ParentId == item.F_ModuleButtonId) == 0 ? false : true;
                tree.id    = item.F_ModuleButtonId;
                tree.text  = item.F_FullName;
                tree.value = item.F_ModuleButtonId;
                if (item.F_ParentId == "0")
                {
                    tree.parentId = item.F_ModuleId;
                }
                else
                {
                    tree.parentId = item.F_ParentId;
                }
                tree.checkstate  = existModuleButton.Count(t => t.F_ItemId == item.F_ModuleButtonId);
                tree.showcheck   = true;
                tree.isexpand    = true;
                tree.complete    = true;
                tree.img         = "fa fa-wrench " + item.F_ModuleId;
                tree.hasChildren = hasChildren;
                treeList.Add(tree);
            }
            return(Content(treeList.TreeToJson()));
        }