public async Task <ActionResult> CreateModule(string id, string parentid = "") { (List <SysDictionary> list, long count)buttons = await SysDictionaryDAL.QueryAsync(w => w.Status == 1 && w.Parent.DictNo == AuthorizeName.PermissionButton); ViewBag.ButtonList = buttons.list.Select(s => new SelectListItem { Text = s.DictName, Value = s.DictNo.ToString() }).ToList(); (List <SysMenu> list, long count)menus = await SysMenuDAL.QueryAsync(w => w.Status == 1); //var lists = menus.list.Select(s => new SysMenuTreeNode //{ // name = s.MenuName, // id = s.Id.ToString() //}).ToList(); ViewBag.SysMenuList = menus.list.Select(s => new SelectListItem { Text = s.MenuName, Value = s.Id.ToString() }).ToList(); SysMenuView model = new SysMenuView() { Status = 1 }; if (!string.IsNullOrEmpty(parentid)) { model.ParentID = Convert.ToInt32(parentid); } return(View(model)); }
public async Task <ActionResult> UpdateModule(string id) { //获取菜单已经绑定的按钮 var menubuttons = await SysMenuButtonDAL.QueryAsync(u => u.MenuID == Convert.ToInt32(id), null, null); //回去权限按钮字典 (List <SysDictionary> list, long count)buttons = await SysDictionaryDAL.QueryAsync(w => w.Status == 1 && w.Parent.DictNo == AuthorizeName.PermissionButton); ViewBag.ButtonList = buttons.list.Select(s => new SelectListItem { Text = s.DictName, Value = s.DictNo.ToString(), Selected = menubuttons.list.Exists(e => e.ButtonCode == s.DictNo) }).ToList(); (List <SysMenu> list, long count)menus = await SysMenuDAL.QueryAsync(w => w.Status == 1); ViewBag.SysMenuList = menus.list.Select(s => new SelectListItem { Text = s.MenuName, Value = s.Id.ToString() }).ToList(); SysMenuView model = new SysMenuView() { }; if (!string.IsNullOrEmpty(id) && id != "0") { int _id = Convert.ToInt32(id); var tempModel = await new SysMenuDAL().GetByOneAsync(w => w.Id == _id); model = _mapper.Map <SysMenuView>(tempModel); } return(View(model)); }
public async Task <ActionResult> UpdateModule(string id) { var roleMenus = await SysRoleMenuDAL.QueryUserRole(u => u.RoleId == Convert.ToInt32(id), null, null); (List <SysMenu> list, long count)menus = await SysMenuDAL.QueryAsync(w => w.Status == 1); ViewBag.Menus = menus.list.Select(s => new SelectListItem { Selected = roleMenus.list.Exists(ss => ss.RoleId == s.Id), Text = s.MenuName, Value = s.Id.ToString() }).ToList(); SysRole model = new SysRole() { }; if (!string.IsNullOrEmpty(id) && id != "0") { int _id = Convert.ToInt32(id); model = await SysRoleDAL.GetByOneAsync(w => w.Id == _id); } return(View(model)); }
public async Task <ActionResult> GetTree(long id, int type = 1) { //已授权的角色菜单 var roleMenus = await SysRoleMenuDAL.QueryUserRole(u => u.RoleId == Convert.ToInt32(id), null, null); var roleButtons = await SysRoleButtonDAL.QueryAsync(u => u.RoleId == Convert.ToInt32(id), null, null); //所有状态为有效的菜单 (List <SysMenu> list, long count)menus = await SysMenuDAL.QueryAsync(w => w.Status == 1); var lists = menus.list.Select(s => { var btns = s.SysMenuButtons ?? new List <SysMenuButton>(); var newBtns = btns.Select(b => new TreeNode { id = b.Id.ToString(), name = b.ButtonCode, title = b.ButtonName, ischecked = roleButtons.list.Exists(e => e.ButtonId == b.Id) }).ToList(); var strbtns = Newtonsoft.Json.JsonConvert.SerializeObject(newBtns); return(new SysMenuTreeNode { ischecked = roleMenus.list.Exists(ss => ss.MenuId == s.Id), name = s.MenuName, title = s.MenuName, pid = (s.ParentID ?? 0).ToString(), id = s.Id.ToString(), //buttons = newBtns, jsonButtons = strbtns }); }).ToList(); return(Json(lists)); }