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

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