/// <summary> /// Index 列表 /// </summary> /// <param name="pagination"></param> /// <param name="keyword"></param> /// <returns></returns> public ActionResult GetTreeGridJson(Pagination pagination, string keyword) { var list = authorizeApp.GetAuthorizeList(); var acountTypeList = accountTypeApp.GetAccountTypeList(); foreach (var item in list) { var temp = acountTypeList.Find(x => x.ID == item.AccountTypeID); if (temp != null) { item.AccountTypeID = temp.TypeName; } } var treeList = new List <TreeGridModel>(); foreach (var item in list) { TreeGridModel treeModel = new TreeGridModel(); bool hasChildren = list.Count(t => t.PID == item.ID) == 0 ? false : true; treeModel.id = item.ID; treeModel.isLeaf = hasChildren; treeModel.parentId = item.PID; treeModel.expanded = hasChildren; treeModel.entityJson = item.ToJson(); treeList.Add(treeModel); } return(Content(treeList.TreeGridJson())); }
public ActionResult GetPermissionTree(string roleId, string accountTypeID) { var authorizedata = authorizeApp.GetAuthorizeList(AuthorizeType.Menu.GetEnumCode(), accountTypeID); var buttondata = authorizeButtonApp.GetButtonListByAuthList(authorizedata); var roleAuthorize = new List <RoleAuthorize>(); if (!string.IsNullOrEmpty(roleId)) { roleAuthorize = roleAuthorizeApp.GetList(roleId, "1"); } var treeList = new List <TreeViewModel>(); foreach (Authorize item in authorizedata) { TreeViewModel tree = new TreeViewModel(); bool hasChildren = authorizedata.Count(t => t.PID == item.ID) == 0 ? false : true; tree.id = item.ID; tree.text = item.AuthorizeName; tree.value = item.EnCode; tree.parentId = item.PID; tree.isexpand = true; tree.complete = true; tree.showcheck = true; tree.checkstate = roleAuthorize.Count(t => t.AuthorizeID == item.ID); tree.hasChildren = true; tree.img = item.Icon == "" ? "" : item.Icon; treeList.Add(tree); } foreach (Authorize item in buttondata) { TreeViewModel tree = new TreeViewModel(); bool hasChildren = buttondata.Count(t => t.PID == item.ID) == 0 ? false : true; tree.id = item.ID; tree.text = item.AuthorizeName; tree.value = item.EnCode; tree.parentId = item.PID; tree.isexpand = true; tree.complete = true; tree.showcheck = true; tree.checkstate = roleAuthorize.Count(t => t.AuthorizeID == item.ID); tree.hasChildren = hasChildren; tree.img = item.Icon == "" ? "" : item.Icon; treeList.Add(tree); } return(Content(treeList.TreeViewJson())); }