From 0c1ba8722aeb2fd1c628dca715137afc91c541c8 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 29 Sep 2023 08:19:25 +0200 Subject: [PATCH 1/2] Update test paginazione --- MP-TAB/MP-TAB.Client/Pages/TCHistory.razor | 33 ++++++++++++++++------ MP.Data/Services/OrderDataSrv.cs | 2 +- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/MP-TAB/MP-TAB.Client/Pages/TCHistory.razor b/MP-TAB/MP-TAB.Client/Pages/TCHistory.razor index 1e59e5f2..e38d5f3d 100644 --- a/MP-TAB/MP-TAB.Client/Pages/TCHistory.razor +++ b/MP-TAB/MP-TAB.Client/Pages/TCHistory.razor @@ -9,7 +9,6 @@
- @@ -38,7 +37,7 @@ @item.DescArticolo @@ -54,17 +53,18 @@ }
- @item.Tcassegnato +
@item.Tcassegnato
@item.Tcassegnato
@item.Note
- -
+ @code { - [Parameter] - public int MatrOpr { get; set; } = 0; + [Parameter] + public int MatrOpr { get; set; } = 0; - [Inject] - protected IConfiguration config { get; set; } = null!; + [Inject] + protected IConfiguration config { get; set; } = null!; protected int SearchMinChar = 3; protected string CodArt = ""; @@ -72,6 +72,11 @@ protected string BaseAddr = ""; protected bool isLoading = false; + protected int PageSize = 10; + protected int TotalCount = 0; + protected int PageNum = 1; + + protected List ListComplete { get; set; } = new List(); protected List ListODL { get; set; } = new List(); protected override async Task OnInitializedAsync() @@ -102,7 +107,17 @@ var rawData = await Http.GetFromJsonAsync>(ApiUrl); if (rawData != null) { - ListODL = rawData; + ListComplete = rawData; + TotalCount = ListComplete.Count; + // esegue paginazione + if(TotalCount>PageSize) + { + ListODL = ListComplete.Skip((PageNum - 1) * PageSize).Take(PageSize).ToList(); + } + else + { + ListODL = ListComplete; + } } } catch(Exception exc) diff --git a/MP.Data/Services/OrderDataSrv.cs b/MP.Data/Services/OrderDataSrv.cs index 89329c48..c52d7043 100644 --- a/MP.Data/Services/OrderDataSrv.cs +++ b/MP.Data/Services/OrderDataSrv.cs @@ -61,7 +61,7 @@ namespace MP.Data.Services /// Cod articolo /// Macchina selezionata /// - public async Task> ListODLFilt(string CodArt, string IdxMacchina) + public async Task> ListODLFilt(string CodArt, string IdxMacchina="*") { // setup parametri costanti bool inCorso = false; From fe3321647ae688e893a9c14f07f02ab17f34b61b Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 29 Sep 2023 09:18:36 +0200 Subject: [PATCH 2/2] Update con paginatore x TC History --- MP-TAB/MP-TAB.Client/MP-TAB.Client.csproj | 2 + MP-TAB/MP-TAB.Client/Pages/TCHistory.razor | 73 ++++++++++++++++------ 2 files changed, 57 insertions(+), 18 deletions(-) diff --git a/MP-TAB/MP-TAB.Client/MP-TAB.Client.csproj b/MP-TAB/MP-TAB.Client/MP-TAB.Client.csproj index 4717ce9c..008e6d63 100644 --- a/MP-TAB/MP-TAB.Client/MP-TAB.Client.csproj +++ b/MP-TAB/MP-TAB.Client/MP-TAB.Client.csproj @@ -31,6 +31,8 @@ + + diff --git a/MP-TAB/MP-TAB.Client/Pages/TCHistory.razor b/MP-TAB/MP-TAB.Client/Pages/TCHistory.razor index e38d5f3d..f24f2bfc 100644 --- a/MP-TAB/MP-TAB.Client/Pages/TCHistory.razor +++ b/MP-TAB/MP-TAB.Client/Pages/TCHistory.razor @@ -16,18 +16,43 @@ TCiclo Note Periodo - Impianto + Impianto @if (isLoading) { - ...loading... + @for (int i = 0; i < NumRecPage; i++) + { + + +
+ + + +
+ + + + + +
+ + + + } } else { - griglia risultati - @if (ListODL != null && ListODL.Count > 0) + @if (ListODL == null || ListODL.Count == 0) + { + + +
Nessun record trovato
+ + + } + else { foreach (var item in ListODL) { @@ -37,12 +62,12 @@ @item.DescArticolo -
@item.Tcassegnato
- @item.Tcassegnato +
@item.Tcassegnato.ToString("N3")
+ @item.Tcassegnato.ToString("N3") @item.Note @item.DataInizio --> @item.DataFine - +
@item.IdxMacchina
@item.NumPezzi pz @@ -54,17 +79,17 @@ - + @code { - [Parameter] - public int MatrOpr { get; set; } = 0; + [Parameter] + public int MatrOpr { get; set; } = 0; - [Inject] - protected IConfiguration config { get; set; } = null!; + [Inject] + protected IConfiguration config { get; set; } = null!; protected int SearchMinChar = 3; protected string CodArt = ""; @@ -72,7 +97,7 @@ protected string BaseAddr = ""; protected bool isLoading = false; - protected int PageSize = 10; + protected int NumRecPage = 10; protected int TotalCount = 0; protected int PageNum = 1; @@ -110,9 +135,9 @@ ListComplete = rawData; TotalCount = ListComplete.Count; // esegue paginazione - if(TotalCount>PageSize) + if (TotalCount > NumRecPage) { - ListODL = ListComplete.Skip((PageNum - 1) * PageSize).Take(PageSize).ToList(); + ListODL = ListComplete.Skip((PageNum - 1) * NumRecPage).Take(NumRecPage).ToList(); } else { @@ -120,7 +145,7 @@ } } } - catch(Exception exc) + catch (Exception exc) { Log.Error($"Error on dataload{Environment.NewLine}{exc}"); } @@ -128,5 +153,17 @@ isLoading = false; } + protected async Task SavePage(int newNum) + { + PageNum = newNum; + await ReloadData(); + } + + protected async Task SaveNumRec(int newNum) + { + NumRecPage = newNum; + await ReloadData(); + } + private static NLog.Logger Log = LogManager.GetCurrentClassLogger(); }