SSTable.razor.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. using AntDesign;
  2. using AntDesign.TableModels;
  3. using Microsoft.AspNetCore.Components;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Threading.Tasks;
  8. using wispro.sp.entity;
  9. using wispro.sp.web.Models;
  10. using wispro.sp.web.Services;
  11. namespace wispro.sp.web.Components
  12. {
  13. public partial class SSTable
  14. {
  15. protected AntDesign.Table<AppealRecord> table;
  16. AntDesign.Column<AppealRecord> column;
  17. int _total;
  18. int _pageIndex=1;
  19. int _pageSize=10;
  20. bool _loading;
  21. [Parameter]
  22. public List<AppealRecord> Datas { get; set; }
  23. //[Inject] protected UserService _userService { get; set; }
  24. [Inject] protected AppealTypeService _atService { get; set; }
  25. [Parameter]
  26. public bool ShowAction { get; set; } = true;
  27. [Parameter]
  28. public int? UserId { get; set; }
  29. AppealRecord CurrentAppealRecord;
  30. bool _ShowDetail;
  31. List<InputFieldValue> _FieldValues;
  32. List<InputFieldValue> _ReviewValues;
  33. List<AttachFile> attachFiles;
  34. async Task ShowDetail(AppealRecord appealRecord)
  35. {
  36. CurrentAppealRecord = appealRecord;
  37. _FieldValues = await _atService.GetInputFieldValues(appealRecord.Id, 0);
  38. attachFiles = await _atService.GetAppealRecordAttachFiles(CurrentAppealRecord.Id);
  39. if (appealRecord.State > 0)
  40. {
  41. _ReviewValues = await _atService.GetInputFieldValues(appealRecord.Id, 1);
  42. }
  43. _ShowDetail = true;
  44. StateHasChanged();
  45. }
  46. void CloseDetail()
  47. {
  48. _ShowDetail = false;
  49. }
  50. Dictionary<string, object> OnRow(RowData<AppealRecord> row) => new()
  51. {
  52. ["id"] = row.Data.Id,
  53. ["onclick"] = ((Action)delegate
  54. {
  55. _ = ShowDetail(row.Data);
  56. })
  57. };
  58. //CurrentUser currentUser;
  59. [Parameter]
  60. public EventCallback<AppealRecord> OnReview { get; set; }
  61. [Parameter]
  62. public EventCallback<AppealRecord> OnChangeReviewer { get; set; }
  63. protected override void OnParametersSet()
  64. {
  65. _total = Datas.Count;
  66. base.OnParametersSet();
  67. }
  68. public int serialNumber(int pageIndex, int pageSize, AppealRecord appealRecord)
  69. {
  70. //int iIndex = 0;
  71. //foreach (AppealRecord sf in Datas)
  72. //{
  73. // iIndex++;
  74. // if (sf == appealRecord)
  75. // {
  76. // break;
  77. // }
  78. //}
  79. var queryModel = table.GetQueryModel();
  80. if (table.SortDirections.Count() > 0)
  81. {
  82. //Console.WriteLine(table.SortDirections[0].Name);
  83. //Console.WriteLine(table.SortDirections[0].Value);
  84. }
  85. return Datas.IndexOf(appealRecord) + 1;
  86. //return iIndex;
  87. }
  88. private void HandlePageChange(PaginationEventArgs args)
  89. {
  90. if (_pageIndex != args.Page)
  91. {
  92. _pageIndex = args.Page;
  93. }
  94. if (_pageSize != args.PageSize)
  95. {
  96. _pageSize = args.PageSize;
  97. }
  98. }
  99. private async void _OnReview(AppealRecord appealRecord)
  100. {
  101. if (OnReview.HasDelegate)
  102. {
  103. await OnReview.InvokeAsync(appealRecord);
  104. }
  105. }
  106. private async void _OnChangeReviewer(AppealRecord appealRecord)
  107. {
  108. if (OnChangeReviewer.HasDelegate)
  109. {
  110. await OnChangeReviewer.InvokeAsync(appealRecord);
  111. }
  112. }
  113. }
  114. }