Пример #1
0
        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
            });
        }
Пример #2
0
        /// <summary>
        /// 根据 ID获取单个菜单配置
        /// </summary>
        /// <param name="keyValue"></param>
        /// <returns></returns>
        public ActionResult GetMenuSettingFormJson(string keyValue)
        {
            AppMenuSettingBLL    settingBLL = new AppMenuSettingBLL();
            AppMenuSettingEntity entity     = settingBLL.GetEntity(keyValue);

            return(Json(entity, JsonRequestBehavior.AllowGet));
        }
Пример #3
0
        /// <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));
        }
Пример #4
0
        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 });
            }
        }
Пример #5
0
        /// <summary>
        /// 保存菜单设置
        /// </summary>
        /// <param name="keyValue"></param>
        /// <param name="entity"></param>
        /// <returns></returns>
        public ActionResult SaveMenuSetting(string keyValue, AppMenuSettingEntity entity)
        {
            AppMenuSettingBLL settingBLL = new AppMenuSettingBLL();

            settingBLL.SaveForm(keyValue, entity);
            //判断该菜单是不是安卓终端的,是的话就更新版本

            MenuAuthorizeEntity menuAuthorize = authorizeBLL.GetEntityByDeptId(entity.DeptId);

            if (menuAuthorize != null)
            {
                authorizeBLL.SaveForm(menuAuthorize.Id, menuAuthorize);    //此处单纯的改变一下版本号
            }
            return(Success("操作成功。"));
        }
Пример #6
0
        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 });
            }
        }
Пример #7
0
        /// <summary>
        /// 删除栏目(因为栏目Id是唯一的,所以不用根据platform平台类型去区分删除)
        /// </summary>
        /// <param name="keyValue">栏目ID</param>
        /// <returns></returns>
        public ActionResult RemoveMenuSetting(string keyValue)
        {
            AppMenuSettingBLL    settingBLL = new AppMenuSettingBLL();
            AppMenuSettingEntity appMenu    = settingBLL.GetEntity(keyValue);

            settingBLL.Remove(keyValue);
            AppSettingAssociationBLL associationBLL = new AppSettingAssociationBLL();

            associationBLL.RemoveByColumnId(keyValue);//删除栏目与菜单的关联关系

            //判断该菜单是不是安卓终端的,是的话就更新版本
            if (appMenu.PlatformType == 1)
            {
                MenuAuthorizeEntity menuAuthorize = authorizeBLL.GetEntityByDeptId(appMenu.DeptId);
                if (menuAuthorize != null)
                {
                    authorizeBLL.SaveForm(menuAuthorize.Id, menuAuthorize);//此处单纯的改变一下版本号
                }
            }

            return(Success("操作成功。"));
        }
Пример #8
0
        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 });
            }
        }
