CaseManager.razor.cs 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. using AntDesign;
  2. using AntDesign.TableModels;
  3. using Microsoft.AspNetCore.Components;
  4. using Microsoft.Extensions.Configuration;
  5. using ServiceStack;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Threading.Tasks;
  10. using wispro.sp.entity;
  11. using wispro.sp.share;
  12. using wispro.sp.web.Services;
  13. namespace wispro.sp.web.Pages.AppCase
  14. {
  15. public partial class CaseManager
  16. {
  17. [Inject]
  18. protected IconService iconService { get; set; }
  19. public TableFilter<string>[] CaseCoeFilters = new TableFilter<string>[] {
  20. new() { Text = "S", Value = "S" },
  21. new() { Text = "A", Value = "A" },
  22. new() { Text = "B", Value = "B" },
  23. new() { Text = "C", Value = "C" },
  24. new() { Text = "D", Value = "D" }
  25. };
  26. [Inject]
  27. protected AppealTypeService apTypeService { get; set; }
  28. private List<PerformanceItem> _Datas;
  29. private List<StaffStatistics> MyStatistics;
  30. IEnumerable<PerformanceItem> selectedItems = new List<PerformanceItem>();
  31. private CalMonth HandlingCalMonth;
  32. private List<CalMonth> calMonths;
  33. int _pageIndex = 1;
  34. int _pageSize = 10;
  35. int _total;
  36. bool _loading = false;
  37. private Table<PerformanceItem> table;
  38. [Inject] public PerformanceItemServices _ItemService { get; set; }
  39. [Inject] public MessageService _message { get; set; }
  40. [Inject] protected NavigationManager NavigationManager { get; set; }
  41. [Inject] protected IUserService _userService { get; set; }
  42. [Inject] protected CalMonthServices _CalMonthService { get; set; }
  43. [Inject] IConfiguration _configuration { get; set; }
  44. [Inject] protected IAuthService _authService { get; set; }
  45. [Inject] protected AppealTypeService AppealTypeService { get;set; }
  46. protected override async Task OnInitializedAsync()
  47. {
  48. await _authService.CanVisitResource();
  49. await iconService.CreateFromIconfontCN("//at.alicdn.com/t/font_8d5l8fzk5b87iudi.js");
  50. calMonths = await _CalMonthService.GetAll();
  51. if (calMonths != null && calMonths.Count > 0)
  52. {
  53. await calMonthClick(calMonths[0]);
  54. }
  55. }
  56. private async Task HandleTableChange(QueryModel<PerformanceItem> queryModel)
  57. {
  58. var _user = await _userService.GetUser();
  59. _loading = true;
  60. var data = await _ItemService.Query(HandlingCalMonth, queryModel);
  61. _Datas = data.Results;
  62. _total = data.TotalCount;
  63. _loading = false;
  64. StateHasChanged();
  65. }
  66. private async Task calMonthClick(CalMonth calMonth)
  67. {
  68. HandlingCalMonth = calMonth;
  69. var data = await _ItemService.Query(HandlingCalMonth,_pageIndex ,_pageSize,null);
  70. _Datas = data.Results;
  71. _total = data.TotalCount;
  72. _loading = false;
  73. StateHasChanged();
  74. }
  75. bool isGuiDang = false;
  76. private async Task GuidangCalMonth(CalMonth calMonth)
  77. {
  78. isGuiDang = true;
  79. //还未实现,此处需要添加归档代码
  80. var fileData = await _ItemService.FinishedCalMonth(calMonth);
  81. while (!fileData.Finished)
  82. {
  83. fileData = await _ItemService.getExportDataProcessing(fileData.Id);
  84. await Task.Delay(1000);
  85. }
  86. if (!string.IsNullOrEmpty(fileData.ErrorMessage))
  87. {
  88. //calMonths = await _CalMonthService.GetAll();
  89. calMonth.Status = 4;
  90. //calMonthClick(calMonth);
  91. }
  92. isGuiDang = false;
  93. StateHasChanged();
  94. }
  95. private int serialNumber(int pageIndex, int pageSize, int id)
  96. {
  97. int iIndex = 0;
  98. foreach (PerformanceItem sf in _Datas)
  99. {
  100. iIndex++;
  101. if (sf.Id == id)
  102. {
  103. break;
  104. }
  105. }
  106. return (pageIndex - 1) * pageSize + iIndex;
  107. }
  108. bool isDownloading = false;
  109. private async Task ExportDataAsync(CalMonth calMonth)
  110. {
  111. isDownloading = true;
  112. var fileData = await _ItemService.ExportData(calMonth.Id);
  113. while (!fileData.Finished)
  114. {
  115. try
  116. {
  117. fileData = await _ItemService.getExportDataProcessing(fileData.Id);
  118. await Task.Delay(100);
  119. }
  120. catch {
  121. await Task.Delay(1000);
  122. }
  123. }
  124. NavigationManager.NavigateTo($"{_configuration.GetValue<string>("APIUrl")}FileProcesTask/Download?Id={fileData.Id}");
  125. isDownloading = false;
  126. }
  127. private async Task ExportJXDataAsync(CalMonth calMonth)
  128. {
  129. isDownloading = true;
  130. var fileData = await _ItemService.ExportJXReport(calMonth.Year,calMonth.Month);
  131. while (!fileData.Finished)
  132. {
  133. fileData = await _ItemService.getExportDataProcessing(fileData.Id);
  134. await Task.Delay(20);
  135. }
  136. NavigationManager.NavigateTo($"{_configuration.GetValue<string>("APIUrl")}FileProcesTask/Download?Id={fileData.Id}");
  137. isDownloading = false;
  138. }
  139. private async Task ExportCCSDataAsync(CalMonth calMonth)
  140. {
  141. isDownloading = true;
  142. var fileData = await AppealTypeService.ExportCustomerCCSFile(calMonth.Id);
  143. while (!fileData.Finished)
  144. {
  145. fileData = await _ItemService.getExportDataProcessing(fileData.Id);
  146. await Task.Delay(20);
  147. }
  148. NavigationManager.NavigateTo($"{_configuration.GetValue<string>("APIUrl")}FileProcesTask/Download?Id={fileData.Id}");
  149. isDownloading = false;
  150. }
  151. private async Task ExportCurrentMonthJXList()
  152. {
  153. isDownloading = true;
  154. var fileData = await _ItemService.CurrentData2Excel(HandlingCalMonth);
  155. while (!fileData.Finished)
  156. {
  157. fileData = await _ItemService.getExportDataProcessing(fileData.Id);
  158. await Task.Delay(20);
  159. }
  160. NavigationManager.NavigateTo($"{_configuration.GetValue<string>("APIUrl")}FileProcesTask/Download?Id={fileData.Id}");
  161. isDownloading = false;
  162. }
  163. async Task OnRefresh(PerformanceItem item)
  164. {
  165. item = await _ItemService.RefreshItem(item.Id);
  166. table.ReloadData();
  167. StateHasChanged();
  168. }
  169. async Task<string> CalItemJX(PerformanceItem item)
  170. {
  171. return null;
  172. }
  173. }
  174. }