CaseManager.razor.cs 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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. protected override async Task OnInitializedAsync()
  46. {
  47. await _authService.CanVisitResource();
  48. await iconService.CreateFromIconfontCN("//at.alicdn.com/t/font_8d5l8fzk5b87iudi.js");
  49. calMonths = await _CalMonthService.GetAll();
  50. if (calMonths != null && calMonths.Count > 0)
  51. {
  52. await calMonthClick(calMonths[0]);
  53. }
  54. }
  55. private async Task HandleTableChange(QueryModel<PerformanceItem> queryModel)
  56. {
  57. var _user = await _userService.GetUser();
  58. _loading = true;
  59. var data = await _ItemService.Query(HandlingCalMonth, queryModel);
  60. _Datas = data.Results;
  61. _total = data.TotalCount;
  62. _loading = false;
  63. StateHasChanged();
  64. }
  65. private async Task calMonthClick(CalMonth calMonth)
  66. {
  67. HandlingCalMonth = calMonth;
  68. var data = await _ItemService.Query(HandlingCalMonth,_pageIndex ,_pageSize,null);
  69. _Datas = data.Results;
  70. _total = data.TotalCount;
  71. _loading = false;
  72. StateHasChanged();
  73. }
  74. bool isGuiDang = false;
  75. private async Task GuidangCalMonth(CalMonth calMonth)
  76. {
  77. isGuiDang = true;
  78. //还未实现,此处需要添加归档代码
  79. var fileData = await _ItemService.FinishedCalMonth(calMonth);
  80. while (!fileData.Finished)
  81. {
  82. fileData = await _ItemService.getExportDataProcessing(fileData.Id);
  83. await Task.Delay(1000);
  84. }
  85. if (!string.IsNullOrEmpty(fileData.ErrorMessage))
  86. {
  87. //calMonths = await _CalMonthService.GetAll();
  88. calMonth.Status = 4;
  89. //calMonthClick(calMonth);
  90. }
  91. isGuiDang = false;
  92. StateHasChanged();
  93. }
  94. private int serialNumber(int pageIndex, int pageSize, int id)
  95. {
  96. int iIndex = 0;
  97. foreach (PerformanceItem sf in _Datas)
  98. {
  99. iIndex++;
  100. if (sf.Id == id)
  101. {
  102. break;
  103. }
  104. }
  105. return (pageIndex - 1) * pageSize + iIndex;
  106. }
  107. bool isDownloading = false;
  108. private async Task ExportDataAsync(CalMonth calMonth)
  109. {
  110. isDownloading = true;
  111. var fileData = await _ItemService.ExportData(calMonth.Id);
  112. while (!fileData.Finished)
  113. {
  114. fileData = await _ItemService.getExportDataProcessing(fileData.Id);
  115. await Task.Delay(20);
  116. }
  117. NavigationManager.NavigateTo($"{_configuration.GetValue<string>("APIUrl")}FileProcesTask/Download?Id={fileData.Id}");
  118. isDownloading = false;
  119. }
  120. private async Task ExportJXDataAsync(CalMonth calMonth)
  121. {
  122. isDownloading = true;
  123. var fileData = await _ItemService.ExportJXReport(calMonth.Year,calMonth.Month);
  124. while (!fileData.Finished)
  125. {
  126. fileData = await _ItemService.getExportDataProcessing(fileData.Id);
  127. await Task.Delay(20);
  128. }
  129. NavigationManager.NavigateTo($"{_configuration.GetValue<string>("APIUrl")}FileProcesTask/Download?Id={fileData.Id}");
  130. isDownloading = false;
  131. }
  132. private async Task ExportCurrentMonthJXList()
  133. {
  134. isDownloading = true;
  135. var fileData = await _ItemService.CurrentData2Excel(HandlingCalMonth);
  136. while (!fileData.Finished)
  137. {
  138. fileData = await _ItemService.getExportDataProcessing(fileData.Id);
  139. await Task.Delay(20);
  140. }
  141. NavigationManager.NavigateTo($"{_configuration.GetValue<string>("APIUrl")}FileProcesTask/Download?Id={fileData.Id}");
  142. isDownloading = false;
  143. }
  144. async Task OnRefresh(PerformanceItem item)
  145. {
  146. item = await _ItemService.RefreshItem(item.Id);
  147. table.ReloadData();
  148. StateHasChanged();
  149. }
  150. async Task<string> CalItemJX(PerformanceItem item)
  151. {
  152. return null;
  153. }
  154. }
  155. }