using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using System.Text; using System.Collections; using Bowin.Common.Utility; using Bowin.Web.Controls.Mvc; using EMIS.Utility; using EMIS.Web.Controls; using EMIS.ViewModel; using EMIS.ViewModel.EvaluationManage.EvaluationTable; using EMIS.CommonLogic.EvaluationManage.EvaluationTable; namespace EMIS.Web.Controllers.EvaluationManage.EvaluationTable { [Authorization] public class EvaluationFormController : Controller { public Lazy EvaluationTargetServices { get; set; } public Lazy EvaluationNormServices { get; set; } public Lazy EvaluationProjectServices { get; set; } /// /// 评价表格页面 /// /// public ActionResult List() { return View(); } /// /// 评价表格标题 /// /// public JsonResult FormTitle() { ArrayList formTitleList = new ArrayList(); formTitleList.Add(new { field = "OrderNo", title = "次序", align = "center", width = "150" }); formTitleList.Add(new { field = "EvaluationProjectName", title = "评价项目", align = "center", width = "350", formatter = "formatCellTooltip" }); formTitleList.Add(new { field = "Weight", title = "权重", align = "center", width = "100" }); formTitleList.Add(new { field = "EvaluationNormName", title = "评分标准", align = "center", width = "250" }); return Json(new { UpTitle = JsonHelper.ToJSON(formTitleList) }, JsonRequestBehavior.AllowGet); } /// /// 评价表格内容 /// /// public JsonResult Content(Guid? evaluationTableID) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null); var evaluationTargetViewList = EvaluationTargetServices.Value.GetEvaluationTargetViewList(configuretView, null, null, evaluationTableID, null) .Select(x => new { x.EvaluationTargetID, x.EvaluationNormID, x.Name, x.Weight }).ToList(); int i = 1; StringBuilder strRows = new StringBuilder(); foreach (var evaluationTargetView in evaluationTargetViewList) { StringBuilder strRowtg = new StringBuilder(); var tgNormNames = string.Join(" ", EvaluationNormServices.Value.GetEvaluationNormDetailViewList(configuretView, evaluationTargetView.EvaluationNormID).Select(s => s.Name + s.Weight)); strRowtg.Append("{"); strRowtg.Append("\"OrderNo\":\"" + evaluationTargetView.Name + "\""); strRowtg.Append(",\"EvaluationProjectName\":\"\""); strRowtg.Append(",\"Weight\":\"" + evaluationTargetView.Weight + "\""); strRowtg.Append(",\"EvaluationNormName\":\"" + tgNormNames + "\""); strRowtg.Append("}"); if (string.IsNullOrEmpty(strRows.ToString())) { strRows.Append(strRowtg); } else { strRows.Append("," + strRowtg); } var evaluationProjectViewList = EvaluationProjectServices.Value.GetEvaluationProjectViewList(configuretView, null, null, evaluationTableID, evaluationTargetView.EvaluationTargetID) .Select(x => new { x.EvaluationProjectID, x.OrderNo, x.Name, x.Weight }).ToList(); int j = 1; var evaluationNormDetailViewList = EvaluationNormServices.Value.GetEvaluationNormDetailViewList(configuretView, evaluationTargetView.EvaluationNormID).ToList(); foreach (var evaluationProjectView in evaluationProjectViewList) { var prNormNames = string.Join(" ", evaluationNormDetailViewList.Select((s, index) => s.Name + "")); StringBuilder strRowpr = new StringBuilder(); strRowpr.Append("{"); strRowpr.Append("\"OrderNo\":\"" + evaluationProjectView.OrderNo + "\""); strRowpr.Append(",\"EvaluationProjectName\":\"" + evaluationProjectView.Name + "\""); strRowpr.Append(",\"Weight\":\"" + evaluationProjectView.Weight + "\""); strRowpr.Append(",\"EvaluationNormName\":\"" + prNormNames + "\""); strRowpr.Append("}"); if (string.IsNullOrEmpty(strRows.ToString())) { strRows.Append(strRowpr); } else { strRows.Append("," + strRowpr); } j++; } i++; } return Json(new { rows = strRows.ToString(), total = 0 }, JsonRequestBehavior.AllowGet); } /// /// Excel导出 /// /// [HttpPost] public ActionResult Excel() { NpoiExcelHelper neh = new NpoiExcelHelper(); ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null); var evaluationParticipateTypeID = Request.Form["EvaluationParticipateTypeDropdown"].ParseStrTo(); var evaluationTypeID = Request.Form["EvaluationTypeDropdown"].ParseStrTo(); var evaluationTableID = Request.Form["EvaluationTableDropdown"].ParseStrTo(); return Json(new ReturnMessage() { IsSuccess = true, Message = "导出成功。" }); } } }