Exemplo n.º 1
0
        /// <summary>
        /// 删除栏目与菜单之间的关联关系
        /// </summary>
        /// <param name="keyValue">菜单Id</param>
        /// <param name="ColumnId">栏目ID</param>
        /// <returns></returns>
        public ActionResult RemoveAssociation(string ModuleId, string ColumnId)
        {
            try
            {
                AppSettingAssociationBLL    associationBLL = new AppSettingAssociationBLL();
                AppSettingAssociationEntity association    = associationBLL.GetEntity(ModuleId, ColumnId);
                //========因页面上的授权都改为了级联添加,删除也要做成级联删除===hm====//
                //1、先找查询出所有的菜单,然后递归找出所有的子级菜单
                List <MenuConfigEntity> menuConfigEntities = new MenuConfigBLL().GetAllList();
                List <MenuConfigEntity> childMenus         = new List <MenuConfigEntity>();
                childMenus.Add(menuConfigEntities.FirstOrDefault(p => p.ModuleId == ModuleId)); //当前项也要删除
                MenuTreeHelper.FindAllChild(menuConfigEntities, childMenus, ModuleId);          //找出所有的下级菜单

                //====================END==============================//
                associationBLL.Remove(childMenus.Select(x => x.ModuleId).ToList(), ColumnId);
                //判断该菜单是不是安卓终端的,是的话就更新版本
                var module = new MenuConfigBLL().GetEntity(ModuleId);
                if (module.PaltformType == 1)
                {
                    MenuAuthorizeEntity menuAuthorize = authorizeBLL.GetEntityByDeptId(association.DeptId);
                    if (menuAuthorize != null)
                    {
                        authorizeBLL.SaveForm(menuAuthorize.Id, menuAuthorize);//此处单纯的改变一下版本号
                    }
                }
                return(Success("操作成功。"));
            }
            catch (Exception ex)
            {
                return(Error("操作失败:" + ex.Message));
            }
        }
Exemplo n.º 2
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));
        }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 4
0
        /// <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));
        }
Exemplo n.º 5
0
 /// <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));
     }
 }