248 lines
9.1 KiB
C#
248 lines
9.1 KiB
C#
using Core.Web.WebHelper;
|
|
using CRM.Core.BLL.Base;
|
|
using CRM.Core.Model.Entity;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Web.Mvc;
|
|
using WX.CRM.Common;
|
|
|
|
namespace Core.Web.Controllers
|
|
{
|
|
public class MenuController : BaseController
|
|
{
|
|
ValidationErrors errors = new ValidationErrors();
|
|
private BAS_MODULEMENU_BL moduleMenuBiz = new BAS_MODULEMENU_BL();
|
|
private BAS_LEFTMEMU_BL leftMemuBiz = new BAS_LEFTMEMU_BL();
|
|
|
|
//[AuthorizeRedirect(Roles = InitRights.CONST_菜单管理)]
|
|
[HttpGet]
|
|
public ActionResult Index()
|
|
{
|
|
//ToolBar tool = new ToolBar();
|
|
//string[] toolbtn = new ToolButtonView().ToolButtonRight(InitRights.菜单管理, userRightId);
|
|
//List<string> listBtn = new List<string>(toolbtn);
|
|
//List<string> Buttons = new List<string>();
|
|
//Buttons.Add("Other6");
|
|
//Buttons.Add("Other7");
|
|
//Buttons.Add("Other5");
|
|
//Buttons.AddRange(listBtn);
|
|
//tool.AllowButton(Buttons.ToArray());
|
|
//// tool.AllowButton("Other4", "Other5", "Other6", "Other7", "Other3", "Other1", "Other2", "Edit", "Delete");
|
|
//tool.AddOtherButton("Other1", "新增模块菜单", "icon-add", "AddBas_ModuleMenu_Click", true);
|
|
//tool.AddOtherButton("Other2", "新增系统菜单", "icon-add", "AddBas_leftMemu_Click", true);
|
|
//tool.AddOtherButton("Other5", "刷新", "icon-reload", "Reload_Click", true);
|
|
//tool.AddOtherButton("Other6", "展开全部", "icon-flag", "ExpandAll_Click", true);
|
|
//tool.AddOtherButton("Other7", "折叠全部", "icon-show", "CollapseAll_Click", true);
|
|
//tool.AddOtherButton("Other3", "向上", "icon-up", "Up_Click", true);
|
|
//tool.AddOtherButton("Other4", "向下", "icon-down", "Down_Click", true);
|
|
|
|
//ViewBag.ToolBar = tool;
|
|
return View();
|
|
}
|
|
|
|
[HttpPost]
|
|
public JsonResult Index(string where)
|
|
{
|
|
//{
|
|
// "code":0,
|
|
// "msg":"操作成功",
|
|
// "data": [{
|
|
// "id":"001",
|
|
// "title": "湖南省",
|
|
// "isLast": true,
|
|
// "level": "1",
|
|
// "parentId": "0",
|
|
// "children":[]
|
|
// }]
|
|
//}
|
|
object leftMemuList = leftMemuBiz.GetTreeList_leftMenu();
|
|
|
|
return Json(new { status = new { code = 200, message = "操作成功" }, data = leftMemuList }, JsonRequestBehavior.AllowGet);
|
|
}
|
|
|
|
#region ModuleMenu编辑
|
|
[HttpGet]
|
|
//[AuthorizeToolBar(InitRights.CONST_菜单管理, InitToolBar.CONST_Edit)]
|
|
public ActionResult ModuleEdit(string id)
|
|
{
|
|
var model = new BAS_MODULEMENU();
|
|
|
|
if (id != null)
|
|
{
|
|
model = moduleMenuBiz.GetModel_ModuleMenu(Convert.ToDecimal(id));
|
|
if (model != null && model.RIGHTID != null)
|
|
model.RIGHTID = model.RIGHTID;
|
|
}
|
|
return View(model);
|
|
}
|
|
[HttpPost]
|
|
//[AuthorizeToolBar(InitRights.CONST_菜单管理, InitToolBar.CONST_Edit)]
|
|
public JsonResult ModuleEdit(BAS_MODULEMENU model)
|
|
{
|
|
if (!ModelState.IsValid)
|
|
return JsonHandler.ValidateFailMessage();
|
|
if (model.RIGHTID != null)
|
|
model.RIGHTID = model.RIGHTID;
|
|
if (model.MODULEMENUID == 0)
|
|
{
|
|
model.CTIME = DateTime.Now;
|
|
bool result = moduleMenuBiz.Create_ModuleMenu(ref errors, model);
|
|
return JsonHandler.InsertMessage(errors, result);
|
|
}
|
|
else
|
|
{
|
|
bool result = moduleMenuBiz.Update_ModuleMenu(ref errors, model);
|
|
return JsonHandler.UpdateMessage(errors, result);
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region ModuleMenu删除
|
|
//[AuthorizeToolBar(InitRights.CONST_菜单管理, InitToolBar.CONST_Delete)]
|
|
public JsonResult ModuleDelete(string id)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(id))
|
|
return JsonHandler.ManageMessage("参数不对", false);
|
|
bool result = moduleMenuBiz.Delete_ModuleMenu(ref errors, Convert.ToDecimal(id));
|
|
return JsonHandler.DeleteMessage(errors, result);
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region ModuleMenu修改顺序
|
|
/// <summary>
|
|
/// 修改顺序
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public JsonResult ModuleSaveSortId(string ids, string sortIds)
|
|
{
|
|
bool result = moduleMenuBiz.Sort_ModuleMenu(ref errors, ids, sortIds);
|
|
return JsonHandler.ManageMessage(errors, result);
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region LeftMenu编辑
|
|
[HttpGet]
|
|
//[AuthorizeToolBar(InitRights.CONST_菜单管理, InitToolBar.CONST_Other2)]
|
|
public ActionResult LeftMenuEdit(string id)
|
|
{
|
|
var model = new BAS_LEFTMEMU();
|
|
model.ISGROUP = 0;//设定默认
|
|
model.ISSHOW = 1;
|
|
if (Request.QueryString["fid"] != null)
|
|
model.PARENTID = Convert.ToDecimal(Request.QueryString["fid"]);
|
|
else
|
|
model.PARENTID = null;
|
|
if (id != null)
|
|
{
|
|
model = leftMemuBiz.GetModel_leftMenu(Convert.ToDecimal(id));
|
|
if (model.PARENTID == 0)
|
|
model.PARENTID = -model.MODULEMENUID;
|
|
if (model.PARENTID != null)
|
|
model.PARENTID = model.PARENTID;
|
|
}
|
|
return View(model);
|
|
}
|
|
[HttpPost]
|
|
//[AuthorizeToolBar(InitRights.CONST_菜单管理, InitToolBar.CONST_Other2)]
|
|
public JsonResult LeftMenuEdit(BAS_LEFTMEMU model)
|
|
{
|
|
if (!ModelState.IsValid)
|
|
{
|
|
return JsonHandler.ValidateFailMessage();
|
|
}
|
|
if (model.PARENTID < 0)
|
|
model.PARENTID = 0;
|
|
if (model.RIGHTID != null)
|
|
model.RIGHTID = model.RIGHTID;
|
|
if (model.MENUID == 0)
|
|
{
|
|
model.CTIME = DateTime.Now;
|
|
bool result = leftMemuBiz.Create_leftMemu(ref errors, model);
|
|
return JsonHandler.InsertMessage(errors, result);
|
|
}
|
|
else
|
|
{
|
|
bool result = leftMemuBiz.Update_leftMemu(ref errors, model);
|
|
return JsonHandler.UpdateMessage(errors, result);
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region LeftMenu删除
|
|
//[AuthorizeToolBar(InitRights.CONST_菜单管理, InitToolBar.CONST_Delete)]
|
|
public JsonResult LeftMenuDelete(string id)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(id))
|
|
{
|
|
return JsonHandler.ManageMessage("参数不对!", false);
|
|
}
|
|
bool result = leftMemuBiz.Delete_leftMemu(ref errors, Convert.ToDecimal(id));
|
|
return JsonHandler.DeleteMessage(errors, result);
|
|
}
|
|
#endregion
|
|
|
|
#region LeftMenu修改顺序
|
|
/// <summary>
|
|
/// 修改顺序
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
//[AuthorizeToolBar(InitRights.CONST_菜单管理, InitToolBar.CONST_Other3)]
|
|
public JsonResult LeftMenuSaveSortId(string ids, string sortIds)
|
|
{
|
|
bool result = leftMemuBiz.Sort_leftMemu(ref errors, ids, sortIds);
|
|
return JsonHandler.ManageMessage(errors, result);
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region 获取菜单的所有数据
|
|
/// <summary>
|
|
/// 获取菜单的所有数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public JsonResult GetMenuTreeJson()
|
|
{
|
|
object leftMemuList = leftMemuBiz.GetTreeList_leftMenu();
|
|
return Json(leftMemuList, JsonRequestBehavior.AllowGet);
|
|
}
|
|
/// <summary>
|
|
/// 获取菜单的所有数据 更新权限
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public JsonResult GetMenuTreeJsonByRight()
|
|
{
|
|
object leftMemuList = leftMemuBiz.GetTreeList_leftMenu(userRightId);
|
|
return Json(leftMemuList, JsonRequestBehavior.AllowGet);
|
|
}
|
|
#endregion
|
|
#region 获取模块图片
|
|
/// <summary>
|
|
/// 读取/Content/Menu 的所有模块图标
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public JsonResult GetMenuImg()
|
|
{
|
|
List<object> obj = new List<object>();
|
|
string[] imgExtension = new string[] { ".png", ".gif" };
|
|
string folder = Server.MapPath("~/Content/Images/Menu");
|
|
DirectoryInfo TheFolder = new DirectoryInfo(folder);
|
|
foreach (FileInfo info in TheFolder.GetFiles())
|
|
{
|
|
if (imgExtension.Contains(info.Extension))
|
|
{
|
|
obj.Add(new { name = info.Name, imgurl = "/Content/Images/Menu/" + info.Name });
|
|
}
|
|
}
|
|
return Json(obj, JsonRequestBehavior.AllowGet);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
} |