ProjectReviewer.razor.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. using AntDesign;
  2. using Microsoft.AspNetCore.Components;
  3. using Microsoft.AspNetCore.Components.Web;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Threading.Tasks;
  8. using wispro.sp.entity;
  9. using wispro.sp.share;
  10. using wispro.sp.web.Services;
  11. namespace wispro.sp.web.Pages.Project
  12. {
  13. public partial class ProjectReviewer
  14. {
  15. private List<ProjectContents> projectContents;
  16. private ProjectInfo projectInfo;
  17. private List<ProjectInfo> waitingReviewProjects;
  18. private ViewProjectWorkContent editObj;
  19. [Parameter]
  20. public string ProjectNo { get; set; }
  21. [Inject]
  22. IProjectService projectService { get; set; }
  23. [Inject]
  24. CalMonthServices calMonthServices { get; set; }
  25. [Inject] public MessageService _message { get; set; }
  26. [Inject] NavigationManager _NavigationManager { get; set; }
  27. protected async override Task OnInitializedAsync()
  28. {
  29. CalMonth cal =await calMonthServices.GetHandlingMonth();
  30. if (!string.IsNullOrEmpty(ProjectNo))
  31. {
  32. projectContents = await projectService.GetProjectCanReviewWorkContent(ProjectNo, cal);
  33. HistroyContents = await projectService.GetProjectHistroy(ProjectNo);
  34. }
  35. else
  36. {
  37. waitingReviewProjects = await projectService.GetWaitingReviewProjects();
  38. }
  39. await base.OnInitializedAsync();
  40. }
  41. void startEdit(ViewProjectWorkContent pp)
  42. {
  43. editObj = pp;
  44. }
  45. void stopEdit()
  46. {
  47. editObj = null;
  48. }
  49. void ContentChanged(ViewProjectWorkContent pp)
  50. {
  51. pp.modifyState = ModifyState.Modified;
  52. }
  53. void OnInput(ChangeEventArgs e)
  54. {
  55. if (editObj != null)
  56. {
  57. editObj.modifyState = ModifyState.Modified;
  58. }
  59. }
  60. async void Save()
  61. {
  62. var ret = await projectService.ReviewProjectWorkContent(projectContents);
  63. if (ret.Success)
  64. {
  65. _NavigationManager.NavigateTo("/Home");
  66. await _message.Success("保存成功!");
  67. }
  68. else
  69. {
  70. await _message.Error(ret.ErrorMessage);
  71. }
  72. }
  73. List<ProjectContents> HistroyContents;
  74. bool _ShowHistory = false;
  75. async void ReviewHistory()
  76. {
  77. if (HistroyContents == null)
  78. {
  79. HistroyContents = await projectService.GetProjectHistroy(ProjectNo);
  80. }
  81. _ShowHistory = true;
  82. StateHasChanged();
  83. }
  84. void CloseDetail()
  85. {
  86. _ShowHistory = false;
  87. }
  88. private List<CalMonth> GetMonth(List<ProjectContents> projectContents)
  89. {
  90. List<CalMonth> monthList = new List<CalMonth>();
  91. foreach (var projectContentsItem in projectContents)
  92. {
  93. CalMonth calMonth = projectContentsItem.ProjectContentRecord.CalMonth;
  94. var temMonth =monthList.FirstOrDefault(c => c.Month == calMonth.Month && c.Year == calMonth.Year);
  95. if (temMonth == null)
  96. {
  97. monthList.Add(calMonth);
  98. }
  99. }
  100. return monthList;
  101. }
  102. private List<ProjectContents> GetByMonth(CalMonth calMonth, List<ProjectContents> projectContents)
  103. {
  104. return projectContents.Where(p => p.ProjectContentRecord.CalMonthId == calMonth.Id).ToList();
  105. }
  106. private string GetPointString(ProjectContentRecord record,string CaseXS)
  107. {
  108. if(record != null)
  109. {
  110. switch (CaseXS)
  111. {
  112. case "S":
  113. return record.PointS.HasValue ? record.PointS.Value.ToString() : "__";
  114. break;
  115. case "A":
  116. return record.PointA.HasValue ? record.PointA.Value.ToString() : "__";
  117. break;
  118. case "B":
  119. return record.PointB.HasValue ? record.PointB.Value.ToString() : "__";
  120. break;
  121. case "C":
  122. return record.PointC.HasValue ? record.PointC.Value.ToString() : "__";
  123. break;
  124. case "D":
  125. return record.PointD.HasValue ? record.PointD.Value.ToString() : "__";
  126. break;
  127. }
  128. }
  129. return "";
  130. }
  131. }
  132. }