MyProject.razor.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. using AntDesign;
  2. using Microsoft.AspNetCore.Components;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Threading.Tasks;
  7. using wispro.sp.entity;
  8. using wispro.sp.web.Services;
  9. namespace wispro.sp.web.Pages.Project
  10. {
  11. public partial class MyProject
  12. {
  13. List<ProjectContentRecord> ProjectInfos;
  14. int _pageIndex = 1;
  15. int _pageSize = 10;
  16. int _total = 0;
  17. bool _loading = false;
  18. private ModalRef _modalRef;
  19. [Inject] protected IProjectService _itemService { get; set; }
  20. [Inject] public MessageService MsgSvr { get; set; }
  21. [Inject] NavigationManager _NavigationManager { get; set; }
  22. [Inject] ModalService _ModalService { get; set; }
  23. [Inject] MessageService _msgService { get; set; }
  24. private string getStatus(int state)
  25. {
  26. switch (state)
  27. {
  28. case 0:
  29. return "未提交";
  30. break;
  31. case 1:
  32. return "待审核";
  33. break;
  34. case 2:
  35. return "已审核";
  36. break;
  37. default:
  38. return "";
  39. }
  40. }
  41. protected async override Task OnInitializedAsync()
  42. {
  43. ProjectInfos = await _itemService.GetMyProjects();
  44. _total = ProjectInfos.Count;
  45. await base.OnInitializedAsync();
  46. }
  47. public int serialNumber(int pageIndex, int pageSize, ProjectContentRecord pr)
  48. {
  49. int iIndex = ProjectInfos.IndexOf(pr);
  50. return iIndex + 1;
  51. }
  52. public async Task SetFinished(string CaseNo)
  53. {
  54. var result = await _itemService.SetProjectFinish(CaseNo);
  55. if (!result)
  56. {
  57. await MsgSvr.Error($"设定专案[{CaseNo}]为已完成时出错,请稍后再试!");
  58. }
  59. }
  60. private void HandlePageChange(PaginationEventArgs args)
  61. {
  62. if (_pageIndex != args.Page)
  63. {
  64. _pageIndex = args.Page;
  65. }
  66. if (_pageSize != args.PageSize)
  67. {
  68. _pageSize = args.PageSize;
  69. }
  70. }
  71. public void AddNew()
  72. {
  73. _NavigationManager.NavigateTo("/Project/WorkContent");
  74. }
  75. public void Edit(ProjectContentRecord projectContent)
  76. {
  77. _NavigationManager.NavigateTo($"/Project/WorkContent/{projectContent.Id}");
  78. }
  79. async void Submit(ProjectContentRecord projectContent)
  80. {
  81. var modalConfig = new ModalOptions();
  82. modalConfig.Title = $"{projectContent.Project.CaseNo}工作内容提交审核";
  83. modalConfig.Width = 850;
  84. //modalConfig.Footer = null;
  85. modalConfig.DestroyOnClose = true;
  86. modalConfig.MaskClosable = false;
  87. modalConfig.OkText = "提交";
  88. modalConfig.CancelText = "取消";
  89. _modalRef = await _ModalService
  90. .CreateModalAsync<Components.SubmitWorkContent, ProjectContentRecord>(modalConfig, projectContent);
  91. _modalRef.OnOpen = () =>
  92. {
  93. return Task.CompletedTask;
  94. };
  95. _modalRef.OnOk = async () =>
  96. {
  97. try
  98. {
  99. if (projectContent.Project.ReviewerId.HasValue)
  100. {
  101. await _itemService.SubmitToReview(projectContent.Id, projectContent.Project.ReviewerId.Value);
  102. var SuccessConfig = new ConfirmOptions()
  103. {
  104. Content = @"提交成功!"
  105. };
  106. modalConfig.DestroyOnClose = true;
  107. _ModalService.Success(SuccessConfig);
  108. ProjectInfos = await _itemService.GetMyProjects();
  109. }
  110. else
  111. {
  112. _ModalService.Info(new ConfirmOptions()
  113. {
  114. Content = "请选择审核人员!",
  115. });
  116. }
  117. }
  118. catch (Exception ex)
  119. {
  120. _ModalService.Error(new ConfirmOptions()
  121. {
  122. Title = "错误",
  123. Content = ex.Message,
  124. });
  125. }
  126. };
  127. _modalRef.OnCancel = () =>
  128. {
  129. return Task.CompletedTask;
  130. };
  131. _modalRef.OnClose = () =>
  132. {
  133. return Task.CompletedTask;
  134. };
  135. StateHasChanged();
  136. }
  137. }
  138. }