ProjectSearch.razor.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. await _authService.CanVisitResource();
  33. ProjectInfos = await _itemService.GetAllProjects();
  34. _total = ProjectInfos.Count;
  35. await base.OnInitializedAsync();
  36. }
  37. public int serialNumber(int pageIndex, int pageSize, string name)
  38. {
  39. int iIndex = 0;
  40. foreach (ProjectInfo sf in ProjectInfos)
  41. {
  42. iIndex++;
  43. if (sf.CaseNo == name)
  44. {
  45. break;
  46. }
  47. }
  48. return iIndex;
  49. }
  50. public async Task SetFinished(string CaseNo)
  51. {
  52. var result = await _itemService.SetProjectFinish(CaseNo);
  53. if (!result)
  54. {
  55. await MsgSvr.Error($"设定专案[{CaseNo}]为已完成时出错,请稍后再试!");
  56. }
  57. }
  58. public async Task OnChange(QueryModel<ProjectInfo> queryModel)
  59. {
  60. //Console.WriteLine(JsonSerializer.Serialize(queryModel));
  61. }
  62. private void HandlePageChange(PaginationEventArgs args)
  63. {
  64. if (_pageIndex != args.Page)
  65. {
  66. _pageIndex = args.Page;
  67. }
  68. if (_pageSize != args.PageSize)
  69. {
  70. _pageSize = args.PageSize;
  71. }
  72. }
  73. }
  74. }