Welcome.razor.cs 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  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(HandlingMonth.Id, _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. var retData = await _atService.ReviewerAppeal(templateOptions);
  116. if (retData.Success)
  117. {
  118. await _modalRef.CloseAsync();
  119. AppealRecords = await _atService.GetUserAppeals(_CurrentUser.Userid);
  120. StateHasChanged();
  121. var SuccessConfig = new ConfirmOptions()
  122. {
  123. Content = @"审核成功!"
  124. };
  125. //modalConfig.Footer = null;
  126. modalConfig.DestroyOnClose = true;
  127. _ModalService.Success(SuccessConfig);
  128. }
  129. else
  130. {
  131. throw new ApplicationException(retData.ErrorMessage);
  132. }
  133. }
  134. catch (Exception ex)
  135. {
  136. _ModalService.Error(new ConfirmOptions()
  137. {
  138. Title = "审核错误",
  139. Content = ex.Message,
  140. });
  141. }
  142. };
  143. _modalRef.OnCancel = () =>
  144. {
  145. return Task.CompletedTask;
  146. };
  147. _modalRef.OnClose = () =>
  148. {
  149. return Task.CompletedTask;
  150. };
  151. StateHasChanged();
  152. }
  153. int serialNumber(ProjectInfo project)
  154. {
  155. int i = 0;
  156. foreach(var p in WaitingReviewProjects)
  157. {
  158. i++;
  159. if(p.CaseNo == project.CaseNo)
  160. {
  161. break;
  162. }
  163. }
  164. return i;
  165. }
  166. #region 审核人变更
  167. bool _visible;
  168. List<Staff> _Staffs;
  169. AppealRecord _ChangedRecord;
  170. async Task ShowChangeReviewer(AppealRecord appealRecord)
  171. {
  172. _Staffs = await _userService.GetReviewers(appealRecord.ItemId, appealRecord.TypeId);
  173. _ChangedRecord = appealRecord;
  174. _visible = true;
  175. }
  176. private async System.Threading.Tasks.Task HandleOk(MouseEventArgs e)
  177. {
  178. var response = await _atService.ChangeReviewer(_ChangedRecord);
  179. if (response.Success)
  180. {
  181. AppealRecords = await _atService.GetUserAppeals(_CurrentUser.Userid);
  182. StateHasChanged();
  183. _visible = false;
  184. }
  185. else
  186. {
  187. await _msgService.Error(response.ErrorMessage);
  188. }
  189. }
  190. private void HandleCancel(MouseEventArgs e)
  191. {
  192. _visible = false;
  193. }
  194. #endregion
  195. }
  196. }