List.razor.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. using AntDesign;
  2. using Microsoft.AspNetCore.Components;
  3. using System.Collections.Generic;
  4. using System;
  5. using wispro.sp.entity.CompareCase;
  6. using wispro.sp.entity;
  7. using AntDesign.TableModels;
  8. using System.Threading.Tasks;
  9. using wispro.sp.web.Services;
  10. using wispro.sp.share;
  11. using Microsoft.AspNetCore.Components.Web;
  12. using Newtonsoft.Json.Linq;
  13. using System.Linq;
  14. namespace wispro.sp.web.Pages.CompareFile
  15. {
  16. public partial class List
  17. {
  18. [Inject] public CompareFileService _CompareFileService { get; set; }
  19. int _pageIndex = 1;
  20. int _pageSize = 10;
  21. Pagination _pagination;
  22. int _total;
  23. bool _loading = false;
  24. QueryFilter _filter;
  25. Field _selectedItem;
  26. List<CaseInfo> _caseList;
  27. bool _DetailShow = false;
  28. int _value = 1;
  29. int _ShowResultString = 1;
  30. List<Field> _fields = new List<Field>() {
  31. new Field(){ FieldName="处理人",FieldValue="Handlers"},
  32. new Field(){ FieldName="审核人",FieldValue="Reviewer.Name"},
  33. new Field(){ FieldName="客户",FieldValue="Customer.Name"},
  34. new Field(){ FieldName="案号",FieldValue="CaseNo"},
  35. new Field(){ FieldName="案件名称",FieldValue="CaseName"}
  36. };
  37. protected override async Task OnInitializedAsync()
  38. {
  39. await _authService.CanVisitResource();
  40. await GetData();
  41. StateHasChanged();
  42. }
  43. private void OnSelectedItemChangedHandler(Field value)
  44. {
  45. _selectedItem = value;
  46. }
  47. private string txtValue = string.Empty;
  48. private async void OnSearch()
  49. {
  50. if (!string.IsNullOrEmpty(txtValue))
  51. {
  52. _pageIndex = 1;
  53. _filter.ConditionTree.Add(
  54. new FieldCondition()
  55. {
  56. FieldName = _selectedItem.FieldValue,
  57. LogicOperate = LogicEnum.And,
  58. Operator = OperatorEnum.Contains,
  59. Value = txtValue,
  60. ValueType = "System.String"
  61. }
  62. );
  63. }
  64. await GetData();
  65. StateHasChanged();
  66. }
  67. private string ConvertFiledCondition2String(FieldCondition c)
  68. {
  69. if(c != null)
  70. {
  71. var f = _fields.Where(s => s.FieldValue == c.FieldName).FirstOrDefault();
  72. if(f != null)
  73. {
  74. return $"{f.FieldName}={c.Value}";
  75. }
  76. }
  77. return string.Empty;
  78. }
  79. private async void RemoveCondition(FieldCondition c)
  80. {
  81. Console.WriteLine($"{c.FieldName}={c.Value}");
  82. _pageIndex = 1;
  83. _filter.ConditionTree.Remove(c);
  84. await GetData();
  85. StateHasChanged();
  86. }
  87. private int serialNumber(int pageIndex, int pageSize, int id)
  88. {
  89. int iIndex = 0;
  90. foreach (CaseInfo sf in _caseList)
  91. {
  92. iIndex++;
  93. if (sf.Id == id)
  94. {
  95. break;
  96. }
  97. }
  98. return (pageIndex - 1) * pageSize + iIndex;
  99. }
  100. CaseInfo _currentCase = null;
  101. private void Showdetail(CaseInfo caseInfo)
  102. {
  103. _currentCase = caseInfo;
  104. _DetailShow = true;
  105. }
  106. private void btnOk(MouseEventArgs e)
  107. {
  108. _DetailShow = false;
  109. }
  110. private void btnCancel(MouseEventArgs e)
  111. {
  112. _DetailShow = false;
  113. }
  114. private async Task GetData()
  115. {
  116. _loading = true;
  117. if (_filter == null)
  118. {
  119. _filter = new QueryFilter();
  120. }
  121. _filter.PageIndex = _pageIndex;
  122. _filter.PageSize = _pageSize;
  123. var data = await _CompareFileService.Query(_filter);
  124. _caseList = data.Results;
  125. _total = data.TotalCount;
  126. _loading = false;
  127. StateHasChanged();
  128. }
  129. async void OnPageChange(int PageIndex)
  130. {
  131. _pageIndex = PageIndex;
  132. await GetData();
  133. StateHasChanged();
  134. }
  135. class Field
  136. {
  137. public string FieldName { get; set; }
  138. public string FieldValue { get; set; }
  139. }
  140. }
  141. }