Exemplo n.º 1
0
        /// <summary>
        /// 获取权限树
        /// </summary>
        /// <returns></returns>
        //[UserAuth("AUTH_FUNC_VIW")]
        public ActionResult SearchOrgsTree(string id)
        {
            var all = new SYS_USER_DAL().GetUserORG(UserState.UserID);

            foreach (var org in all.Where(obj => obj.PAR_ORG_ID == ""))
            {
                org.PAR_ORG_ID = null;
            }
            var treelist = all.Where(obj => obj.ORG_LEVEL == all.Min(obj2 => obj2.ORG_LEVEL) &&
                                     obj.ORG_LEVEL <= 2)
                           .Select(obj => new ZtreeNode_ORG
            {
                id       = obj.ORG_ID.ToString(),
                name     = obj.ORG_NAM,
                open     = true,
                isParent = true,
                children = all.Where(o => o.PAR_ORG_ID == obj.ORG_ID && o.ORG_LEVEL == 2)//只显示市,没有市不显示
                           .Select(obj2 => new ZtreeNode_ORG
                {
                    id       = obj2.ORG_ID.ToString(),
                    name     = obj2.ORG_NAM,
                    open     = true,
                    isParent = true
                }).ToList()
            }).ToList();

            return(Json(treelist, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取权限树
        /// </summary>
        /// <returns></returns>
        //[UserAuth("AUTH_FUNC_VIW")]
        public ActionResult GetOrgsManagerTree(string id, string check, int?disabled, string searchNam)
        {
            var all = new SYS_USER_DAL().GetUserORG(UserState.UserID);

            foreach (var org in all.Where(obj => obj.PAR_ORG_ID == ""))
            {
                org.PAR_ORG_ID = null;
            }
            bool rootHasAuth = true;

            if (!all.Any(o => o.ORG_LEVEL == 1))//处理没有省权限的数据
            {
                rootHasAuth = false;
                all.Where(o => o.ORG_LEVEL == (all.Min(o2 => o2.ORG_LEVEL)))
                .ToList().ForEach(o => o.PAR_ORG_ID = null);
            }
            var tree = new ZtreeNode_ORG
            {
                id        = "",
                name      = "顶级机构",
                @checked  = check == null,
                open      = true,
                isParent  = true,
                nocheck   = true,
                hasauth   = rootHasAuth,
                highlight = (!string.IsNullOrEmpty(searchNam) && "顶级机构".IndexOf(searchNam) > -1),
                children  = GenOrgsManagerTree(all, null, check, disabled, searchNam)
            };
            var treelist = new List <ZtreeNode_ORG> {
                tree
            };

            if (!string.IsNullOrEmpty(id) || Request.Form["lv"] == "0")
            {
                if (id == "")
                {
                    id = null;
                }
                treelist = GenOrgsManagerTree(all, id, check, disabled, searchNam);
            }
            if (!string.IsNullOrEmpty(searchNam))
            {
                GenOrgsManagerTreeOpen(tree);
                GenOrgsManagerTreeOpen(tree);//递归达不到足够的深度,改为多次调用
                GenOrgsManagerTreeOpen(tree);
            }
            return(Json(treelist, JsonRequestBehavior.AllowGet));
        }