/// <summary> /// 查询分页 /// </summary> /// <returns></returns> public ActionResult GetList() { int pageIndex = WebUtil.GetFormValue <int>("pageIndex", 1); int pageSize = WebUtil.GetFormValue <int>("pageSize", 15); string ResNum = WebUtil.GetFormValue <string>("ResNum", string.Empty); string ResName = WebUtil.GetFormValue <string>("ResName", string.Empty); string Url = WebUtil.GetFormValue <string>("Url", string.Empty); string CompanyID = WebUtil.GetFormValue <string>("CompanyID", string.Empty); PageInfo pageInfo = new PageInfo() { PageIndex = pageIndex, PageSize = pageSize }; SysResourceProvider provider = new SysResourceProvider(CompanyID); SysResourceEntity entity = new SysResourceEntity(); entity.ResNum = ResNum; entity.ResName = ResName; entity.Url = Url; List <SysResourceEntity> listResult = provider.GetList(entity, ref pageInfo); DataListResult <SysResourceEntity> result = new DataListResult <SysResourceEntity>() { Code = (int)EResponseCode.Success, PageInfo = pageInfo, Result = listResult, Message = "响应成功" }; return(Content(JsonHelper.SerializeObject(result))); }
/// <summary> /// 获得父类菜单 /// </summary> /// <param name="parentNum"></param> /// <returns></returns> public static string GetParentMenu(string parentNum) { SysResourceProvider sysRes = new SysResourceProvider(); List <SysResourceEntity> list = sysRes.GetList(); StringBuilder sb = new StringBuilder(); string menuTemplate = "<option value='{0}' {1}>{2}</option>"; sb.AppendFormat(menuTemplate, "", "", "请选择"); if (!list.IsNullOrEmpty()) { foreach (SysResourceEntity entity in list.Where(a => a.ResType == (short)EResourceType.Page)) { sb.AppendFormat(menuTemplate, entity.ResNum, entity.ResNum == parentNum ? "selected='selected'" : string.Empty, entity.ResName); } } return(sb.ToString()); }
public ActionResult GetMenuList(int pageIndex, int pageSize, string resName, string parentNum) { SysResourceProvider provider = new SysResourceProvider(); List <SysResourceEntity> list = provider.GetList(); if (!list.IsNullOrEmpty()) { List <SysResourceEntity> listResult = list; if (!resName.IsEmpty()) { listResult = listResult.Where(a => a.ResName.Contains(resName)).ToList(); } if (!parentNum.IsEmpty()) { listResult = listResult.Where(a => a.ParentNum.Contains(parentNum)).ToList(); } List <SysResourceEntity> returnList = listResult.Skip((pageIndex - 1) * pageSize).Take(pageSize).OrderByDescending(a => a.ID).ToList(); this.ReturnJson.AddProperty("Data", ConvertJson.ListToJson <SysResourceEntity>(returnList, "List")); this.ReturnJson.AddProperty("RowCount", listResult.Count); } return(Content(this.ReturnJson.ToString())); }
/// <summary> /// 设置导航信息 /// </summary> private void SetNav() { StringBuilder sb = new StringBuilder(); sb.Append("<ul class=\"breadcrumb\">"); sb.Append("<li>"); sb.Append("<i class=\"icon-home\"></i>"); sb.Append("<a href=\"/Home/Welcome\">首页</a>"); sb.Append("<i class=\"icon-angle-right\"></i>"); sb.Append("</li>"); if (IsLogin() && !this.LoginUser.RoleNum.IsEmpty()) { PowerProvider provider = new PowerProvider(); SysResourceProvider SysResourceProvider = new SysResourceProvider(); List <SysResourceEntity> listSource = SysResourceProvider.GetList(); List <SysResourceEntity> list = provider.GetRoleResource(this.LoginUser.RoleNum); if (!list.IsNullOrEmpty()) { SysResourceEntity item = list.SingleOrDefault(a => a.Url.ToLower() == this.Path.ToLower()); List <SysResourceEntity> listResult = new List <SysResourceEntity>(); while (item != null) { listResult.Insert(0, item); if (item.ParentNum.IsEmpty()) { break; } else { if (listSource.Exists(a => a.ResNum == item.ParentNum)) { item = listSource.First(a => a.ResNum == item.ParentNum); } else { break; } } } for (int i = 0; i < listResult.Count; i++) { if (i != listResult.Count - 1) { sb.Append("<li>"); sb.AppendFormat("<a href=\"{0}\">{1}</a>", listResult[i].Url.IsEmpty() ? "javascript:void(0)" : listResult[i].Url, listResult[i].ResName); sb.Append("<i class=\"icon-angle-right\"></i>"); sb.Append("</li>"); } else { sb.Append("<li>"); sb.AppendFormat("<a href=\"javascript:void(0)\">{0}</a>", listResult[i].ResName); sb.Append("</li>"); } } } } sb.Append("</ul>"); ViewBag.NavMenu = sb.ToString(); }