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.
 
 
 
 
 
 

194 lines
5.8 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. /// <param name="parentId"></param>
  79. /// <returns></returns>
  80. [HttpGet]
  81. [AjaxOnly]
  82. public ActionResult GetTreeNoCheck(string companyId, string parentId)
  83. {
  84. if (string.IsNullOrEmpty(companyId))
  85. {
  86. var companylist = companyIBLL.GetList();
  87. var data = departmentIBLL.GetTreeNoCheck(companylist);
  88. return JsonResult(data);
  89. }
  90. else
  91. {
  92. var data = departmentIBLL.GetTreeNoCheck(companyId, parentId);
  93. return JsonResult(data);
  94. }
  95. }
  96. /// <summary>
  97. /// 获取部门实体数据
  98. /// </summary>
  99. /// <param name="companyId"></param>
  100. /// <returns></returns>
  101. [HttpGet]
  102. [AjaxOnly]
  103. public ActionResult GetEntity(string departmentId)
  104. {
  105. var data = departmentIBLL.GetEntity(departmentId);
  106. return JsonResult(data);
  107. }
  108. [HttpGet]
  109. [AjaxOnly]
  110. public ActionResult GetDepartmentList(string listId)
  111. {
  112. var data = departmentIBLL.GetDepartmentList(listId);
  113. return JsonResult(data);
  114. }
  115. /// <summary>
  116. /// 获取映射数据
  117. /// </summary>
  118. /// <returns></returns>
  119. [HttpGet]
  120. [AjaxOnly]
  121. public ActionResult GetMap(string ver)
  122. {
  123. var data = departmentIBLL.GetModelMap();
  124. string md5 = Md5Helper.Encrypt(data.ToJson(), 32);
  125. if (md5 == ver)
  126. {
  127. return Success("no update");
  128. }
  129. else
  130. {
  131. var jsondata = new
  132. {
  133. data = data,
  134. ver = md5
  135. };
  136. return JsonResult(jsondata);
  137. }
  138. }
  139. #endregion
  140. #region 提交数据
  141. /// <summary>
  142. /// 保存表单数据
  143. /// </summary>
  144. /// <param name="keyValue"></param>
  145. /// <param name="entity"></param>
  146. /// <returns></returns>
  147. [HttpPost]
  148. [ValidateAntiForgeryToken]
  149. [AjaxOnly]
  150. public ActionResult SaveForm(string keyValue, DepartmentEntity entity)
  151. {
  152. var model = departmentIBLL.GetEntityByCode(entity.F_EnCode);
  153. if (string.IsNullOrEmpty(keyValue))
  154. {
  155. if (model != null)
  156. {
  157. if (model.F_CompanyId == entity.F_CompanyId)
  158. return Fail("部门编号已存在!");
  159. }
  160. }
  161. else
  162. {
  163. if (model != null && model.F_DepartmentId != keyValue)
  164. {
  165. if (model.F_CompanyId == entity.F_CompanyId)
  166. return Fail("部门编号已存在!");
  167. }
  168. }
  169. //发送标识false
  170. entity.SendFlag = false;
  171. departmentIBLL.SaveEntity(keyValue, entity);
  172. return Success("保存成功!");
  173. }
  174. /// <summary>
  175. /// 删除表单数据
  176. /// </summary>
  177. /// <param name="keyValue"></param>
  178. /// <returns></returns>
  179. [HttpPost]
  180. [AjaxOnly]
  181. public ActionResult DeleteForm(string keyValue)
  182. {
  183. departmentIBLL.VirtualDelete(keyValue);
  184. return Success("删除成功!");
  185. }
  186. #endregion
  187. }
  188. }