123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224 |
- using LeaRun.Application.Busines.AuthorizeManage;
- using LeaRun.Application.Code;
- using LeaRun.Application.Entity.AuthorizeManage;
- using LeaRun.Util;
- using LeaRun.Util.WebControl;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web.Mvc;
- namespace LeaRun.Application.Web.Areas.AuthorizeManage.Controllers
- {
- /// <summary>
- /// 版 本 6.1
- /// Copyright (c) 2013-2016 上海力软信息技术有限公司
- /// 创建人:佘赐雄
- /// 日 期:2015.10.27 09:16
- /// 描 述:系统功能
- /// </summary>
- public class ModuleController : MvcControllerBase
- {
- private ModuleBLL moduleBLL = new ModuleBLL();
- #region 视图功能
- /// <summary>
- /// 功能管理
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- [HandlerAuthorize(PermissionMode.Enforce)]
- public ActionResult Index()
- {
- return View();
- }
- /// <summary>
- /// 功能表单
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- [HandlerAuthorize(PermissionMode.Enforce)]
- public ActionResult Form()
- {
- ViewBag.ModuleId = Request["keyValue"];
- return View();
- }
- /// <summary>
- /// 功能图标
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Icon()
- {
- return View();
- }
- #endregion
- #region 获取数据
- /// <summary>
- /// 功能列表
- /// </summary>
- /// <param name="keyword">关键字</param>
- /// <returns>返回树形Json</returns>
- [HttpGet]
- public ActionResult GetTreeJson(string keyword)
- {
- var data = moduleBLL.GetList();
- if (!string.IsNullOrEmpty(keyword))
- {
- data = data.TreeWhere(t => t.FullName.Contains(keyword), "");
- }
- var treeList = new List<TreeEntity>();
- foreach (ModuleEntity item in data)
- {
- TreeEntity tree = new TreeEntity();
- bool hasChildren = data.Count(t => t.ParentId == item.ModuleId) == 0 ? false : true;
- tree.id = item.ModuleId;
- tree.text = item.FullName;
- tree.value = item.ModuleId;
- tree.isexpand = true;
- tree.complete = true;
- tree.hasChildren = hasChildren;
- tree.parentId = item.ParentId;
- tree.img = item.Icon;
- treeList.Add(tree);
- }
- return Content(treeList.TreeToJson());
- }
- /// <summary>
- /// 获取目录级功能列表
- /// </summary>
- /// <param name="keyword">关键字</param>
- /// <returns>返回树形Json</returns>
- [HttpGet]
- public ActionResult GetCatalogTreeJson(string keyword)
- {
- var data = moduleBLL.GetList();
- data = data.FindAll(t => t.IsMenu != 1);
- if (!string.IsNullOrEmpty(keyword))
- {
- data = data.TreeWhere(t => t.FullName.Contains(keyword), "");
- }
- var treeList = new List<TreeEntity>();
- foreach (ModuleEntity item in data)
- {
- TreeEntity tree = new TreeEntity();
- bool hasChildren = data.Count(t => t.ParentId == item.ModuleId) == 0 ? false : true;
- tree.id = item.ModuleId;
- tree.text = item.FullName;
- tree.value = item.ModuleId;
- tree.isexpand = true;
- tree.complete = true;
- tree.hasChildren = hasChildren;
- tree.parentId = item.ParentId;
- tree.img = item.Icon;
- treeList.Add(tree);
- }
- return Content(treeList.TreeToJson());
- }
- /// <summary>
- /// 功能列表
- /// </summary>
- /// <param name="parentid">节点Id</param>
- /// <param name="condition">查询条件</param>
- /// <param name="keyword">关键字</param>
- /// <returns>返回列表Json</returns>
- [HttpGet]
- public ActionResult GetListJson(string parentid, string condition, string keyword)
- {
- var data = moduleBLL.GetList(parentid);
- if (!string.IsNullOrEmpty(condition) && !string.IsNullOrEmpty(keyword))
- {
- #region 多条件查询
- switch (condition)
- {
- case "EnCode": //编号
- data = data.FindAll(t => t.EnCode.Contains(keyword));
- break;
- case "FullName": //名称
- data = data.FindAll(t => t.FullName.Contains(keyword));
- break;
- case "UrlAddress": //地址
- data = data.FindAll(t => t.UrlAddress.Contains(keyword));
- break;
- default:
- break;
- }
- #endregion
- }
- return Content(data.ToJson());
- }
- /// <summary>
- /// 功能实体 返回对象Json
- /// </summary>
- /// <param name="keyValue">主键值</param>
- /// <returns></returns>
- [HttpGet]
- public ActionResult GetFormJson(string keyValue)
- {
- var data = moduleBLL.GetEntity(keyValue);
- return Content(data.ToJson());
- }
- #endregion
- #region 验证数据
- /// <summary>
- /// 功能编号不能重复
- /// </summary>
- /// <param name="EnCode">编号</param>
- /// <param name="keyValue">主键</param>
- /// <returns></returns>
- [HttpGet]
- public ActionResult ExistEnCode(string EnCode, string keyValue)
- {
- bool IsOk = moduleBLL.ExistEnCode(EnCode, keyValue);
- return Content(IsOk.ToString());
- }
- /// <summary>
- /// 功能名称不能重复
- /// </summary>
- /// <param name="FullName">名称</param>
- /// <param name="keyValue">主键</param>
- /// <returns></returns>
- [HttpGet]
- public ActionResult ExistFullName(string FullName, string keyValue)
- {
- bool IsOk = moduleBLL.ExistFullName(FullName, keyValue);
- return Content(IsOk.ToString());
- }
- #endregion
- #region 提交数据
- /// <summary>
- /// 删除功能
- /// </summary>
- /// <param name="keyValue">主键值</param>
- /// <returns></returns>
- [HttpPost]
- [ValidateAntiForgeryToken]
- [AjaxOnly]
- [HandlerAuthorize(PermissionMode.Enforce)]
- public ActionResult RemoveForm(string keyValue)
- {
- moduleBLL.RemoveForm(keyValue);
- return Success("删除成功。");
- }
- /// <summary>
- /// 保存功能表单
- /// </summary>
- /// <param name="keyValue">主键值</param>
- /// <param name="moduleEntity">功能实体</param>
- /// <param name="moduleButtonList">按钮实体列表</param>
- /// <param name="moduleColumnList">视图实体列表</param>
- /// <returns></returns>
- [HttpPost]
- [ValidateAntiForgeryToken]
- [AjaxOnly]
- public ActionResult SaveForm(string keyValue, ModuleEntity moduleEntity, string moduleButtonListJson, string moduleColumnListJson)
- {
- moduleBLL.SaveForm(keyValue, moduleEntity, moduleButtonListJson, moduleColumnListJson);
- return Success("保存成功。");
- }
- #endregion
- }
- }
|