Continuo gestione selezione a 2 livelli

This commit is contained in:
2025-09-18 13:08:45 +02:00
parent 31bd6a74fc
commit 67d672a5ff
9 changed files with 264 additions and 7 deletions
+1 -1
View File
@@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Version>0.9.2509.1812</Version>
<Version>0.9.2509.1813</Version>
</PropertyGroup>
<ItemGroup>
+40
View File
@@ -0,0 +1,40 @@
<table class="table table-sm table-striped">
<thead>
<tr>
<th>
<button class="btn btn-sm btn-primary" title="Reset selezione" @onclick="DoReset"><i class="fa-solid fa-arrow-rotate-right"></i></button>
</th>
<th>Cod</th>
<th>Descrizione</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in ListRecords)
{
<tr>
<td class="text-start text-nowrap">
<button class="btn btn-sm btn-primary" @onclick="() => DoSelect(item)"><i class="fa-solid fa-magnifying-glass"></i></button>
@* <button class="btn btn-sm btn-info" @onclick="() => DoEdit(item)"><i class="fa-solid fa-pencil"></i></button>
<button class="btn btn-sm btn-success" @onclick="() => DoClone(item)"><i class="fa-solid fa-clone"></i></button> *@
</td>
<td>@item.ClassCod</td>
<td>@item.Description</td>
<td>
@* <button class="btn btn-sm btn-danger" @onclick="() => DoDelete(item)"><i class="fa-solid fa-trash-can"></i></button> *@
</td>
</tr>
}
</tbody>
<tfoot>
<tr>
<td colspan="4">
@if (totalCount >= numRecord)
{
<EgwCoreLib.Razor.DataPager currPage="@currPage" PageSize="@numRecord" totalCount="@totalCount" numPageChanged="SavePage" numRecordChanged="SaveNumRec"></EgwCoreLib.Razor.DataPager>
}
</td>
</tr>
</tfoot>
</table>
@@ -0,0 +1,205 @@
using EgwCoreLib.Lux.Data.DbModel;
using EgwCoreLib.Lux.Data.Services;
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using NLog.LayoutRenderers;
namespace Lux.UI.Components.Compo
{
public partial class GenClassMan
{
[Parameter]
public List<GenClassModel> ListGenClass { get; set; } = null!;
[Parameter]
public string SearchVal { get; set; } = "";
[Parameter]
public EventCallback<string> EC_Selected { get; set; }
#region Protected Fields
protected List<GenClassModel> AllRecords = new List<GenClassModel>();
protected List<GenClassModel> ListRecords = new List<GenClassModel>();
#endregion Protected Fields
#region Protected Properties
[Inject]
protected DataLayerServices DLService { get; set; } = null!;
[Inject]
protected IJSRuntime JSRuntime { get; set; } = null!;
#endregion Protected Properties
#region Protected Methods
/// <summary>
/// Clona record
/// </summary>
/// <param name="curRec"></param>
protected void DoClone(GenClassModel curRec)
{
#if false
editRecord = new ItemModel()
{
ItemIDParent = curRec.ItemType == Enums.ItemClassType.Bom ? curRec.ItemID : curRec.ItemIDParent,
CodGroup = curRec.CodGroup,
ItemType = curRec.ItemType == Enums.ItemClassType.Bom ? Enums.ItemClassType.BomAlt : curRec.ItemType,
IsService = curRec.IsService,
ItemCode = curRec.ItemCode,
ExtItemCode = $"{curRec.ExtItemCode} - COPY",
SupplCode = curRec.ItemType == Enums.ItemClassType.Bom ? $"{curRec.SupplCode} ALT" : curRec.SupplCode,
Description = $"{curRec.Description} - COPY",
Cost = curRec.Cost,
Margin = curRec.Margin,
QtyMin = curRec.QtyMin,
QtyMax = curRec.QtyMax,
UM = curRec.UM
};
#endif
}
/// <summary>
/// impossta record x eliminazione
/// </summary>
/// <param name="selRec"></param>
protected async Task DoDelete(GenClassModel selRec)
{
if (!await JSRuntime.InvokeAsync<bool>("confirm", $"Sicuro di voler eliminare il record? Dettagli: {selRec.ClassCod} | {selRec.Description}"))
return;
//// esegue eliminazione del record...
//await DLService.ItemDeleteAsync(selRec);
editRecord = null;
selRecord = null;
ReloadData();
UpdateTable();
}
/// <summary>
/// Edit articolo selezionato
/// </summary>
/// <param name="curRec"></param>
protected void DoEdit(GenClassModel curRec)
{
editRecord = curRec;
}
/// <summary>
/// Reset selezione
/// </summary>
protected async void DoReset()
{
editRecord = null;
await EC_Selected.InvokeAsync("");
}
/// <summary>
/// Selezione articolo x display info
/// </summary>
/// <param name="curRec"></param>
protected async void DoSelect(GenClassModel curRec)
{
selRecord = curRec;
await EC_Selected.InvokeAsync(curRec.ClassCod);
}
protected override void OnParametersSet()
{
ReloadData();
UpdateTable();
}
protected void SaveNumRec(int newNum)
{
numRecord = newNum;
UpdateTable();
}
protected void SavePage(int newNum)
{
currPage = newNum;
UpdateTable();
}
#endregion Protected Methods
#region Private Fields
private int currPage = 1;
private GenClassModel? editRecord = null;
private bool isLoading = false;
private int numRecord = 10;
private GenClassModel? selRecord = null;
private int totalCount = 0;
#endregion Private Fields
#region Private Methods
private void DoCancel()
{
ResetEdit();
UpdateTable();
}
private async Task DoSave(GenClassModel currRec)
{
// salvo
await Task.Delay(10);
#if false
await DLService.ItemUpsertAsync(currRec);
#endif
ResetEdit();
UpdateTable();
}
private void ReloadData()
{
isLoading = true;
AllRecords = ListGenClass;
// se ho ricerca testuale faccio filtro ulteriore...
if (!string.IsNullOrEmpty(SearchVal))
{
AllRecords = AllRecords
.Where(x =>
x.ClassCod.Contains(SearchVal, StringComparison.InvariantCultureIgnoreCase) ||
x.Description.Contains(SearchVal, StringComparison.InvariantCultureIgnoreCase))
.ToList();
}
totalCount = AllRecords.Count;
}
private void ResetEdit()
{
// reset edit
editRecord = null;
ReloadData();
}
/// <summary>
/// Filtro e paginazione
/// </summary>
private void UpdateTable()
{
// fix paginazione
ListRecords = AllRecords
.Skip(numRecord * (currPage - 1))
.Take(numRecord)
.ToList();
isLoading = false;
}
#endregion Private Methods
}
}
+8 -1
View File
@@ -37,6 +37,13 @@
</div>
</div>
<div class="card-body">
<GenValMan SelFilt="CurrFilt" ListGenClass="ListGenClass"></GenValMan>
<div class="row">
<div class="col-4">
<GenClassMan ListGenClass="ListGenClass" EC_Selected="SaveSel"></GenClassMan>
</div>
<div class="col-8">
<GenValMan SelFilt="CurrFilt" ListGenClass="ListGenClass"></GenValMan>
</div>
</div>
</div>
</div>
+6 -1
View File
@@ -54,7 +54,7 @@ namespace Lux.UI.Components.Pages
editRecord = new ItemModel()
{
#if false
CodGroup = ListGenClass.FirstOrDefault()?.CodGroup ?? "",
CodGroup = ListGenClass.FirstOrDefault()?.CodGroup ?? "",
#endif
ItemType = EgwCoreLib.Lux.Core.Enums.ItemClassType.ND,
IsService = false,
@@ -101,6 +101,11 @@ namespace Lux.UI.Components.Pages
ListGenClass = await DLService.GenClassGetAllAsync();
}
private void SaveSel(string codGroup)
{
SelCodGroup = codGroup;
}
#endregion Private Methods
}
}
+1 -1
View File
@@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>aspnet-Lux.UI-a758c101-a2f4-4e38-977d-1c4887dbbd50</UserSecretsId>
<Version>0.9.2509.1812</Version>
<Version>0.9.2509.1813</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>LUX - Web Windows MES</i>
<h4>Versione: 0.9.2509.1812</h4>
<h4>Versione: 0.9.2509.1813</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
0.9.2509.1812
0.9.2509.1813
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>0.9.2509.1812</version>
<version>0.9.2509.1813</version>
<url>http://nexus.steamware.net/repository/SWS/GPW/stable/GPW.UI.zip</url>
<changelog>http://nexus.steamware.net/repository/SWS/GPW/stable/ChangeLog.html</changelog>
<mandatory>false</mandatory>