public ActionResult AuthorizeForm(string DepartId, string DepartName, string DepartCode) { ViewBag.DepartId = DepartId; ViewBag.DepartName = DepartName; ViewBag.DepartCode = DepartCode; var data = MenuConfigBLL.GetAllList().OrderBy(x => x.Sort).ToList(); //所有的菜单 List <string> menuAuthList = deptMenuAuthBLL.GetList(DepartId).Select(x => x.ModuleId).ToList(); //授权了的菜单ID ViewBag.MenuAuthList = menuAuthList; var treeModel = MenuTreeHelper.InitData(); foreach (var firstLevel in treeModel) { MenuTreeHelper.FomateTree(firstLevel, data, menuAuthList, false, true); } ViewBag.MenuTree = treeModel; var authTreeModel = MenuTreeHelper.InitData(); foreach (var firstLevel in authTreeModel) { MenuTreeHelper.FomateTree(firstLevel, data, false, false, true); } ViewBag.AuthTreeModel = authTreeModel; return(View(data)); }
/// <summary> /// 返回某一个平台下所有的模块 /// </summary> /// <param name="platform">0 windows 1 安卓终端 2手机app</param> /// <returns></returns> public object GetMenuList(int?platform) { try { MenuConfigBLL configBLL = new MenuConfigBLL(); var menuList = configBLL.GetAllList().Where(p => p.PaltformType == platform).ToList(); return(new { Code = 0, Info = "请求成功", Data = menuList, Count = menuList.Count }); } catch (Exception ex) { return(new { Code = -1, Info = "获取数据失败", ex.Message }); } }
/// <summary> /// 获取所有的数据(以树的形式) /// </summary> /// <returns></returns> public JsonResult GetTreeJson(bool showCheckBox = false) { var data = menuConfigBll.GetAllList(); var treeModel = MenuTreeHelper.InitData(); //foreach (var item in data) //{ // MenuTreeHelper.FomateTree(treeModel, item, showCheckBox); //} foreach (var firstLevel in treeModel) { MenuTreeHelper.FomateTree(firstLevel, data, showCheckBox); } return(Json(treeModel, JsonRequestBehavior.AllowGet)); }