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

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 AreaController : ControllerBase
{
private AreaApp areaApp = new AreaApp();
[HttpGet]
[HandlerAjaxOnly]
public ActionResult GetTreeSelectJson()
{
var data = areaApp.GetList();
var treeList = new List<TreeSelectModel>();
foreach (AreaEntity item in data)
{
TreeSelectModel treeModel = new TreeSelectModel();
treeModel.id = item.F_Id;
treeModel.text = item.F_FullName;
treeModel.parentId = item.F_ParentId;
treeList.Add(treeModel);
}
return Content(treeList.TreeSelectJson());
}
[HttpGet]
[HandlerAjaxOnly]
public ActionResult GetTreeGridJson(string keyword)
{
var data = areaApp.GetList();
var treeList = new List<TreeGridModel>();
foreach (AreaEntity 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.text = item.F_FullName;
treeModel.isLeaf = hasChildren;
treeModel.parentId = item.F_ParentId;
treeModel.expanded = true;
treeModel.entityJson = item.ToJson();
treeList.Add(treeModel);
}
if (!string.IsNullOrEmpty(keyword))
{
treeList = treeList.TreeWhere(t => t.text.Contains(keyword), "id", "parentId");
}
return Content(treeList.TreeGridJson());
}
[HttpGet]
[HandlerAjaxOnly]
public ActionResult GetFormJson(string keyValue)
{
var data = areaApp.GetForm(keyValue);
return Content(data.ToJson());
}
[HttpPost]
[HandlerAjaxOnly]
[ValidateAntiForgeryToken]
public ActionResult SubmitForm(AreaEntity areaEntity, string keyValue)
{
areaApp.SubmitForm(areaEntity, keyValue);
return Success("操作成功。");
}
[HttpPost]
[HandlerAjaxOnly]
[HandlerAuthorize]
[ValidateAntiForgeryToken]
public ActionResult DeleteForm(string keyValue)
{
areaApp.DeleteForm(keyValue);
return Success("删除成功。");
}
}
}