Aggiunta preliminare RawItem con dimensioni mostrate dinamicamente

This commit is contained in:
Samuele Locatelli
2024-01-19 19:18:13 +01:00
parent d69bc8f18d
commit b9c5db56f5
11 changed files with 534 additions and 23 deletions
+115 -3
View File
@@ -1,5 +1,117 @@
<h3>ItemMan</h3>
<div class="card">
<div class="card-header">
<div class="d-flex justify-content-between">
<div class="px-2">
<h3>Articoli</h3>
</div>
<div class="px-2">
<div class="d-flex">
<div class="px-2">
@if (CurrItem == null)
{
<button class="btn btn-success" @onclick="()=>CreateNew()"><i class="fa-solid fa-square-plus"></i> Add New</button>
}
else
{
<button class="btn btn-warning" @onclick="()=> DoEdit(null)"><i class="fa-solid fa-ban"></i> Cancel</button>
}
</div>
</div>
</div>
</div>
@if (CurrItem != null)
{
<hr />
@* <MaterialEdit CurrRecord="CurrItem" EC_update="ForceReload"></MaterialEdit> *@
}
</div>
<div class="card-body p-1">
@if (ListRecords == null || isLoading)
{
<EgwCoreLib.Razor.LoadingData></EgwCoreLib.Razor.LoadingData>
}
else if (totalCount == 0)
{
<div class="alert alert-info">Nessun record trovato</div>
}
else
{
<table class="table table-striped table-sm text-start">
<thead>
<tr class="">
<th>
<button class="btn btn-primary btn-sm" @onclick="() => DoEdit(null)"><i class="fa-solid fa-rotate"></i></button>
</th>
<th>ID <Sorter ParamName="RawItemId" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter></th>
<th>Location <Sorter ParamName="Location" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter></th>
<th>Note <Sorter ParamName="Note" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter></th>
<th class="text-end">Qty <Sorter ParamName="Qty" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter></th>
@if (MaterialSel.IsWall)
{
<th class="text-end">W (mm) <Sorter ParamName="W" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter></th>
}
@* <th class="text-end">H (mm) <Sorter ParamName="H" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter></th> *@
<th class="text-end">L (mm) <Sorter ParamName="L" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter></th>
@* <th class="text-end"></th> *@
</tr>
</thead>
<tbody>
@foreach (var item in ListRecords)
{
<tr class="align-middle @CheckSel(item)">
<td>
<button class="btn btn-info btn-sm" @onclick="() => DoSelect(item)"><i class="fa-solid fa-search"></i></button>
<button class="btn btn-primary btn-sm" @onclick="() => DoEdit(item)"><i class="fa-solid fa-edit"></i></button>
</td>
<td>
@if (item.IsActive)
{
<span class="border border-primary rounded px-1">
<i class="fa-regular fa-thumbs-up"></i>
</span>
}
else
{
<span class="border border-info rounded px-1">
<i class="fa-regular fa-thumbs-down"></i>
</span>
}
&nbsp;@item.RawItemId
</td>
<td>
@item.Location
</td>
<td>
@item.Note
</td>
<td class="text-end fs-5">
<b>@item.QtyAvail</b>
</td>
@if (MaterialSel.IsWall)
{
<td class="text-end">
@($"{item.WMm:N2}")
</td>
}
@* <td class="text-end">
@($"{item.HMm:N2}")
</td> *@
<td class="text-end">
@($"{item.LMm:N2}")
</td>
@* <td class="text-end">
<button class="btn btn-sm btn-danger" @onclick="() => DeleteRecord(item)"><i class="fa-solid fa-trash-can"></i></button>
</td> *@
</tr>
}
</tbody>
</table>
}
</div>
<div class="card-footer">
<EgwCoreLib.Razor.DataPager PageSize="@numRecord" currPage="@currPage" numRecordChanged="SetNumRec" numPageChanged="SetPage" totalCount="@totalCount" showLoading="@isLoading"></EgwCoreLib.Razor.DataPager>
</div>
</div>
@code {
}
+344
View File
@@ -0,0 +1,344 @@
using EgwCoreLib.Razor;
using MagMan.Core.Services;
using MagMan.Data.Tenant.DbModels;
using MagMan.Data.Tenant.Services;
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
namespace MagMan.UI.Components
{
public partial class ItemMan
{
#region Public Properties
[Parameter]
public int CustomerId { get; set; } = 0;
[Parameter]
public EventCallback<int> E_RawItemSel { get; set; }
[Parameter]
public int KeyNum { get; set; } = 0;
[Parameter]
public MaterialModel MaterialSel { get; set; } = null!;
#endregion Public Properties
#region Protected Properties
[Inject]
protected MessageService AppMService { get; set; } = null!;
[Inject]
protected IConfiguration Configuration { get; set; } = null!;
[Inject]
protected IJSRuntime JSRuntime { get; set; } = null!;
protected int totalCount { get; set; } = 0;
[Inject]
protected TenantService TService { get; set; } = null!;
#endregion Protected Properties
#region Protected Methods
protected string CheckSel(RawItemModel curItem)
{
string answ = "";
if (CurrItem != null)
{
answ = curItem.RawItemId == CurrItem.RawItemId ? "table-info" : "";
}
else
{
answ = curItem.RawItemId == RawItemId ? "table-info" : "";
}
return answ;
}
protected async Task CreateNew()
{
CurrItem = new RawItemModel()
{
MatId = MaterialSel.MatId,
Location = "nd",
Note = "...",
QtyAvail = 0,
IsActive = true,
IsRemn = false,
HMm = MaterialSel.HMm,
LMm = MaterialSel.LMm,
WMm = MaterialSel.WMm
};
await InvokeAsync(StateHasChanged);
}
protected async Task DeleteRecord(RawItemModel selItem)
{
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Sicuro di voler eliminare il record?"))
return;
await TService.ItemDelete(KeyNum, selItem);
await ReloadData();
}
protected void DoEdit(RawItemModel? selItem)
{
CurrItem = selItem;
if (selItem == null)
{
DoSelect(null);
}
}
protected void DoSelect(RawItemModel? selItem)
{
if (selItem != null)
{
RawItemId = selItem.MatId;
}
else
{
RawItemId = 0;
}
E_RawItemSel.InvokeAsync(RawItemId);
}
protected async Task ForceReload(bool force)
{
CurrItem = null;
await ReloadData();
}
protected override void OnInitialized()
{
currSearch = "";
AppMService.EA_SearchUpdated += AppMService_EA_SearchUpdated;
}
protected override async Task OnParametersSetAsync()
{
await ReloadData();
}
protected void SetNumRec(int newNum)
{
numRecord = newNum;
currPage = 1;
InvokeAsync(ReloadData);
}
protected void SetPage(int newNum)
{
currPage = newNum;
InvokeAsync(ReloadData);
}
protected async Task SortRequested(Sorter.SortCallBack e)
{
sortField = e.ParamName;
sortAsc = e.IsAscending;
await ReloadData();
}
#endregion Protected Methods
#region Private Fields
private RawItemModel? CurrItem = null;
private string currSearch = "";
private int filtType = 0;
private List<RawItemModel>? ListRecords = null;
private int RawItemId = 0;
private List<RawItemModel>? SearchRecords = null;
private bool sortAsc = true;
private string sortField = "";
#endregion Private Fields
#region Private Properties
private int currPage { get; set; } = 1;
private int FiltType
{
get => filtType;
set
{
if (filtType != value)
{
filtType = value;
InvokeAsync(ReloadData);
InvokeAsync(StateHasChanged);
}
}
}
private bool isLoading { get; set; } = false;
private int numRecord { get; set; } = 10;
#endregion Private Properties
#region Private Methods
private async void AppMService_EA_SearchUpdated()
{
currSearch = AppMService.SearchVal;
await ReloadData();
}
private async Task ReloadData()
{
isLoading = true;
await InvokeAsync(StateHasChanged);
ListRecords = null;
SearchRecords = await TService.ItemGetByMat(KeyNum, MaterialSel.MatId);
// verifico filtro per ricerca
if (!string.IsNullOrEmpty(currSearch))
{
SearchRecords = SearchRecords.Where(x => x.Note.Contains(currSearch, StringComparison.InvariantCultureIgnoreCase)).ToList();
}
totalCount = SearchRecords.Count;
SortTable();
isLoading = false;
await InvokeAsync(StateHasChanged);
}
private void SortTable()
{
if (SearchRecords != null)
{
// se ho ordinamento riordino...
if (!string.IsNullOrEmpty(sortField))
{
switch (sortField)
{
case "RawItemId":
if (sortAsc)
{
SearchRecords = SearchRecords.OrderBy(x => x.RawItemId).ThenBy(x => x.Note).ToList();
}
else
{
SearchRecords = SearchRecords.OrderByDescending(x => x.RawItemId).ThenByDescending(x => x.Note).ToList();
}
break;
case "Location":
if (sortAsc)
{
SearchRecords = SearchRecords.OrderBy(x => x.Location).ToList();
}
else
{
SearchRecords = SearchRecords.OrderByDescending(x => x.Location).ToList();
}
break;
case "QtyAvail":
if (sortAsc)
{
SearchRecords = SearchRecords.OrderBy(x => x.QtyAvail).ToList();
}
else
{
SearchRecords = SearchRecords.OrderByDescending(x => x.QtyAvail).ToList();
}
break;
case "Note":
if (sortAsc)
{
SearchRecords = SearchRecords.OrderBy(x => x.Note).ToList();
}
else
{
SearchRecords = SearchRecords.OrderByDescending(x => x.Note).ToList();
}
break;
case "IsActive":
if (sortAsc)
{
SearchRecords = SearchRecords.OrderBy(x => x.IsActive).ToList();
}
else
{
SearchRecords = SearchRecords.OrderByDescending(x => x.IsActive).ToList();
}
break;
case "IsRemn":
if (sortAsc)
{
SearchRecords = SearchRecords.OrderBy(x => x.IsRemn).ToList();
}
else
{
SearchRecords = SearchRecords.OrderByDescending(x => x.IsRemn).ToList();
}
break;
case "W":
if (sortAsc)
{
SearchRecords = SearchRecords.OrderBy(x => x.WMm).ToList();
}
else
{
SearchRecords = SearchRecords.OrderByDescending(x => x.WMm).ToList();
}
break;
case "H":
if (sortAsc)
{
SearchRecords = SearchRecords.OrderBy(x => x.HMm).ToList();
}
else
{
SearchRecords = SearchRecords.OrderByDescending(x => x.HMm).ToList();
}
break;
case "L":
if (sortAsc)
{
SearchRecords = SearchRecords.OrderBy(x => x.LMm).ToList();
}
else
{
SearchRecords = SearchRecords.OrderByDescending(x => x.LMm).ToList();
}
break;
default:
break;
}
}
// filtro x display
ListRecords = SearchRecords
.Skip(numRecord * (currPage - 1))
.Take(numRecord)
.ToList();
}
else
{
ListRecords = new List<RawItemModel>();
}
}
private string textCss(bool isActive)
{
return isActive ? "text-dark" : "text-secondary text-decoration-line-through";
}
#endregion Private Methods
}
}
+17 -9
View File
@@ -57,7 +57,7 @@
<th>Descr. <Sorter ParamName="MatDesc" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter></th>
<th class="text-end">W (mm) <Sorter ParamName="W" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter></th>
<th class="text-end">H (mm) <Sorter ParamName="H" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter></th>
<th class="text-end">L (mm) <Sorter ParamName="L" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter></th>
@* <th class="text-end">L (mm) <Sorter ParamName="L" IsAsc="@sortAsc" CurrParam="@sortField" sortReq="SortRequested"></Sorter></th> *@
@* <th class="text-end"></th> *@
</tr>
</thead>
@@ -66,14 +66,15 @@
{
<tr class="align-middle @CheckSel(item)">
<td>
<button class="btn btn-info btn-sm" @onclick="() => DoSelect(item)"><i class="fa-solid fa-search"></i></button>
<button class="btn btn-primary btn-sm" @onclick="() => DoEdit(item)"><i class="fa-solid fa-edit"></i></button>
</td>
<td>
@if (item.IsBeam)
{
<span class="border border-primary rounded px-1">
<i class="fa-solid fa-lines-leaning"></i>
</span>
<span class="border border-primary rounded px-1">
<i class="fa-solid fa-lines-leaning"></i>
</span>
}
else if (@item.IsWall)
{
@@ -81,7 +82,7 @@
<i class="fa-solid fa-draw-polygon"></i>
</span>
}
&nbsp;@item.MatId&nbsp;
&nbsp;@item.MatId
</td>
<td>
@item.MatCode
@@ -90,14 +91,21 @@
@item.MatDesc
</td>
<td class="text-end">
@($"{item.WMm:N2}")
@if (item.IsBeam)
{
@($"{item.WMm:N2}")
}
else
{
<span>-</span>
}
</td>
<td class="text-end">
@($"{item.HMm:N2}")
</td>
<td class="text-end">
@($"{item.LMm:N2}")
</td>
@* <td class="text-end">
@($"{item.LMm:N2}")
</td> *@
@* <td class="text-end">
<button class="btn btn-sm btn-danger" @onclick="() => DeleteRecord(item)"><i class="fa-solid fa-trash-can"></i></button>
</td> *@
+27 -1
View File
@@ -19,6 +19,9 @@ namespace MagMan.UI.Components
[Parameter]
public int CustomerId { get; set; } = 0;
[Parameter]
public EventCallback<MaterialModel?> E_MaterialSel { get; set; }
[Parameter]
public int KeyNum { get; set; } = 0;
@@ -51,6 +54,10 @@ namespace MagMan.UI.Components
{
answ = curItem.MatId == CurrItem.MatId ? "table-info" : "";
}
else
{
answ = curItem.MatId == MaterialId ? "table-info" : "";
}
return answ;
}
@@ -75,6 +82,22 @@ namespace MagMan.UI.Components
protected void DoEdit(MaterialModel? selItem)
{
CurrItem = selItem;
if (selItem == null)
{
DoSelect(null);
}
}
protected void DoSelect(MaterialModel? selItem)
{
if (selItem != null)
{
MaterialId = selItem.MatId;
}
else
{
MaterialId = 0;
}
E_MaterialSel.InvokeAsync(selItem);
}
protected async Task ForceReload(bool force)
@@ -98,11 +121,13 @@ namespace MagMan.UI.Components
{
numRecord = newNum;
currPage = 1;
InvokeAsync(ReloadData);
}
protected void SetPage(int newNum)
{
currPage = newNum;
InvokeAsync(ReloadData);
}
protected async Task SortRequested(Sorter.SortCallBack e)
@@ -117,6 +142,7 @@ namespace MagMan.UI.Components
#region Private Fields
private MaterialModel? CurrItem = null;
private int MaterialId = 0;
private string currSearch = "";
private int filtType = 0;
@@ -193,7 +219,7 @@ namespace MagMan.UI.Components
{
switch (sortField)
{
case "MatId":
case "RawItemId":
if (sortAsc)
{
SearchRecords = SearchRecords.OrderBy(x => x.MatId).ThenBy(x => x.MatCode).ToList();
+1 -1
View File
@@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Version>1.0.2401.1917</Version>
<Version>1.0.2401.1919</Version>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
+2 -2
View File
@@ -55,7 +55,7 @@
<div class="col-6 col-md-4">
<AuthorizeView Roles="SuperAdmin, Admin, User">
<Authorized>
<NavLink type="button" class="btn btn-block btn-primary text-light p-3 m-2 w-100" title="Stato Impianti" href="PlantStatus">
<NavLink type="button" class="btn btn-block btn-primary text-light p-3 m-2 w-100" title="Stato Impianti" href="MachineStatus">
<i class="fa-solid fa-screwdriver-wrench fa-2x mb-2" aria-hidden="true"></i>
<h4>Dati Macchine</h4>
</NavLink>
@@ -65,7 +65,7 @@
<div class="col-6 col-md-4">
<AuthorizeView Roles="SuperAdmin, Admin, User">
<Authorized>
<NavLink type="button" class="btn btn-block btn-primary text-light p-3 m-2 w-100" title="Scheda Stazione" href="GasStation">
<NavLink type="button" class="btn btn-block btn-primary text-light p-3 m-2 w-100" title="Scheda Stazione" href="WareHouse">
<i class="fa-solid fa-warehouse fa-2x mb-2" aria-hidden="true"></i>
<h4>Magazzino</h4>
</NavLink>
+13 -4
View File
@@ -28,12 +28,21 @@
}
else
{
@if (currMode == CtMode.Materials)
@* @if (currMode == CtMode.Materials)
{
<MaterialMan CustomerId="@CustomerID" KeyNum="@nKey"></MaterialMan>
}
else if (currMode == CtMode.Items)
{
<ItemMan></ItemMan>
}
} *@
<div class="row">
<div class="@mainCss">
<MaterialMan CustomerId="@CustomerID" KeyNum="@nKey" E_MaterialSel="SaveMat"></MaterialMan>
</div>
@if (MaterialSel != null)
{
<div class="col-6">
<ItemMan CustomerId="@CustomerID" KeyNum="@nKey" MaterialSel="@MaterialSel"></ItemMan>
</div>
}
</div>
}
+12
View File
@@ -1,6 +1,7 @@
using MagMan.Core.Services;
using MagMan.Data.Admin.DbModels;
using MagMan.Data.Admin.Services;
using MagMan.Data.Tenant.DbModels;
using Microsoft.AspNetCore.Components;
using YamlDotNet.Core.Tokens;
@@ -62,6 +63,7 @@ namespace MagMan.UI.Pages
private CtMode currMode = CtMode.Materials;
private int KeyNum = 0;
private MaterialModel? MaterialSel = null;
#endregion Private Fields
@@ -73,6 +75,16 @@ namespace MagMan.UI.Pages
#region Private Methods
protected void SaveMat(MaterialModel? newMat)
{
MaterialSel = newMat;
}
protected string mainCss
{
get => MaterialSel == null ? "col-12" : "col-6 small";
}
private string IsActive(CtMode modeReq)
{
string answ = currMode == modeReq ? "active" : "";
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>MagMan - Wood Warehouse Management System</i>
<h4>Versione: 1.0.2401.1917</h4>
<h4>Versione: 1.0.2401.1919</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
1.0.2401.1917
1.0.2401.1919
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>1.0.2401.1917</version>
<version>1.0.2401.1919</version>
<url>http://nexus.steamware.net/repository/SWS/MagMan/stable/0/MagMan.UI.zip</url>
<changelog>http://nexus.steamware.net/repository/SWS/MagMan/stable/0/ChangeLog.html</changelog>
<mandatory>false</mandatory>