cbd4a90d01
- Correzione MSE i MSEModel x naming - fix e test vari su app CORE (IOC/SPEC/TAB3/MON)
222 lines
5.5 KiB
C#
222 lines
5.5 KiB
C#
using global::Microsoft.AspNetCore.Components;
|
|
using MP.Data;
|
|
using MP.Data.DbModels;
|
|
using MP.Data.Services;
|
|
|
|
namespace MP_TAB3.Components
|
|
{
|
|
public partial class ScrapEditor
|
|
{
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public EventCallback<bool> E_Updated { get; set; }
|
|
|
|
[Parameter]
|
|
public MappaStatoExplModel? RecMSE { get; set; } = null;
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Protected Properties
|
|
|
|
protected string btnCss
|
|
{
|
|
get => ShowDetail ? "bt-dark border-primary border-2" : "btn-primary";
|
|
}
|
|
|
|
protected DateTime DateSel
|
|
{
|
|
get => dateSel.Round(TimeSpan.FromSeconds(1));
|
|
set
|
|
{
|
|
if (dateSel != value)
|
|
{
|
|
dateSel = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
protected string errMsg { get; set; } = "";
|
|
|
|
protected string faCss
|
|
{
|
|
get => ShowDetail ? "fa-chevron-up" : "fa-chevron-down";
|
|
}
|
|
|
|
protected List<vSelCauScartoModel> listCauScarto { get; set; } = new List<vSelCauScartoModel>();
|
|
|
|
[Inject]
|
|
protected MessageService MServ { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected MessageService MsgServ { get; set; } = null!;
|
|
|
|
protected int NumPz
|
|
{
|
|
get => numPz;
|
|
set
|
|
{
|
|
if (numPz != value)
|
|
{
|
|
numPz = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
[Inject]
|
|
protected StatusData SDService { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected SharedMemService SMServ { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected TabDataService TabServ { get; set; } = null!;
|
|
|
|
protected string Title
|
|
{
|
|
get => ShowDetail ? "Nascondi Registrazione Scarti" : "Mostra Registrazione Scarti";
|
|
}
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected void doCancel()
|
|
{
|
|
DoReset();
|
|
}
|
|
|
|
protected async Task doSave(vSelCauScartoModel currCau)
|
|
{
|
|
bool isMulti = false;
|
|
// verifico se la macchina sia configurata tra le MSFD...
|
|
if (SMServ.DictMacchMulti.ContainsKey(IdxMacc))
|
|
{
|
|
isMulti = SMServ.DictMacchMulti[IdxMacc] == 1;
|
|
}
|
|
string IdxMaccSel = IdxMacc;
|
|
if (isMulti)
|
|
{
|
|
var idxMSel = MsgServ.UserPrefGet(IdxMacc);
|
|
if (!string.IsNullOrEmpty(idxMSel))
|
|
{
|
|
IdxMaccSel = idxMSel;
|
|
}
|
|
}
|
|
// registro scarto
|
|
RegistroScartiModel newRec = new RegistroScartiModel()
|
|
{
|
|
IdxMacchina = IdxMaccSel,
|
|
DataOra = DateSel,
|
|
Causale = currCau.value,
|
|
Qta = NumPz,
|
|
MatrOpr = MatrOpr,
|
|
Note = UserComment
|
|
};
|
|
// inserisco
|
|
var done = await TabServ.RegScartiInsert(newRec);
|
|
if (done)
|
|
{
|
|
// reset
|
|
DoReset();
|
|
// prima di tutto svuoto dati prod
|
|
SDService.MachProdStRem(IdxMaccSel);
|
|
errMsg = "";
|
|
await E_Updated.InvokeAsync(true);
|
|
await ReloadData();
|
|
await InvokeAsync(StateHasChanged);
|
|
}
|
|
else
|
|
{
|
|
errMsg = "Insert non possibile: ODL non attivo o data/ora errato";
|
|
}
|
|
ShowDetail = false;
|
|
}
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await ReloadData();
|
|
}
|
|
|
|
protected async Task ReloadData()
|
|
{
|
|
var rawData = await TabServ.VSCS_getAll();
|
|
listCauScarto = rawData
|
|
.Where(x => x.isEnabled)
|
|
.OrderBy(x => x.label)
|
|
.ToList();
|
|
}
|
|
|
|
protected void resetDate()
|
|
{
|
|
DateSel = DateTime.Now;
|
|
}
|
|
|
|
protected void resetNumPz()
|
|
{
|
|
NumPz = 1;
|
|
}
|
|
|
|
protected void ToggleCtrl()
|
|
{
|
|
ShowDetail = !ShowDetail;
|
|
if (ShowDetail)
|
|
{
|
|
DateSel = DateTime.Now;
|
|
errMsg = "";
|
|
}
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Properties
|
|
|
|
private string CodArt
|
|
{
|
|
get => RecMSE != null ? RecMSE.CodArticolo : "";
|
|
}
|
|
|
|
private DateTime dateSel { get; set; } = DateTime.Now;
|
|
|
|
private string IdxMacc
|
|
{
|
|
get => RecMSE != null ? RecMSE.IdxMacchina : "";
|
|
}
|
|
|
|
private int MatrOpr
|
|
{
|
|
get => MServ.MatrOpr;
|
|
}
|
|
|
|
private int numPz { get; set; } = 1;
|
|
|
|
private bool ShowDetail { get; set; } = false;
|
|
|
|
private string userComment { get; set; } = "";
|
|
|
|
private string UserComment
|
|
{
|
|
get => userComment.Trim();
|
|
set
|
|
{
|
|
if (userComment != value)
|
|
{
|
|
userComment = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
private void DoReset()
|
|
{
|
|
UserComment = "";
|
|
DateSel = DateTime.Now;
|
|
ShowDetail = true;
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |