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

105 lines
3.5 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 OrganizeController : ControllerBase
  10. {
  11. private OrganizeApp organizeApp = new OrganizeApp();
  12. [HttpGet]
  13. [HandlerAjaxOnly]
  14. public ActionResult GetTreeSelectJson()
  15. {
  16. var data = organizeApp.GetList();
  17. var treeList = new List<TreeSelectModel>();
  18. foreach (OrganizeEntity 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. treeModel.data = item;
  25. treeList.Add(treeModel);
  26. }
  27. return Content(treeList.TreeSelectJson());
  28. }
  29. [HttpGet]
  30. [HandlerAjaxOnly]
  31. public ActionResult GetTreeJson()
  32. {
  33. var data = organizeApp.GetList();
  34. var treeList = new List<TreeViewModel>();
  35. foreach (OrganizeEntity item in data)
  36. {
  37. TreeViewModel tree = new TreeViewModel();
  38. bool hasChildren = data.Count(t => t.F_ParentId == item.F_Id) == 0 ? false : true;
  39. tree.id = item.F_Id;
  40. tree.text = item.F_FullName;
  41. tree.value = item.F_EnCode;
  42. tree.parentId = item.F_ParentId;
  43. tree.isexpand = true;
  44. tree.complete = true;
  45. tree.hasChildren = hasChildren;
  46. treeList.Add(tree);
  47. }
  48. return Content(treeList.TreeViewJson());
  49. }
  50. [HttpGet]
  51. [HandlerAjaxOnly]
  52. public ActionResult GetTreeGridJson(string keyword)
  53. {
  54. var data = organizeApp.GetList();
  55. if (!string.IsNullOrEmpty(keyword))
  56. {
  57. data = data.TreeWhere(t => t.F_FullName.Contains(keyword));
  58. }
  59. var treeList = new List<TreeGridModel>();
  60. foreach (OrganizeEntity item in data)
  61. {
  62. TreeGridModel treeModel = new TreeGridModel();
  63. bool hasChildren = data.Count(t => t.F_ParentId == item.F_Id) == 0 ? false : true;
  64. treeModel.id = item.F_Id;
  65. treeModel.isLeaf = hasChildren;
  66. treeModel.parentId = item.F_ParentId;
  67. treeModel.expanded = hasChildren;
  68. treeModel.entityJson = item.ToJson();
  69. treeList.Add(treeModel);
  70. }
  71. return Content(treeList.TreeGridJson());
  72. }
  73. [HttpGet]
  74. [HandlerAjaxOnly]
  75. public ActionResult GetFormJson(string keyValue)
  76. {
  77. var data = organizeApp.GetForm(keyValue);
  78. return Content(data.ToJson());
  79. }
  80. [HttpPost]
  81. [HandlerAjaxOnly]
  82. [ValidateAntiForgeryToken]
  83. public ActionResult SubmitForm(OrganizeEntity organizeEntity, string keyValue)
  84. {
  85. organizeApp.SubmitForm(organizeEntity, keyValue);
  86. return Success("操作成功。");
  87. }
  88. [HttpPost]
  89. [HandlerAjaxOnly]
  90. [HandlerAuthorize]
  91. [ValidateAntiForgeryToken]
  92. public ActionResult DeleteForm(string keyValue)
  93. {
  94. organizeApp.DeleteForm(keyValue);
  95. return Success("删除成功。");
  96. }
  97. }
  98. }