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

83 lines
2.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.Linq;
  6. using System.Web.Mvc;
  7. namespace NFine.Web.Areas.SystemManage.Controllers
  8. {
  9. public class AreaController : ControllerBase
  10. {
  11. private AreaApp areaApp = new AreaApp();
  12. [HttpGet]
  13. [HandlerAjaxOnly]
  14. public ActionResult GetTreeSelectJson()
  15. {
  16. var data = areaApp.GetList();
  17. var treeList = new List<TreeSelectModel>();
  18. foreach (AreaEntity 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 = areaApp.GetList();
  33. var treeList = new List<TreeGridModel>();
  34. foreach (AreaEntity item in data)
  35. {
  36. TreeGridModel treeModel = new TreeGridModel();
  37. bool hasChildren = data.Count(t => t.F_ParentId == item.F_Id) == 0 ? false : true;
  38. treeModel.id = item.F_Id;
  39. treeModel.text = item.F_FullName;
  40. treeModel.isLeaf = hasChildren;
  41. treeModel.parentId = item.F_ParentId;
  42. treeModel.expanded = true;
  43. treeModel.entityJson = item.ToJson();
  44. treeList.Add(treeModel);
  45. }
  46. if (!string.IsNullOrEmpty(keyword))
  47. {
  48. treeList = treeList.TreeWhere(t => t.text.Contains(keyword), "id", "parentId");
  49. }
  50. return Content(treeList.TreeGridJson());
  51. }
  52. [HttpGet]
  53. [HandlerAjaxOnly]
  54. public ActionResult GetFormJson(string keyValue)
  55. {
  56. var data = areaApp.GetForm(keyValue);
  57. return Content(data.ToJson());
  58. }
  59. [HttpPost]
  60. [HandlerAjaxOnly]
  61. [ValidateAntiForgeryToken]
  62. public ActionResult SubmitForm(AreaEntity areaEntity, string keyValue)
  63. {
  64. areaApp.SubmitForm(areaEntity, keyValue);
  65. return Success("操作成功。");
  66. }
  67. [HttpPost]
  68. [HandlerAjaxOnly]
  69. [HandlerAuthorize]
  70. [ValidateAntiForgeryToken]
  71. public ActionResult DeleteForm(string keyValue)
  72. {
  73. areaApp.DeleteForm(keyValue);
  74. return Success("删除成功。");
  75. }
  76. }
  77. }