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.
 
 
 
 
 
 

356 lines
11 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. /// <summary>
  118. /// 获取树形数据(带勾选框)--系统模块
  119. /// </summary>
  120. /// <returns></returns>
  121. [HttpGet]
  122. [AjaxOnly]
  123. public ActionResult GetCheckTreeForModuleList()
  124. {
  125. var moduleList = moduleIBLL.GetModuleCheckTree();
  126. var jsonData = new
  127. {
  128. moduleList,
  129. };
  130. return this.JsonResult(jsonData);
  131. }
  132. /// <summary>
  133. /// 获取树形数据(带勾选框)--系统按钮
  134. /// </summary>
  135. /// <returns></returns>
  136. [HttpGet]
  137. [AjaxOnly]
  138. public ActionResult GetCheckTreeForButtonList()
  139. {
  140. var buttonList = moduleIBLL.GetButtonCheckTree();
  141. var jsonData = new
  142. {
  143. buttonList,
  144. };
  145. return this.JsonResult(jsonData);
  146. }
  147. /// <summary>
  148. /// 获取树形数据(带勾选框)--系统视图
  149. /// </summary>
  150. /// <returns></returns>
  151. [HttpGet]
  152. [AjaxOnly]
  153. public ActionResult GetCheckTreeForColumnList()
  154. {
  155. var columnList = moduleIBLL.GetColumnCheckTree();
  156. var jsonData = new
  157. {
  158. columnList
  159. //formList
  160. };
  161. return this.JsonResult(jsonData);
  162. }
  163. #endregion
  164. #region 模块按钮
  165. /// <summary>
  166. /// 获取功能模块按钮数据列表
  167. /// </summary>
  168. /// <param name="moduleId">模块主键</param>
  169. /// <returns></returns>
  170. [HttpGet]
  171. [AjaxOnly]
  172. public ActionResult GetButtonListNoAuthorize(string moduleId)
  173. {
  174. var data = moduleIBLL.GetButtonListNoAuthorize(moduleId);
  175. return this.JsonResult(data);
  176. }
  177. /// <summary>
  178. /// 获取功能模块按钮数据列表
  179. /// </summary>
  180. /// <param name="moduleId">模块主键</param>
  181. /// <returns></returns>
  182. [HttpGet]
  183. [AjaxOnly]
  184. public ActionResult GetButtonList(string moduleId)
  185. {
  186. var data = moduleIBLL.GetButtonList(moduleId);
  187. return this.JsonResult(data);
  188. }
  189. /// <summary>
  190. /// 获取树形数据(带勾选框)
  191. /// </summary>
  192. /// <returns></returns>
  193. [HttpGet]
  194. [AjaxOnly]
  195. public ActionResult GetButtonCheckTree()
  196. {
  197. var data = moduleIBLL.GetButtonCheckTree();
  198. return this.JsonResult(data);
  199. }
  200. #endregion
  201. #region 模块视图
  202. /// <summary>
  203. /// 获取功能模块视图数据列表
  204. /// </summary>
  205. /// <param name="moduleId">模块主键</param>
  206. /// <returns></returns>
  207. [HttpGet]
  208. [AjaxOnly]
  209. public ActionResult GetColumnList(string moduleId)
  210. {
  211. var data = moduleIBLL.GetColumnList(moduleId);
  212. return this.JsonResult(data);
  213. }
  214. /// <summary>
  215. /// 获取树形数据(带勾选框)
  216. /// </summary>
  217. /// <returns></returns>
  218. [HttpGet]
  219. [AjaxOnly]
  220. public ActionResult GetColumnCheckTree()
  221. {
  222. var data = moduleIBLL.GetColumnCheckTree();
  223. return this.JsonResult(data);
  224. }
  225. #endregion
  226. #region 获取数据
  227. /// <summary>
  228. /// 获取表单数据
  229. /// </summary>
  230. /// <param name="keyValue">主键</param>
  231. /// <returns></returns>
  232. [HttpGet]
  233. [AjaxOnly]
  234. public ActionResult GetFormData(string keyValue)
  235. {
  236. var module = moduleIBLL.GetModuleEntity(keyValue);
  237. var btns = moduleIBLL.GetButtonList(keyValue);
  238. var cols = moduleIBLL.GetColumnList(keyValue);
  239. var fields = moduleIBLL.GetFormList(keyValue);
  240. var jsondata = new
  241. {
  242. moduleEntity = module,
  243. moduleButtons = btns,
  244. moduleColumns = cols,
  245. moduleFields = fields
  246. };
  247. return this.JsonResult(jsondata);
  248. }
  249. #endregion
  250. #region 提交数据
  251. /// <summary>
  252. /// 保存功能表单
  253. /// </summary>
  254. /// <param name="keyValue">主键值</param>
  255. /// <param name="moduleEntity">功能实体</param>
  256. /// <param name="moduleButtonListJson">按钮实体列表</param>
  257. /// <param name="moduleColumnListJson">视图实体列表</param>
  258. /// <param name="moduleFormListJson">表单字段列表</param>
  259. /// <returns></returns>
  260. [HttpPost]
  261. [ValidateAntiForgeryToken]
  262. [AjaxOnly]
  263. public ActionResult SaveForm(string keyValue, string moduleEntityJson, string moduleButtonListJson, string moduleColumnListJson,string moduleFormListJson)
  264. {
  265. var moduleButtonList = moduleButtonListJson.ToList<ModuleButtonEntity>();
  266. var moduleColumnList = moduleColumnListJson.ToList<ModuleColumnEntity>();
  267. var moduleFormList = moduleFormListJson.ToList<ModuleFormEntity>();
  268. var moduleEntity = moduleEntityJson.ToObject<ModuleEntity>();
  269. moduleIBLL.SaveEntity(keyValue, moduleEntity, moduleButtonList, moduleColumnList, moduleFormList);
  270. return Success("保存成功。");
  271. }
  272. /// <summary>
  273. /// 删除表单数据
  274. /// </summary>
  275. /// <param name="keyValue">主键</param>
  276. /// <returns></returns>
  277. [HttpPost]
  278. [AjaxOnly]
  279. public ActionResult DeleteForm(string keyValue)
  280. {
  281. bool res = moduleIBLL.Delete(keyValue);
  282. if (res)
  283. {
  284. return Success("删除成功。");
  285. }
  286. else
  287. {
  288. return Fail("有子节点无法删除。");
  289. }
  290. }
  291. #endregion
  292. #region 权限数据
  293. /// <summary>
  294. /// 获取权限按钮和列表信息
  295. /// </summary>
  296. /// <param name="url">页面地址</param>
  297. /// <returns></returns>
  298. [HttpGet]
  299. [AjaxOnly]
  300. public ActionResult GetAuthorizeButtonColumnList(string url)
  301. {
  302. Dictionary<string, string> dicButton = new Dictionary<string, string>();
  303. Dictionary<string, string> dicColumn = new Dictionary<string, string>();
  304. ModuleEntity moduleEntity = moduleIBLL.GetModuleByUrl(url);
  305. if (moduleEntity != null)
  306. {
  307. List<ModuleButtonEntity> buttonList = moduleIBLL.GetButtonList(moduleEntity.F_ModuleId);
  308. foreach (var item in buttonList)
  309. {
  310. if (!dicButton.ContainsKey(item.F_EnCode))
  311. {
  312. dicButton.Add(item.F_EnCode, item.F_FullName);
  313. }
  314. }
  315. List<ModuleColumnEntity> columnList = moduleIBLL.GetColumnList(moduleEntity.F_ModuleId);
  316. foreach (var item in columnList)
  317. {
  318. if (!dicColumn.ContainsKey(item.F_EnCode))
  319. {
  320. dicColumn.Add(item.F_EnCode.ToLower(), item.F_FullName);
  321. }
  322. }
  323. }
  324. var jsonData = new
  325. {
  326. module = moduleEntity,
  327. btns = dicButton,
  328. cols = dicColumn
  329. };
  330. return this.JsonResult(jsonData);
  331. }
  332. #endregion
  333. }
  334. }