using AntDesign; using AntDesign.TableModels; using Microsoft.AspNetCore.Components; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using wispro.sp.entity; using wispro.sp.web.Models; using wispro.sp.web.Services; namespace wispro.sp.web.Components { public partial class SSTable { protected AntDesign.Table table; AntDesign.Column column; int _total; int _pageIndex=1; int _pageSize=10; bool _loading; [Parameter] public List Datas { get; set; } //[Inject] protected UserService _userService { get; set; } [Inject] protected AppealTypeService _atService { get; set; } [Parameter] public bool ShowAction { get; set; } = true; [Parameter] public int? UserId { get; set; } AppealRecord CurrentAppealRecord; bool _ShowDetail; List _FieldValues; List _ReviewValues; List attachFiles; async Task ShowDetail(AppealRecord appealRecord) { CurrentAppealRecord = appealRecord; _FieldValues = await _atService.GetInputFieldValues(appealRecord.Id, 0); attachFiles = await _atService.GetAppealRecordAttachFiles(CurrentAppealRecord.Id); if (appealRecord.State > 0) { _ReviewValues = await _atService.GetInputFieldValues(appealRecord.Id, 1); } _ShowDetail = true; StateHasChanged(); } void CloseDetail() { _ShowDetail = false; } Dictionary OnRow(RowData row) => new() { ["id"] = row.Data.Id, ["onclick"] = ((Action)delegate { _ = ShowDetail(row.Data); }) }; //CurrentUser currentUser; [Parameter] public EventCallback OnReview { get; set; } [Parameter] public EventCallback OnChangeReviewer { get; set; } protected override void OnParametersSet() { _total = Datas.Count; base.OnParametersSet(); } public int serialNumber(int pageIndex, int pageSize, AppealRecord appealRecord) { //int iIndex = 0; //foreach (AppealRecord sf in Datas) //{ // iIndex++; // if (sf == appealRecord) // { // break; // } //} var queryModel = table.GetQueryModel(); if (table.SortDirections.Count() > 0) { //Console.WriteLine(table.SortDirections[0].Name); //Console.WriteLine(table.SortDirections[0].Value); } return Datas.IndexOf(appealRecord) + 1; //return iIndex; } private bool isSameQuery(IList frist, IList second) { if (frist != null && second != null) { if (frist.Count != second.Count) { return false; } else { for (int i = 0; i < frist.Count; i++) { if (frist[i].FieldName != second[i].FieldName) { return false; } else { if(frist[i].SelectedValues != second[i].SelectedValues) { return false; } } } return true; } } else { return true; } } private IList lastQuery = null; private void onChange() { //var queryModel = table.GetQueryModel(); //if (isSameQuery(queryModel.FilterModel,lastQuery)) //{ // Console.WriteLine(queryModel.FilterModel); // lastQuery = queryModel.FilterModel; // _pageIndex = 1; // //_pageIndex = queryModel.PageSize; //} //StateHasChanged(); } private void HandlePageChange(PaginationEventArgs args) { if (_pageIndex != args.Page) { _pageIndex = args.Page; } if (_pageSize != args.PageSize) { _pageSize = args.PageSize; } } private async void _OnReview(AppealRecord appealRecord) { if (OnReview.HasDelegate) { await OnReview.InvokeAsync(appealRecord); } } private async void _OnChangeReviewer(AppealRecord appealRecord) { if (OnChangeReviewer.HasDelegate) { await OnChangeReviewer.InvokeAsync(appealRecord); } } } }