using Microsoft.AspNetCore.Components; using Microsoft.JSInterop; using MP.Data.DbModels; using MP.Data.Services; namespace MP_TAB3.Components { public partial class TechSheetMan { #region Public Properties [Parameter] public MappaStatoExplModel? RecMSE { get; set; } = null; #endregion Public Properties #region Protected Properties [Inject] protected IJSRuntime JSRuntime { get; set; } = null!; protected List ListGruppi { get; set; } = new List(); [Inject] protected TabDataService TabDServ { get; set; } = null!; #endregion Protected Properties #region Protected Methods protected async Task ClearOdl() { if (!await JSRuntime.InvokeAsync("confirm", $"Sicuro di voler resettare?")) return; if (IdxOdl > 0) { await TabDServ.ST_CheckCleanByOdl(IdxOdl); } checkReset(); } protected async Task ForceRefresh() { isProcessing = true; await InvokeAsync(StateHasChanged); await ReloadData(); isProcessing = false; } protected override async Task OnParametersSetAsync() { if (RecMSE != null && !RecMSE.MostlyEquals(lastRecMSE)) { CodArticolo = RecMSE.CodArticolo; IdxMaccSel = RecMSE.IdxMacchina; IdxOdl = RecMSE.IdxOdl ?? 0; lastRecMSE = RecMSE; await ReloadData(); checkReset(); } } #endregion Protected Methods #region Private Fields private string CodArticolo = ""; private bool inAttr = false; private bool isProcessing = false; #endregion Private Fields #region Private Properties private string IdxMaccSel { get; set; } = ""; private int IdxOdl { get; set; } = 0; private MappaStatoExplModel? lastRecMSE { get; set; } = null; #endregion Private Properties #region Private Methods /// /// Verifica visibilit� reset /// private void checkReset() { // condizioni booleane inAttr = false; // SOLO SE ho articolo senn� niente reset... if (!string.IsNullOrEmpty(CodArticolo)) { // controllo se la macchina sia in attrezzaggio... var rigaStato = TabDServ.StatoMacchina(IdxMaccSel); if (rigaStato != null) { inAttr = (rigaStato.IdxStato == 2); } } } private async Task ReloadData() { ListGruppi = await TabDServ.ST_AnagGruppiList(); } #endregion Private Methods } }