fix ordinamento items
This commit is contained in:
@@ -1,4 +1,11 @@
|
||||
@if (isLoading)
|
||||
<div class="d-flex justify-content-between">
|
||||
<div class="w-25">
|
||||
<label for="search">Search</label>
|
||||
<input id="search" @bind="searchVal" class="form-control" />
|
||||
</div>
|
||||
<button data-bs-toggle="modal" data-bs-target="#modalNewFam" class="h-50 mt-4 buttonNew"><i class="fa-solid fa-plus"></i> NUOVO ARTICOLO</button>
|
||||
</div>
|
||||
@if (isLoading)
|
||||
{
|
||||
<LoadingData></LoadingData>
|
||||
}
|
||||
@@ -8,10 +15,6 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="text-end mb-2 w-25">
|
||||
<label>Search</label>
|
||||
<input @bind="searchVal" class="form-control"/>
|
||||
</div>
|
||||
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
@@ -24,8 +27,11 @@ else
|
||||
<th>
|
||||
DESC. ARTICOLO
|
||||
</th>
|
||||
<th>
|
||||
GIACENZA
|
||||
<th @onclick="()=>orderByCodForn()">
|
||||
COD. FORNITORE
|
||||
</th>
|
||||
<th @onclick="()=>orderByStock()">
|
||||
STOCK
|
||||
</th>
|
||||
<th>
|
||||
VALORE UNIT.
|
||||
@@ -47,27 +53,92 @@ else
|
||||
<td>
|
||||
@item.CodInt
|
||||
</td>
|
||||
<td style="width: 34rem;">
|
||||
<td style="width: 34rem;" class="small">
|
||||
@item.Descr
|
||||
</td>
|
||||
<td class="small">
|
||||
@item.CodExt
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
@item.QtaBatch
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<td class="small">
|
||||
@($"{item.CurrValue:C2}")
|
||||
</td>
|
||||
<td>
|
||||
@(item.CurrValue * item.QtaBatch)
|
||||
<td class="small">
|
||||
@($"{(item.CurrValue * item.QtaBatch):C2}")
|
||||
</td>
|
||||
<td class="d-flex justify-content-center">
|
||||
<button class="btnDup"><i class="fa-solid fa-magnifying-glass-plus"></i></button>
|
||||
<button class="btnDup" data-bs-toggle="modal" data-bs-target="#modalNewFam" @onclick="()=>dupItem(item)"><i class="fa-solid fa-copy"></i></button>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
<!-- Modal -->
|
||||
<div class="modal fade" id="modalNewFam" tabindex="-1" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h1 class="modal-title fs-5" id="modalNewFamLabel">Aggiungere nuova famiglia articoli</h1>
|
||||
<button type="button" class="btn-close" aria-label="Close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="w-100">
|
||||
<div class="form-floating">
|
||||
<input id="codArt" @bind-value="@codArt" class="form-control w-100 w-100w-100 my-1" />
|
||||
<label for="codArt" class="form-label">Codice Articolo</label>
|
||||
</div>
|
||||
<div class="form-floating">
|
||||
<textarea id="descArt" @bind="@descArt" class="form-control w-100" rows="3"></textarea>
|
||||
<label for="descArt" class="form-label">Descr. Articolo</label>
|
||||
</div>
|
||||
<div class="form-floating">
|
||||
<select id="famId" @bind="@famArt" class="form-select w-100 my-1">
|
||||
@if (itemFamList != null)
|
||||
{
|
||||
foreach (var fam in itemFamList)
|
||||
{
|
||||
<option value="@fam.Id">@fam.Descr</option>
|
||||
}
|
||||
}
|
||||
</select>
|
||||
<label for="famId" class="form-label">Fam. Articolo</label>
|
||||
</div>
|
||||
<div class="form-floating">
|
||||
<input id="codExt" @bind="@codForn" class="form-control w-100 my-1" />
|
||||
<label for="codExt" class="form-label">Cod. Fornitore</label>
|
||||
</div>
|
||||
<div class="form-floating">
|
||||
<textarea id="descExt" @bind="descForn" class="form-control w-100" rows="5"></textarea>
|
||||
<label for="descExt" class="form-label">Descr. Fornitore</label>
|
||||
</div>
|
||||
<div class="form-floating">
|
||||
<input id="qtaMin" type="number" @bind="@minGiac" class="form-control w-100 my-1" />
|
||||
<label for="qtaMin" class="form-label">Giacenza Minima</label>
|
||||
</div>
|
||||
<div class="form-floating">
|
||||
<input id="qtaBatch" type="number" @bind="@lottoGiac" class="form-control w-100 my-1" />
|
||||
<label for="qtaBatch" class="form-label">Lotto Acquisto</label>
|
||||
</div>
|
||||
<div class="form-floating">
|
||||
<input id="currVal" type="number" @bind="@valoreUnit" class="form-control w-100 my-1" />
|
||||
<label for="currVal" class="form-label">Valore Unit.</label>
|
||||
</div>
|
||||
<div class="form-floating">
|
||||
<input id="um" @bind="@uM" class="form-control w-100 my-1" />
|
||||
<label for="um" class="form-label">Unità di Misura</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-center mt-5">
|
||||
<button class="btnAccept" @onclick="()=>addNewItem()"><i class="fa-regular fa-circle-check"></i></button>
|
||||
<button class="btnDecline" data-bs-dismiss="modal"><i class="fa-solid fa-ban"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
@@ -28,6 +28,7 @@ namespace StockMan.CORE.Components
|
||||
|
||||
public List<ItemModel>? ListRecord { get; set; } = null;
|
||||
public List<ItemModel>? SearchRecords { get; set; } = null;
|
||||
public List<ItemFamilyModel>? itemFamList { get; set; } = null;
|
||||
|
||||
//protected override async Task OnInitializedAsync()
|
||||
//{
|
||||
@@ -77,6 +78,8 @@ namespace StockMan.CORE.Components
|
||||
private IConfiguration Configuration { get; set; } = null!;
|
||||
|
||||
protected bool isLoading = false;
|
||||
protected bool isStockAscending = false;
|
||||
protected bool isCodExtAscending = false;
|
||||
|
||||
private async Task reloadData()
|
||||
{
|
||||
@@ -90,16 +93,80 @@ namespace StockMan.CORE.Components
|
||||
SearchRecords = await SDService.ItemsGetAll();
|
||||
}
|
||||
totalCount = SearchRecords.Count;
|
||||
if (isStockAscending)
|
||||
{
|
||||
SearchRecords = SearchRecords.OrderBy(x => x.QtaBatch).ToList();
|
||||
}
|
||||
else if (!isStockAscending)
|
||||
{
|
||||
SearchRecords = SearchRecords.OrderByDescending(x => x.QtaBatch).ToList();
|
||||
}
|
||||
else if (isCodExtAscending)
|
||||
{
|
||||
SearchRecords = SearchRecords.OrderBy(x => x.CodExt).ToList();
|
||||
}
|
||||
else if (!isCodExtAscending)
|
||||
{
|
||||
SearchRecords = SearchRecords.OrderByDescending(x => x.CodExt).ToList();
|
||||
}
|
||||
ListRecord = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
|
||||
itemFamList = await SDService.ItemFamilyGetAll();
|
||||
await Task.Delay(1);
|
||||
await InvokeAsync(() => StateHasChanged());
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
private void selItemToDet(int selItem)
|
||||
{
|
||||
currItem = selItem;
|
||||
NavManager.NavigateTo(rawCode, true);
|
||||
}
|
||||
|
||||
protected async Task orderByStock()
|
||||
{
|
||||
isStockAscending = !isStockAscending;
|
||||
await reloadData();
|
||||
}
|
||||
protected async Task orderByCodForn()
|
||||
{
|
||||
isCodExtAscending = !isCodExtAscending;
|
||||
await reloadData();
|
||||
}
|
||||
protected async Task addNewItem()
|
||||
{
|
||||
ItemModel newRec = new ItemModel()
|
||||
{
|
||||
Descr = descArt,
|
||||
CodInt = codArt,
|
||||
ItemFamilyId = famArt,
|
||||
CodExt = codForn,
|
||||
DescrExt = descForn,
|
||||
QtaMin = minGiac,
|
||||
QtaBatch = lottoGiac,
|
||||
CurrValue = valoreUnit,
|
||||
Um = uM
|
||||
};
|
||||
var done = await SDService.ItemAdd(newRec);
|
||||
if (done)
|
||||
{
|
||||
NavManager.NavigateTo(NavManager.Uri, true);
|
||||
}
|
||||
}
|
||||
protected void dupItem(ItemModel itemDup)
|
||||
{
|
||||
if (itemDup != null)
|
||||
{
|
||||
codArt = itemDup.CodInt;
|
||||
descArt = itemDup.Descr;
|
||||
famArt = itemDup.ItemFamilyId;
|
||||
codForn = itemDup.CodExt;
|
||||
descForn = itemDup.DescrExt;
|
||||
minGiac = itemDup.QtaMin;
|
||||
lottoGiac = itemDup.QtaBatch;
|
||||
valoreUnit = itemDup.CurrValue;
|
||||
uM = itemDup.Um;
|
||||
}
|
||||
}
|
||||
protected int? _currItem;
|
||||
protected int? currItem
|
||||
{
|
||||
@@ -117,6 +184,89 @@ namespace StockMan.CORE.Components
|
||||
}
|
||||
}
|
||||
|
||||
protected string _descArt = "";
|
||||
protected string descArt
|
||||
{
|
||||
get => _descArt;
|
||||
set
|
||||
{
|
||||
_descArt = value;
|
||||
}
|
||||
}
|
||||
protected string _codArt = "";
|
||||
protected string codArt
|
||||
{
|
||||
get => _codArt;
|
||||
set
|
||||
{
|
||||
_codArt = value;
|
||||
}
|
||||
}
|
||||
protected string _famArt = "";
|
||||
protected string famArt
|
||||
{
|
||||
get => _famArt;
|
||||
set
|
||||
{
|
||||
_famArt = value;
|
||||
}
|
||||
}
|
||||
protected string _codForn = "";
|
||||
protected string codForn
|
||||
{
|
||||
get => _codForn;
|
||||
set
|
||||
{
|
||||
_codForn = value;
|
||||
}
|
||||
}
|
||||
protected string _descForn = "";
|
||||
protected string descForn
|
||||
{
|
||||
get => _descForn;
|
||||
set
|
||||
{
|
||||
_descForn = value;
|
||||
}
|
||||
}
|
||||
protected int _minGiac = 0;
|
||||
protected int minGiac
|
||||
{
|
||||
get => _minGiac;
|
||||
set
|
||||
{
|
||||
_minGiac = value;
|
||||
}
|
||||
}
|
||||
protected int _lottoGiac = 0;
|
||||
protected int lottoGiac
|
||||
{
|
||||
get => _lottoGiac;
|
||||
set
|
||||
{
|
||||
_lottoGiac = value;
|
||||
}
|
||||
}
|
||||
protected decimal _valoreUnit = 0;
|
||||
protected decimal valoreUnit
|
||||
{
|
||||
get => _valoreUnit;
|
||||
set
|
||||
{
|
||||
_valoreUnit = value;
|
||||
}
|
||||
}
|
||||
protected string _uM = "";
|
||||
protected string uM
|
||||
{
|
||||
get => _uM;
|
||||
set
|
||||
{
|
||||
_uM = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected string rawCode
|
||||
{
|
||||
|
||||
@@ -23,7 +23,8 @@
|
||||
background-color: rgba(254, 152, 83, 0.2);
|
||||
color: #fe9853;
|
||||
}
|
||||
.btnDet {
|
||||
.btnDet,
|
||||
.btnAccept {
|
||||
border-radius: 50%;
|
||||
padding: 0.5rem;
|
||||
width: 2.8rem;
|
||||
@@ -34,4 +35,23 @@
|
||||
margin-right: 1rem;
|
||||
background-color: rgba(86, 184, 167, 0.2);
|
||||
color: #56b8a7;
|
||||
}
|
||||
.btnDecline {
|
||||
border-radius: 50%;
|
||||
padding: 0.5rem;
|
||||
width: 2.8rem;
|
||||
height: 2.8rem;
|
||||
border: none;
|
||||
padding: 0;
|
||||
text-align: center;
|
||||
margin-right: 1rem;
|
||||
background-color: rgba(192, 57, 43, 0.2);
|
||||
color: #C0392B;
|
||||
}
|
||||
.buttonNew {
|
||||
border: none;
|
||||
border-radius: 0.4rem;
|
||||
padding: 0.2rem;
|
||||
background-color: #27ae60;
|
||||
color: #fff;
|
||||
}
|
||||
@@ -18,9 +18,22 @@
|
||||
background-color: rgba(254,152,83,0.2);
|
||||
color: #fe9853;
|
||||
}
|
||||
|
||||
.btnDet{
|
||||
.btnDet, .btnAccept {
|
||||
.buttonGlobal;
|
||||
background-color: rgba(86,184,167,0.2);
|
||||
color: #56b8a7;
|
||||
}
|
||||
|
||||
.btnDecline {
|
||||
.buttonGlobal;
|
||||
background-color: rgba(192, 57, 43, 0.2);
|
||||
color: #C0392B;
|
||||
}
|
||||
|
||||
.buttonNew {
|
||||
border: none;
|
||||
border-radius: 0.4rem;
|
||||
padding: 0.2rem;
|
||||
background-color: rgb(39, 174, 96);
|
||||
color: #fff;
|
||||
}
|
||||
+1
-1
@@ -1 +1 @@
|
||||
td{height:3.8rem;}.buttonGlobal{border-radius:50%;padding:.5rem;width:2.8rem;height:2.8rem;border:0;padding:0;text-align:center;margin-right:1rem;}.btnDup{border-radius:50%;padding:.5rem;width:2.8rem;height:2.8rem;border:0;padding:0;text-align:center;margin-right:1rem;background-color:rgba(254,152,83,.2);color:#fe9853;}.btnDet{border-radius:50%;padding:.5rem;width:2.8rem;height:2.8rem;border:0;padding:0;text-align:center;margin-right:1rem;background-color:rgba(86,184,167,.2);color:#56b8a7;}
|
||||
td{height:3.8rem;}.buttonGlobal{border-radius:50%;padding:.5rem;width:2.8rem;height:2.8rem;border:0;padding:0;text-align:center;margin-right:1rem;}.btnDup{border-radius:50%;padding:.5rem;width:2.8rem;height:2.8rem;border:0;padding:0;text-align:center;margin-right:1rem;background-color:rgba(254,152,83,.2);color:#fe9853;}.btnDet,.btnAccept{border-radius:50%;padding:.5rem;width:2.8rem;height:2.8rem;border:0;padding:0;text-align:center;margin-right:1rem;background-color:rgba(86,184,167,.2);color:#56b8a7;}.btnDecline{border-radius:50%;padding:.5rem;width:2.8rem;height:2.8rem;border:0;padding:0;text-align:center;margin-right:1rem;background-color:rgba(192,57,43,.2);color:#c0392b;}.buttonNew{border:0;border-radius:.4rem;padding:.2rem;background-color:#27ae60;color:#fff;}
|
||||
@@ -125,7 +125,7 @@ namespace StockMan.CORE.Data
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// inserimento nuovo record
|
||||
/// inserimento nuovo record famiglia item
|
||||
/// </summary>
|
||||
/// <param name="newRec"></param>
|
||||
/// <returns></returns>
|
||||
@@ -138,8 +138,23 @@ namespace StockMan.CORE.Data
|
||||
await Task.Delay(1);
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// inserimento nuovo record
|
||||
/// inserimento nuovo record item
|
||||
/// </summary>
|
||||
/// <param name="newRec"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> ItemAdd(ItemModel newRec)
|
||||
{
|
||||
var dbResult = await dbController.ItemAdd(newRec);
|
||||
// elimino cache redis...
|
||||
RedisValue pattern = new RedisValue($"{rKeyItems}:*");
|
||||
bool answ = await ExecFlushRedisPattern(pattern);
|
||||
await Task.Delay(1);
|
||||
return dbResult;
|
||||
}
|
||||
/// <summary>
|
||||
/// eliminazione record item family
|
||||
/// </summary>
|
||||
/// <param name="currRec"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
@@ -150,7 +150,7 @@ namespace StockMan.Data.Controllers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lista Item Flux (ALL!)
|
||||
/// Aggiunta famiglia di item
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> ItemFamilyAdd(ItemFamilyModel newRec)
|
||||
@@ -185,6 +185,43 @@ namespace StockMan.Data.Controllers
|
||||
}
|
||||
return fatto;
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// aggiunta item
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> ItemAdd(ItemModel newRec)
|
||||
{
|
||||
bool fatto = false;
|
||||
List<ItemModel> dbResult = new List<ItemModel>();
|
||||
using (StockManContext localDbCtx = new StockManContext(_configuration))
|
||||
{
|
||||
try
|
||||
{
|
||||
var currRec = localDbCtx
|
||||
.DbSetItem
|
||||
.Where(x => x.Id == newRec.Id)
|
||||
.FirstOrDefault();
|
||||
if (currRec != null)
|
||||
{
|
||||
fatto = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
localDbCtx
|
||||
.DbSetItem
|
||||
.Add(newRec);
|
||||
}
|
||||
await localDbCtx.SaveChangesAsync();
|
||||
fatto = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione durante ItemAdd{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
return fatto;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -266,7 +303,7 @@ namespace StockMan.Data.Controllers
|
||||
{
|
||||
var risultato = localDbCtx
|
||||
.DbSetItem
|
||||
.Where(x => ((x.Id.ToString()==searchVal)) || (x.CodInt.Contains(searchVal)) || (x.Descr.Contains(searchVal) || (x.CurrValue.ToString().Contains(searchVal))))
|
||||
.Where(x => ((x.Id.ToString()==searchVal)) || (x.CodInt.Contains(searchVal)) || (x.CodExt.Contains(searchVal)) || (x.Descr.Contains(searchVal) || (x.CurrValue.ToString().Contains(searchVal))))
|
||||
.ToList();
|
||||
|
||||
if (risultato != null)
|
||||
|
||||
Reference in New Issue
Block a user