Пример #9
0
        public ActionResult CopyInfo(CopyRequestModel model)
        {
            if (!string.IsNullOrWhiteSpace(model.DeptId) && !string.IsNullOrWhiteSpace(model.Id))
            {
                //先查询出授权信息
                MenuAuthorizeEntity entity = authorizeBLL.GetEntity(model.Id);
                if (entity != null)
                {
                    DepartmentBLL departmentBll = new DepartmentBLL();
                    var           deptIdArry    = model.DeptId.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    var           deptCodeArry  = model.DeptCode.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    var           deptNameArry  = model.DeptName.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    //菜单授权信息
                    DeptMenuAuthBLL           deptMenuAuthBll  = new DeptMenuAuthBLL();
                    List <DeptMenuAuthEntity> deptMenuAuthList = deptMenuAuthBll.GetList(entity.DepartId);
                    //界面设置
                    List <AppMenuSettingEntity> appMenuSettingEntities =
                        new AppMenuSettingBLL().GetListByDeptId(entity.DepartId);
                    //栏目与菜单的关联关系
                    List <AppSettingAssociationEntity> appSettingAssociationList =
                        new AppSettingAssociationBLL().GetList(entity.DepartId);

                    List <DeptMenuAuthEntity>          insetDeptMenuAuthList     = new List <DeptMenuAuthEntity>();
                    List <MenuAuthorizeEntity>         authorizeEntities         = new List <MenuAuthorizeEntity>();         //复制之后要保存到数据库中的单位授权数据
                    List <AppMenuSettingEntity>        insertMenuSettingEntities = new List <AppMenuSettingEntity>();        //界面设置
                    List <AppSettingAssociationEntity> insertAssociationEntities = new List <AppSettingAssociationEntity>(); //关联关系

                    for (int i = 0; i < deptIdArry.Length; i++)
                    {
                        //1、先复制单位的授权信息
                        DepartmentEntity    deptEntity   = departmentBll.GetEntity(deptIdArry[i]);
                        MenuAuthorizeEntity insertEntity = new MenuAuthorizeEntity()
                        {
                            Id             = Guid.NewGuid().ToString(),
                            DepartId       = deptIdArry[i],
                            DepartCode     = deptCodeArry[i],
                            DepartName     = deptNameArry[i],
                            DisplayName    = deptNameArry[i],
                            BZApiUrl       = entity.BZApiUrl,
                            CreateDate     = entity.CreateDate,
                            CreateUserId   = entity.CreateUserId,
                            CreateUserName = entity.CreateUserName,
                            CulturalUrl    = entity.CulturalUrl,
                            ModifyDate     = entity.ModifyDate,
                            ModifyUserId   = entity.ModifyUserId,
                            ModifyUserName = entity.ModifyUserName,
                            PXApiUrl       = entity.PXApiUrl,
                            RegistCode     = entity.RegistCode,
                            SKApiUrl       = entity.SKApiUrl,
                            TerminalCode   = entity.TerminalCode,
                            ThemeType      = entity.ThemeType,
                            VersionCode    = entity.VersionCode,
                            ParentId       = deptEntity != null? deptEntity.ParentId : "",
                            ParentName     =
                                deptEntity != null && deptEntity.ParentId == "0"
                                    ? ""
                                    : departmentBll.GetEntity(deptEntity.ParentId).FullName
                        };
                        authorizeEntities.Add(insertEntity);
                        //2、复制界面设置
                        appMenuSettingEntities.ForEach(setting =>
                        {
                            AppMenuSettingEntity appMenu = setting.Clone(deptIdArry[i], deptNameArry[i], deptCodeArry[i], appSettingAssociationList, insertAssociationEntities);
                            insertMenuSettingEntities.Add(appMenu);
                        });
                        //3、  复制关联关系
                        //appSettingAssociationList.ForEach(e =>
                        //{
                        //    AppSettingAssociationEntity association = e.Clone(deptIdArry[i], ,insetDeptMenuAuthList);
                        //    insertAssociationEntities.Add(association);
                        //});
                        //4、复制菜单授权信息
                        deptMenuAuthList.ForEach(p =>
                        {
                            DeptMenuAuthEntity deptMenu = p.Clone(deptIdArry[i], deptCodeArry[i], deptNameArry[i]);
                            insetDeptMenuAuthList.Add(deptMenu);
                        });
                    }
                    authorizeBLL.InsertEntity(authorizeEntities.ToArray());
                    new AppMenuSettingBLL().InsertList(insertMenuSettingEntities);
                    new AppSettingAssociationBLL().InsertList(insertAssociationEntities);
                    new DeptMenuAuthBLL().InsertList(insetDeptMenuAuthList);
                }
            }
            return(Success("操作成功"));
        }
Пример #10
0
        /// <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
        }
