You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

304 lines
9.6 KiB

  1. using Learun.Application.Base.SystemModule;
  2. using Learun.Util;
  3. using System.Collections.Generic;
  4. using System.Web.Mvc;
  5. namespace Learun.Application.Web.Areas.LR_SystemModule.Controllers
  6. {
  7. /// <summary>
  8. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  9. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  10. /// 创建人:陈彬彬
  11. /// 日 期:2017.03.09
  12. /// 描 述:功能模块控制器
  13. /// </summary>
  14. public class ModuleController : MvcControllerBase
  15. {
  16. #region 模块对象
  17. private ModuleIBLL moduleIBLL = new ModuleBLL();
  18. #endregion
  19. #region 视图
  20. /// <summary>
  21. /// 功能模块管理视图
  22. /// </summary>
  23. /// <returns></returns>
  24. [HttpGet]
  25. public ActionResult Index()
  26. {
  27. return View();
  28. }
  29. /// <summary>
  30. /// 表单页面
  31. /// </summary>
  32. /// <returns></returns>
  33. [HttpGet]
  34. public ActionResult Form() {
  35. return View();
  36. }
  37. #endregion
  38. #region 功能模块
  39. /// <summary>
  40. /// 获取功能模块数据列表
  41. /// </summary>
  42. /// <returns></returns>
  43. [HttpGet]
  44. [AjaxOnly]
  45. public ActionResult GetModuleList()
  46. {
  47. var data = moduleIBLL.GetModuleList();
  48. return this.JsonResult(data);
  49. }
  50. /// <summary>
  51. /// 获取树形数据
  52. /// </summary>
  53. /// <returns></returns>
  54. [HttpGet]
  55. [AjaxOnly]
  56. public ActionResult GetModuleTree()
  57. {
  58. var data = moduleIBLL.GetModuleTree();
  59. return this.JsonResult(data);
  60. }
  61. /// <summary>
  62. /// 获取树形数据(带勾选框)
  63. /// </summary>
  64. /// <returns></returns>
  65. [HttpGet]
  66. [AjaxOnly]
  67. public ActionResult GetModuleCheckTree()
  68. {
  69. var data = moduleIBLL.GetModuleCheckTree();
  70. return this.JsonResult(data);
  71. }
  72. /// <summary>
  73. /// 获取功能列表的树形数据(只有展开项)
  74. /// </summary>
  75. /// <returns></returns>
  76. [HttpGet]
  77. [AjaxOnly]
  78. public ActionResult GetExpendModuleTree()
  79. {
  80. var data = moduleIBLL.GetExpendModuleTree();
  81. return this.JsonResult(data);
  82. }
  83. /// <summary>
  84. /// 获取列表数据根据父级id
  85. /// </summary>
  86. /// <param name="parentId">父级id</param>
  87. /// <param name="type">功能类型</param>
  88. /// <returns></returns>
  89. [HttpGet]
  90. [AjaxOnly]
  91. public ActionResult GetModuleListByParentId(string keyword, string parentId)
  92. {
  93. var jsondata = moduleIBLL.GetModuleListByParentId(keyword, parentId);
  94. return this.JsonResult(jsondata);
  95. }
  96. /// <summary>
  97. /// 获取树形数据(带勾选框)
  98. /// </summary>
  99. /// <returns></returns>
  100. [HttpGet]
  101. [AjaxOnly]
  102. public ActionResult GetCheckTree()
  103. {
  104. var moduleList = moduleIBLL.GetModuleCheckTree();
  105. var buttonList = moduleIBLL.GetButtonCheckTree();
  106. var columnList = moduleIBLL.GetColumnCheckTree();
  107. //var formList = moduleIBLL.GetFormCheckTree();
  108. var jsonData = new
  109. {
  110. moduleList,
  111. buttonList,
  112. columnList
  113. //formList
  114. };
  115. return this.JsonResult(jsonData);
  116. }
  117. #endregion
  118. #region 模块按钮
  119. /// <summary>
  120. /// 获取功能模块按钮数据列表
  121. /// </summary>
  122. /// <param name="moduleId">模块主键</param>
  123. /// <returns></returns>
  124. [HttpGet]
  125. [AjaxOnly]
  126. public ActionResult GetButtonListNoAuthorize(string moduleId)
  127. {
  128. var data = moduleIBLL.GetButtonListNoAuthorize(moduleId);
  129. return this.JsonResult(data);
  130. }
  131. /// <summary>
  132. /// 获取功能模块按钮数据列表
  133. /// </summary>
  134. /// <param name="moduleId">模块主键</param>
  135. /// <returns></returns>
  136. [HttpGet]
  137. [AjaxOnly]
  138. public ActionResult GetButtonList(string moduleId)
  139. {
  140. var data = moduleIBLL.GetButtonList(moduleId);
  141. return this.JsonResult(data);
  142. }
  143. /// <summary>
  144. /// 获取树形数据(带勾选框)
  145. /// </summary>
  146. /// <returns></returns>
  147. [HttpGet]
  148. [AjaxOnly]
  149. public ActionResult GetButtonCheckTree()
  150. {
  151. var data = moduleIBLL.GetButtonCheckTree();
  152. return this.JsonResult(data);
  153. }
  154. #endregion
  155. #region 模块视图
  156. /// <summary>
  157. /// 获取功能模块视图数据列表
  158. /// </summary>
  159. /// <param name="moduleId">模块主键</param>
  160. /// <returns></returns>
  161. [HttpGet]
  162. [AjaxOnly]
  163. public ActionResult GetColumnList(string moduleId)
  164. {
  165. var data = moduleIBLL.GetColumnList(moduleId);
  166. return this.JsonResult(data);
  167. }
  168. /// <summary>
  169. /// 获取树形数据(带勾选框)
  170. /// </summary>
  171. /// <returns></returns>
  172. [HttpGet]
  173. [AjaxOnly]
  174. public ActionResult GetColumnCheckTree()
  175. {
  176. var data = moduleIBLL.GetColumnCheckTree();
  177. return this.JsonResult(data);
  178. }
  179. #endregion
  180. #region 获取数据
  181. /// <summary>
  182. /// 获取表单数据
  183. /// </summary>
  184. /// <param name="keyValue">主键</param>
  185. /// <returns></returns>
  186. [HttpGet]
  187. [AjaxOnly]
  188. public ActionResult GetFormData(string keyValue)
  189. {
  190. var module = moduleIBLL.GetModuleEntity(keyValue);
  191. var btns = moduleIBLL.GetButtonList(keyValue);
  192. var cols = moduleIBLL.GetColumnList(keyValue);
  193. var fields = moduleIBLL.GetFormList(keyValue);
  194. var jsondata = new
  195. {
  196. moduleEntity = module,
  197. moduleButtons = btns,
  198. moduleColumns = cols,
  199. moduleFields = fields
  200. };
  201. return this.JsonResult(jsondata);
  202. }
  203. #endregion
  204. #region 提交数据
  205. /// <summary>
  206. /// 保存功能表单
  207. /// </summary>
  208. /// <param name="keyValue">主键值</param>
  209. /// <param name="moduleEntity">功能实体</param>
  210. /// <param name="moduleButtonListJson">按钮实体列表</param>
  211. /// <param name="moduleColumnListJson">视图实体列表</param>
  212. /// <param name="moduleFormListJson">表单字段列表</param>
  213. /// <returns></returns>
  214. [HttpPost]
  215. [ValidateAntiForgeryToken]
  216. [AjaxOnly]
  217. public ActionResult SaveForm(string keyValue, string moduleEntityJson, string moduleButtonListJson, string moduleColumnListJson,string moduleFormListJson)
  218. {
  219. var moduleButtonList = moduleButtonListJson.ToList<ModuleButtonEntity>();
  220. var moduleColumnList = moduleColumnListJson.ToList<ModuleColumnEntity>();
  221. var moduleFormList = moduleFormListJson.ToList<ModuleFormEntity>();
  222. var moduleEntity = moduleEntityJson.ToObject<ModuleEntity>();
  223. moduleIBLL.SaveEntity(keyValue, moduleEntity, moduleButtonList, moduleColumnList, moduleFormList);
  224. return Success("保存成功。");
  225. }
  226. /// <summary>
  227. /// 删除表单数据
  228. /// </summary>
  229. /// <param name="keyValue">主键</param>
  230. /// <returns></returns>
  231. [HttpPost]
  232. [AjaxOnly]
  233. public ActionResult DeleteForm(string keyValue)
  234. {
  235. bool res = moduleIBLL.Delete(keyValue);
  236. if (res)
  237. {
  238. return Success("删除成功。");
  239. }
  240. else
  241. {
  242. return Fail("有子节点无法删除。");
  243. }
  244. }
  245. #endregion
  246. #region 权限数据
  247. /// <summary>
  248. /// 获取权限按钮和列表信息
  249. /// </summary>
  250. /// <param name="url">页面地址</param>
  251. /// <returns></returns>
  252. [HttpGet]
  253. [AjaxOnly]
  254. public ActionResult GetAuthorizeButtonColumnList(string url)
  255. {
  256. Dictionary<string, string> dicButton = new Dictionary<string, string>();
  257. Dictionary<string, string> dicColumn = new Dictionary<string, string>();
  258. ModuleEntity moduleEntity = moduleIBLL.GetModuleByUrl(url);
  259. if (moduleEntity != null)
  260. {
  261. List<ModuleButtonEntity> buttonList = moduleIBLL.GetButtonList(moduleEntity.F_ModuleId);
  262. foreach (var item in buttonList)
  263. {
  264. if (!dicButton.ContainsKey(item.F_EnCode))
  265. {
  266. dicButton.Add(item.F_EnCode, item.F_FullName);
  267. }
  268. }
  269. List<ModuleColumnEntity> columnList = moduleIBLL.GetColumnList(moduleEntity.F_ModuleId);
  270. foreach (var item in columnList)
  271. {
  272. if (!dicColumn.ContainsKey(item.F_EnCode))
  273. {
  274. dicColumn.Add(item.F_EnCode.ToLower(), item.F_FullName);
  275. }
  276. }
  277. }
  278. var jsonData = new
  279. {
  280. module = moduleEntity,
  281. btns = dicButton,
  282. cols = dicColumn
  283. };
  284. return this.JsonResult(jsonData);
  285. }
  286. #endregion
  287. }
  288. }