新增文档分类列表树

This commit is contained in:
hogan
2019-01-25 16:49:09 +08:00
parent a9afd0d23d
commit 96c2a66131
25 changed files with 875 additions and 515 deletions

View File

@ -35,15 +35,6 @@ namespace FreeSql.Site.UI.Areas.Admin.Controllers
return View(model);
}
#region
public IActionResult DocType()
{
DocumentType model = new DocumentType();
return View(model);
}
#endregion
#region
public IActionResult DocContent()
{
@ -82,7 +73,7 @@ namespace FreeSql.Site.UI.Areas.Admin.Controllers
public ActionResult DocContentEditModule(string id)
{
ViewBag.DocumentTypeList = DocumentTypeDAL.Query(w => w.Status == 1).Select(s => new SelectListItem { Text = s.TypeName, Value = s.ID.ToString() }).ToList();
ViewBag.DocumentTypeList = DocumentTypeDAL.Query(w => w.Status == 1).list.Select(s => new SelectListItem { Text = s.TypeName, Value = s.ID.ToString() }).ToList();
DocumentContent model = new DocumentContent();
if (!string.IsNullOrEmpty(id))
{
@ -140,6 +131,109 @@ namespace FreeSql.Site.UI.Areas.Admin.Controllers
return Json(resdata);
}
#endregion
#region
public IActionResult DocType()
{
DocumentType model = new DocumentType();
ViewBag.TypeList = DocumentTypeDAL.Query(w => w.Status == 1).list.Select(s => new DocumentTypeTreeNode
{
id = s.ID.ToString(),
pid = (s.UpID ?? 0).ToString(),
title = s.TypeName,
tag = s.Tag,
createdt = s.CreateDt
}).ToList();
return View(model);
}
[HttpGet]
public IActionResult DocTypeList(string searchContent, string seniorQueryJson, int page = 1, int limit = 10)
{
DocumentType model = null;
if (!string.IsNullOrWhiteSpace(seniorQueryJson))
{
model = Newtonsoft.Json.JsonConvert.DeserializeObject<DocumentType>(seniorQueryJson);
}
Expression<Func<DocumentType, bool>> predicate = i => 1 == 0;
var searchPredicate = PredicateExtensions.True<DocumentType>();
if (model != null)
{
searchPredicate = searchPredicate.And(u => u.Status == 1);
}
var contents = DocumentTypeDAL.Query(searchPredicate);
return Json(new DataPage<DocumentType>
{
code = "0",
msg = "",
count = contents.count,
data = contents.list
});
}
public ActionResult DocTypeEditModule(string id)
{
DocumentType model = new DocumentType();
if (!string.IsNullOrEmpty(id))
{
int _id = Convert.ToInt32(id);
model = DocumentTypeDAL.GetByOne(w => w.ID == _id);
}
return View(model);
}
// POST: Documents/Create
[HttpPost]
//[ValidateAntiForgeryToken]
public ActionResult DocTypeCreate([FromBody]DocumentContent model)
{
var resdata = AutoException.Excute<long>((result) =>
{
result.Data = DocumentContentDAL.Insert(model);
if (result.Data == 0)
{
throw new Exception("数据新增异常JSON:" + Newtonsoft.Json.JsonConvert.SerializeObject(model));
}
}, false);
return Json(resdata);
}
// POST: Documents/Create
[HttpPost]
//[ValidateAntiForgeryToken]
public ActionResult DocTypeUpdate([FromBody]DocumentContent model)
{
var resdata = AutoException.Excute<bool>((result) =>
{
model.UpdateBy = "admin";
model.UpdateDt = DateTime.Now;
result.Data = DocumentContentDAL.Update(model);
if (result.Data == false)
{
throw new Exception("数据新增异常JSON:" + Newtonsoft.Json.JsonConvert.SerializeObject(model));
}
}, false);
return Json(resdata);
}
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult DocTypeDelete(int id, IFormCollection collection)
{
var resdata = AutoException.Excute<long>((result) =>
{
if (!DocumentContentDAL.Delete(id))
{
throw new Exception("数据删除异常ID:" + id);
}
}, false);
return Json(resdata);
}
#endregion
}
}