Welcome.razor.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  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. using Microsoft.JSInterop;
  14. using System.Linq;
  15. namespace wispro.sp.web.Pages
  16. {
  17. public partial class Welcome
  18. {
  19. private readonly EditableLink[] _links =
  20. {
  21. new EditableLink {Title = "Operation 1", Href = ""},
  22. new EditableLink {Title = "Operation 2", Href = ""},
  23. new EditableLink {Title = "Operation 3", Href = ""},
  24. new EditableLink {Title = "Operation 4", Href = ""},
  25. new EditableLink {Title = "Operation 5", Href = ""},
  26. new EditableLink {Title = "Operation 6", Href = ""}
  27. };
  28. private ActivitiesType[] _activities = { };
  29. private NoticeType[] _projectNotice = { };
  30. private CurrentUser _CurrentUser;
  31. private List<AppealRecord> AppealRecords = new List<AppealRecord>();
  32. private List<ProjectInfo> WaitingReviewProjects = new List<ProjectInfo>();
  33. [Inject] public IProjectService ProjectService { get; set; }
  34. [Inject] public IUserService _userService { get; set; }
  35. [Inject] protected AppealTypeService _atService { get; set; }
  36. private ModalRef _modalRef;
  37. [Inject] ModalService _ModalService { get; set; }
  38. [Inject] MessageService _msgService { get; set; }
  39. private Models.CurrentUser _user;
  40. [Inject] PerformanceItemServices _ItemService { get; set; }
  41. [Inject] CalMonthServices CalMonthServices { get; set; }
  42. [Inject] IUserService UserService { get; set; }
  43. [Inject] IJSRuntime JSRuntime { get; set; }
  44. int waitingHandleItems = 0;
  45. int allItems = 0;
  46. CalMonth HandlingMonth = null;
  47. protected AntDesign.Table<AppealRecord> table;
  48. int _total;
  49. int _pageIndex = 1;
  50. int _pageSize = 10;
  51. protected override async System.Threading.Tasks.Task OnInitializedAsync()
  52. {
  53. //await base.OnInitializedAsync();
  54. _CurrentUser =await _userService.GetUser();
  55. //_user = _CurrentUser;
  56. HandlingMonth = await CalMonthServices.GetHandlingMonth();
  57. if (HandlingMonth != null)
  58. {
  59. //Console.WriteLine(System.Text.Json.JsonSerializer.Serialize())
  60. var data = await _ItemService.Query(HandlingMonth.Id, _CurrentUser.Userid.Value, jxType.doing
  61. ,null);
  62. waitingHandleItems = data.TotalCount;
  63. }
  64. var data1 = await _ItemService.GetMyList(_CurrentUser.Userid.Value, jxType.all);
  65. allItems = data1.TotalCount;
  66. if (_CurrentUser != null)
  67. {
  68. AppealRecords = await _atService.GetUserAppeals(_CurrentUser.Userid);
  69. _total = AppealRecords.Count;
  70. }
  71. WaitingReviewProjects = await ProjectService.GetWaitingReviewProjects();
  72. StateHasChanged();
  73. }
  74. private int serialNumber(int pageIndex, int pageSize, AppealRecord appealRecord)
  75. {
  76. int iIndex = 0;
  77. foreach (AppealRecord sf in AppealRecords)
  78. {
  79. iIndex++;
  80. if (sf == appealRecord)
  81. {
  82. break;
  83. }
  84. }
  85. return (pageIndex - 1) * pageSize + iIndex;
  86. }
  87. private void HandlePageChange(PaginationEventArgs args)
  88. {
  89. if (_pageIndex != args.Page)
  90. {
  91. _pageIndex = args.Page;
  92. }
  93. if (_pageSize != args.PageSize)
  94. {
  95. _pageSize = args.PageSize;
  96. }
  97. }
  98. async void ShowModel(AppealRecord appealRecord)
  99. {
  100. var templateOptions = new Models.ReviewerAppealModel();
  101. await templateOptions.Init(_atService, appealRecord.Id);
  102. Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(templateOptions));
  103. if (templateOptions.AppealRecord.Type.Name == "案件系数复核")
  104. {
  105. var ifValue = templateOptions.CreateAppealFieldValues.Where(iv => iv.InputField.FieldName == "案件系数").FirstOrDefault();
  106. if (ifValue.Value == "A" || ifValue.Value == "S")
  107. {
  108. var temCssObj = new CaseCoefficientStatistics()
  109. {
  110. Totals = templateOptions.cssObject.Totals,
  111. SCount = templateOptions.cssObject.SCount,
  112. ACount = templateOptions.cssObject.ACount,
  113. customer = templateOptions.cssObject.customer
  114. };
  115. if (ifValue != null)
  116. {
  117. switch (ifValue.Value)
  118. {
  119. case "S":
  120. temCssObj.SCount += 1;
  121. break;
  122. case "A":
  123. temCssObj.ACount += 1;
  124. break;
  125. }
  126. }
  127. switch (templateOptions.Item.CaseCoefficient)
  128. {
  129. case "S":
  130. temCssObj.SCount -= 1;
  131. break;
  132. case "A":
  133. temCssObj.ACount -= 1;
  134. break;
  135. }
  136. if (temCssObj.isExceedingLimit())
  137. {
  138. var reviewer = await UserService.GetUser(templateOptions.AppealRecord.ReviewerId.Value);
  139. if (reviewer.Name != "钟子敏")
  140. {
  141. var SuccessConfig1 = new ConfirmOptions()
  142. {
  143. Content = $"客户:【{temCssObj.customer.Name}】新申请案件系数A或者S超出阈值,请将审核人变更为“钟子敏”!"
  144. };
  145. _ModalService.Error(SuccessConfig1);
  146. //await JSRuntime.InvokeAsync<object>("alert", $"客户:【{temCssObj.customer.Name}】新申请案件系数A或者S超出阈值,请将审核人变更为“钟子敏”!");
  147. return;
  148. }
  149. }
  150. }
  151. }
  152. var modalConfig = new ModalOptions();
  153. modalConfig.Title = $"{appealRecord.Type.Name}审核" ;
  154. modalConfig.Width = 650;
  155. //modalConfig.Footer = null;
  156. modalConfig.DestroyOnClose = true;
  157. modalConfig.MaskClosable = false;
  158. _modalRef = await _ModalService
  159. .CreateModalAsync<ReviewerAppeal, Models.ReviewerAppealModel>(modalConfig, templateOptions);
  160. _modalRef.OnOpen = () =>
  161. {
  162. return Task.CompletedTask;
  163. };
  164. _modalRef.OnOk = async () =>
  165. {
  166. try
  167. {
  168. var retData = await _atService.ReviewerAppeal(templateOptions);
  169. if (retData.Success)
  170. {
  171. await _modalRef.CloseAsync();
  172. AppealRecords = await _atService.GetUserAppeals(_CurrentUser.Userid);
  173. StateHasChanged();
  174. var SuccessConfig = new ConfirmOptions()
  175. {
  176. Content = @"审核成功!"
  177. };
  178. //modalConfig.Footer = null;
  179. modalConfig.DestroyOnClose = true;
  180. _ModalService.Success(SuccessConfig);
  181. }
  182. else
  183. {
  184. throw new ApplicationException(retData.ErrorMessage);
  185. }
  186. }
  187. catch (Exception ex)
  188. {
  189. _ModalService.Error(new ConfirmOptions()
  190. {
  191. Title = "审核错误",
  192. Content = ex.Message,
  193. });
  194. }
  195. };
  196. _modalRef.OnCancel = () =>
  197. {
  198. return Task.CompletedTask;
  199. };
  200. _modalRef.OnClose = () =>
  201. {
  202. return Task.CompletedTask;
  203. };
  204. StateHasChanged();
  205. }
  206. int serialNumber(ProjectInfo project)
  207. {
  208. int i = 0;
  209. foreach(var p in WaitingReviewProjects)
  210. {
  211. i++;
  212. if(p.CaseNo == project.CaseNo)
  213. {
  214. break;
  215. }
  216. }
  217. return i;
  218. }
  219. #region 审核人变更
  220. bool _visible;
  221. List<Staff> _Staffs;
  222. AppealRecord _ChangedRecord;
  223. async Task ShowChangeReviewer(AppealRecord appealRecord)
  224. {
  225. _Staffs = await _userService.GetReviewers(appealRecord.ItemId, appealRecord.TypeId);
  226. _ChangedRecord = appealRecord;
  227. _visible = true;
  228. }
  229. private async System.Threading.Tasks.Task HandleOk(MouseEventArgs e)
  230. {
  231. var response = await _atService.ChangeReviewer(_ChangedRecord);
  232. if (response.Success)
  233. {
  234. AppealRecords = await _atService.GetUserAppeals(_CurrentUser.Userid);
  235. StateHasChanged();
  236. _visible = false;
  237. }
  238. else
  239. {
  240. await _msgService.Error(response.ErrorMessage);
  241. }
  242. }
  243. private void HandleCancel(MouseEventArgs e)
  244. {
  245. _visible = false;
  246. }
  247. #endregion
  248. }
  249. }