public ListResult <MenuSettingData> GetAnonymousMenus(ParameterModel <MenuFilterModel> parameterModel) { var baseurl = new DataItemDetailBLL().GetItemValue("imgUrl"); AppMenuSettingBLL settingBLL = new AppMenuSettingBLL(); AppSettingAssociationBLL settingAssociationBLL = new AppSettingAssociationBLL(); List <AppMenuSettingEntity> appMenuSettingEntities = settingBLL.GetList(parameterModel.Data.DeptId, int.Parse(parameterModel.Data.ThemeType), int.Parse(parameterModel.Data.Platform)); List <AppSettingAssociationEntity> settingAssociationEntities = settingAssociationBLL.GetList(parameterModel.UserId); MenuConfigBLL menuConfigBLL = new MenuConfigBLL(); List <MenuConfigEntity> menusAll = menuConfigBLL.GetList("", int.Parse(parameterModel.Data.Platform), null).Distinct().ToList(); List <MenuSettingData> menuSettingDatas = new List <MenuSettingData>(); foreach (var item in appMenuSettingEntities) { MenuSettingData menuSettingData = new MenuSettingData() { Id = item.Id, Name = item.Name, Remark = item.Remark, Sort = item.Sort, Icon = string.IsNullOrWhiteSpace(item.Icon) ? null : baseurl + item.Icon, }; var menusIds = settingAssociationEntities.Where(p => p.ColumnId == item.Id).Select(x => x.ModuleId).ToList(); if (menusIds != null && menusIds.Count > 0) { var appMenu = menusAll.Where(x => menusIds.Contains(x.ModuleId)).ToList(); menuSettingData.AddChild(appMenu, settingAssociationEntities.Where(p => p.ColumnId == item.Id).ToList()); } menuSettingDatas.Add(menuSettingData); } var data = menuSettingDatas.OrderBy(x => x.Sort).ToList(); return(new ListResult <MenuSettingData> { Success = true, Data = data }); }
/// <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 object GetTerminalMenuList([FromBody] JObject json) { try { string res = json.Value <string>("json"); dynamic dy = JsonConvert.DeserializeObject <ExpandoObject>(res); string id = dy.id; //单位注册ID long themeTypeParam = dy.themetype; //0 第一套工作栏 1 第二套 int themeType = int.Parse(themeTypeParam.ToString()); //取出单位的注册信息 MenuAuthorizeEntity menuAuthorize = new MenuAuthorizeBLL().GetEntity(id); //1、先取出所有的栏目 AppMenuSettingBLL settingBLL = new AppMenuSettingBLL(); List <AppMenuSettingEntity> appMenuSettingEntities = settingBLL.GetList(menuAuthorize.DepartId, themeType, 1).OrderBy(p => p.Sort).ToList(); //2、取当前用户所有的授权的菜单 MenuConfigBLL menuConfigBLL = new MenuConfigBLL(); List <MenuConfigEntity> menus = menuConfigBLL.GetList(null, null, null).Distinct().ToList(); //3、根据栏目与菜单的关系配置取菜单 AppSettingAssociationBLL settingAssociationBLL = new AppSettingAssociationBLL(); List <AppSettingAssociationEntity> settingAssociationEntities = settingAssociationBLL.GetList(menuAuthorize.DepartId, menus.Select(p => p.ModuleId).ToList()); //4、组装数据 List <MenuSettingData> menuSettingDatas = new List <MenuSettingData>(); foreach (var item in appMenuSettingEntities) { MenuSettingData menuSettingData = new MenuSettingData() { Id = item.Id, Name = item.Name, Remark = item.Remark, Sort = item.Sort, Icon = string.IsNullOrWhiteSpace(item.Icon) ? null : new DataItemDetailBLL().GetItemValue("imgUrl") + item.Icon, }; var menusSearch = settingAssociationEntities.Where(p => p.ColumnId == item.Id).OrderBy(p => p.Sort).ToList(); if (menusSearch != null && menusSearch.Count > 0) { var menusIds = menusSearch.Select(p => p.ModuleId).ToList(); var appMenu = menus.Where(x => menusIds.Contains(x.ModuleId)).ToList(); menuSettingData.AddChild(appMenu, menusSearch); } menuSettingData.Child = menuSettingData.Child.OrderBy(p => p.Sort).ToList(); menuSettingDatas.Add(menuSettingData); } var data = menuSettingDatas.OrderBy(x => x.Sort).ToList(); return(new { Code = 0, data.Count, Info = "获取数据成功", data }); } catch (Exception ex) { return(new { Code = -1, Count = 0, Info = "获取数据失败", ex.Message }); } }
public object ModuleShow([FromBody] JObject json) { try { string res = json.Value <string>("json"); dynamic dy = JsonConvert.DeserializeObject <ExpandoObject>(res); string id = dy.id; //单位注册ID long themeTypeParam = dy.themetype; //0 第一套工作栏 1 第二套 int themeType = int.Parse(themeTypeParam.ToString()); //取出单位的注册信息 MenuAuthorizeEntity menuAuthorize = new MenuAuthorizeBLL().GetEntity(id); //1、先取出所有的栏目 AppMenuSettingBLL settingBLL = new AppMenuSettingBLL(); List <AppMenuSettingEntity> appMenuSettingEntities = settingBLL.GetList(menuAuthorize.DepartId, themeType, 1); //2、取当前用户所有的授权的菜单 MenuConfigBLL menuConfigBLL = new MenuConfigBLL(); List <MenuConfigEntity> menus = menuConfigBLL.GetList(null, null, null).Distinct().ToList(); //3、根据栏目与菜单的关系配置取菜单 AppSettingAssociationBLL settingAssociationBLL = new AppSettingAssociationBLL(); List <AppSettingAssociationEntity> settingAssociationEntities = settingAssociationBLL.GetList(menuAuthorize.DepartId, menus.Select(p => p.ModuleId).ToList()); //4、组装数据 List <MenuConfigEntity> authMenu = new List <MenuConfigEntity>(); foreach (var item in appMenuSettingEntities) { var menusIds = settingAssociationEntities.Where(p => p.ColumnId == item.Id).Select(x => x.ModuleId).ToList(); if (menusIds != null && menusIds.Count > 0) { var appMenu = menus.Where(x => menusIds.Contains(x.ModuleId)).ToList(); authMenu.AddRange(appMenu); } } //根据名字判断班务公开显示的tab页 var data = new { kqb = authMenu.Count(p => p.ModuleName.Contains("考勤管理")) > 0 ? 1 : 0, zbb = authMenu.Count(p => p.ModuleName.Contains("考勤管理")) > 0 ? 1 : 0, jxkhb = authMenu.Count(p => p.ModuleName.Contains("绩效管理")) > 0 ? 1 : 0, }; return(new { Code = 0, Info = "获取数据成功", Data = data }); } catch (Exception ex) { return(new { Code = -1, Count = 0, Info = "获取数据失败", ex.Message }); } }
public object GetMenuList([FromBody] JObject json) { try { string res = json.Value <string>("json"); dynamic dy = JsonConvert.DeserializeObject <ExpandoObject>(res); string userId = dy.userid; //用户名 long themeTypeParam = dy.data.themetype; //0 第一套工作栏 1 第二套 long platformParam = dy.data.platform; //2 手机APP 1 安卓终端 int themeType = int.Parse(themeTypeParam.ToString()); int platform = int.Parse(platformParam.ToString()); //获取用户基本信息 OperatorProvider.AppUserId = userId; //设置当前用户 Operator user = OperatorProvider.Provider.Current(); if (user == null || user.RoleId == null) { //logMessage.ExceptionSource = Error.Source; //logMessage.ExceptionRemark = Error.StackTrace; LogEntity logEntity = new LogEntity(); logEntity.CategoryId = 4; logEntity.OperateTypeId = ((int)OperationType.Exception).ToString(); logEntity.OperateType = EnumAttribute.GetDescription(OperationType.Exception); if (null != OperatorProvider.Provider.Current()) { logEntity.OperateUserId = OperatorProvider.Provider.Current().UserId; } logEntity.ExecuteResult = -1; logEntity.ExecuteResultJson = "用户或用户的角色为空"; logEntity.Module = "菜单配置"; logEntity.ModuleId = SystemInfo.CurrentModuleId; logEntity.WriteLog(); return(new { Code = -1, Info = "获取数据失败", Message = "用户或用户的角色为空" }); } List <string> roleId = user.RoleId.Replace(" ", "").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); if (user.IsTrainAdmin == 1) { roleId.Add("15006a63-94d8-479f-8478-575e567671bc"); } else { roleId.Add("f405d85b-4f92-4e0d-8030-2f4e7a280f41"); } DepartmentBLL departmentBLL = new DepartmentBLL(); //先判断当前用户的部门是不是在厂级及以上 var depart = departmentBLL.GetList() .Where(x => x.Nature.Contains("集团") || x.Nature.Contains("省级") || x.Nature.Contains("厂级")); bool ishave = depart.Any(entity => entity.DepartmentId == user.DeptId); string deptId = user.DeptId; if (!ishave) { deptId = user.OrganizeId; } //1、先取出所有的栏目 AppMenuSettingBLL settingBLL = new AppMenuSettingBLL(); List <AppMenuSettingEntity> appMenuSettingEntities = settingBLL.GetList(deptId, themeType, platform); //2、取当前用户所有的授权的菜单 MenuConfigBLL menuConfigBLL = new MenuConfigBLL(); List <MenuConfigEntity> menusAll = menuConfigBLL.GetList("", platform, null).Distinct().ToList(); List <MenuConfigEntity> menus = new List <MenuConfigEntity>(); roleId.ForEach(role => { menus.AddRange(menusAll.Where(p => !string.IsNullOrWhiteSpace(p.AuthorizeId) && p.AuthorizeId.Contains(role))); }); menus = menus.Distinct().ToList(); DeptMenuAuthBLL deptMenuAuthBll = new DeptMenuAuthBLL(); var deptauthList = deptMenuAuthBll.GetList(deptId).Select(x => x.ModuleId); menus = menus.Where(x => deptauthList.Contains(x.ModuleId)).ToList(); //3、根据栏目与菜单的关系配置取菜单 AppSettingAssociationBLL settingAssociationBLL = new AppSettingAssociationBLL(); List <AppSettingAssociationEntity> settingAssociationEntities = settingAssociationBLL.GetList(deptId, menus.Select(p => p.ModuleId).ToList()); //4、组装数据 List <MenuSettingData> menuSettingDatas = new List <MenuSettingData>(); foreach (var item in appMenuSettingEntities) { MenuSettingData menuSettingData = new MenuSettingData() { Id = item.Id, Name = item.Name, Remark = item.Remark, Sort = item.Sort, Icon = string.IsNullOrWhiteSpace(item.Icon) ? null : new DataItemDetailBLL().GetItemValue("imgUrl") + item.Icon, }; var menusIds = settingAssociationEntities.Where(p => p.ColumnId == item.Id).Select(x => x.ModuleId).ToList(); if (menusIds != null && menusIds.Count > 0) { var appMenu = menus.Where(x => menusIds.Contains(x.ModuleId)).ToList(); menuSettingData.AddChild(appMenu, settingAssociationEntities.Where(p => p.ColumnId == item.Id).ToList()); } menuSettingDatas.Add(menuSettingData); } var data = menuSettingDatas.OrderBy(x => x.Sort).ToList(); return(new { Code = 0, data.Count, Info = "获取数据成功", data }); } catch (Exception ex) { LogMessage logMessage = new LogMessage(); logMessage.OperationTime = DateTime.Now; logMessage.Url = HttpContext.Current.Request.RawUrl; logMessage.Class = "MenuConfig"; logMessage.Ip = Net.Ip; logMessage.Host = Net.Host; logMessage.Browser = Net.Browser; if (null != OperatorProvider.Provider.Current()) { logMessage.UserName = OperatorProvider.Provider.Current().Account + "(" + OperatorProvider.Provider.Current().UserName + ")"; } logMessage.ExceptionInfo = Newtonsoft.Json.JsonConvert.SerializeObject(ex); //logMessage.ExceptionSource = Error.Source; //logMessage.ExceptionRemark = Error.StackTrace; string strMessage = new LogFormat().ExceptionFormat(logMessage); LogEntity logEntity = new LogEntity(); logEntity.CategoryId = 4; logEntity.OperateTypeId = ((int)OperationType.Exception).ToString(); logEntity.OperateType = EnumAttribute.GetDescription(OperationType.Exception); logEntity.OperateAccount = logMessage.UserName; if (null != OperatorProvider.Provider.Current()) { logEntity.OperateUserId = OperatorProvider.Provider.Current().UserId; } logEntity.ExecuteResult = -1; logEntity.ExecuteResultJson = strMessage; logEntity.Module = "菜单配置"; logEntity.ModuleId = SystemInfo.CurrentModuleId; logEntity.WriteLog(); return(new { Code = -1, Info = "获取数据失败", ex.Message }); } }
/// <summary> /// 获取菜单配置信息 /// </summary> /// <param name="rquestModel"></param> /// <returns></returns> public ContentResult GetAPPMenuSetting(MenuSettingRquestModel rquestModel) { try { AppMenuSettingBLL settingBLL = new AppMenuSettingBLL(); AppSettingAssociationBLL associationBLL = new AppSettingAssociationBLL(); List <AppMenuSettingEntity> settingEntities = settingBLL.GetList(rquestModel.deptId, rquestModel.themeType, rquestModel.platform).OrderBy(p => p.Sort).ToList(); //先找出所有的栏目 List <DeptMenuAuthEntity> deptMenuAuthEntities = deptMenuAuthBLL.GetList(rquestModel.deptId); //找到所有的授权的菜单 List <AppSettingAssociationEntity> associationEntities = associationBLL.GetList(rquestModel.deptId, deptMenuAuthEntities.Select(x => x.ModuleId).ToList()).OrderBy(x => x.Sort).ToList(); //再找出所有的关系(排除掉非授权的菜单) List <MenuConfigEntity> menuConfigEntities = MenuConfigBLL.GetListByModuleIds(associationEntities.Select(x => x.ModuleId).ToList()); //获取完整的菜单的 //构建树 var treeList = new List <TreeGridEntity>(); settingEntities.ForEach(setting => { //添加栏目 MenuTreeGridModel treeGridModel = new MenuTreeGridModel() { Id = setting.Id, Name = setting.Name, DeptId = setting.DeptId, DataSouceType = 0, Remark = setting.Remark, ParentId = "0", Sort = setting.Sort, ColumnId = setting.Id }; TreeGridEntity treeGridEntity = new TreeGridEntity() { parentId = "0", entityJson = JsonConvert.SerializeObject(treeGridModel), expanded = false, hasChildren = true, id = setting.Id, text = setting.Name, code = setting.Id }; treeList.Add(treeGridEntity); //添加该栏目下面的菜单 var menuassocia = associationEntities.Where(x => x.ColumnId == setting.Id).OrderBy(s => s.Sort).ToList(); var moduleIds = menuassocia.Select(p => p.ModuleId); var menuList = menuConfigEntities.Where(x => moduleIds.Contains(x.ModuleId)).ToList(); menuassocia.ForEach(a => { var aa = menuConfigEntities.FirstOrDefault(x => x.ModuleId == a.ModuleId); if (aa != null) { MenuTreeGridModel treeGrid1 = new MenuTreeGridModel() { Id = aa.Id, Name = aa.ModuleName, DeptId = a.DeptId, DataSouceType = 1, Remark = aa.Remark, ParentId = aa.ParentId.Equals(rquestModel.platform.ToString()) ? setting.Id : aa.ParentId, //最顶级菜单 ParentName = aa.ParentId.Equals(rquestModel.platform.ToString()) ? setting.Name : aa.ParentName, //最顶级菜单 Sort = a.Sort, ColumnId = setting.Id }; if (!menuassocia.Any(x => x.ModuleId == treeGrid1.ParentId)) { treeGrid1.ParentId = setting.Id; treeGrid1.ParentName = setting.Name; } TreeGridEntity treeGridEntity1 = new TreeGridEntity() { parentId = treeGrid1.ParentId, entityJson = JsonConvert.SerializeObject(treeGrid1), expanded = false, hasChildren = true, id = aa.Id, text = aa.ModuleName, code = aa.Id, }; treeList.Add(treeGridEntity1); } }); }); return(Content(treeList.TreeJson())); } catch (Exception ex) { throw new Exception("请求失败", ex); } #region 测试 //var data1 = new //{ // EnCode = "001", // Name = "测试", // ParentId = "0", //}; //var data2 = new //{ // EnCode = "006", // Name = "测试1", // ParentId = "001", //}; //var data3 = new //{ // EnCode = "006002", // Name = "测试1-2", // ParentId = "006", //}; //var data4 = new //{ // EnCode = "007", // Name = "???", // ParentId = "0", //}; //var data5 = new //{ // EnCode = "009", // Name = "XX", // ParentId = "0", //}; // treeList = new List<TreeGridEntity>(); //TreeGridEntity tree = new TreeGridEntity() //{ // parentId = data1.ParentId, // entityJson = JsonConvert.SerializeObject(data1), // expanded = false, // hasChildren = true, // id = data1.EnCode, // text = data1.Name, // code = data1.EnCode //}; //TreeGridEntity tree1 = new TreeGridEntity() //{ // parentId = data2.ParentId, // entityJson = JsonConvert.SerializeObject(data2), // expanded = false, // hasChildren = true, // id = data2.EnCode, // text = data2.Name, // code = data2.EnCode //}; //TreeGridEntity tree2 = new TreeGridEntity() //{ // parentId = data3.ParentId, // entityJson = JsonConvert.SerializeObject(data3), // expanded = false, // hasChildren = true, // id = data3.EnCode, // text = data3.Name, // code = data3.EnCode //}; //TreeGridEntity tree4 = new TreeGridEntity() //{ // parentId = "0", // entityJson = JsonConvert.SerializeObject(data4), // expanded = false, // hasChildren = true, // id = data4.EnCode, // text = data4.Name, // code = data4.EnCode //}; //TreeGridEntity tree5 = new TreeGridEntity() //{ // parentId = "0", // entityJson = JsonConvert.SerializeObject(data5), // expanded = false, // hasChildren = false, // id = data5.EnCode, // text = data5.Name, // code = data5.EnCode //}; //treeList.Add(tree); //treeList.Add(tree1); //treeList.Add(tree2); //treeList.Add(tree4); //treeList.Add(tree5); #endregion }
public object GetMenuList([FromBody] JObject json) { try { string res = json.Value <string>("json"); dynamic dy = JsonConvert.DeserializeObject <ExpandoObject>(res); string userId = dy.userid; //用户名 long themeTypeParam = dy.data.themetype; //0 第一套工作栏 1 第二套 long platformParam = dy.data.platform; //2 手机APP 1 安卓终端 int themeType = int.Parse(themeTypeParam.ToString()); int platform = int.Parse(platformParam.ToString()); //获取用户基本信息 OperatorProvider.AppUserId = userId; //设置当前用户 Operator user = OperatorProvider.Provider.Current(); if (user.RoleId == null) { return(new { Code = -1, Info = "获取数据失败", Message = "用户的角色为空" }); } List <string> roleId = user.RoleId.Replace(" ", "").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); DepartmentBLL departmentBLL = new DepartmentBLL(); //先判断当前用户的部门是不是在厂级及以上 var depart = departmentBLL.GetList() .Where(x => x.Nature.Contains("集团") || x.Nature.Contains("省级") || x.Nature.Contains("厂级")); bool ishave = depart.Any(entity => entity.DepartmentId == user.DeptId); string deptId = user.DeptId; if (!ishave) { deptId = user.OrganizeId; } //1、先取出所有的栏目 AppMenuSettingBLL settingBLL = new AppMenuSettingBLL(); List <AppMenuSettingEntity> appMenuSettingEntities = settingBLL.GetList(deptId, themeType, platform); //2、取当前用户所有的授权的菜单 MenuConfigBLL menuConfigBLL = new MenuConfigBLL(); List <MenuConfigEntity> menus = menuConfigBLL.GetList("", platform, roleId).Distinct().ToList(); DeptMenuAuthBLL deptMenuAuthBll = new DeptMenuAuthBLL(); var deptauthList = deptMenuAuthBll.GetList(deptId).Select(x => x.ModuleId); menus = menus.Where(x => deptauthList.Contains(x.ModuleId)).ToList(); //3、根据栏目与菜单的关系配置取菜单 AppSettingAssociationBLL settingAssociationBLL = new AppSettingAssociationBLL(); List <AppSettingAssociationEntity> settingAssociationEntities = settingAssociationBLL.GetList(deptId, menus.Select(p => p.ModuleId).ToList()); //4、组装数据 List <MenuSettingData> menuSettingDatas = new List <MenuSettingData>(); foreach (var item in appMenuSettingEntities) { MenuSettingData menuSettingData = new MenuSettingData() { Id = item.Id, Name = item.Name, Remark = item.Remark, Sort = item.Sort, }; var menusIds = settingAssociationEntities.Where(p => p.ColumnId == item.Id).Select(x => x.ModuleId).ToList(); if (menusIds != null && menusIds.Count > 0) { var appMenu = menus.Where(x => menusIds.Contains(x.ModuleId)).ToList(); menuSettingData.AddChild(appMenu, settingAssociationEntities.Where(p => p.ColumnId == item.Id).ToList()); } menuSettingDatas.Add(menuSettingData); } var data = menuSettingDatas.OrderBy(x => x.Sort).ToList(); return(new { Code = 0, data.Count, Info = "获取数据成功", data }); } catch (Exception ex) { return(new { Code = -1, Info = "获取数据失败", ex.Message }); } }