ProjectSearch.razor.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. using AntDesign;
  2. using AntDesign.TableModels;
  3. using Microsoft.AspNetCore.Components;
  4. using Microsoft.JSInterop;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Text.Json;
  9. using System.Threading.Tasks;
  10. using wispro.sp.entity;
  11. using wispro.sp.web.Services;
  12. namespace wispro.sp.web.Pages.Project
  13. {
  14. public partial class ProjectSearch
  15. {
  16. List<ProjectInfo> ProjectInfos;
  17. int _pageIndex = 1;
  18. int _pageSize = 10;
  19. int _total = 0;
  20. bool _loading = false;
  21. ITable table;
  22. [Inject] protected IProjectService _itemService { get; set; }
  23. [Inject] public MessageService MsgSvr { get; set; }
  24. [Inject] protected NavigationManager navigation { get; set; }
  25. [Inject] protected IAuthService _authService { get; set; }
  26. [Inject] protected IJSRuntime JSRuntime { get; set; }
  27. protected async override Task OnInitializedAsync()
  28. {
  29. string strResourceId = navigation.Uri.Replace(navigation.BaseUri,"/");
  30. Console.WriteLine(navigation.ToAbsoluteUri(navigation.Uri));
  31. Console.WriteLine(navigation.ToBaseRelativePath(navigation.Uri));
  32. var canVisist = await _authService.CanVisitResource(strResourceId);
  33. if (!canVisist)
  34. {
  35. var config = new MessageConfig()
  36. {
  37. Content = "您没有权限使用该功能",
  38. Type = MessageType.Error
  39. };
  40. var ret = MsgSvr.Open(config);
  41. await JSRuntime.InvokeVoidAsync("history.back");
  42. }
  43. ProjectInfos = await _itemService.GetAllProjects();
  44. _total = ProjectInfos.Count;
  45. await base.OnInitializedAsync();
  46. }
  47. public int serialNumber(int pageIndex, int pageSize, string name)
  48. {
  49. int iIndex = 0;
  50. foreach (ProjectInfo sf in ProjectInfos)
  51. {
  52. iIndex++;
  53. if (sf.CaseNo == name)
  54. {
  55. break;
  56. }
  57. }
  58. return iIndex;
  59. }
  60. public async Task SetFinished(string CaseNo)
  61. {
  62. var result = await _itemService.SetProjectFinish(CaseNo);
  63. if (!result)
  64. {
  65. await MsgSvr.Error($"设定专案[{CaseNo}]为已完成时出错,请稍后再试!");
  66. }
  67. }
  68. public async Task OnChange(QueryModel<ProjectInfo> queryModel)
  69. {
  70. Console.WriteLine(JsonSerializer.Serialize(queryModel));
  71. }
  72. private void HandlePageChange(PaginationEventArgs args)
  73. {
  74. if (_pageIndex != args.Page)
  75. {
  76. _pageIndex = args.Page;
  77. }
  78. if (_pageSize != args.PageSize)
  79. {
  80. _pageSize = args.PageSize;
  81. }
  82. }
  83. }
  84. }