public string TreeRefresh() { string refreshId = Request.Querys("refreshid"); if (!refreshId.IsGuid(out Guid rid)) { return("[]"); } Business.Dictionary dictionary = new Business.Dictionary(); var childs = dictionary.GetChilds(rid); Newtonsoft.Json.Linq.JArray jArray = new Newtonsoft.Json.Linq.JArray(); foreach (var child in childs) { Newtonsoft.Json.Linq.JObject jObject = new Newtonsoft.Json.Linq.JObject { { "id", child.Id }, { "parentID", child.ParentId }, { "title", child.Status == 1 ? "<span style='color:#999'>" + child.Title + "[作废]</span>" : child.Title }, { "type", "2" }, { "ico", "" }, { "hasChilds", dictionary.HasChilds(child.Id) ? 1 :0 } }; jArray.Add(jObject); } return(jArray.ToString()); }
/// <summary> /// 加载树JSON /// </summary> /// <returns></returns> public string Tree1() { string rootId = Request.Querys("root"); string tempitem = Request.Querys("tempitem"); //需要临时添加的项(如表单管理流程管理需要额外添加已删除的项目) string tempitemid = Request.Querys("tempitemid"); //需要临时添加项的ID Business.Dictionary dictionary = new Business.Dictionary(); if (rootId.IsNullOrEmpty()) { rootId = dictionary.GetRootId().ToString(); } Newtonsoft.Json.Linq.JArray jArray = new Newtonsoft.Json.Linq.JArray(); string[] rootIds = rootId.Split(','); foreach (string rid in rootIds) { if (!rid.IsGuid(out Guid rootGuid)) { continue; } var rootDict = dictionary.Get(rootGuid); if (null == rootDict) { continue; } var childs = dictionary.GetChilds(rootGuid); Newtonsoft.Json.Linq.JObject jObject = new Newtonsoft.Json.Linq.JObject { { "id", rootDict.Id }, { "parentID", rootDict.ParentId }, { "title", rootDict.Status == 1 ? "<span style='color:#999'>" + rootDict.Title + "[作废]</span>" : rootDict.Title }, { "type", childs.Count > 0 ? "0" : "2" }, { "ico", "fa-briefcase" }, { "hasChilds", childs.Count } }; Newtonsoft.Json.Linq.JArray jArray1 = new Newtonsoft.Json.Linq.JArray(); foreach (var child in childs) { Newtonsoft.Json.Linq.JObject jObject1 = new Newtonsoft.Json.Linq.JObject { { "id", child.Id }, { "parentID", rootDict.Id }, { "title", child.Status == 1 ? "<span style='color:#999'>" + child.Title + "[作废]</span>" : child.Title }, { "type", "2" }, { "ico", "" }, { "hasChilds", dictionary.HasChilds(child.Id) ? 1 : 0 }, { "childs", new Newtonsoft.Json.Linq.JArray() } }; jArray1.Add(jObject1); } if (!tempitem.IsNullOrWhiteSpace() && !tempitemid.IsNullOrWhiteSpace() && rid.Equals(rootIds[rootIds.Length - 1])) { Newtonsoft.Json.Linq.JObject tempObject = new Newtonsoft.Json.Linq.JObject { { "id", tempitemid }, { "parentID", rootDict.Id }, { "title", tempitem }, { "type", "2" }, { "ico", "" }, { "hasChilds", 0 }, { "childs", new Newtonsoft.Json.Linq.JArray() } }; jArray1.Add(tempObject); } jObject.Add("childs", jArray1); jArray.Add(jObject); } return(jArray.ToString()); }