ModuleButtonController.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. using Lottomat.Application.Busines.AuthorizeManage;
  2. using Lottomat.Application.Entity.AuthorizeManage;
  3. using Lottomat.Util;
  4. using Lottomat.Util.WebControl;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Web.Mvc;
  8. using Lottomat.Util.Extension;
  9. namespace Lottomat.Application.Admin.Areas.AuthorizeManage.Controllers
  10. {
  11. /// <summary>
  12. /// 版 本 1.0
  13. /// Copyright (c) 2016-2017
  14. /// 创建人:赵轶
  15. /// 日 期:2015.08.01 14:00
  16. /// 描 述:系统按钮
  17. /// </summary>
  18. public class ModuleButtonController : MvcControllerBase
  19. {
  20. private ModuleButtonBLL moduleButtonBLL = new ModuleButtonBLL();
  21. #region 视图功能
  22. /// <summary>
  23. /// 按钮表单
  24. /// </summary>
  25. /// <returns></returns>
  26. [HttpGet]
  27. public ActionResult Form()
  28. {
  29. return View();
  30. }
  31. /// <summary>
  32. /// 选择系统功能
  33. /// </summary>
  34. /// <returns></returns>
  35. [HttpGet]
  36. public ActionResult OptionModule()
  37. {
  38. return View();
  39. }
  40. #endregion
  41. #region 获取数据
  42. /// <summary>
  43. /// 按钮列表
  44. /// </summary>
  45. /// <returns>返回列表Json</returns>
  46. [HttpGet]
  47. public ActionResult GetListJson(string moduleId)
  48. {
  49. var data = moduleButtonBLL.GetList(moduleId);
  50. return Content(data.ToJson());
  51. }
  52. /// <summary>
  53. /// 按钮列表
  54. /// </summary>
  55. /// <returns>返回树形列表Json</returns>
  56. [HttpGet]
  57. public ActionResult GetTreeListJson(string moduleId)
  58. {
  59. var data = moduleButtonBLL.GetList(moduleId);
  60. if (data != null)
  61. {
  62. var TreeList = new List<TreeGridEntity>();
  63. foreach (ModuleButtonEntity item in data)
  64. {
  65. bool hasChildren = data.Count(t => t.ParentId == item.ModuleButtonId) != 0;
  66. TreeGridEntity tree = new TreeGridEntity
  67. {
  68. id = item.ModuleButtonId,
  69. parentId = item.ParentId,
  70. expanded = true,
  71. hasChildren = hasChildren,
  72. entityJson = item.ToJson()
  73. };
  74. TreeList.Add(tree);
  75. }
  76. return Content(TreeList.TreeJson());
  77. }
  78. return null;
  79. }
  80. #endregion
  81. #region 提交数据
  82. /// <summary>
  83. /// 按钮列表Json转换按钮树形Json
  84. /// </summary>
  85. /// <param name="moduleButtonJson">按钮列表</param>
  86. /// <returns>返回树形Json</returns>
  87. [HttpPost]
  88. public ActionResult ListToTreeJson(string moduleButtonJson)
  89. {
  90. var data = from items in moduleButtonJson.ToList<ModuleButtonEntity>() orderby items.SortCode select items;
  91. var treeList = new List<TreeEntity>();
  92. foreach (ModuleButtonEntity item in data)
  93. {
  94. TreeEntity tree = new TreeEntity();
  95. bool hasChildren = data.Count(t => t.ParentId == item.ModuleButtonId) != 0;
  96. tree.id = item.ModuleButtonId;
  97. tree.text = item.FullName;
  98. tree.value = item.ModuleId;
  99. tree.isexpand = true;
  100. tree.complete = true;
  101. tree.hasChildren = hasChildren;
  102. tree.parentId = item.ParentId;
  103. treeList.Add(tree);
  104. }
  105. return Content(treeList.TreeToJson());
  106. }
  107. /// <summary>
  108. /// 按钮列表Json转换按钮树形Json
  109. /// </summary>
  110. /// <param name="moduleButtonJson">按钮列表</param>
  111. /// <returns>返回树形列表Json</returns>
  112. [HttpPost]
  113. public ActionResult ListToListTreeJson(string moduleButtonJson)
  114. {
  115. var data = from items in moduleButtonJson.ToList<ModuleButtonEntity>() orderby items.SortCode select items;
  116. var TreeList = new List<TreeGridEntity>();
  117. foreach (ModuleButtonEntity item in data)
  118. {
  119. TreeGridEntity tree = new TreeGridEntity();
  120. bool hasChildren = data.Count(t => t.ParentId == item.ModuleButtonId) != 0;
  121. tree.id = item.ModuleButtonId;
  122. tree.parentId = item.ParentId;
  123. tree.expanded = true;
  124. tree.hasChildren = hasChildren;
  125. tree.entityJson = item.ToJson();
  126. TreeList.Add(tree);
  127. }
  128. return Content(TreeList.TreeJson());
  129. }
  130. /// <summary>
  131. /// 复制按钮
  132. /// </summary>
  133. /// <param name="keyValue">主键</param>
  134. /// <param name="moduleId">功能主键</param>
  135. /// <returns></returns>
  136. [HttpPost]
  137. public ActionResult CopyForm(string keyValue, string moduleId)
  138. {
  139. moduleButtonBLL.CopyForm(keyValue, moduleId);
  140. return Content(new AjaxResult<string> { type = ResultType.Success, message = "复制成功。" }.ToJson());
  141. }
  142. #endregion
  143. }
  144. }