Esempio n. 1
0
        /// <summary>
        /// 初始化树 默认找出顶级菜单
        /// add by lpl
        /// 2019-1-2
        /// </summary>
        /// <returns></returns>
        public List <MenuModels> InitTree()
        {
            var user = CurrentUser.CrmUser;
            //根据权限加载用户树
            bool isAdmin  = new CrmUserMenuBll().GetAuthorizationByUserId("System", "Admin", user.Id);
            var  TreeList = new ComMenuBll().GetAllMenu(new ComMenuEntity()
            {
                IsMenu = 1
            }, isAdmin);
            List <MenuModels> rootNode = new List <MenuModels>();

            foreach (var plist in TreeList.Where(t => t.ParentMenuId == "00001"))
            {
                MenuModels jt = new MenuModels();
                jt.id         = plist.Id;
                jt.text       = plist.MenuName;
                jt.parentid   = plist.ParentMenuId;
                jt.icon       = "";
                jt.url        = plist.MenuUrl;
                jt.attributes = CreateUrl(TreeList, jt);
                jt.menus      = CreateChildTree(TreeList, jt);
                rootNode.Add(jt);
            }
            return(rootNode);
        }
Esempio n. 2
0
        /// <summary>
        /// 加载左侧TreeViewJson
        /// 添加人:周 鹏
        /// 添加时间:2014-12-15
        /// </summary>
        /// <history>
        /// 修改描述:时间+作者+描述
        /// </history>
        /// <returns></returns>
        public JsonResult TreeMenu()
        {
            try
            {
                var menus    = new ComMenuBll().GetAllMenu(new ComMenuEntity());
                var topMenus = menus.Where(x => x.ParentMenuId == "-").ToList();
                var menuList = (from comMenuEntity in topMenus
                                let childs = ChildTree(menus, comMenuEntity.Id)
                                             select new TreeNode()
                {
                    id = comMenuEntity.Id,
                    text = comMenuEntity.MenuName,
                    img = !string.IsNullOrEmpty(comMenuEntity.IconPic) ? "/Content/Images/Icon16/" + comMenuEntity.IconPic : "/Content/Images/Icon16/messenger.png",
                    Location = comMenuEntity.MenuUrl,
                    showcheck = false,
                    isexpand = true,
                    complete = true,
                    hasChildren = childs.Count > 0,
                    ChildNodes = childs
                }).ToList();

                return(Json(menuList, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(null);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 获取系统功能菜单Json 数据
        /// 添加人:周 鹏
        /// 添加时间:2014-03-26
        /// </summary>
        /// <history>
        /// 修改描述:时间+作者+描述
        /// </history>
        /// <returns></returns>
        public JsonResult GetLeftMenu(string menuId)
        {
            ComMenuEntity titleMenu = new ComMenuBll().GetMenuByID(menuId);
            var           menus     = new ComMenuBll().GetUserMenus(CurrentUser.CrmUser.Id);

            menus = menus.Where(t => t.Id.Substring(0, 4).ToString().Equals(menuId) && !t.Id.Equals(menuId)).ToList();
            var menuList = menus.Select(comMenuEntity => new ZTreeNode()
            {
                id       = comMenuEntity.Id,
                pId      = comMenuEntity.ParentMenuId,
                name     = comMenuEntity.MenuName,
                openFlag = comMenuEntity.OpenType.ToString(),
                icon     = string.IsNullOrEmpty(comMenuEntity.IconPic) ? "/Content/Theme/Default/Images/treesystem.gif" : comMenuEntity.IconPic,
                open     = false
            }).ToList();

            var rtEntity = new StatusModel <ZTreeNode>
            {
                rtData  = menuList,
                rtMsrg  = titleMenu.MenuName,
                rtState = 0
            };

            return(Json(rtEntity, JsonRequestBehavior.AllowGet));
        }
Esempio n. 4
0
        public ActionResult Right(string menuID)
        {
            ComMenuEntity        cm      = new ComMenuBll().GetMenuByID(menuID);
            List <ComMenuEntity> allmenu = new ComMenuBll().GetUserMenus(CurrentUser.CrmUser.Id) as List <ComMenuEntity>;
            Dictionary <ComMenuEntity, List <ComMenuEntity> > dic = new Dictionary <ComMenuEntity, List <ComMenuEntity> >();
            List <ComMenuEntity> menuLsit = allmenu.Where(t => t.ParentMenuId == menuID).ToList();
            List <ComMenuEntity> temp;
            int count = 0;

            foreach (ComMenuEntity item in menuLsit)
            {
                temp = allmenu.Where(t => t.MenuLevel > 1 && t.Id.Substring(0, 8).Equals(item.Id) && !string.IsNullOrEmpty(t.MenuUrl)).ToList();
                foreach (var item2 in temp)
                {
                    item2.MenuUrl = GetUrl(item2.Id);
                }
                if (temp.Count > 0)
                {
                    dic.Add(item, temp);
                }
                else
                {
                    item.MenuUrl = GetUrl(item.Id);
                    temp         = new List <ComMenuEntity>();
                    temp.Add(item);
                    dic.Add(item, temp);
                }
                if (count == 3)
                {
                    break;
                }
                count++;
            }

            ViewData["MenuList"] = dic;
            return(View(cm));
        }
Esempio n. 5
0
        /// <summary>
        /// 菜单等级
        /// 添加人:周 鹏
        /// 添加时间:2014-03-28
        /// </summary>
        /// <history>
        /// 修改描述:时间+作者+描述
        /// </history>
        /// <param name="menuLevel">菜单等级(1:一级菜单 2:二级菜单 3:三级菜单)</param>
        /// <returns></returns>
        public string AjaxLoadMenus(int menuLevel)
        {
            //父级菜单
            var menus   = new ComMenuBll().GetAllMenu(menuLevel - 1);
            var sbMenus = new StringBuilder();

            sbMenus.AppendFormat("<option value=\"0\">请选择父级菜单</option>");
            if (menus.Count > 0)
            {
                foreach (var t in menus.Where(t => !string.IsNullOrEmpty(t.MenuName)))
                {
                    sbMenus.AppendFormat("<option value=\"" + t.Id + "\">" + t.MenuName + "</option>");
                }
            }
            return(sbMenus.ToString());
        }
Esempio n. 6
0
        /// <summary>
        /// 加载菜单
        /// 添加人:周 鹏
        /// 添加时间:2014-12-15
        /// </summary>
        /// <history>
        /// 修改描述:时间+作者+描述
        /// </history>
        /// <param name="moduleId">菜单编号</param>
        /// <returns></returns>
        public JsonResult LoadTreeMenu(string moduleId)
        {
            try
            {
                var currentUser = CurrentUser.CrmUser;
                var userMenus   = new ComMenuBll().GetUserMenus(currentUser.Id);

                List <ComMenuEntity> childMenus;
                if (!string.IsNullOrEmpty(moduleId))
                {
                    childMenus = userMenus.Where(x => x.ParentMenuId == moduleId).ToList();
                }
                else
                {
                    return(null);
                }
                var menuList = (from comMenuEntity in childMenus
                                let childs = ChildTree(userMenus, comMenuEntity.Id)
                                             select new TreeNode()
                {
                    id = comMenuEntity.Id,
                    text = comMenuEntity.MenuName,
                    img = !string.IsNullOrEmpty(comMenuEntity.IconPic) ? "/Content/Images/Icon16/" + comMenuEntity.IconPic : "/Content/Images/Icon16/messenger.png",
                    Location = comMenuEntity.MenuUrl,
                    showcheck = false,
                    isexpand = false,
                    complete = true,
                    hasChildren = childs.Count > 0,
                    ChildNodes = childs
                }).ToList();

                return(Json(menuList, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(null);
            }
        }