/// <summary> /// 生成单位授权过的菜单的下拉列表数据 /// </summary> /// <param name="deptId">单位ID</param> /// <param name="platform">平台类型</param> /// <param name="keyword">关键字</param> /// <param name="columnId">栏目ID</param> /// <returns></returns> public ActionResult GetMenuAuthCheckBoxData(string deptId, int?platform, string keyword, string columnId, int themeType) { AppMenuSettingBLL settingBLL = new AppMenuSettingBLL(); AppSettingAssociationBLL associationBLL = new AppSettingAssociationBLL(); //AppMenuSettingEntity settingEntity = settingBLL.GetEntity(columnId); //找到当前栏目 List <DeptMenuAuthEntity> deptMenuAuthEntities = deptMenuAuthBLL.GetList(deptId); //找到所有的授权的菜单 List <MenuConfigEntity> menuConfigEntities = MenuConfigBLL.GetListByModuleIds(deptMenuAuthEntities.Select(p => p.ModuleId).ToList(), platform).ToList(); //获取当前单位下的菜单 List <AppSettingAssociationEntity> associationEntities = associationBLL.GetList(deptId, deptMenuAuthEntities.Select(x => x.ModuleId).ToList()).OrderBy(x => x.Sort).ToList(); //再找出所有的关系(排除掉非授权的菜单) //剔除已经被其他栏目选择了的菜单,但不包括当前选中的栏目 var columnIds = settingBLL.GetList(deptId, themeType, platform.Value).Where(p => p.Id != columnId).Select(x => x.Id).ToList(); List <string> setedIds = associationEntities.Where(x => columnIds.Contains(x.ColumnId)).Select(p => p.ModuleId).ToList(); var columnMenu = menuConfigEntities.Where(x => !setedIds.Contains(x.ModuleId)).ToList(); //当前栏目可选的菜单,即没有被其他栏目选择过的菜单 List <AppSettingAssociationEntity> checkMenus = associationBLL.GetListByColumnId(columnId, deptMenuAuthEntities.Select(x => x.ModuleId).ToList()).ToList().OrderBy(x => x.Sort).ToList(); //获取当前栏目下授权了的菜单 //var data = MenuTreeHelper.BuildMenuTree(menuList, true); var firstLevelMenus = columnMenu.Where(x => x.ParentId == platform.ToString()); List <MenuTreeModel> data = new List <MenuTreeModel>(); foreach (var firstmenu in firstLevelMenus) { data.Add(new MenuTreeModel(firstmenu, platform.ToString(), true)); } foreach (var firstLevel in data) { MenuTreeHelper.FomateTree(firstLevel, columnMenu, checkMenus.Select(p => p.ModuleId).ToList(), true); } return(Json(data, JsonRequestBehavior.AllowGet)); }
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> /// <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)); }
/// <summary> /// 从双控获模块菜单 /// </summary> /// <param name="platform">平台类型 0 windows 1安卓终端 2手机APP</param> /// <returns></returns> public ActionResult GetMenuList(int platform) { try { var columnMenu = new TerminalDataSetBLL().GetMenuConfigList(platform); var firstLevelMenus = columnMenu.Where(x => x.ParentId == platform.ToString()); List <MenuTreeModel> data = new List <MenuTreeModel>(); foreach (var firstmenu in firstLevelMenus) { data.Add(new MenuTreeModel(firstmenu, platform.ToString())); } foreach (var firstLevel in data) { MenuTreeHelper.FomateTree(firstLevel, columnMenu); } return(Json(data, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new List <MenuTreeModel>(), JsonRequestBehavior.AllowGet)); } }