Update gestione filtro TC
This commit is contained in:
@@ -1,38 +1,12 @@
|
||||
using global::System;
|
||||
using global::System.Collections.Generic;
|
||||
using global::System.Linq;
|
||||
using global::System.Threading.Tasks;
|
||||
using global::Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
using Microsoft.AspNetCore.Components.Forms;
|
||||
using Microsoft.AspNetCore.Components.Routing;
|
||||
using Microsoft.AspNetCore.Components.Web;
|
||||
using Microsoft.AspNetCore.Components.Web.Virtualization;
|
||||
using Microsoft.JSInterop;
|
||||
using MP_TAB_SERV;
|
||||
using MP_TAB_SERV.Shared;
|
||||
using MP_TAB_SERV.Components;
|
||||
using MP.Data;
|
||||
using MP.Data.DatabaseModels;
|
||||
using MP.Data.DTO;
|
||||
using MP.Data.Services;
|
||||
using NLog;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Json;
|
||||
|
||||
namespace MP_TAB_SERV.Components
|
||||
{
|
||||
public partial class TcHistoryFilter
|
||||
{
|
||||
[Parameter]
|
||||
public int MatrOpr { get; set; } = 102;
|
||||
|
||||
[Parameter]
|
||||
public string Title { get; set; } = "TC History";
|
||||
|
||||
[Parameter]
|
||||
public int SearchMinChar { get; set; }
|
||||
#region Public Properties
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<string> E_CodArt { get; set; }
|
||||
@@ -40,52 +14,109 @@ namespace MP_TAB_SERV.Components
|
||||
[Parameter]
|
||||
public EventCallback<string> E_IdxMacc { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public int MatrOpr { get; set; } = 102;
|
||||
|
||||
[Parameter]
|
||||
public int SearchMinChar { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string Title { get; set; } = "TC History";
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected string BaseAddr = "";
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
protected string CodArtSel
|
||||
{
|
||||
get => codArtSel;
|
||||
set
|
||||
{
|
||||
if (codArtSel != value)
|
||||
{
|
||||
codArtSel = value;
|
||||
var pUpd = Task.Run(async () =>
|
||||
{
|
||||
await ReportArt();
|
||||
});
|
||||
pUpd.Wait();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Inject]
|
||||
protected ListSelectDataSrv CtrDataServ { get; set; } = null!;
|
||||
|
||||
protected string BaseAddr = "";
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
BaseAddr = config.GetValue<string>("OptConf:BaseAddr") ?? "";
|
||||
await ReloadAllData();
|
||||
}
|
||||
protected int DisplayCount { get; set; } = 0;
|
||||
|
||||
protected async Task ReloadAllData()
|
||||
protected string IdxMaccSel
|
||||
{
|
||||
await ReloadArticoli();
|
||||
await ReloadMacchine();
|
||||
}
|
||||
|
||||
protected async Task ReloadArticoli()
|
||||
{
|
||||
await GetArticoli();
|
||||
FiltArticoli();
|
||||
}
|
||||
|
||||
protected async Task ReportArt()
|
||||
{
|
||||
await E_CodArt.InvokeAsync(CodArtSel);
|
||||
}
|
||||
|
||||
protected async Task ReportMacc()
|
||||
{
|
||||
await E_IdxMacc.InvokeAsync(IdxMaccSel);
|
||||
}
|
||||
|
||||
protected async Task GetArticoli()
|
||||
{
|
||||
if (!ListArtDisabled)
|
||||
get => codArtSel;
|
||||
set
|
||||
{
|
||||
Log.Debug("GetArticoli");
|
||||
var rawData = await CtrDataServ.ArticoliGetSearch(10000, "*", searchVal);
|
||||
// trasformo!
|
||||
if (rawData != null)
|
||||
if (idxMaccSel != value)
|
||||
{
|
||||
ListArticoliAll = rawData.ToDictionary(x => x.CodArticolo, x => $"{x.CodArticolo} | {x.DescArticolo} | {x.Disegno}");
|
||||
idxMaccSel = value;
|
||||
var pUpd = Task.Run(async () =>
|
||||
{
|
||||
await ReportMacc();
|
||||
});
|
||||
pUpd.Wait();
|
||||
}
|
||||
}
|
||||
}
|
||||
private string idxMaccSel { get; set; } = "";
|
||||
|
||||
protected bool ListArtDisabled { get => string.IsNullOrEmpty(SearchVal) || SearchVal.Length < SearchMinChar; }
|
||||
|
||||
protected Dictionary<string, string>? ListArticoli { get; set; } = null;
|
||||
|
||||
protected Dictionary<string, string> ListArticoliAll { get; set; } = new Dictionary<string, string>();
|
||||
|
||||
protected Dictionary<string, string> ListMacchineAll { get => MServ.DictMacchine; set => MServ.DictMacchine = value; }
|
||||
|
||||
protected int Num2Displ
|
||||
{
|
||||
get => num2Displ;
|
||||
set
|
||||
{
|
||||
if (num2Displ != value)
|
||||
{
|
||||
num2Displ = value;
|
||||
FiltArticoli();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected string SearchVal
|
||||
{
|
||||
get => searchVal;
|
||||
set
|
||||
{
|
||||
if (searchVal != value)
|
||||
{
|
||||
searchVal = value;
|
||||
var pUpd = Task.Run(async () =>
|
||||
{
|
||||
await ReloadArticoli();
|
||||
});
|
||||
pUpd.Wait();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected int TotalCount { get; set; } = 0;
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected void FiltArticoli()
|
||||
{
|
||||
@@ -109,6 +140,53 @@ namespace MP_TAB_SERV.Components
|
||||
}
|
||||
}
|
||||
|
||||
protected async Task GetArticoli()
|
||||
{
|
||||
if (!ListArtDisabled)
|
||||
{
|
||||
Log.Debug("GetArticoli");
|
||||
var rawData = await CtrDataServ.ArticoliGetSearch(10000, "*", searchVal);
|
||||
// trasformo!
|
||||
if (rawData != null)
|
||||
{
|
||||
ListArticoliAll = rawData.ToDictionary(x => x.CodArticolo, x => $"{x.CodArticolo} | {x.DescArticolo} | {x.Disegno}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
BaseAddr = config.GetValue<string>("OptConf:BaseAddr") ?? "";
|
||||
await ReloadAllData();
|
||||
}
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
#if false
|
||||
// update IdxMaccSel
|
||||
await ReportMacc();
|
||||
|
||||
// update SearchVal
|
||||
await ReloadArticoli();
|
||||
|
||||
// updateCodArtSel
|
||||
await ReportArt();
|
||||
#endif
|
||||
//return base.OnParametersSetAsync();
|
||||
}
|
||||
|
||||
protected async Task ReloadAllData()
|
||||
{
|
||||
await ReloadArticoli();
|
||||
await ReloadMacchine();
|
||||
}
|
||||
|
||||
protected async Task ReloadArticoli()
|
||||
{
|
||||
await GetArticoli();
|
||||
FiltArticoli();
|
||||
}
|
||||
|
||||
protected async Task ReloadMacchine()
|
||||
{
|
||||
if (ListMacchineAll == null || ListMacchineAll.Count == 0)
|
||||
@@ -124,71 +202,30 @@ namespace MP_TAB_SERV.Components
|
||||
}
|
||||
}
|
||||
|
||||
protected bool ListArtDisabled { get => string.IsNullOrEmpty(SearchVal) || SearchVal.Length < SearchMinChar; }
|
||||
|
||||
protected string SearchVal
|
||||
protected async Task ReportArt()
|
||||
{
|
||||
get => searchVal;
|
||||
set
|
||||
{
|
||||
if (searchVal != value)
|
||||
{
|
||||
searchVal = value;
|
||||
}
|
||||
}
|
||||
await E_CodArt.InvokeAsync(CodArtSel);
|
||||
}
|
||||
|
||||
protected string CodArtSel
|
||||
protected async Task ReportMacc()
|
||||
{
|
||||
get => codArtSel;
|
||||
set
|
||||
{
|
||||
if (codArtSel != value)
|
||||
{
|
||||
codArtSel = value;
|
||||
}
|
||||
}
|
||||
await E_IdxMacc.InvokeAsync(IdxMaccSel);
|
||||
}
|
||||
|
||||
protected int Num2Displ
|
||||
{
|
||||
get => num2Displ;
|
||||
set
|
||||
{
|
||||
if (num2Displ != value)
|
||||
{
|
||||
num2Displ = value;
|
||||
FiltArticoli();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion Protected Methods
|
||||
|
||||
protected string IdxMaccSel { get; set; } = "";
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
#if false
|
||||
// update IdxMaccSel
|
||||
await ReportMacc();
|
||||
|
||||
// update SearchVal
|
||||
await ReloadArticoli();
|
||||
|
||||
// updateCodArtSel
|
||||
await ReportArt();
|
||||
#endif
|
||||
//return base.OnParametersSetAsync();
|
||||
}
|
||||
|
||||
protected Dictionary<string, string> ListMacchineAll { get => MServ.DictMacchine; set => MServ.DictMacchine = value; }
|
||||
protected Dictionary<string, string> ListArticoliAll { get; set; } = new Dictionary<string, string>();
|
||||
protected Dictionary<string, string>? ListArticoli { get; set; } = null;
|
||||
protected int TotalCount { get; set; } = 0;
|
||||
protected int DisplayCount { get; set; } = 0;
|
||||
private string searchVal { get; set; } = "";
|
||||
private string codArtSel { get; set; } = "";
|
||||
private int num2Displ { get; set; } = 20;
|
||||
#region Private Fields
|
||||
|
||||
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private string codArtSel { get; set; } = "";
|
||||
private int num2Displ { get; set; } = 20;
|
||||
private string searchVal { get; set; } = "";
|
||||
|
||||
#endregion Private Properties
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user