00a0fc81ce
- FIX Selezione stato comemssa e filtraggio
153 lines
3.7 KiB
C#
153 lines
3.7 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.JSInterop;
|
|
using MP.Data.DatabaseModels;
|
|
using MP.SPEC.Data;
|
|
|
|
namespace MP.SPEC.Components
|
|
{
|
|
public partial class ListODL
|
|
{
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public EventCallback<bool> PagerResetReq { get; set; }
|
|
|
|
[Parameter]
|
|
public string StatoSel
|
|
{
|
|
get => _statoSel;
|
|
set
|
|
{
|
|
if (_statoSel != value)
|
|
{
|
|
_statoSel = value;
|
|
var pUpd = Task.Run(async () => await reloadData());
|
|
pUpd.Wait();
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Public Methods
|
|
|
|
public string checkSelect(string CodArticolo)
|
|
{
|
|
string answ = "";
|
|
if (currRecord != null)
|
|
{
|
|
try
|
|
{
|
|
answ = (currRecord.CodArticolo == CodArticolo) ? "table-info" : "";
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Protected Properties
|
|
|
|
[Inject]
|
|
protected IJSRuntime JSRuntime { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected MpDataService MDService { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected MessageService MessageService { get; set; } = null!;
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
MessageService.EA_PageUpdated += MessageService_EA_PageUpdated;
|
|
MessageService.EA_SearchUpdated += OnSeachUpdated;
|
|
await reloadData();
|
|
}
|
|
|
|
protected async void OnSeachUpdated()
|
|
{
|
|
await InvokeAsync(() =>
|
|
{
|
|
PagerResetReq.InvokeAsync(true);
|
|
//currPage = 1;
|
|
Task task = UpdateData();
|
|
StateHasChanged();
|
|
});
|
|
}
|
|
|
|
protected async Task UpdateData()
|
|
{
|
|
currRecord = null;
|
|
await reloadData();
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private string _statoSel = "*";
|
|
|
|
private ODLModel? currRecord = null;
|
|
|
|
private List<ODLModel>? ListRecords;
|
|
|
|
private List<ODLModel>? SearchRecords;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
private int currPage
|
|
{
|
|
get => MessageService.currPage;
|
|
set => MessageService.currPage = value;
|
|
}
|
|
|
|
private bool isLoading { get; set; } = false;
|
|
|
|
private int numRecord
|
|
{
|
|
get => MessageService.numRecord;
|
|
set => MessageService.numRecord = value;
|
|
}
|
|
|
|
private string SearchVal
|
|
{
|
|
get => string.IsNullOrEmpty(MessageService.SearchVal) ? "*" : MessageService.SearchVal;
|
|
}
|
|
|
|
private int totalCount
|
|
{
|
|
get => MessageService.totalCount;
|
|
set => MessageService.totalCount = value;
|
|
}
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
private async void MessageService_EA_PageUpdated()
|
|
{
|
|
await reloadData();
|
|
}
|
|
|
|
private async Task reloadData()
|
|
{
|
|
isLoading = true;
|
|
SearchRecords = await MDService.ListODLFilt(true, SearchVal, StatoSel);
|
|
totalCount = SearchRecords.Count;
|
|
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
|
|
await Task.Delay(1);
|
|
await InvokeAsync(() => StateHasChanged());
|
|
isLoading = false;
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |