/// <summary> /// 获取权限树 /// </summary> /// <returns></returns> protected string GetRightTree() { List <Right> rights = new URBasicInfoService().GetRights(SelectedSysID); List <RightItem> selectedRights = UserID > 0 ? new URRightsService().GetUserRights(SelectedSysID, UserID) : new URRightsService().GetRoleRights(RoleID); StringBuilder jsonBuilder = new StringBuilder("["); for (int i = 0; i < rights.Count(); i++) { Right right = rights.ElementAt(i); jsonBuilder.AppendFormat("{{\"id\":\"{0}\",\"pId\":\"{1}\",\"name\":\"{2}\",\"open\":{3}", right.ID, right.ParentID, right.Name, "true"); RightItem rr = selectedRights.FirstOrDefault(r => r.RightID == right.ID); if (rr != null) { jsonBuilder.Append(",\"checked\":true"); if (rr.FromRole) { jsonBuilder.Append(",\"disabled\":true"); } } jsonBuilder.Append("},"); } return(jsonBuilder.ToString().TrimEnd(',') + "]"); }