using AntDesign; using Microsoft.AspNetCore.Components; using System.Collections.Generic; using System; using wispro.sp.entity.CompareCase; using wispro.sp.entity; using AntDesign.TableModels; using System.Threading.Tasks; using wispro.sp.web.Services; using wispro.sp.share; using Microsoft.AspNetCore.Components.Web; using Newtonsoft.Json.Linq; using System.Linq; namespace wispro.sp.web.Pages.CompareFile { public partial class List { [Inject] public CompareFileService _CompareFileService { get; set; } int _pageIndex = 1; int _pageSize = 10; Pagination _pagination; int _total; bool _loading = false; QueryFilter _filter; Field _selectedItem; List _caseList; bool _DetailShow = false; int _value = 1; int _ShowResultString = 1; List _fields = new List() { new Field(){ FieldName="处理人",FieldValue="Handlers"}, new Field(){ FieldName="审核人",FieldValue="Reviewer.Name"}, new Field(){ FieldName="客户",FieldValue="Customer.Name"}, new Field(){ FieldName="案号",FieldValue="CaseNo"}, new Field(){ FieldName="案件名称",FieldValue="CaseName"} }; protected override async Task OnInitializedAsync() { await _authService.CanVisitResource(); await GetData(); StateHasChanged(); } private void OnSelectedItemChangedHandler(Field value) { _selectedItem = value; } private string txtValue = string.Empty; private async void OnSearch() { if (!string.IsNullOrEmpty(txtValue)) { _pageIndex = 1; _filter.ConditionTree.Add( new FieldCondition() { FieldName = _selectedItem.FieldValue, LogicOperate = LogicEnum.And, Operator = OperatorEnum.Contains, Value = txtValue, ValueType = "System.String" } ); } await GetData(); StateHasChanged(); } private string ConvertFiledCondition2String(FieldCondition c) { if(c != null) { var f = _fields.Where(s => s.FieldValue == c.FieldName).FirstOrDefault(); if(f != null) { return $"{f.FieldName}={c.Value}"; } } return string.Empty; } private async void RemoveCondition(FieldCondition c) { Console.WriteLine($"{c.FieldName}={c.Value}"); _pageIndex = 1; _filter.ConditionTree.Remove(c); await GetData(); StateHasChanged(); } private int serialNumber(int pageIndex, int pageSize, int id) { int iIndex = 0; foreach (CaseInfo sf in _caseList) { iIndex++; if (sf.Id == id) { break; } } return (pageIndex - 1) * pageSize + iIndex; } CaseInfo _currentCase = null; private void Showdetail(CaseInfo caseInfo) { _currentCase = caseInfo; _DetailShow = true; } private void btnOk(MouseEventArgs e) { _DetailShow = false; } private void btnCancel(MouseEventArgs e) { _DetailShow = false; } private async Task GetData() { _loading = true; if (_filter == null) { _filter = new QueryFilter(); } _filter.PageIndex = _pageIndex; _filter.PageSize = _pageSize; var data = await _CompareFileService.Query(_filter); _caseList = data.Results; _total = data.TotalCount; _loading = false; StateHasChanged(); } async void OnPageChange(int PageIndex) { _pageIndex = PageIndex; await GetData(); StateHasChanged(); } class Field { public string FieldName { get; set; } public string FieldValue { get; set; } } } }