using NFine.Application.SystemManage; using NFine.Code; using NFine.Domain.Entity.SystemManage; using System.Collections.Generic; using System.Linq; using System.Web.Mvc; namespace NFine.Web.Areas.SystemManage.Controllers { public class OrganizeController : ControllerBase { private OrganizeApp organizeApp = new OrganizeApp(); [HttpGet] [HandlerAjaxOnly] public ActionResult GetTreeSelectJson() { var data = organizeApp.GetList(); var treeList = new List(); foreach (OrganizeEntity item in data) { TreeSelectModel treeModel = new TreeSelectModel(); treeModel.id = item.F_Id; treeModel.text = item.F_FullName; treeModel.parentId = item.F_ParentId; treeModel.data = item; treeList.Add(treeModel); } return Content(treeList.TreeSelectJson()); } [HttpGet] [HandlerAjaxOnly] public ActionResult GetTreeJson() { var data = organizeApp.GetList(); var treeList = new List(); foreach (OrganizeEntity item in data) { TreeViewModel tree = new TreeViewModel(); bool hasChildren = data.Count(t => t.F_ParentId == item.F_Id) == 0 ? false : true; tree.id = item.F_Id; tree.text = item.F_FullName; tree.value = item.F_EnCode; tree.parentId = item.F_ParentId; tree.isexpand = true; tree.complete = true; tree.hasChildren = hasChildren; treeList.Add(tree); } return Content(treeList.TreeViewJson()); } [HttpGet] [HandlerAjaxOnly] public ActionResult GetTreeGridJson(string keyword) { var data = organizeApp.GetList(); if (!string.IsNullOrEmpty(keyword)) { data = data.TreeWhere(t => t.F_FullName.Contains(keyword)); } var treeList = new List(); foreach (OrganizeEntity item in data) { TreeGridModel treeModel = new TreeGridModel(); bool hasChildren = data.Count(t => t.F_ParentId == item.F_Id) == 0 ? false : true; treeModel.id = item.F_Id; treeModel.isLeaf = hasChildren; treeModel.parentId = item.F_ParentId; treeModel.expanded = hasChildren; treeModel.entityJson = item.ToJson(); treeList.Add(treeModel); } return Content(treeList.TreeGridJson()); } [HttpGet] [HandlerAjaxOnly] public ActionResult GetFormJson(string keyValue) { var data = organizeApp.GetForm(keyValue); return Content(data.ToJson()); } [HttpPost] [HandlerAjaxOnly] [ValidateAntiForgeryToken] public ActionResult SubmitForm(OrganizeEntity organizeEntity, string keyValue) { organizeApp.SubmitForm(organizeEntity, keyValue); return Success("操作成功。"); } [HttpPost] [HandlerAjaxOnly] [HandlerAuthorize] [ValidateAntiForgeryToken] public ActionResult DeleteForm(string keyValue) { organizeApp.DeleteForm(keyValue); return Success("删除成功。"); } } }