Welcome.razor.cs 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. using System.Threading.Tasks;
  2. using wispro.sp.web.Models;
  3. using wispro.sp.web.Services;
  4. using Microsoft.AspNetCore.Components;
  5. using wispro.sp.web.Components;
  6. using System.Collections.Generic;
  7. using wispro.sp.entity;
  8. using System.Text.Json;
  9. using AntDesign;
  10. using System;
  11. using wispro.sp.share;
  12. using Microsoft.AspNetCore.Components.Web;
  13. namespace wispro.sp.web.Pages
  14. {
  15. public partial class Welcome
  16. {
  17. private readonly EditableLink[] _links =
  18. {
  19. new EditableLink {Title = "Operation 1", Href = ""},
  20. new EditableLink {Title = "Operation 2", Href = ""},
  21. new EditableLink {Title = "Operation 3", Href = ""},
  22. new EditableLink {Title = "Operation 4", Href = ""},
  23. new EditableLink {Title = "Operation 5", Href = ""},
  24. new EditableLink {Title = "Operation 6", Href = ""}
  25. };
  26. private ActivitiesType[] _activities = { };
  27. private NoticeType[] _projectNotice = { };
  28. private CurrentUser _CurrentUser;
  29. private List<AppealRecord> AppealRecords = new List<AppealRecord>();
  30. private List<ProjectInfo> WaitingReviewProjects = new List<ProjectInfo>();
  31. [Inject] public IProjectService ProjectService { get; set; }
  32. [Inject] public IUserService _userService { get; set; }
  33. [Inject] protected AppealTypeService _atService { get; set; }
  34. private ModalRef _modalRef;
  35. [Inject] ModalService _ModalService { get; set; }
  36. [Inject] MessageService _msgService { get; set; }
  37. private Models.CurrentUser _user;
  38. [Inject] PerformanceItemServices _ItemService { get; set; }
  39. [Inject] CalMonthServices CalMonthServices { get; set; }
  40. int waitingHandleItems = 0;
  41. int allItems = 0;
  42. CalMonth HandlingMonth = null;
  43. protected AntDesign.Table<AppealRecord> table;
  44. int _total;
  45. int _pageIndex = 1;
  46. int _pageSize = 10;
  47. protected override async System.Threading.Tasks.Task OnInitializedAsync()
  48. {
  49. //await base.OnInitializedAsync();
  50. _CurrentUser =await _userService.GetUser();
  51. //_user = _CurrentUser;
  52. HandlingMonth = await CalMonthServices.GetHandlingMonth();
  53. if (HandlingMonth != null)
  54. {
  55. //Console.WriteLine(System.Text.Json.JsonSerializer.Serialize())
  56. var data = await _ItemService.Query(_CurrentUser.Userid.Value, jxType.doing
  57. ,null);
  58. waitingHandleItems = data.TotalCount;
  59. }
  60. var data1 = await _ItemService.GetMyList(_CurrentUser.Userid.Value, jxType.all);
  61. allItems = data1.TotalCount;
  62. if (_CurrentUser != null)
  63. {
  64. AppealRecords = await _atService.GetUserAppeals(_CurrentUser.Userid);
  65. _total = AppealRecords.Count;
  66. }
  67. WaitingReviewProjects = await ProjectService.GetWaitingReviewProjects();
  68. StateHasChanged();
  69. }
  70. private int serialNumber(int pageIndex, int pageSize, AppealRecord appealRecord)
  71. {
  72. int iIndex = 0;
  73. foreach (AppealRecord sf in AppealRecords)
  74. {
  75. iIndex++;
  76. if (sf == appealRecord)
  77. {
  78. break;
  79. }
  80. }
  81. return (pageIndex - 1) * pageSize + iIndex;
  82. }
  83. private void HandlePageChange(PaginationEventArgs args)
  84. {
  85. if (_pageIndex != args.Page)
  86. {
  87. _pageIndex = args.Page;
  88. }
  89. if (_pageSize != args.PageSize)
  90. {
  91. _pageSize = args.PageSize;
  92. }
  93. }
  94. async void ShowModel(AppealRecord appealRecord)
  95. {
  96. var templateOptions = new Models.ReviewerAppealModel();
  97. await templateOptions.Init(_atService, appealRecord.Id);
  98. //Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(templateOptions));
  99. var modalConfig = new ModalOptions();
  100. modalConfig.Title = $"{appealRecord.Type.Name}审核" ;
  101. modalConfig.Width = 650;
  102. //modalConfig.Footer = null;
  103. modalConfig.DestroyOnClose = true;
  104. modalConfig.MaskClosable = false;
  105. _modalRef = await _ModalService
  106. .CreateModalAsync<ReviewerAppeal, Models.ReviewerAppealModel>(modalConfig, templateOptions);
  107. _modalRef.OnOpen = () =>
  108. {
  109. return Task.CompletedTask;
  110. };
  111. _modalRef.OnOk = async () =>
  112. {
  113. try
  114. {
  115. await _atService.ReviewerAppeal(templateOptions);
  116. await _modalRef.CloseAsync();
  117. AppealRecords = await _atService.GetUserAppeals(_CurrentUser.Userid);
  118. StateHasChanged();
  119. var SuccessConfig = new ConfirmOptions()
  120. {
  121. Content = @"审核成功!"
  122. };
  123. //modalConfig.Footer = null;
  124. modalConfig.DestroyOnClose = true;
  125. _ModalService.Success(SuccessConfig);
  126. }
  127. catch (Exception ex)
  128. {
  129. _ModalService.Error(new ConfirmOptions()
  130. {
  131. Title = "审核错误",
  132. Content = ex.Message,
  133. });
  134. }
  135. };
  136. _modalRef.OnCancel = () =>
  137. {
  138. return Task.CompletedTask;
  139. };
  140. _modalRef.OnClose = () =>
  141. {
  142. return Task.CompletedTask;
  143. };
  144. StateHasChanged();
  145. }
  146. int serialNumber(ProjectInfo project)
  147. {
  148. int i = 0;
  149. foreach(var p in WaitingReviewProjects)
  150. {
  151. i++;
  152. if(p.CaseNo == project.CaseNo)
  153. {
  154. break;
  155. }
  156. }
  157. return i;
  158. }
  159. #region 审核人变更
  160. bool _visible;
  161. List<Staff> _Staffs;
  162. AppealRecord _ChangedRecord;
  163. async Task ShowChangeReviewer(AppealRecord appealRecord)
  164. {
  165. _Staffs = await _userService.GetReviewers(appealRecord.ItemId, appealRecord.TypeId);
  166. _ChangedRecord = appealRecord;
  167. _visible = true;
  168. }
  169. private async System.Threading.Tasks.Task HandleOk(MouseEventArgs e)
  170. {
  171. var response = await _atService.ChangeReviewer(_ChangedRecord);
  172. if (response.Success)
  173. {
  174. AppealRecords = await _atService.GetUserAppeals(_CurrentUser.Userid);
  175. StateHasChanged();
  176. _visible = false;
  177. }
  178. else
  179. {
  180. await _msgService.Error(response.ErrorMessage);
  181. }
  182. }
  183. private void HandleCancel(MouseEventArgs e)
  184. {
  185. _visible = false;
  186. }
  187. #endregion
  188. }
  189. }