@@ -44,7 +44,8 @@ namespace Learun.Application.Web.Areas.LR_SystemModule.Controllers | |||||
/// <returns></returns> | /// <returns></returns> | ||||
[HttpGet] | [HttpGet] | ||||
[AjaxOnly] | [AjaxOnly] | ||||
public ActionResult Getlist(string parentId, string keyword) { | |||||
public ActionResult Getlist(string parentId, string keyword) | |||||
{ | |||||
var data = areaIBLL.GetList(parentId, keyword); | var data = areaIBLL.GetList(parentId, keyword); | ||||
return JsonResult(data); | return JsonResult(data); | ||||
} | } | ||||
@@ -74,6 +75,22 @@ namespace Learun.Application.Web.Areas.LR_SystemModule.Controllers | |||||
[AjaxOnly] | [AjaxOnly] | ||||
public ActionResult SaveForm(string keyValue, AreaEntity entity) | public ActionResult SaveForm(string keyValue, AreaEntity entity) | ||||
{ | { | ||||
var model = areaIBLL.GetEntityByCode(entity.F_AreaCode); | |||||
if (string.IsNullOrEmpty(keyValue)) | |||||
{ | |||||
if (model.F_AreaCode == entity.F_AreaCode) | |||||
{ | |||||
return Fail("编号重复,新重新输入!"); | |||||
} | |||||
} | |||||
else | |||||
{ | |||||
if (model.F_AreaCode == entity.F_AreaCode && model.F_AreaId != keyValue) | |||||
{ | |||||
return Fail("编号重复,新重新输入!"); | |||||
} | |||||
} | |||||
areaIBLL.SaveEntity(keyValue, entity); | areaIBLL.SaveEntity(keyValue, entity); | ||||
return Success("保存成功!"); | return Success("保存成功!"); | ||||
} | } | ||||
@@ -75,7 +75,7 @@ var bootstrap = function ($, learun) { | |||||
$('#lr_left_tree').lrtree({ | $('#lr_left_tree').lrtree({ | ||||
url: top.$.rootUrl + '/LR_SystemModule/Area/GetTree', | url: top.$.rootUrl + '/LR_SystemModule/Area/GetTree', | ||||
nodeClick: function (item) { | nodeClick: function (item) { | ||||
parentId = item.id; | |||||
parentId = item.value; | |||||
page.search(); | page.search(); | ||||
$('#titleinfo').text(item.text); | $('#titleinfo').text(item.text); | ||||
} | } | ||||
@@ -114,6 +114,28 @@ namespace Learun.Application.Base.SystemModule | |||||
throw; | throw; | ||||
} | } | ||||
} | } | ||||
public AreaEntity GetEntityByCode(string code) | |||||
{ | |||||
try | |||||
{ | |||||
return areaService.GetEntityByCode(code); | |||||
} | |||||
catch (Exception ex) | |||||
{ | |||||
if (ex is ExceptionEx) | |||||
{ | |||||
throw; | |||||
} | |||||
else | |||||
{ | |||||
throw ExceptionEx.ThrowBusinessException(ex); | |||||
} | |||||
throw; | |||||
} | |||||
} | |||||
/// <summary> | /// <summary> | ||||
/// 获取区域数据树(某一级的) | /// 获取区域数据树(某一级的) | ||||
/// </summary> | /// </summary> | ||||
@@ -129,12 +151,12 @@ namespace Learun.Application.Base.SystemModule | |||||
foreach (var item in list) | foreach (var item in list) | ||||
{ | { | ||||
TreeModel node = new TreeModel(); | TreeModel node = new TreeModel(); | ||||
node.id = item.F_AreaId; | |||||
node.id = item.F_AreaCode; | |||||
node.text = item.F_AreaName; | node.text = item.F_AreaName; | ||||
node.value = item.F_AreaCode; | node.value = item.F_AreaCode; | ||||
node.showcheck = false; | node.showcheck = false; | ||||
node.checkstate = 0; | node.checkstate = 0; | ||||
node.hasChildren = GetList(item.F_AreaId).Count > 0 ? true : false; | |||||
node.hasChildren = GetList(item.F_AreaCode).Count > 0 ? true : false; | |||||
node.isexpand = false; | node.isexpand = false; | ||||
node.complete = false; | node.complete = false; | ||||
treeList.Add(node); | treeList.Add(node); | ||||
@@ -38,6 +38,12 @@ namespace Learun.Application.Base.SystemModule | |||||
/// <param name="keyValue">主键值</param> | /// <param name="keyValue">主键值</param> | ||||
/// <returns></returns> | /// <returns></returns> | ||||
AreaEntity GetEntity(string keyValue); | AreaEntity GetEntity(string keyValue); | ||||
/// <summary> | |||||
/// 根据编码获取实体 | |||||
/// </summary> | |||||
/// <param name="code"></param> | |||||
/// <returns></returns> | |||||
AreaEntity GetEntityByCode(string code); | |||||
#endregion | #endregion | ||||
#region 提交数据 | #region 提交数据 | ||||
@@ -104,6 +104,26 @@ namespace Learun.Application.Base.SystemModule | |||||
} | } | ||||
} | } | ||||
} | } | ||||
public AreaEntity GetEntityByCode(string code) | |||||
{ | |||||
try | |||||
{ | |||||
return this.BaseRepository().FindEntity<AreaEntity>(x => x.F_AreaCode == code); | |||||
} | |||||
catch (Exception ex) | |||||
{ | |||||
if (ex is ExceptionEx) | |||||
{ | |||||
throw; | |||||
} | |||||
else | |||||
{ | |||||
throw ExceptionEx.ThrowServiceException(ex); | |||||
} | |||||
} | |||||
} | |||||
#endregion | #endregion | ||||
#region 提交数据 | #region 提交数据 | ||||