纽威
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.

140 lines
4.8 KiB

3 years ago
  1. using NFine.Application.SystemManage;
  2. using NFine.Code;
  3. using NFine.Domain.Entity.SystemManage;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Web.Mvc;
  7. namespace NFine.Web.Areas.SystemManage.Controllers
  8. {
  9. public class ModuleButtonController : ControllerBase
  10. {
  11. private ModuleApp moduleApp = new ModuleApp();
  12. private ModuleButtonApp moduleButtonApp = new ModuleButtonApp();
  13. [HttpGet]
  14. [HandlerAjaxOnly]
  15. public ActionResult GetTreeSelectJson(string moduleId)
  16. {
  17. var data = moduleButtonApp.GetList(moduleId);
  18. var treeList = new List<TreeSelectModel>();
  19. foreach (ModuleButtonEntity item in data)
  20. {
  21. TreeSelectModel treeModel = new TreeSelectModel();
  22. treeModel.id = item.F_Id;
  23. treeModel.text = item.F_FullName;
  24. treeModel.parentId = item.F_ParentId;
  25. treeList.Add(treeModel);
  26. }
  27. return Content(treeList.TreeSelectJson());
  28. }
  29. [HttpGet]
  30. [HandlerAjaxOnly]
  31. public ActionResult GetTreeGridJson(string moduleId)
  32. {
  33. var data = moduleButtonApp.GetList(moduleId);
  34. var treeList = new List<TreeGridModel>();
  35. foreach (ModuleButtonEntity item in data)
  36. {
  37. TreeGridModel treeModel = new TreeGridModel();
  38. bool hasChildren = data.Count(t => t.F_ParentId == item.F_Id) == 0 ? false : true;
  39. treeModel.id = item.F_Id;
  40. treeModel.isLeaf = hasChildren;
  41. treeModel.parentId = item.F_ParentId;
  42. treeModel.expanded = hasChildren;
  43. treeModel.entityJson = item.ToJson();
  44. treeList.Add(treeModel);
  45. }
  46. return Content(treeList.TreeGridJson());
  47. }
  48. [HttpGet]
  49. [HandlerAjaxOnly]
  50. public ActionResult GetFormJson(string keyValue)
  51. {
  52. var data = moduleButtonApp.GetForm(keyValue);
  53. return Content(data.ToJson());
  54. }
  55. [HttpPost]
  56. [HandlerAjaxOnly]
  57. [ValidateAntiForgeryToken]
  58. public ActionResult SubmitForm(ModuleButtonEntity moduleButtonEntity, string keyValue)
  59. {
  60. moduleButtonApp.SubmitForm(moduleButtonEntity, keyValue);
  61. return Success("操作成功。");
  62. }
  63. [HttpPost]
  64. [HandlerAjaxOnly]
  65. [ValidateAntiForgeryToken]
  66. public ActionResult DeleteForm(string keyValue)
  67. {
  68. moduleButtonApp.DeleteForm(keyValue);
  69. return Success("删除成功。");
  70. }
  71. [HttpGet]
  72. public ActionResult CloneButton()
  73. {
  74. return View();
  75. }
  76. [HttpGet]
  77. [HandlerAjaxOnly]
  78. public ActionResult GetCloneButtonTreeJson()
  79. {
  80. var moduledata = moduleApp.GetList();
  81. var buttondata = moduleButtonApp.GetList();
  82. var treeList = new List<TreeViewModel>();
  83. foreach (ModuleEntity item in moduledata)
  84. {
  85. TreeViewModel tree = new TreeViewModel();
  86. bool hasChildren = moduledata.Count(t => t.F_ParentId == item.F_Id) == 0 ? false : true;
  87. tree.id = item.F_Id;
  88. tree.text = item.F_FullName;
  89. tree.value = item.F_EnCode;
  90. tree.parentId = item.F_ParentId;
  91. tree.isexpand = true;
  92. tree.complete = true;
  93. tree.hasChildren = true;
  94. treeList.Add(tree);
  95. }
  96. foreach (ModuleButtonEntity item in buttondata)
  97. {
  98. TreeViewModel tree = new TreeViewModel();
  99. bool hasChildren = buttondata.Count(t => t.F_ParentId == item.F_Id) == 0 ? false : true;
  100. tree.id = item.F_Id;
  101. tree.text = item.F_FullName;
  102. tree.value = item.F_EnCode;
  103. if (item.F_ParentId == "0")
  104. {
  105. tree.parentId = item.F_ModuleId;
  106. }
  107. else
  108. {
  109. tree.parentId = item.F_ParentId;
  110. }
  111. tree.isexpand = true;
  112. tree.complete = true;
  113. tree.showcheck = true;
  114. tree.hasChildren = hasChildren;
  115. if (item.F_Icon != "")
  116. {
  117. tree.img = item.F_Icon;
  118. }
  119. treeList.Add(tree);
  120. }
  121. return Content(treeList.TreeViewJson());
  122. }
  123. [HttpPost]
  124. [HandlerAjaxOnly]
  125. public ActionResult SubmitCloneButton(string moduleId, string Ids)
  126. {
  127. moduleButtonApp.SubmitCloneButton(moduleId, Ids);
  128. return Success("克隆成功。");
  129. }
  130. }
  131. }