EvaluationFormController.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using System.Text;
  7. using System.Collections;
  8. using Bowin.Common.Utility;
  9. using Bowin.Web.Controls.Mvc;
  10. using EMIS.Utility;
  11. using EMIS.Web.Controls;
  12. using EMIS.ViewModel;
  13. using EMIS.ViewModel.EvaluationManage.EvaluationTable;
  14. using EMIS.CommonLogic.EvaluationManage.EvaluationTable;
  15. namespace EMIS.Web.Controllers.EvaluationManage.EvaluationTable
  16. {
  17. [Authorization]
  18. public class EvaluationFormController : Controller
  19. {
  20. public Lazy<IEvaluationTargetServices> EvaluationTargetServices { get; set; }
  21. public Lazy<IEvaluationNormServices> EvaluationNormServices { get; set; }
  22. public Lazy<IEvaluationProjectServices> EvaluationProjectServices { get; set; }
  23. /// <summary>
  24. /// 评价表格页面
  25. /// </summary>
  26. /// <returns></returns>
  27. public ActionResult List()
  28. {
  29. return View();
  30. }
  31. /// <summary>
  32. /// 评价表格标题
  33. /// </summary>
  34. /// <returns></returns>
  35. public JsonResult FormTitle()
  36. {
  37. ArrayList formTitleList = new ArrayList();
  38. formTitleList.Add(new { field = "OrderNo", title = "次序", align = "center", width = "150" });
  39. formTitleList.Add(new { field = "EvaluationProjectName", title = "评价项目", align = "center", width = "350", formatter = "formatCellTooltip" });
  40. formTitleList.Add(new { field = "Weight", title = "权重", align = "center", width = "100" });
  41. formTitleList.Add(new { field = "EvaluationNormName", title = "评分标准", align = "center", width = "250" });
  42. return Json(new { UpTitle = JsonHelper.ToJSON(formTitleList) }, JsonRequestBehavior.AllowGet);
  43. }
  44. /// <summary>
  45. /// 评价表格内容
  46. /// </summary>
  47. /// <returns></returns>
  48. public JsonResult Content(Guid? evaluationTableID)
  49. {
  50. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  51. var evaluationTargetViewList = EvaluationTargetServices.Value.GetEvaluationTargetViewList(configuretView, null, null, evaluationTableID, null)
  52. .Select(x => new { x.EvaluationTargetID, x.EvaluationNormID, x.Name, x.Weight }).ToList();
  53. int i = 1;
  54. StringBuilder strRows = new StringBuilder();
  55. foreach (var evaluationTargetView in evaluationTargetViewList)
  56. {
  57. StringBuilder strRowtg = new StringBuilder();
  58. var tgNormNames = string.Join(" ", EvaluationNormServices.Value.GetEvaluationNormDetailViewList(configuretView, evaluationTargetView.EvaluationNormID).Select(s => s.Name + s.Weight));
  59. strRowtg.Append("{");
  60. strRowtg.Append("\"OrderNo\":\"" + evaluationTargetView.Name + "\"");
  61. strRowtg.Append(",\"EvaluationProjectName\":\"\"");
  62. strRowtg.Append(",\"Weight\":\"" + evaluationTargetView.Weight + "\"");
  63. strRowtg.Append(",\"EvaluationNormName\":\"" + tgNormNames + "\"");
  64. strRowtg.Append("}");
  65. if (string.IsNullOrEmpty(strRows.ToString()))
  66. {
  67. strRows.Append(strRowtg);
  68. }
  69. else
  70. {
  71. strRows.Append("," + strRowtg);
  72. }
  73. var evaluationProjectViewList = EvaluationProjectServices.Value.GetEvaluationProjectViewList(configuretView, null, null, evaluationTableID, evaluationTargetView.EvaluationTargetID)
  74. .Select(x => new { x.EvaluationProjectID, x.OrderNo, x.Name, x.Weight }).ToList();
  75. int j = 1;
  76. var evaluationNormDetailViewList = EvaluationNormServices.Value.GetEvaluationNormDetailViewList(configuretView, evaluationTargetView.EvaluationNormID).ToList();
  77. foreach (var evaluationProjectView in evaluationProjectViewList)
  78. {
  79. var prNormNames = string.Join(" ", evaluationNormDetailViewList.Select((s, index) => s.Name + "<input type='radio' name='" + j + "" + i + "'>"));
  80. StringBuilder strRowpr = new StringBuilder();
  81. strRowpr.Append("{");
  82. strRowpr.Append("\"OrderNo\":\"" + evaluationProjectView.OrderNo + "\"");
  83. strRowpr.Append(",\"EvaluationProjectName\":\"" + evaluationProjectView.Name + "\"");
  84. strRowpr.Append(",\"Weight\":\"" + evaluationProjectView.Weight + "\"");
  85. strRowpr.Append(",\"EvaluationNormName\":\"" + prNormNames + "\"");
  86. strRowpr.Append("}");
  87. if (string.IsNullOrEmpty(strRows.ToString()))
  88. {
  89. strRows.Append(strRowpr);
  90. }
  91. else
  92. {
  93. strRows.Append("," + strRowpr);
  94. }
  95. j++;
  96. }
  97. i++;
  98. }
  99. return Json(new { rows = strRows.ToString(), total = 0 }, JsonRequestBehavior.AllowGet);
  100. }
  101. /// <summary>
  102. /// Excel导出
  103. /// </summary>
  104. /// <returns></returns>
  105. [HttpPost]
  106. public ActionResult Excel()
  107. {
  108. NpoiExcelHelper neh = new NpoiExcelHelper();
  109. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  110. var evaluationParticipateTypeID = Request.Form["EvaluationParticipateTypeDropdown"].ParseStrTo<Guid>();
  111. var evaluationTypeID = Request.Form["EvaluationTypeDropdown"].ParseStrTo<Guid>();
  112. var evaluationTableID = Request.Form["EvaluationTableDropdown"].ParseStrTo<Guid>();
  113. return Json(new ReturnMessage()
  114. {
  115. IsSuccess = true,
  116. Message = "导出成功。"
  117. });
  118. }
  119. }
  120. }