EvaluationNeedController.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using Bowin.Common.Data;
  7. using Bowin.Common.Exceptions;
  8. using Bowin.Common.Utility;
  9. using Bowin.Web.Controls.Mvc;
  10. using EMIS.Web.Controls;
  11. using EMIS.Utility;
  12. using EMIS.ViewModel;
  13. using EMIS.ViewModel.EvaluationManage.EvaluationSetting;
  14. using EMIS.CommonLogic.EvaluationManage.EvaluationSetting;
  15. namespace EMIS.Web.Controllers.EvaluationManage.EvaluationSetting
  16. {
  17. [Authorization]
  18. public class EvaluationNeedController : Controller
  19. {
  20. public Lazy<IEvaluationNeedServices> EvaluationNeedServices { get; set; }
  21. /// <summary>
  22. /// 评价需知页面
  23. /// </summary>
  24. /// <returns></returns>
  25. public ActionResult List()
  26. {
  27. return View();
  28. }
  29. /// <summary>
  30. /// 评价需知列表查询
  31. /// </summary>
  32. /// <param name="pararms"></param>
  33. /// <returns></returns>
  34. [HttpPost]
  35. public ActionResult List(QueryParamsModel pararms)
  36. {
  37. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  38. var participateTypeID = pararms.getExtraInt("DictionaryParticipateType") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryParticipateType");
  39. var isEnabled = pararms.getExtraInt("IsEnabledDropdown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("IsEnabledDropdown");
  40. return base.Json(EvaluationNeedServices.Value.GetEvaluationNeedViewGrid(configuretView, participateTypeID, isEnabled, (int)pararms.page, (int)pararms.rows));
  41. }
  42. /// <summary>
  43. /// 复制新增
  44. /// </summary>
  45. /// <param name="evaluationNeedID"></param>
  46. /// <returns></returns>
  47. public ActionResult CopyAdd(Guid evaluationNeedID)
  48. {
  49. var evaluationNeedView = new EvaluationNeedView();
  50. evaluationNeedView = EvaluationNeedServices.Value.GetEvaluationNeedView(evaluationNeedID);
  51. return View("Edit", evaluationNeedView);
  52. }
  53. /// <summary>
  54. /// 复制新增
  55. /// </summary>
  56. /// <param name="evaluationNeedView"></param>
  57. /// <returns></returns>
  58. [HttpPost]
  59. public ActionResult CopyAdd(EvaluationNeedView evaluationNeedView)
  60. {
  61. evaluationNeedView.EvaluationNeedID = Guid.Empty;
  62. return this.Edit(evaluationNeedView);
  63. }
  64. /// <summary>
  65. /// 编辑(新增、修改)
  66. /// </summary>
  67. /// <param name="evaluationNeedID"></param>
  68. /// <returns></returns>
  69. [HttpGet]
  70. public ActionResult Edit(Guid? evaluationNeedID)
  71. {
  72. var evaluationNeedView = new EvaluationNeedView();
  73. if (evaluationNeedID.HasValue && evaluationNeedID != Guid.Empty)
  74. {
  75. evaluationNeedView = EvaluationNeedServices.Value.GetEvaluationNeedView(evaluationNeedID);
  76. }
  77. else
  78. {
  79. evaluationNeedView.IsEnabled = true;
  80. }
  81. return View(evaluationNeedView);
  82. }
  83. /// <summary>
  84. /// 编辑(新增、修改)
  85. /// </summary>
  86. /// <param name="evaluationNeedView"></param>
  87. /// <returns></returns>
  88. [HttpPost]
  89. public ActionResult Edit(EvaluationNeedView evaluationNeedView)
  90. {
  91. try
  92. {
  93. EvaluationNeedServices.Value.EvaluationNeedEdit(evaluationNeedView);
  94. return Json(new ReturnMessage()
  95. {
  96. IsSuccess = true,
  97. Message = "保存成功。"
  98. });
  99. }
  100. catch (Exception ex)
  101. {
  102. return Json(new ReturnMessage()
  103. {
  104. IsSuccess = false,
  105. Message = "保存失败,原因:" + ex.Message
  106. });
  107. }
  108. }
  109. /// <summary>
  110. /// 删除
  111. /// </summary>
  112. /// <param name="evaluationNeedIDs"></param>
  113. /// <returns></returns>
  114. [HttpPost]
  115. public ActionResult Delete(string evaluationNeedIDs)
  116. {
  117. try
  118. {
  119. List<Guid?> list = evaluationNeedIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  120. EvaluationNeedServices.Value.EvaluationNeedDelete(list);
  121. return base.Json(new ReturnMessage { IsSuccess = true, Message = "删除成功。" });
  122. }
  123. catch (Exception ex)
  124. {
  125. return base.Json(new ReturnMessage() { IsSuccess = false, Message = "删除失败,原因:" + ex.Message });
  126. }
  127. }
  128. /// <summary>
  129. /// Excel导出
  130. /// </summary>
  131. /// <returns></returns>
  132. [HttpPost]
  133. public ActionResult Excel()
  134. {
  135. NpoiExcelHelper neh = new NpoiExcelHelper();
  136. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  137. var participateTypeID = Request.Form["DictionaryParticipateType"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryParticipateType"].ParseStrTo<int>();
  138. var isEnabled = Request.Form["IsEnabledDropdown"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["IsEnabledDropdown"].ParseStrTo<int>();
  139. var dt = EvaluationNeedServices.Value.GetEvaluationNeedViewList(configuretView, participateTypeID, isEnabled)
  140. .Select(x => new
  141. {
  142. x.Code,
  143. x.Title,
  144. x.ParticipateTypeName,
  145. x.Content,
  146. x.IsEnabledName,
  147. x.Remark,
  148. x.CreateUserName,
  149. x.ModifyUserName,
  150. ModifyTime = x.ModifyTime == null ? null : x.ModifyTime.Value.ToString("yyyy-MM-dd HH:mm:ss")
  151. }).ToTable();
  152. string[] liststring = {
  153. "编号", "标题", "参评类型", "内容", "是否启用", "备注", "创建人", "修改人", "修改时间"
  154. };
  155. neh.Export(dt, liststring, "评价需知信息" + DateTime.Now.ToString("yyyyMMdd"));
  156. return Json(new ReturnMessage()
  157. {
  158. IsSuccess = true,
  159. Message = "导出成功。"
  160. });
  161. }
  162. }
  163. }