예제 #1
0
        //[UserAuth("AUTH_FUNC_VIW")]
        public ActionResult GetFuncsTree(int?id, int?check, int?disabled, string searchNam)
        {
            var funcsall = DaoFunction.FindList();
            var tree     = new ZtreeNode
            {
                id        = "",
                name      = "顶级权限",
                @checked  = check == null,
                open      = true,
                isParent  = true,
                nocheck   = true,
                highlight = (!string.IsNullOrEmpty(searchNam) && "顶级权限".IndexOf(searchNam) > -1),
                children  = GenFuncsTree(funcsall, null, check, disabled, searchNam)
            };
            var treelist = new List <ZtreeNode> {
                tree
            };

            if (null != id || Request.Form["lv"] == "0")
            {
                if (id == 0)
                {
                    id = null;
                }
                treelist = GenFuncsTree(funcsall, id, check, disabled, searchNam);
            }
            if (!string.IsNullOrEmpty(searchNam))
            {
                GenFuncsTreeHighlight(tree);
            }
            return(Json(treelist, JsonRequestBehavior.AllowGet));
        }
예제 #2
0
        /// <summary>
        /// 获取所有的菜单树节点
        /// </summary>
        /// <returns></returns>
        public MsgResult GetZtreeNodeByUserId()
        {
            MsgResult result = new MsgResult();

            try
            {
                List <ZtreeNode>  nodeList = new List <ZtreeNode>();
                List <T_SysMenus> sysMenus = SysMenusDal.GetModel(x => x.Id >= 0).ToList();
                for (int i = 0; i < sysMenus.Count; i++)
                {
                    ZtreeNode node = new ZtreeNode();
                    node.Id   = sysMenus[i].Id;
                    node.Name = sysMenus[i].MenuName;
                    node.Pid  = sysMenus[i].ParentId;
                    nodeList.Add(node);
                }
                result.IsSuccess = true;
                result.Data      = JsonConvert.SerializeObject(nodeList);
            }
            catch (Exception ex)
            {
                result.IsSuccess = false;
                result.Message   = ex.Message;
            }
            return(result);
        }
예제 #3
0
        public ActionResult GetMenusTree(int?id, int?check, int?disabled, string searchNam)
        {
            var menusall = dao.FindList();

            var tree = new ZtreeNode
            {
                id        = "",
                name      = "顶级菜单",
                @checked  = check == null,
                open      = true,
                isParent  = true,
                highlight = (!string.IsNullOrEmpty(searchNam) && "顶级菜单".IndexOf(searchNam) > -1),
                children  = GenMenusTree(menusall, new int?(), check, disabled, searchNam)
            };
            var treelist = new List <ZtreeNode> {
                tree
            };

            if (null != id || Request.Form["lv"] == "0")
            {
                if (id == 0)
                {
                    id = null;
                }
                treelist = GenMenusTree(menusall, id, check, disabled, searchNam);
            }
            if (!string.IsNullOrEmpty(searchNam))
            {
                GenMenusTreeHighlight(tree);
                GenMenusTreeHighlight(tree);//递归达不到足够的树深度,改为多次调用
            }
            return(Json(treelist, JsonRequestBehavior.AllowGet));
        }
예제 #4
0
 private void GenFuncsTreeHighlight(ZtreeNode tree)
 {
     if (tree.children != null && tree.children.Any(obj => obj.highlight))
     {
         tree.open = true;
     }
     foreach (var item in tree.children)
     {
         GenFuncsTreeHighlight(item);
     }
 }
예제 #5
0
 private void GenQueSerialOpen(ZtreeNode tree)
 {
     if (tree.children != null && tree.children.Any(obj => obj.highlight))
     {
         tree.open = true;
     }
     foreach (var item in tree.children)
     {
         GenQueSerialOpen(item);
     }
 }
