Aggiunta preliminare gestione amteriali alternativi

This commit is contained in:
Samuele Locatelli
2025-09-16 19:16:21 +02:00
parent 914aacf475
commit 2c83d229b5
13 changed files with 170 additions and 45 deletions
@@ -13,7 +13,14 @@ namespace EgwCoreLib.Lux.Core.RestPayload
public string DescriptionCode { get; set; } = "";
public string ItemCode { get; set; } = "";
public double Qty { get; set; } = 0;
/// <summary>
/// Prezzo (SE ricevuto dalla BOM)
/// </summary>
public double Price { get; set; } = 0;
/// <summary>
/// Prezzo calcolato (dalla BOM o calcolato da anagrafica ITEMS)
/// </summary>
public double PriceCalc { get; set; } = 0;
public int ItemID { get; set; } = 0;
public int ItemQty { get; set; } = 0;
}
@@ -611,8 +611,7 @@ namespace EgwCoreLib.Lux.Data.Controllers
{
// conto l'item
numItemOk++;
// ...e aggiorno totale
totCost += item.Price;
item.PriceCalc = item.Price;
}
else
{
@@ -629,14 +628,15 @@ namespace EgwCoreLib.Lux.Data.Controllers
{
numItemOk++;
item.ItemID = recCost.ItemID;
item.Price = recCost.Cost * (1 + recCost.Margin) * item.Qty;
totCost += item.Price;
item.PriceCalc = recCost.Cost * (1 + recCost.Margin) * item.Qty;
}
else
{
item.ItemID = 0;
item.Price = 0;
item.PriceCalc = 0;
}
// ...e aggiorno totale
totCost += item.PriceCalc;
}
}
// salvo BOM...
@@ -712,8 +712,7 @@ namespace EgwCoreLib.Lux.Data.Controllers
item.ItemID = 0;
// conto l'item
numItemOk++;
// ...e aggiorno totale
totCost += item.Price;
item.PriceCalc = item.Price;
}
else
{
@@ -730,14 +729,15 @@ namespace EgwCoreLib.Lux.Data.Controllers
{
numItemOk++;
item.ItemID = recCost.ItemID;
item.Price = recCost.Cost * (1 + recCost.Margin) * item.Qty;
totCost += item.Price;
item.PriceCalc = recCost.Cost * (1 + recCost.Margin) * item.Qty;
}
else
{
item.ItemID = 0;
item.Price = 0;
item.PriceCalc = 0;
}
// ...e aggiorno totale
totCost += item.PriceCalc;
}
}
@@ -351,6 +351,22 @@ namespace EgwCoreLib.Lux.Data.Services
return result;
}
/// <summary>
/// Converte il campo raw della BOM in lista oggetti da gestire
/// </summary>
/// <param name="currRec"></param>
/// <returns></returns>
public List<BomItemDTO> OffertGetBomList(OfferRowModel currRec)
{
List<BomItemDTO> answ = new List<BomItemDTO>();
var bomList = JsonConvert.DeserializeObject<List<BomItemDTO>>(currRec.ItemBOM);
if (bomList != null)
{
answ = bomList;
}
return answ;
}
/// <summary>
/// Effettua update dei costi di tutte le righe dell'offerta indicata
/// </summary>
+1 -1
View File
@@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Version>0.9.2509.1618</Version>
<Version>0.9.2509.1619</Version>
</PropertyGroup>
<ItemGroup>
+32
View File
@@ -0,0 +1,32 @@
<table class="table table-sm table-striped">
<thead>
<tr>
<td>Class</td>
<td>Descrizione</td>
<td>Cod</td>
<td>Qty</td>
<td>Prezzo</td>
<td>Alt</td>
</tr>
</thead>
<tbody>
@foreach (var item in BomList)
{
<tr>
<td>@item.ClassCode</td>
<td>@item.ItemCode</td>
<td>@item.DescriptionCode</td>
<td>@($"{item.Qty:N2}")</td>
<td>@($"{item.PriceCalc:C2}")</td>
<td>
@if (item.Price == 0)
{
<button class="btn btn-sm btn-warning" title="Effettua Cambio"><i class="fa-solid fa-arrow-right-arrow-left"></i></button>
}
</td>
</tr>
}
</tbody>
</table>
Trovati @BomList.Count record
+13
View File
@@ -0,0 +1,13 @@
using EgwCoreLib.Lux.Core.RestPayload;
using Microsoft.AspNetCore.Components;
namespace Lux.UI.Components.Compo
{
public partial class EditBom
{
[Parameter]
public List<BomItemDTO> BomList { get; set; } = null!;
}
}
+46 -27
View File
@@ -87,6 +87,30 @@ namespace Lux.UI.Components.Compo
#region Protected Methods
/// <summary>
/// Clona articolo
/// </summary>
/// <param name="curRec"></param>
protected void DoClone(ItemModel curRec)
{
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
};
}
/// <summary>
/// impossta record x eliminazione
/// </summary>
@@ -104,43 +128,27 @@ namespace Lux.UI.Components.Compo
UpdateTable();
}
/// <summary>
/// Edit articolo selezionato
/// </summary>
/// <param name="curRec"></param>
protected void DoEdit(ItemModel curRec)
{
editRecord = curRec;
}
private string doCloneCss(ItemModel item)
{
return item.ItemType == Enums.ItemClassType.Bom ? "btn-warning" : "btn-success";
}
protected void DoClone(ItemModel curRec)
{
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
};
}
/// <summary>
/// Reset selezione
/// </summary>
protected void DoReset()
{
editRecord = null;
}
/// <summary>
/// Selezione articolo x display info
/// </summary>
/// <param name="curRec"></param>
protected void DoSelect(ItemModel curRec)
{
selRecord = curRec;
@@ -173,11 +181,17 @@ namespace Lux.UI.Components.Compo
#region Private Fields
private FiltSelect actFilt = new FiltSelect();
private int currPage = 1;
private ItemModel? editRecord = null;
private bool isLoading = false;
private int numRecord = 10;
private ItemModel? selRecord = null;
private int totalCount = 0;
#endregion Private Fields
@@ -190,6 +204,11 @@ namespace Lux.UI.Components.Compo
UpdateTable();
}
private string doCloneCss(ItemModel item)
{
return item.ItemType == Enums.ItemClassType.Bom ? "btn-warning" : "btn-success";
}
private async Task DoSave(ItemModel currRec)
{
// salvo
+23 -3
View File
@@ -17,7 +17,7 @@ else
<div class="px-0">
<button class="btn btn-sm btn-primary" @onclick="() => RecalcOffer()">Ricalcola <i class="fa-solid fa-calculator"></i></button>
</div>
</div>
<div class="cad-body px-2">
@if (isLoading || ListRecords == null)
@@ -77,7 +77,7 @@ else
<td>@item.Note</td>
<td class="text-end">@item.Qty</td>
<td class="text-end">
@if(!(item.BomOk && item.ItemOk))
@if (!(item.BomOk && item.ItemOk))
{
<span class="text-danger me-2" title=""><i class="fa-solid fa-triangle-exclamation"></i></span>
}
@@ -87,7 +87,10 @@ else
@if (DisplayMode == EgwCoreLib.Lux.Core.Enums.DisplayMode.Edit)
{
<td class="text-end">
<button class="btn btn-sm btn-info" title="cambio materiali assegnati"><i class="fa-solid fa-arrow-right-arrow-left"></i></button>
@if(!string.IsNullOrEmpty(item.ItemBOM))
{
<button class="btn btn-sm btn-info" title="cambio materiali assegnati" @onclick="() => DoSwapMat(item)"><i class="fa-solid fa-arrow-right-arrow-left"></i></button>
}
</td>
}
</tr>
@@ -98,3 +101,20 @@ else
</div>
</div>
}
@if (showChangeMat && EditBomRecord != null)
{
<div class="modal" tabindex="-1" style="display:block; background-color: rgba(10,10,10,.6);" role="dialog">
<div class="modal-dialog modal-xl">
<div class="modal-content">
<div class="modal-header">
<div class="modal-title fs-4">Cambio Materiali offerta <b>@EditBomRecord.OfferRowUID</b></div>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close" @onclick="ClosePopup">
</button>
</div>
<div class="modal-body">
<EditBom BomList="@CurrBomList"></EditBom>
</div>
</div>
</div>
</div>
}
@@ -1,3 +1,4 @@
using EgwCoreLib.Lux.Core.RestPayload;
using EgwCoreLib.Lux.Data;
using EgwCoreLib.Lux.Data.DbModel;
using EgwCoreLib.Lux.Data.Services;
@@ -77,12 +78,29 @@ namespace Lux.UI.Components.Compo
#endregion Protected Methods
protected void ClosePopup()
{
showChangeMat = false;
EditBomRecord = null;
}
protected void DoSwapMat(OfferRowModel currRow)
{
showChangeMat = true;
EditBomRecord = currRow;
CurrBomList = DLService.OffertGetBomList(EditBomRecord);
}
#region Private Fields
private bool showChangeMat = false;
private List<BomItemDTO>? CurrBomList = null;
private List<OfferRowModel> AllRecords = new List<OfferRowModel>();
private string apiUrl = "";
private int currPage = 1;
private OfferRowModel? EditRecord = null;
private OfferRowModel? EditBomRecord = null;
private string imgBasePath = "";
private bool isLoading = false;
private List<OfferRowModel> ListRecords = new List<OfferRowModel>();
+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.1618</Version>
<Version>0.9.2509.1619</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>LUX - Web Windows MES</i>
<h4>Versione: 0.9.2509.1618</h4>
<h4>Versione: 0.9.2509.1619</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
0.9.2509.1618
0.9.2509.1619
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>0.9.2509.1618</version>
<version>0.9.2509.1619</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>