Welcome.razor.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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. //_user = await _userService.GetUser();
  47. AppealRecords.Sort((a, b) =>
  48. {
  49. var sd = (a.ReviewTime == null) ? a.ReviewTime : a.CreateTime;
  50. var ed = (b.ReviewTime == null) ? b.ReviewTime : b.CreateTime;
  51. if (ed > sd)
  52. {
  53. return 1;
  54. }
  55. else
  56. {
  57. return -1;
  58. }
  59. });
  60. }
  61. }
  62. else
  63. {
  64. //NavigationManager.
  65. }
  66. StateHasChanged();
  67. }
  68. async Task ShowModel(AppealRecord appealRecord)
  69. {
  70. var templateOptions = new Models.ReviewerAppealModel();
  71. await templateOptions.Init(_atService, appealRecord.Id);
  72. var modalConfig = new ModalOptions();
  73. modalConfig.Title = $"{appealRecord.Type.Name}审核" ;
  74. modalConfig.Width = 650;
  75. //modalConfig.Footer = null;
  76. modalConfig.DestroyOnClose = true;
  77. _modalRef = await _ModalService
  78. .CreateModalAsync<Components.ReviewerAppeal, Models.ReviewerAppealModel>(modalConfig, templateOptions);
  79. _modalRef.OnOpen = () =>
  80. {
  81. return Task.CompletedTask;
  82. };
  83. _modalRef.OnOk = async () =>
  84. {
  85. try
  86. {
  87. await _atService.ReviewerAppeal(templateOptions);
  88. await _modalRef.CloseAsync();
  89. AppealRecords = await _atService.GetUserAppeals(_CurrentUser.Userid);
  90. AppealRecords.Sort((a, b) =>
  91. {
  92. var sd = (a.ReviewTime == null) ? a.ReviewTime : a.CreateTime;
  93. var ed = (b.ReviewTime == null) ? b.ReviewTime : b.CreateTime;
  94. if (ed > sd)
  95. {
  96. return 1;
  97. }
  98. else
  99. {
  100. return -1;
  101. }
  102. });
  103. StateHasChanged();
  104. var SuccessConfig = new ConfirmOptions()
  105. {
  106. Content = @"审核成功!"
  107. };
  108. //modalConfig.Footer = null;
  109. modalConfig.DestroyOnClose = true;
  110. _ModalService.Success(SuccessConfig);
  111. }
  112. catch (Exception ex)
  113. {
  114. _ModalService.Error(new ConfirmOptions()
  115. {
  116. Title = "审核错误",
  117. Content = ex.Message,
  118. });
  119. }
  120. };
  121. _modalRef.OnCancel = () =>
  122. {
  123. return Task.CompletedTask;
  124. };
  125. _modalRef.OnClose = () =>
  126. {
  127. return Task.CompletedTask;
  128. };
  129. StateHasChanged();
  130. }
  131. }
  132. }