Esempio n. 1
0
        /// <summary>
        /// 获取权限树
        /// </summary>
        /// <returns></returns>
        //[UserAuth("AUTH_FUNC_VIW")]
        public ActionResult GetOrgs2Tree(string id, string check, int?disabled, string searchNam)
        {
            var all     = new SYS_USER_DAL().GetUserORG(UserState.UserID);
            var hallall = DaoHall.FindList();

            foreach (var org in all.Where(obj => obj.PAR_ORG_ID == ""))
            {
                org.PAR_ORG_ID = null;
            }
            var treelist = all.Where(obj => obj.ORG_LEVEL == 2)//市级
                           .Select(obj => new ZtreeNode_ORG
            {
                id          = obj.ORG_ID.ToString(),
                name        = obj.ORG_NAM,
                @checked    = (check != null && check == obj.ORG_ID),
                open        = true,
                Org_LV      = (byte)obj.ORG_LEVEL,
                isParent    = all.Any(obj2 => obj2.PAR_ORG_ID == obj.ORG_ID),
                chkDisabled = (disabled != null && disabled.ToString() == obj.ORG_ID),
                highlight   = (!string.IsNullOrEmpty(searchNam) && obj.ORG_NAM.IndexOf(searchNam) > -1)
            }).ToList();

            if (null != treelist && treelist.Count > 0)
            {
                foreach (var leaf in treelist)
                {
                    List <ZtreeNode_ORG> leafchild = new List <ZtreeNode_ORG>();
                    GenOrgs2Tree(all, hallall, ref leafchild, leaf.id, check, disabled, searchNam);
                    leaf.children = leafchild;
                }
            }
            else
            {
                if (null != all && all.Count > 0)
                {
                    foreach (var item in all.Where(o => o.ORG_LEVEL == 4))
                    {
                        List <ZtreeNode_ORG> leafchild = new List <ZtreeNode_ORG>();
                        GenOrgs2Tree(all, hallall, ref leafchild, item.PAR_ORG_ID, check, disabled, searchNam);
                        treelist.AddRange(leafchild);
                    }
                }
            }
            if (!string.IsNullOrEmpty(searchNam))
            {
                GenOrgs2TreeOpen(treelist);
            }
            return(Json(treelist, JsonRequestBehavior.AllowGet));
        }
Esempio 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));
        }