Пример #1
0
        public ResponseMessageWrap <List <LayUITreeDto> > QueryDataByAuthorize()
        {
            UserInfo            user = GetCurrentUser.GetUserInfo(Request.HttpContext);
            LayUITreeDto        tree = _sysOrgService.QueryDataByAuthorizeForLayUITree(user.org_id, user.group_id);
            List <LayUITreeDto> ss   = new List <LayUITreeDto>();

            ss.Add(tree);
            return(new ResponseMessageWrap <List <LayUITreeDto> > {
                data = ss
            });
        }
Пример #2
0
        public LayUITreeDto QueryDataByAuthorizeForLayUITree(string id, string group_id)
        {
            LayUITreeDto  res  = null;
            List <SysOrg> list = SysOrgRepository.QueryData(group_id);

            if (list != null && list.Count > 0)
            {
                res = new LayUITreeDto();
                //当前单位为根节点
                SysOrg rootOrg = list.Where(s => s.id == id).FirstOrDefault();
                res.title  = rootOrg.org_name;
                res.id     = rootOrg.id;
                res.spread = true;
                res.pId    = rootOrg.parent_id;
                res.obj    = rootOrg;
                GetChildOrg(res, list, id);
            }
            return(res);
        }
Пример #3
0
        private void GetChildOrg(LayUITreeDto res, List <SysOrg> orgList, string org_id)
        {
            List <SysOrg> childList = orgList.Where(s => s.parent_id == org_id).ToList();

            if (childList != null && childList.Count > 0)
            {
                foreach (SysOrg item in childList)
                {
                    LayUITreeDto node = new LayUITreeDto();
                    node.title = item.org_name;
                    node.id    = item.id;
                    node.pId   = item.parent_id;
                    node.obj   = item;
                    if (res.children == null)
                    {
                        res.children = new List <LayUITreeDto>();
                    }
                    res.children.Add(node);
                    GetChildOrg(res, orgList, item.id);
                }
            }
        }