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

82 lines
2.6 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 ModuleController : ControllerBase
  10. {
  11. private ModuleApp moduleApp = new ModuleApp();
  12. [HttpGet]
  13. [HandlerAjaxOnly]
  14. public ActionResult GetTreeSelectJson()
  15. {
  16. var data = moduleApp.GetList();
  17. var treeList = new List<TreeSelectModel>();
  18. foreach (ModuleEntity item in data)
  19. {
  20. TreeSelectModel treeModel = new TreeSelectModel();
  21. treeModel.id = item.F_Id;
  22. treeModel.text = item.F_FullName;
  23. treeModel.parentId = item.F_ParentId;
  24. treeList.Add(treeModel);
  25. }
  26. return Content(treeList.TreeSelectJson());
  27. }
  28. [HttpGet]
  29. [HandlerAjaxOnly]
  30. public ActionResult GetTreeGridJson(string keyword)
  31. {
  32. var data = moduleApp.GetList();
  33. if (!string.IsNullOrEmpty(keyword))
  34. {
  35. data = data.TreeWhere(t => t.F_FullName.Contains(keyword));
  36. }
  37. var treeList = new List<TreeGridModel>();
  38. foreach (ModuleEntity item in data)
  39. {
  40. TreeGridModel treeModel = new TreeGridModel();
  41. bool hasChildren = data.Count(t => t.F_ParentId == item.F_Id) == 0 ? false : true;
  42. treeModel.id = item.F_Id;
  43. treeModel.isLeaf = hasChildren;
  44. treeModel.parentId = item.F_ParentId;
  45. treeModel.expanded = hasChildren;
  46. treeModel.entityJson = item.ToJson();
  47. treeList.Add(treeModel);
  48. }
  49. return Content(treeList.TreeGridJson());
  50. }
  51. [HttpGet]
  52. [HandlerAjaxOnly]
  53. public ActionResult GetFormJson(string keyValue)
  54. {
  55. var data = moduleApp.GetForm(keyValue);
  56. return Content(data.ToJson());
  57. }
  58. [HttpPost]
  59. [HandlerAjaxOnly]
  60. [ValidateAntiForgeryToken]
  61. public ActionResult SubmitForm(ModuleEntity moduleEntity, string keyValue)
  62. {
  63. moduleApp.SubmitForm(moduleEntity, keyValue);
  64. return Success("操作成功。");
  65. }
  66. [HttpPost]
  67. [HandlerAjaxOnly]
  68. [HandlerAuthorize]
  69. [ValidateAntiForgeryToken]
  70. public ActionResult DeleteForm(string keyValue)
  71. {
  72. moduleApp.DeleteForm(keyValue);
  73. return Success("删除成功。");
  74. }
  75. }
  76. }