using Core.Web.App_Start; using Core.Web.WebHelper; using CRM.Core.BLL.Base; using CRM.Core.Common.Layui; using CRM.Core.DTO; using CRM.Core.Model.Enum; using CRM.Core.Model.Map; using System; using System.Collections.Generic; using System.Web.Mvc; using WX.CRM.Common; namespace Core.Web.Controllers { public class PermissionController : BaseController { ValidationErrors errors = new ValidationErrors(); [AuthorizeRedirect(RightsConfig.CONST_菜单权限, ToolBarConfig.CONST_NotButton, true)] public ActionResult Index() { ViewBag.rightCode = RightsConfig.CONST_菜单权限; return View(); } BAS_PERMISSION_BL bl = new BAS_PERMISSION_BL(); [AuthorizeRedirect(RightsConfig.CONST_菜单权限, ToolBarConfig.CONST_NotButton, false)] public JsonResult GetList(Laypage pager) { var layUidata = new LayuiData(); try { List list = bl.Get_BasPerMissionList(); layUidata.msg = "数据加载成功"; layUidata.count = pager.count; layUidata.code = 0; layUidata.data = list; } catch (Exception ex) { LogHelper.Error(ex.ToString()); layUidata.SetFail(1, "出现错误!" + ex.Message); } return Json(layUidata, JsonRequestBehavior.AllowGet); } [AuthorizeRedirect(RightsConfig.CONST_菜单权限, ToolBarConfig.CONST_Edit, true)] public ActionResult Edit(int? id) { Bas_Permisson model = new Bas_Permisson(); if (id.HasValue) { model = new BAS_PERMISSION_BL().GetModel(id.Value); } else { model.ID = 0; model.CEID = 0; model.ISFORBIDDEN = 0; model.ISHAVECHILD = 0; model.ISHIDDEN = 0; } return View(model); } [AuthorizeRedirect(RightsConfig.CONST_菜单权限, ToolBarConfig.CONST_Edit, false)] [HttpPost] //[AuthorizeRedirect(RightsConfig.CONST_权限菜单管理, ToolBarConfig.CONST_Edit, false)] public JsonResult Save(Bas_Permisson model) { if (!ModelState.IsValid) return Json(new retMsg { result = false, retmsg = "验证不通过!" }, JsonRequestBehavior.AllowGet); if (model.buttonlist != null) { foreach (Bas_Permisson_Button item in model.buttonlist) { item.BUTTONID = (int)Enum.Parse(typeof(ButtonCode), item.CODE); } } if (model.ID != 0) { model.CEID = Eid; bool ret = bl.Update(ref errors, model); } else { bool ret = bl.Create(ref errors, model); } if (errors.Count > 0) { return Json(new retMsg { result = false, retmsg = errors.Error, retcode = 500 }, JsonRequestBehavior.AllowGet); } else { return Json(new retMsg { result = true, retcode = 400 }, JsonRequestBehavior.AllowGet); } } [HttpPost] //[AuthorizeRedirect(RightsConfig.CONST_权限菜单管理, ToolBarConfig.CONST_Delete, false)] [AuthorizeRedirect(RightsConfig.CONST_菜单权限, ToolBarConfig.CONST_Delete, false)] public JsonResult Delete(int id) { bool ret = bl.Delete(ref errors, id); if (errors.Count > 0) { return Json(new retMsg { result = false, retmsg = errors.Error, retcode = 500 }, JsonRequestBehavior.AllowGet); } else { return Json(new retMsg { result = true, retcode = 400 }, JsonRequestBehavior.AllowGet); } } [HttpPost] //[AuthorizeRedirect(RightsConfig.CONST_权限菜单管理, ToolBarConfig.CONST_Other1, false)] [AuthorizeRedirect(RightsConfig.CONST_菜单权限, ToolBarConfig.CONST_Other1, false)] public JsonResult Sort(int id1, int id2) { bool ret = bl.Sort(ref errors, id1, id2); if (errors.Count > 0) { return Json(new retMsg { result = false, retmsg = errors.Error, retcode = 500 }, JsonRequestBehavior.AllowGet); } else { return Json(new retMsg { result = true, retcode = 400 }, JsonRequestBehavior.AllowGet); } } } }