Welcome.razor.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  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. var modalConfig = new ModalOptions();
  104. modalConfig.Title = $"{appealRecord.Type.Name}审核" ;
  105. modalConfig.Width = 650;
  106. //modalConfig.Footer = null;
  107. modalConfig.DestroyOnClose = true;
  108. modalConfig.MaskClosable = false;
  109. _modalRef = await _ModalService
  110. .CreateModalAsync<ReviewerAppeal, Models.ReviewerAppealModel>(modalConfig, templateOptions);
  111. _modalRef.OnOpen = () =>
  112. {
  113. return Task.CompletedTask;
  114. };
  115. _modalRef.OnOk = async () =>
  116. {
  117. try
  118. {
  119. if (templateOptions.AppealRecord.Type.Name == "案件系数复核")
  120. {
  121. var ifValue = templateOptions.CreateAppealFieldValues.Where(iv => iv.InputField.FieldName == "案件系数").FirstOrDefault();
  122. if (ifValue.Value == "A" || ifValue.Value == "S")
  123. {
  124. var temCssObj = new CaseCoefficientStatistics()
  125. {
  126. Totals = templateOptions.cssObject.Totals,
  127. SCount = templateOptions.cssObject.SCount,
  128. ACount = templateOptions.cssObject.ACount,
  129. customer = templateOptions.cssObject.customer
  130. };
  131. if (ifValue != null)
  132. {
  133. switch (ifValue.Value)
  134. {
  135. case "S":
  136. temCssObj.SCount += 1;
  137. break;
  138. case "A":
  139. temCssObj.ACount += 1;
  140. break;
  141. }
  142. }
  143. switch (templateOptions.Item.CaseCoefficient)
  144. {
  145. case "S":
  146. temCssObj.SCount -= 1;
  147. break;
  148. case "A":
  149. temCssObj.ACount -= 1;
  150. break;
  151. }
  152. if (temCssObj.isExceedingLimit())
  153. {
  154. var shyjObj = templateOptions.inputFieldValues.Where(i => i.InputField.FieldName == "审核意见").FirstOrDefault();
  155. if (shyjObj!= null && shyjObj.Value == "同意")
  156. {
  157. Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(templateOptions));
  158. var reviewer = await UserService.GetUser(templateOptions.AppealRecord.ReviewerId.Value);
  159. if (reviewer.Name != "钟子敏")
  160. {
  161. var SuccessConfig1 = new ConfirmOptions()
  162. {
  163. Content = $"客户:【{temCssObj.customer.Name}】新申请案件系数A或者S超出阈值,请将审核人变更为“钟子敏”!"
  164. };
  165. _ModalService.Error(SuccessConfig1);
  166. //await JSRuntime.InvokeAsync<object>("alert", $"客户:【{temCssObj.customer.Name}】新申请案件系数A或者S超出阈值,请将审核人变更为“钟子敏”!");
  167. return;
  168. }
  169. }
  170. }
  171. }
  172. }
  173. var retData = await _atService.ReviewerAppeal(templateOptions);
  174. if (retData.Success)
  175. {
  176. await _modalRef.CloseAsync();
  177. AppealRecords = await _atService.GetUserAppeals(_CurrentUser.Userid);
  178. StateHasChanged();
  179. var SuccessConfig = new ConfirmOptions()
  180. {
  181. Content = @"审核成功!"
  182. };
  183. //modalConfig.Footer = null;
  184. modalConfig.DestroyOnClose = true;
  185. _ModalService.Success(SuccessConfig);
  186. }
  187. else
  188. {
  189. throw new ApplicationException(retData.ErrorMessage);
  190. }
  191. }
  192. catch (Exception ex)
  193. {
  194. Console.WriteLine($"Error: {ex}");
  195. _ModalService.Error(new ConfirmOptions()
  196. {
  197. Title = "审核错误",
  198. Content = ex.Message,
  199. });
  200. }
  201. };
  202. _modalRef.OnCancel = () =>
  203. {
  204. return Task.CompletedTask;
  205. };
  206. _modalRef.OnClose = () =>
  207. {
  208. return Task.CompletedTask;
  209. };
  210. StateHasChanged();
  211. }
  212. int serialNumber(ProjectInfo project)
  213. {
  214. int i = 0;
  215. foreach(var p in WaitingReviewProjects)
  216. {
  217. i++;
  218. if(p.CaseNo == project.CaseNo)
  219. {
  220. break;
  221. }
  222. }
  223. return i;
  224. }
  225. #region 审核人变更
  226. bool _visible;
  227. List<Staff> _Staffs;
  228. AppealRecord _ChangedRecord;
  229. async Task ShowChangeReviewer(AppealRecord appealRecord)
  230. {
  231. _Staffs = await _userService.GetReviewers(appealRecord.ItemId, appealRecord.TypeId);
  232. _ChangedRecord = appealRecord;
  233. _visible = true;
  234. }
  235. private async System.Threading.Tasks.Task HandleOk(MouseEventArgs e)
  236. {
  237. var response = await _atService.ChangeReviewer(_ChangedRecord);
  238. if (response.Success)
  239. {
  240. AppealRecords = await _atService.GetUserAppeals(_CurrentUser.Userid);
  241. StateHasChanged();
  242. _visible = false;
  243. }
  244. else
  245. {
  246. await _msgService.Error(response.ErrorMessage);
  247. }
  248. }
  249. private void HandleCancel(MouseEventArgs e)
  250. {
  251. _visible = false;
  252. }
  253. #endregion
  254. }
  255. }