220 lines
6.1 KiB
C#
220 lines
6.1 KiB
C#
using global::Microsoft.AspNetCore.Components;
|
|
using MP.Data.DbModels;
|
|
using MP.Data.Services;
|
|
using NLog;
|
|
using static EgwCoreLib.Utils.DtUtils;
|
|
|
|
namespace MP_TAB3.Components
|
|
{
|
|
public partial class ScrapMan
|
|
{
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public EventCallback<string> E_MachSel { get; set; }
|
|
|
|
[Parameter]
|
|
public string IdxMacchSub { get; set; } = "";
|
|
|
|
[Parameter]
|
|
public MappaStatoExplModel? RecMSE { get; set; } = null;
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Protected Properties
|
|
|
|
protected bool enableScarti { get; set; } = true;
|
|
|
|
protected List<RegistroScartiModel> ListComplete { get; set; } = new List<RegistroScartiModel>();
|
|
|
|
protected List<RegistroScartiModel> ListPaged { get; set; } = new List<RegistroScartiModel>();
|
|
|
|
[Inject]
|
|
protected MessageService MServ { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected SharedMemService SMServ { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected TabDataService TabDServ { get; set; } = null!;
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected async Task ForceReload(bool DoClose)
|
|
{
|
|
if (DoClose)
|
|
{
|
|
selItem = null;
|
|
}
|
|
await ReloadData();
|
|
}
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await Task.Delay(1);
|
|
if (RecMSE != null)
|
|
{
|
|
enableScarti = SMServ.GetConfBool("enableScarti");
|
|
IdxMaccSel = RecMSE.IdxMacchina;
|
|
bool isMulti = SMServ.DictMacchMulti[IdxMaccSel] == 1;
|
|
if (isMulti)
|
|
{
|
|
var idxMSel = MServ.UserPrefGet(IdxMaccSel);
|
|
if (!string.IsNullOrEmpty(idxMSel))
|
|
{
|
|
IdxMaccSel = idxMSel;
|
|
}
|
|
}
|
|
|
|
DateTime fine = DateTime.Today.AddDays(1);
|
|
DateTime inizio = fine.AddDays(-3);
|
|
CurrPeriodo = new Periodo(inizio, fine);
|
|
await ReloadData();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Aggiorno valori produzione alla data richiesta...
|
|
/// </summary>
|
|
/// <param name="newDate"></param>
|
|
protected async Task ReloadData()
|
|
{
|
|
isProcessing = true;
|
|
await Task.Delay(1);
|
|
if (!string.IsNullOrEmpty(IdxMaccSel))
|
|
{
|
|
ListComplete = await TabDServ.RegScartiGetFilt(IdxMaccSel, IdxOdl, CurrPeriodo.Inizio, CurrPeriodo.Fine, false);
|
|
TotalCount = ListComplete.Count;
|
|
// esegue paginazione
|
|
UpdateTable();
|
|
}
|
|
isProcessing = false;
|
|
await Task.Delay(1);
|
|
}
|
|
|
|
protected void SaveNumRec(int newNum)
|
|
{
|
|
NumRecPage = newNum;
|
|
UpdateTable();
|
|
}
|
|
|
|
protected void SavePage(int newNum)
|
|
{
|
|
PageNum = newNum;
|
|
UpdateTable();
|
|
}
|
|
|
|
protected string selectedCss(RegistroScartiModel currItem)
|
|
{
|
|
return currItem.Equals(selItem) ? "table-info" : "";
|
|
}
|
|
|
|
protected async Task SetMacc(string selIdxMacc)
|
|
{
|
|
isProcessing = true;
|
|
await Task.Delay(1);
|
|
IdxMaccSel = selIdxMacc;
|
|
await ReloadData();
|
|
isProcessing = false;
|
|
await E_MachSel.InvokeAsync(selIdxMacc);
|
|
}
|
|
|
|
protected async Task SetOdl(int selIdxOdl)
|
|
{
|
|
isProcessing = true;
|
|
await Task.Delay(1);
|
|
IdxOdl = selIdxOdl;
|
|
await ReloadData();
|
|
isProcessing = false;
|
|
await Task.Delay(1);
|
|
}
|
|
|
|
protected async Task SetPeriodo(Periodo newPeriodo)
|
|
{
|
|
CurrPeriodo = newPeriodo;
|
|
await ReloadData();
|
|
}
|
|
|
|
protected async Task ShowKitDetail(RegistroScartiModel currItem)
|
|
{
|
|
isProcessing = true;
|
|
// deve essere != null in primis...
|
|
if (currItem != null)
|
|
{
|
|
// verifico se serve creare split dell'oggetto (hard coded!!!)
|
|
if (currItem.Tipo == "KIT" && !currItem.KitSplit)
|
|
{
|
|
await TabDServ.RegScartiKitSplit(currItem);
|
|
}
|
|
// faccio toggle show item (se era gi� selezionato --> null!)
|
|
if (!currItem.Equals(selItem))
|
|
{
|
|
selItem = currItem;
|
|
}
|
|
else
|
|
{
|
|
selItem = null;
|
|
}
|
|
}
|
|
await ReloadData();
|
|
isProcessing = false;
|
|
}
|
|
|
|
protected void UpdateTable()
|
|
{
|
|
// esegue paginazione
|
|
if (TotalCount > NumRecPage)
|
|
{
|
|
ListPaged = ListComplete.Skip((PageNum - 1) * NumRecPage).Take(NumRecPage).ToList();
|
|
}
|
|
else
|
|
{
|
|
ListPaged = ListComplete;
|
|
}
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private static Logger Log = LogManager.GetCurrentClassLogger();
|
|
private bool isProcessing = false;
|
|
private int NumRecPage = 10;
|
|
private int PageNum = 1;
|
|
private RegistroScartiModel? selItem = null;
|
|
private int TotalCount = 0;
|
|
private bool useOdl = false;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
private Periodo CurrPeriodo { get; set; } = new Periodo();
|
|
|
|
private string IdxMaccSel { get; set; } = "";
|
|
|
|
private int IdxOdl { get; set; } = 0;
|
|
|
|
private string selMessage
|
|
{
|
|
get => useOdl ? "Periodo da ODL" : "Periodo Libero";
|
|
}
|
|
|
|
private bool UseOdl
|
|
{
|
|
get => useOdl;
|
|
set
|
|
{
|
|
useOdl = value;
|
|
if (!value)
|
|
{
|
|
IdxOdl = 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion Private Properties
|
|
}
|
|
} |