Welcome.razor.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. namespace wispro.sp.web.Pages
  12. {
  13. public partial class Welcome
  14. {
  15. private readonly EditableLink[] _links =
  16. {
  17. new EditableLink {Title = "Operation 1", Href = ""},
  18. new EditableLink {Title = "Operation 2", Href = ""},
  19. new EditableLink {Title = "Operation 3", Href = ""},
  20. new EditableLink {Title = "Operation 4", Href = ""},
  21. new EditableLink {Title = "Operation 5", Href = ""},
  22. new EditableLink {Title = "Operation 6", Href = ""}
  23. };
  24. private ActivitiesType[] _activities = { };
  25. private NoticeType[] _projectNotice = { };
  26. private CurrentUser _CurrentUser;
  27. private List<AppealRecord> AppealRecords = new List<AppealRecord>();
  28. [Inject] public IProjectService ProjectService { get; set; }
  29. [Inject] public IUserService _userService { get; set; }
  30. [Inject] protected AppealTypeService _atService { get; set; }
  31. private ModalRef _modalRef;
  32. [Inject] ModalService _ModalService { get; set; }
  33. [Inject] MessageService _msgService { get; set; }
  34. private Models.CurrentUser _user;
  35. protected override async System.Threading.Tasks.Task OnInitializedAsync()
  36. {
  37. await base.OnInitializedAsync();
  38. _CurrentUser =await _userService.GetUser();
  39. if (_CurrentUser != null)
  40. {
  41. //_projectNotice = await ProjectService.GetProjectNoticeAsync();
  42. //_activities = await ProjectService.GetActivitiesAsync();
  43. AppealRecords = await _atService.GetUserAppeals(_CurrentUser.Userid);
  44. if (AppealRecords != null)
  45. {
  46. //try
  47. //{
  48. // //_user = await _userService.GetUser();
  49. // //AppealRecords.Sort((a, b) =>
  50. // //{
  51. // // var sd = (a.ReviewTime == null) ? a.ReviewTime : a.CreateTime;
  52. // // var ed = (b.ReviewTime == null) ? b.ReviewTime : b.CreateTime;
  53. // // if (ed > sd)
  54. // // {
  55. // // return 1;
  56. // // }
  57. // // else
  58. // // {
  59. // // return -1;
  60. // // }
  61. // //});
  62. //}
  63. //catch { }
  64. }
  65. }
  66. else
  67. {
  68. //NavigationManager.
  69. }
  70. StateHasChanged();
  71. }
  72. async Task ShowModel(AppealRecord appealRecord)
  73. {
  74. var templateOptions = new Models.ReviewerAppealModel();
  75. await templateOptions.Init(_atService, appealRecord.Id);
  76. Console.WriteLine(System.Text.Json.JsonSerializer.Serialize(templateOptions));
  77. var modalConfig = new ModalOptions();
  78. modalConfig.Title = $"{appealRecord.Type.Name}审核" ;
  79. modalConfig.Width = 650;
  80. //modalConfig.Footer = null;
  81. modalConfig.DestroyOnClose = true;
  82. _modalRef = await _ModalService
  83. .CreateModalAsync<Components.ReviewerAppeal, Models.ReviewerAppealModel>(modalConfig, templateOptions);
  84. _modalRef.OnOpen = () =>
  85. {
  86. return Task.CompletedTask;
  87. };
  88. _modalRef.OnOk = async () =>
  89. {
  90. try
  91. {
  92. await _atService.ReviewerAppeal(templateOptions);
  93. await _modalRef.CloseAsync();
  94. AppealRecords = await _atService.GetUserAppeals(_CurrentUser.Userid);
  95. //AppealRecords.Sort((a, b) =>
  96. //{
  97. // try
  98. // {
  99. // var sd = (a.ReviewTime == null) ? a.ReviewTime : a.CreateTime;
  100. // var ed = (b.ReviewTime == null) ? b.ReviewTime : b.CreateTime;
  101. // if (ed > sd)
  102. // {
  103. // return 1;
  104. // }
  105. // else
  106. // {
  107. // return -1;
  108. // }
  109. // }
  110. // catch
  111. // {
  112. // return 0;
  113. // }
  114. //});
  115. StateHasChanged();
  116. var SuccessConfig = new ConfirmOptions()
  117. {
  118. Content = @"审核成功!"
  119. };
  120. //modalConfig.Footer = null;
  121. modalConfig.DestroyOnClose = true;
  122. _ModalService.Success(SuccessConfig);
  123. }
  124. catch (Exception ex)
  125. {
  126. _ModalService.Error(new ConfirmOptions()
  127. {
  128. Title = "审核错误",
  129. Content = ex.Message,
  130. });
  131. }
  132. };
  133. _modalRef.OnCancel = () =>
  134. {
  135. return Task.CompletedTask;
  136. };
  137. _modalRef.OnClose = () =>
  138. {
  139. return Task.CompletedTask;
  140. };
  141. StateHasChanged();
  142. }
  143. }
  144. }