using Core.Web.WebHelper; using Core.Web.WebHelper.UserRight; using CRM.Core.BLL.Base; using CRM.Core.Model.Entity; using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using WX.CRM.Common; namespace Core.Web.Controllers { public class RightGroupController : BaseController { private BAS_RIGHTGROUP_BL rightGroupBiz = new BAS_RIGHTGROUP_BL(); ValidationErrors errors = new ValidationErrors(); public RightGroupController() { } #region 首页 //[AuthorizeRedirect(Roles = InitRights.CONST_权限结构管理)] public ActionResult Index() { //ToolBar ToolBar tool = new ToolBar(); string[] toolbtn = new ToolButtonView().ToolButtonRight(InitRights.权限结构管理, userRightId); List listBtn = new List(toolbtn); List Buttons = new List(); Buttons.Add("Other1"); Buttons.Add("Other2"); Buttons.Add("Other5"); Buttons.AddRange(listBtn); //tool.AllowButton(Buttons.ToArray()); //// tool.AllowButton("Other1", "Other2", "Other5", "Other3", "Other4", "Edit", "Details", "Delete"); //tool.AddOtherButton("Other1", "展开全部", "icon-flag", "ExpandAll_Click", true); //tool.AddOtherButton("Other2", "折叠全部", "icon-show", "CollapseAll_Click", true); //tool.AddOtherButton("Other3", "新增组", "icon-add", "CreateGroup_Click", true); //tool.AddOtherButton("Other4", "新增资源", "icon-add", "CreateRight_Click", true); //tool.AddOtherButton("Other5", "重新加载", "icon-reload", "Reload_Click", true); //tool.AddOtherButton("Other6", "更新权限", "icon-reload", "RightLoad_Click", true); //ViewBag.ToolBar = tool; return View(); } #endregion #region 树形数据 /// /// 获取顶端数据 /// /// //[AuthorizeRedirect(Roles = InitRights.CONST_权限结构管理)] public JsonResult GetTopGroupTree() { return Json(rightGroupBiz.GetTopTreeList(), JsonRequestBehavior.AllowGet); } /// /// 获取子数据 /// /// /// //[AuthorizeRedirect(Roles = InitRights.CONST_权限结构管理)] public JsonResult GetGroupTree(string id) { decimal fid = 0; if (!string.IsNullOrWhiteSpace(id)) decimal.TryParse(id, out fid); return Json(rightGroupBiz.GetNodeTreeList(fid), JsonRequestBehavior.AllowGet); } /// /// 获取所有的权限组结构(不包括right) /// /// public JsonResult GetAllGroupTree() { return Json(rightGroupBiz.GetAllTreeList(), JsonRequestBehavior.AllowGet); } /// /// 获取所有的权限组结构(包括了right) /// /// public JsonResult GetRightTreeList(bool isSelect = false) { return Json(rightGroupBiz.GetRightTreeList(isSelect), JsonRequestBehavior.AllowGet); } #endregion #region 初始化 public JsonResult Init() { bool result = new InitRightsToData().Insert(ref errors); return JsonHandler.InsertMessage(errors, result); } #endregion #region 编辑 [HttpGet] //[AuthorizeToolBar(InitRights.CONST_权限结构管理, InitToolBar.CONST_Edit)] public ActionResult Edit(string id) { var model = new BAS_RIGHTGROUP(); if (id != null) model = rightGroupBiz.GetModel(Convert.ToDecimal(id)); string fid = Request.QueryString["fid"]; model.PARENTID = Convert.ToDecimal((model.PKID == 0 ? fid : model.PARENTID.ToString())); return View(model); } [HttpPost] //[AuthorizeToolBar(InitRights.CONST_权限结构管理, InitToolBar.CONST_Edit)] public JsonResult Edit(BAS_RIGHTGROUP model) { if (!ModelState.IsValid) return JsonHandler.ValidateFailMessage(); if (model.PKID == 0) { model.CTIME = DateTime.Now; bool result = rightGroupBiz.Create(ref errors, model); return JsonHandler.InsertMessage(errors, result); } else { bool result = rightGroupBiz.Update(ref errors, model); return JsonHandler.UpdateMessage(errors, result); } } #endregion #region 删除 //[AuthorizeToolBar(InitRights.CONST_权限结构管理, InitToolBar.CONST_Delete)] public JsonResult Delete(string id) { if (string.IsNullOrWhiteSpace(id)) { return JsonHandler.ManageMessage("删除失败", false); } bool result = rightGroupBiz.Delete(ref errors, Convert.ToDecimal(id)); return JsonHandler.DeleteMessage(errors, result); } #endregion } }