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.
 
 
 
 
 
 

170 lines
5.0 KiB

  1. using Learun.Application.Organization;
  2. using Learun.Util;
  3. using System.Linq;
  4. using System.Web.Mvc;
  5. namespace Learun.Application.Web.Areas.LR_OrganizationModule.Controllers
  6. {
  7. /// <summary>
  8. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  9. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  10. /// 创建人:陈彬彬
  11. /// 日 期:2017.04.17
  12. /// 描 述:部门管理
  13. /// </summary>
  14. public class DepartmentController : MvcControllerBase
  15. {
  16. private DepartmentIBLL departmentIBLL = new DepartmentBLL();
  17. private CompanyIBLL companyIBLL = new CompanyBLL();
  18. #region 获取视图
  19. /// <summary>
  20. /// 主页
  21. /// </summary>
  22. /// <returns></returns>
  23. [HttpGet]
  24. public ActionResult Index()
  25. {
  26. return View();
  27. }
  28. /// <summary>
  29. /// 表单
  30. /// </summary>
  31. /// <returns></returns>
  32. [HttpGet]
  33. public ActionResult Form()
  34. {
  35. return View();
  36. }
  37. #endregion
  38. #region 获取数据
  39. /// <summary>
  40. /// 获取部门列表信息(根据公司Id)
  41. /// </summary>
  42. /// <param name="companyId">公司Id</param>
  43. /// <param name="keyWord">查询关键字</param>
  44. /// <returns></returns>
  45. [HttpGet]
  46. [AjaxOnly]
  47. public ActionResult GetList(string companyId, string keyword)
  48. {
  49. var data = departmentIBLL.GetList(companyId, keyword).OrderBy(x => x.F_Order);
  50. return JsonResult(data);
  51. }
  52. /// <summary>
  53. /// 获取树形数据
  54. /// </summary>
  55. /// <param name="companyId">公司id</param>
  56. /// <param name="parentId">父级id</param>
  57. /// <returns></returns>
  58. [HttpGet]
  59. [AjaxOnly]
  60. public ActionResult GetTree(string companyId, string parentId)
  61. {
  62. if (string.IsNullOrEmpty(companyId))
  63. {
  64. var companylist = companyIBLL.GetList();
  65. var data = departmentIBLL.GetTree(companylist);
  66. return JsonResult(data);
  67. }
  68. else
  69. {
  70. var data = departmentIBLL.GetTree(companyId, parentId);
  71. return JsonResult(data);
  72. }
  73. }
  74. /// <summary>
  75. /// 获取部门实体数据
  76. /// </summary>
  77. /// <param name="companyId"></param>
  78. /// <returns></returns>
  79. [HttpGet]
  80. [AjaxOnly]
  81. public ActionResult GetEntity(string departmentId)
  82. {
  83. var data = departmentIBLL.GetEntity(departmentId);
  84. return JsonResult(data);
  85. }
  86. [HttpGet]
  87. [AjaxOnly]
  88. public ActionResult GetDepartmentList(string listId)
  89. {
  90. var data = departmentIBLL.GetDepartmentList(listId);
  91. return JsonResult(data);
  92. }
  93. /// <summary>
  94. /// 获取映射数据
  95. /// </summary>
  96. /// <returns></returns>
  97. [HttpGet]
  98. [AjaxOnly]
  99. public ActionResult GetMap(string ver)
  100. {
  101. var data = departmentIBLL.GetModelMap();
  102. string md5 = Md5Helper.Encrypt(data.ToJson(), 32);
  103. if (md5 == ver)
  104. {
  105. return Success("no update");
  106. }
  107. else
  108. {
  109. var jsondata = new
  110. {
  111. data = data,
  112. ver = md5
  113. };
  114. return JsonResult(jsondata);
  115. }
  116. }
  117. #endregion
  118. #region 提交数据
  119. /// <summary>
  120. /// 保存表单数据
  121. /// </summary>
  122. /// <param name="keyValue"></param>
  123. /// <param name="entity"></param>
  124. /// <returns></returns>
  125. [HttpPost]
  126. [ValidateAntiForgeryToken]
  127. [AjaxOnly]
  128. public ActionResult SaveForm(string keyValue, DepartmentEntity entity)
  129. {
  130. var model = departmentIBLL.GetEntityByCode(entity.F_EnCode);
  131. if (string.IsNullOrEmpty(keyValue))
  132. {
  133. if (model != null)
  134. {
  135. if (model.F_CompanyId == entity.F_CompanyId)
  136. return Fail("部门编号已存在!");
  137. }
  138. }
  139. else
  140. {
  141. if (model != null && model.F_DepartmentId != keyValue)
  142. {
  143. if (model.F_CompanyId == entity.F_CompanyId)
  144. return Fail("部门编号已存在!");
  145. }
  146. }
  147. departmentIBLL.SaveEntity(keyValue, entity);
  148. return Success("保存成功!");
  149. }
  150. /// <summary>
  151. /// 删除表单数据
  152. /// </summary>
  153. /// <param name="keyValue"></param>
  154. /// <returns></returns>
  155. [HttpPost]
  156. [AjaxOnly]
  157. public ActionResult DeleteForm(string keyValue)
  158. {
  159. departmentIBLL.VirtualDelete(keyValue);
  160. return Success("删除成功!");
  161. }
  162. #endregion
  163. }
  164. }