CaseManager.razor.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. private async Task GuidangCalMonth(CalMonth calMonth)
  75. {
  76. //还未实现,此处需要添加归档代码
  77. await _ItemService.FinishedCalMonth(calMonth);
  78. await Task.Delay(1);
  79. StateHasChanged();
  80. }
  81. private int serialNumber(int pageIndex, int pageSize, int id)
  82. {
  83. int iIndex = 0;
  84. foreach (PerformanceItem sf in _Datas)
  85. {
  86. iIndex++;
  87. if (sf.Id == id)
  88. {
  89. break;
  90. }
  91. }
  92. return (pageIndex - 1) * pageSize + iIndex;
  93. }
  94. bool isDownloading = false;
  95. private async Task ExportDataAsync(CalMonth calMonth)
  96. {
  97. isDownloading = true;
  98. var fileData = await _ItemService.ExportData(calMonth.Id);
  99. while (!fileData.Finished)
  100. {
  101. fileData = await _ItemService.getExportDataProcessing(fileData.Id);
  102. await Task.Delay(20);
  103. }
  104. NavigationManager.NavigateTo($"{_configuration.GetValue<string>("APIUrl")}FileProcesTask/Download?Id={fileData.Id}");
  105. isDownloading = false;
  106. }
  107. private async Task ExportCurrentMonthJXList()
  108. {
  109. isDownloading = true;
  110. var fileData = await _ItemService.CurrentData2Excel();
  111. while (!fileData.Finished)
  112. {
  113. fileData = await _ItemService.getExportDataProcessing(fileData.Id);
  114. await Task.Delay(20);
  115. }
  116. NavigationManager.NavigateTo($"{_configuration.GetValue<string>("APIUrl")}FileProcesTask/Download?Id={fileData.Id}");
  117. isDownloading = false;
  118. }
  119. async Task OnRefresh(PerformanceItem item)
  120. {
  121. item = await _ItemService.RefreshItem(item.Id);
  122. StateHasChanged();
  123. }
  124. async Task<string> CalItemJX(PerformanceItem item)
  125. {
  126. return null;
  127. }
  128. }
  129. }