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.

117 lines
3.6 KiB

3 weeks ago
  1. using NFine.Application.SystemManage;
  2. using NFine.Code;
  3. using NFine.Domain.Entity.SystemManage;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Data;
  7. using System.Linq;
  8. using System.Web.Mvc;
  9. namespace NFine.Web.Areas.SystemManage.Controllers
  10. {
  11. public class ModuleController : ControllerBase
  12. {
  13. private ModuleApp moduleApp = new ModuleApp();
  14. [HttpGet]
  15. [HandlerAjaxOnly]
  16. public ActionResult GetTreeSelectJson()
  17. {
  18. var data = moduleApp.GetList();
  19. var treeList = new List<TreeSelectModel>();
  20. foreach (ModuleEntity item in data)
  21. {
  22. TreeSelectModel treeModel = new TreeSelectModel();
  23. treeModel.id = item.F_Id;
  24. treeModel.text = item.F_FullName;
  25. treeModel.parentId = item.F_ParentId;
  26. treeList.Add(treeModel);
  27. }
  28. return Content(treeList.TreeSelectJson());
  29. }
  30. [HttpGet]
  31. [HandlerAjaxOnly]
  32. public ActionResult GetTreeGridJson(string keyword)
  33. {
  34. var data = moduleApp.GetList();
  35. if (!string.IsNullOrEmpty(keyword))
  36. {
  37. data = data.TreeWhere(t => t.F_FullName.Contains(keyword));
  38. }
  39. var treeList = new List<TreeGridModel>();
  40. foreach (ModuleEntity item in data)
  41. {
  42. TreeGridModel treeModel = new TreeGridModel();
  43. bool hasChildren = data.Count(t => t.F_ParentId == item.F_Id) == 0 ? false : true;
  44. treeModel.id = item.F_Id;
  45. treeModel.isLeaf = hasChildren;
  46. treeModel.parentId = item.F_ParentId;
  47. treeModel.expanded = hasChildren;
  48. treeModel.entityJson = item.ToJson();
  49. treeList.Add(treeModel);
  50. }
  51. return Content(treeList.TreeGridJson());
  52. }
  53. [HttpGet]
  54. [HandlerAjaxOnly]
  55. public ActionResult GetFormJson(string keyValue)
  56. {
  57. var data = moduleApp.GetForm(keyValue);
  58. return Content(data.ToJson());
  59. }
  60. [HttpPost]
  61. [HandlerAjaxOnly]
  62. [ValidateAntiForgeryToken]
  63. public ActionResult SubmitForm(ModuleEntity moduleEntity, string keyValue)
  64. {
  65. moduleApp.SubmitForm(moduleEntity, keyValue);
  66. return Success("操作成功。");
  67. }
  68. [HttpPost]
  69. [HandlerAjaxOnly]
  70. [HandlerAuthorize]
  71. [ValidateAntiForgeryToken]
  72. public ActionResult DeleteForm(string keyValue)
  73. {
  74. moduleApp.DeleteForm(keyValue);
  75. return Success("删除成功。");
  76. }
  77. //获取数据权限详情
  78. [HttpGet]
  79. [HandlerAjaxOnly]
  80. public ActionResult GetCondition(Pagination pagination, string SourceID)
  81. {
  82. DataTable data = moduleApp.GetCondition(SourceID);
  83. var JsonData = new
  84. {
  85. total = pagination.total,
  86. page = pagination.page,
  87. records = pagination.records,
  88. rows = data
  89. };
  90. return Content(JsonData.ToJson());
  91. }
  92. //保存数据权限
  93. [HttpPost]
  94. [HandlerAjaxOnly]
  95. public ActionResult SetDataAction(string SourceID, string List_Condition)
  96. {
  97. try
  98. {
  99. moduleApp.SetDataAction(SourceID, List_Condition);
  100. return Content("操作成功。");
  101. }
  102. catch (Exception ex)
  103. {
  104. return Content(ex.ToString());
  105. }
  106. }
  107. }
  108. }