using System.Collections.Generic; using System.Web.Mvc; using WX.CRM.Common; using WX.CRM.IBLL.Base; using WX.CRM.WebHelper; namespace WX.CRM.WEB.Controllers.Base { public class InnerUserRoleController : BaseController { ValidationErrors errors = new ValidationErrors(); IBAS_INNERUSERROLE innerUserRoleBiz; IBAS_INNERUSERROLE_Q innerUserRoleBiz_Q; public InnerUserRoleController(IBAS_INNERUSERROLE _innerUserRoleBiz, IBAS_INNERUSERROLE_Q _innerUserRoleBiz_Q) { this.innerUserRoleBiz = _innerUserRoleBiz; this.innerUserRoleBiz_Q = _innerUserRoleBiz_Q; } #region 首页 [AuthorizeRedirect(Roles = InitRights.CONST_员工角色管理)] public ActionResult Index() { //ToolBar ToolBar tool = new ToolBar(); string[] toolbtn = new ToolButtonView().ToolButtonRight(InitRights.员工角色管理, userRightId); tool.AllowButton(toolbtn); // tool.AllowButton("Other1"); tool.AddOtherButton("Other1", "分配角色", "icon-lookup", "SettingRole_Click", true); ViewBag.ToolBar = tool; Pager pager = new Pager() { order = "companyId", page = 1, rows = 10 }; string tableId = "List"; Table tab = new Table(tableId); tab.isCheckbox = true; tab.AddHiddenHeadCol("pkid", "员工ID"); tab.AddHiddenHeadCol("roleIds", "角色ID"); tab.AddHeadCol("eID", "10%", "工号"); tab.AddHeadCol("uName", "10%", "名称"); tab.AddHeadCol("roleNames", "", "角色 "); tab.AddHeadRow(); ViewBag.gridTable = tab.GetHead() + Pagination.GetPage(pager, tableId, "5,8,10,15"); return View(); } #endregion #region 列表 /// /// 按照条件获取数据 /// /// 分页信息 /// [AuthorizeRedirect(Roles = InitRights.CONST_员工角色管理)] public JsonResult GetHtmlList(Pager pager, string columns) { string roleId = Request.Form["roleId"]; string uName = Request.Form["uName"]; string eId = Request.Form["eId"]; List list = innerUserRoleBiz_Q.GetList(ref pager, eId, uName, roleId); Table table = new Table(columns, true); table.gridPager = pager; table.isCheckbox = true; foreach (WX.CRM.Model.Entity.BAS_INNERUSERROLE_Extend model in list) { table.AddHiddenCol(model.PKID); table.AddHiddenCol(model.ROLEIDS); table.AddCol(model.EID); table.AddCol(model.UNAME); table.AddCol("text-align:left", "", "   " + model.ROLESNAMES); table.AddRow(); } var json = new { totalPages = pager.totalPages, totalRows = pager.totalRows, rowsList = table.GetRows() }; return Json(json, JsonRequestBehavior.AllowGet); } #endregion #region 角色分配 [AuthorizeToolBar(InitRights.CONST_员工角色管理, InitToolBar.CONST_Other1)] public ActionResult SettingInnerUserRole() { ViewBag.isAdmin = Eid == 10000 ? "1" : "0"; return View(); } /// /// 保存权限分配 /// /// /// /// [AuthorizeToolBar(InitRights.CONST_员工角色管理, InitToolBar.CONST_Other1)] public JsonResult Save(string roleIds, string pkids) { if (string.IsNullOrWhiteSpace(pkids)) return JsonHandler.ManageMessage("请选中员工!", false); bool result = innerUserRoleBiz.Save(ref errors, 0, roleIds, pkids); return JsonHandler.ManageMessage(errors, result); } #endregion } }