/// <summary> /// 获取列 /// </summary> /// <returns></returns> public string GetBtnColumn() { string menus = " [\n"; var sql = RMS_ButtonsSet.SelectAll(); List <RMS_Buttons> list = RDBiz.GetOwnList <RMS_Buttons>(sql); if (list != null) { menus += "{ "; menus += "title:\"名称\",field:\"Name\", width: 100"; menus += "},"; menus += "{ "; menus += "title:\"浏览\",field:\"ControlId_Browse\", width: 30,editor:{type:'checkbox',options:{on:'1',off:'0'}}, formatter: formatCheck"; menus += "},"; foreach (RMS_Buttons item in list) { menus += "{ "; menus += "title:\"" + item.ButtonName + "\",field:\"ControlId_" + item.Id + "\", width: 30,editor:{type:'checkbox',options:{on:'1',off:'0'}}, formatter: formatCheck"; menus += "},"; } } menus = menus.Substring(0, menus.Length - 1); menus = menus + "]"; return(menus); }
/// <summary> /// 获取某个角色的权限 数据不要乱改啊!! /// </summary> /// <param name="Id">角色的Id</param> /// <returns></returns> public string GetManeOP(string Id) { string menus = " [\n"; var sql = RMS_MenusSet.SelectAll(); string SysRoleId = ConfigurationManager.AppSettings["SysRoleId"].ToString(); if (!UserData.RoleId.ToString().Equals(SysRoleId))//不是系统管理员的角色,只能返回自己的菜单 { sql = RMS_MenusSet.SelectAll().Where(RMS_MenusSet.Id.In(RMS_RoleManusSet.Select(RMS_RoleManusSet.ManuId).Where(RMS_RoleManusSet.RoleId.Equal(UserData.RoleId)))); } List <RMS_Menus> list = RDBiz.GetOwnList <RMS_Menus>(sql); //所有的菜单集 List <RMS_Buttons> listControlButtons = RDBiz.GetOwnList <RMS_Buttons>(RMS_ButtonsSet.SelectAll()); //所有的按钮 List <RMS_RoleManus> listRoleColumns = RDBiz.GetOwnList <RMS_RoleManus>(RMS_RoleManusSet.SelectAll().Where(RMS_RoleManusSet.RoleId.Equal(Id))); //这个角色已经添加的菜单 List <V_RoleManuButtons> listRoleMenuButtons = RDBiz.GetOwnList <V_RoleManuButtons>(V_RoleManuButtonsSet.SelectAll().Where(V_RoleManuButtonsSet.RoleId.Equal(Id))); //这个角色已经添加的角色按钮 for (int i = 0; i < list.Count; i++) { if (list.Find(p => p.Id == list[i].ParentManuId) == null)//此项没有父级 { menus += "{ \"MenuId\":\"" + list[i].Id + "\","; menus += string.Format(" \"Name\":\"{0}\",", list[i].ManuName); menus += string.Format(" \"iconCls\":\"{0}\",", list[i].Icon); string ControlId_Browse = "0"; RMS_RoleManus rcItem = listRoleColumns.Find(p => p.ManuId.Equals(list[i].Id)); if (rcItem != null) { ControlId_Browse = "1";//如果存在 } menus += string.Format(" \"ControlId_Browse\":\"{0}\",", ControlId_Browse); foreach (RMS_Buttons dd in listControlButtons)//添加列的数据 { string Ishave = "0"; V_RoleManuButtons rmbItem = listRoleMenuButtons.Find(p => p.Id.Equals(dd.Id) && p.ManuId.Equals(list[i].Id)); if (rmbItem != null) { Ishave = "1";//如果角色有此按钮存在 } menus += string.Format("\"ControlId_{0}\":\"{1}\",", dd.Id, Ishave); } menus += GetSonTreeManu(list, list[i], listControlButtons, listRoleColumns, listRoleMenuButtons);//添加children menus += "},"; } } menus = menus.Substring(0, menus.Length - 1); menus = menus + "]"; return(menus); }
/// <summary> /// 获取每个菜单有的按钮 /// </summary> /// <returns></returns> public JsonResult GetMenuButtonsData() { List <RMS_MenuButtons> listMenuButtons = RDBiz.GetOwnList <RMS_MenuButtons>(RMS_MenuButtonsSet.SelectAll());//所有的菜单的按钮 return(Json(listMenuButtons)); }