Update con paginatore x TC History

This commit is contained in:
Samuele Locatelli
2023-09-29 09:18:36 +02:00
parent 0c1ba8722a
commit fe3321647a
2 changed files with 57 additions and 18 deletions
@@ -31,6 +31,8 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="EgwCoreLib.Razor" Version="1.4.2308.216" />
<PackageReference Include="EgwCoreLib.Utils" Version="1.4.2308.216" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.0-rc.1.23421.29" />
</ItemGroup>
+55 -18
View File
@@ -16,18 +16,43 @@
<th>TCiclo</th>
<th>Note</th>
<th>Periodo</th>
<th>Impianto</th>
<th class="text-end">Impianto</th>
</tr>
</thead>
<tbody>
@if (isLoading)
{
<i>...loading...</i>
@for (int i = 0; i < NumRecPage; i++)
{
<tr class="placeholder-glow">
<td>
<div class="placeholder col-4"></div>
<small class="placeholder col-8"></small>
</td>
<td>
<div class="placeholder col-6"></div>
<small class="placeholder col-6"></small>
</td>
<td><span class="placeholder col-12"></span></td>
<td><span class="placeholder col-12"></span></td>
<td class="text-end">
<div class="placeholder col-10"></div>
<small class="placeholder col-10"></small>
</td>
</tr>
}
}
else
{
<b>griglia risultati</b>
@if (ListODL != null && ListODL.Count > 0)
@if (ListODL == null || ListODL.Count == 0)
{
<tr>
<td colspan="5">
<div class="alert alert-warning fs-5 w-100">Nessun record trovato</div>
</td>
</tr>
}
else
{
foreach (var item in ListODL)
{
@@ -37,12 +62,12 @@
<small class="text-secondary">@item.DescArticolo</small>
</td>
<td>
<div>@item.Tcassegnato</div>
<small class="text-secondary">@item.Tcassegnato</small>
<div>@item.Tcassegnato.ToString("N3")</div>
<small class="text-secondary">@item.Tcassegnato.ToString("N3")</small>
</td>
<td>@item.Note</td>
<td>@item.DataInizio --&gt; @item.DataFine</td>
<td>
<td class="text-end">
<div>@item.IdxMacchina</div>
<small class="text-secondary">@item.NumPezzi pz</small>
</td>
@@ -54,17 +79,17 @@
</tbody>
</table>
</div>
<div class="card-footer">
</div>
<div class="card-footer">
<EgwCoreLib.Razor.DataPager currPage="@PageNum" PageSize="@NumRecPage" totalCount="@TotalCount" numPageChanged="SavePage" numRecordChanged="SaveNumRec"></EgwCoreLib.Razor.DataPager>
</div>
</div>
@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();
}