Пример #11
0
        public ActionResult SaveMenuAuth(MenuAuthRquestModel param)
        {
            try
            {
                //先从数据库提取出所有的该单位下的菜单。已经有的就不管,没有的就添加,多的就删除
                var oldData = deptMenuAuthBLL.GetList(param.departId);                            //旧的数据
                var delData = oldData.Where(x => !param.ModuleIds.Contains(x.ModuleId)).ToList(); //要删除逇数据;

                var oldmoduleIdsList = oldData.Select(x => x.ModuleId).ToList();
                var newdataIds       = param.ModuleIds.Where(x => !oldmoduleIdsList.Contains(x)).ToList();//要新增进去的数据Id的集合
                var newData          = new List <DeptMenuAuthEntity>();
                newdataIds.ForEach(p =>
                {
                    newData.Add(new DeptMenuAuthEntity()
                    {
                        Id       = Guid.NewGuid().ToString(),
                        DeptCode = param.departCode,
                        DeptId   = param.departId,
                        DeptName = param.departName,
                        ModuleId = p
                    });
                });
                //执行删除操作之前,判断是否有菜单已经被使用了,被适用的菜单,不允许取消授权。防止误操作
                bool validData = new AppSettingAssociationBLL().CheckData(delData);
                if (!validData)
                {
                    return(Error("操作失败:" + "存在正在被使用的菜单模块,请先删除“APP(安卓终端)界面设置”中工作栏里的菜单后再操作"));
                }

                deptMenuAuthBLL.Remove(delData);
                deptMenuAuthBLL.Add(newData);

                //取消了菜单授权之后 ,要删除对应的单位的栏目菜单关联关系
                new AppSettingAssociationBLL().Remove(param.departId, delData.Select(p => p.ModuleId).ToList());
                // 如果新增的数据里面有安卓终端的数据 ,则把这些菜单添加到默认栏目里面, 没有栏目的则默认新建一个栏目
                //1、找出新增的菜单里面是安卓菜单的数据
                List <MenuConfigEntity> newMenuEntityList = MenuConfigBLL.GetListByModuleIds(newdataIds, 1);
                if (newMenuEntityList != null && newMenuEntityList.Count > 0)
                {
                    //2、先找栏目,栏目没有就新建一个
                    AppMenuSettingBLL    settingBLL  = new AppMenuSettingBLL();
                    AppMenuSettingEntity menusetting = settingBLL.GetList(param.departId, 0, 1).FirstOrDefault();
                    string menusettingId             = Guid.NewGuid().ToString();
                    string menusettingName           = string.Empty;
                    if (menusetting == null)
                    {
                        menusetting              = new AppMenuSettingEntity();
                        menusetting.DeptCode     = param.departCode;
                        menusetting.DeptId       = param.departId;
                        menusetting.DeptName     = param.departName;
                        menusetting.PlatformType = 1;
                        menusetting.Name         = "总栏目";
                        menusetting.Sort         = 1;
                        menusetting.ThemeCode    = 0;
                        menusetting.Id           = menusettingId;
                        menusettingName          = menusetting.Name;
                        settingBLL.SaveForm(null, menusetting);
                    }
                    else
                    {
                        menusettingId   = menusetting.Id;
                        menusettingName = menusetting.Name;
                    }
                    //建立栏目与菜单的关联关系
                    List <AppSettingAssociationEntity> associationEntities = new List <AppSettingAssociationEntity>();
                    newMenuEntityList.ForEach(x => {
                        associationEntities.Add(new AppSettingAssociationEntity()
                        {
                            ColumnId   = menusettingId,
                            ColumnName = menusettingName,
                            DeptId     = param.departId,
                            Id         = Guid.NewGuid().ToString(),
                            ModuleId   = x.ModuleId,
                            Sort       = x.Sort,
                        });
                    });
                    new AppSettingAssociationBLL().SaveList(associationEntities);
                }
                MenuAuthorizeEntity menuAuthorize = authorizeBLL.GetEntityByDeptId(param.departId);
                if (menuAuthorize != null)
                {
                    authorizeBLL.SaveForm(menuAuthorize.Id, menuAuthorize);//此处单纯的改变一下版本号
                }
                return(Success("操作成功。"));
            }
            catch (Exception ex)
            {
                return(Error("操作失败:" + ex.Message));
            }
        }
Пример #12
0
        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 });
            }
        }