예제 #6
0
 private void GenFuncsTreeHighlight2(ZtreeNode tree, IList <SYS_ROLEFUNCTION> rolefunclist)
 {
     if (tree.children == null || tree.children.Count == 0)
     {
         tree.children = new List <ZtreeNode> {
             new ZtreeNode
             {
                 id       = tree.id + "_1",
                 name     = "查看",
                 @checked = rolefunclist.Any(obj => obj.FUNCTION_ID.ToString() == tree.id && obj.FUNCTION_TYP == 1),
                 open     = true,
                 isParent = false
             }, new ZtreeNode
             {
                 id       = tree.id + "_2",
                 name     = "增加",
                 @checked = rolefunclist.Any(obj => obj.FUNCTION_ID.ToString() == tree.id && obj.FUNCTION_TYP == 2),
                 open     = true,
                 isParent = false
             },
             new ZtreeNode
             {
                 id       = tree.id + "_3",
                 name     = "修改",
                 @checked = rolefunclist.Any(obj => obj.FUNCTION_ID.ToString() == tree.id && obj.FUNCTION_TYP == 3),
                 open     = true,
                 isParent = false
             }, new ZtreeNode
             {
                 id       = tree.id + "_4",
                 name     = "删除",
                 @checked = rolefunclist.Any(obj => obj.FUNCTION_ID.ToString() == tree.id && obj.FUNCTION_TYP == 4),
                 open     = true,
                 isParent = false
             }
         };
         tree.@checked = tree.children.Any(obj => obj.@checked);
         return;
     }
     foreach (var item in tree.children)
     {
         if (item.id.IndexOf("_1") > -1)
         {
             return;
         }
         GenFuncsTreeHighlight2(item, rolefunclist);
     }
 }
예제 #7
0
        /// <summary>
        /// 获取权限树
        /// </summary>
        /// <returns></returns>
        //[UserAuth("AUTH_FUNC_VIW")]
        public ActionResult GetOrgsTreeLeafChk(string check, int?disabled, string searchNam)
        {
            var all  = dao.FindList();
            var tree = new ZtreeNode
            {
                id        = "",
                name      = "顶级机构",
                @checked  = check == null,
                open      = true,
                isParent  = true,
                nocheck   = true,
                highlight = (!string.IsNullOrEmpty(searchNam) && "顶级机构".IndexOf(searchNam) > -1),
                children  = GetOrgsTreeLeafChk(all, null, check, disabled, searchNam)
            };

            if (!string.IsNullOrEmpty(searchNam))
            {
                GenOrgsTreeLeafOpen(tree);
            }
            return(Json(tree, JsonRequestBehavior.AllowGet));
        }
예제 #8
0
        /// <summary>
        /// 获取菜单树节点数据
        /// </summary>
        /// <returns></returns>
        public MsgResult GetMenuTreeNodeData()
        {
            MsgResult        result   = new MsgResult();
            List <ZtreeNode> nodeList = new List <ZtreeNode>();

            try
            {
                if (CacheHelper.GetCache("menuList") == null)
                {
                    //var list = MenuDal.GetModels(x => x.IsDeleted == false).Select(x => Mapper.Map<SysMenus>(x)).ToList();
                    var list = SysMenuDal.GetModels(x => x.IsDeleted == false).ToList();
                    for (int i = 0; i < list.Count; i++)
                    {
                        ZtreeNode node = new ZtreeNode();
                        node.Id   = list[i].Id;
                        node.Pid  = list[i].ParentId;
                        node.Name = list[i].MenuName;
                        nodeList.Add(node);
                    }
                    CacheHelper.SetCache("menuList", nodeList, 3600);
                }
                else
                {
                    nodeList = (List <ZtreeNode>)CacheHelper.GetCache("menuList");
                }
                result.IsSuccess = true;
                result.Data      = JsonConvert.SerializeObject(nodeList);
            }
            catch (Exception ex)
            {
                result.IsSuccess = false;
                result.Message   = ex.Message;
                logger.Fatal(new LogContent(ex.InnerException.Message, ex.Message));
            }

            return(result);
        }
예제 #9
0
        public ActionResult GetRoleFuncsTree(int roleid, int?check, int?disabled, string searchNam)
        {
            var rolefunclist = DaoRolefunction.FindList("", "role_id", roleid);
            var funcsall     = DaoFunction.FindList();
            var tree         = new ZtreeNode
            {
                id        = "",
                name      = "顶级权限",
                @checked  = check == null,
                open      = true,
                isParent  = true,
                nocheck   = true,
                highlight = (string.IsNullOrEmpty(searchNam) ? false : "顶级权限".IndexOf(searchNam) > -1),
                children  = GenRoleFuncsTree(funcsall, rolefunclist, null, null
                                             , disabled, searchNam)
            };

            if (!string.IsNullOrEmpty(searchNam))
            {
                GenFuncsTreeHighlight(tree);
            }
            GenFuncsTreeHighlight2(tree, rolefunclist);
            return(Json(tree, JsonRequestBehavior.AllowGet));
        }