在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
/// <summary> /// 获取组织结构树 /// </summary> /// <param name="list"></param> /// <param name="id"></param> /// <param name="treeNodes"></param> /// <returns></returns> static void GetOrganizeSelectTreeNodes(List<BaseOrganizeEntity> list, string id, ref List<SelectTreeNode> treeNodes) { if (list == null) return ; List<BaseOrganizeEntity> sublist; if (!string.IsNullOrWhiteSpace(id)) { sublist = list.Where(t => t.ParentId == id).ToList(); } else { sublist = list.Where(t => string.IsNullOrWhiteSpace(t.ParentId)).ToList(); } if (!sublist.Any()) return; foreach (var item in sublist) { treeNodes.Add(new SelectTreeNode() { id = item.Id, name = item.FullName, parentId = item.ParentId }); GetOrganizeSelectTreeNodes(list, item.Id, ref treeNodes); } }
/// <summary> /// 获取公司树 /// </summary> /// <returns></returns> public ActionResult GetOrganizesTree(string id = null, string name = null) { // 使用程序递归 MySql用SQL语句递归比较暂时不支持,需要用存储过程处理 List<SelectTreeNode> treeNodes = new List<SelectTreeNode>(); GetOrganizeSelectTreeNodes(organizeManager.GetList<BaseOrganizeEntity>(), id, ref treeNodes); var result = new Hashtable { { "treeNodes", treeNodes } }; return Json(result, JsonRequestBehavior.AllowGet); }
|
请发表评论