- correzione filtro TCHist x webassembly
- ok update after bind change
This commit is contained in:
Samuele Locatelli
2023-09-28 18:30:13 +02:00
parent a1cf75e0a1
commit 1d54f18ede
6 changed files with 128 additions and 134 deletions
@@ -1,39 +1,48 @@
@using NLog;
@using System.Net.Http
@using System.Net.Http.Json
@inject HttpClient Http
<div class="row small">
<div class="col-12 col-md-3 mb-2">
<div class="form-floating small">
<input type="text" class="form-control" @bind="SearchVal">
<label for="floatingInput"><i class="fa-solid fa-magnifying-glass"></i> Articolo (3+ char)</label>
<input type="text" class="form-control" @bind="SearchVal" @bind:after="ReloadArticoli">
<label><i class="fa-solid fa-magnifying-glass"></i> Articolo (3+ char)</label>
</div>
</div>
<div class="col-12 col-md-6 mb-2">
<div class="form-floating">
<select class="form-select form-select-sm" disabled="@ListArtDisabled" @bind="@CodArtSel">
<option value="" selected>-- Nessuno --</option>
@if (ListArticoli == null)
{
<option value="" disabled>No record found</option>
}
else
{
@foreach (var item in ListArticoli)
{
<option value="@item.Key">@item.Value</option>
}
}
</select>
<label for="floatingSelect">Selezione Articolo (@DisplayCount / <b>@TotalCount</b>)</label>
<div class="row">
<div class="col-10 pe-0">
<div class="form-floating">
<select class="form-select form-select-sm" disabled="@ListArtDisabled" @bind="@CodArtSel" @bind:after="ReloadMacchine">
<option value="" selected>-- Nessuno --</option>
@if (ListArticoli == null)
{
<option value="" disabled>No record found</option>
}
else
{
@foreach (var item in ListArticoli)
{
<option value="@item.Key">@item.Value</option>
}
}
</select>
<label for="floatingSelect">Selezione Articolo (@DisplayCount / <b>@TotalCount</b>)</label>
</div>
</div>
<div class="col-2 ps-0">
<div class="form-floating small">
<input type="number" class="form-control text-end" @bind="Num2Displ" disabled="@ListArtDisabled">
<label>Max Displ</label>
</div>
</div>
</div>
</div>
<div class="col-12 col-md-3 mb-2">
<div class="form-floating">
<select class="form-select form-select-sm" disabled="@ListMacDisabled" @bind="@IdxMaccSel">
<option value="" selected>-- Nessuno --</option>
<option value="" selected>-- Tutti --</option>
@if (ListMacchineAll == null)
{
<option value="" disabled>No record found</option>
@@ -53,26 +62,38 @@
@code {
protected override async Task OnParametersSetAsync()
[Parameter]
public int SearchMinChar { get; set; }
[Parameter]
public EventCallback<string> E_SearchUpd { get; set; }
[Parameter]
public int MatrOpr { get; set; } = 102;
[Parameter]
public string Title { get; set; } = "TC History";
protected override async Task OnInitializedAsync()
{
await ReloadAllData();
}
// protected override Task OnInitializedAsync()
// {
// return base.OnInitializedAsync();
// }
string BaseAddr = "https://localhost:7057/MP/TAB2/";
private string BaseAddr = "https://localhost:7057/MP/TAB2/";
protected async Task ReloadAllData()
{
await ReloadArticoli();
await ReloadMacchine();
}
protected async Task ReloadArticoli()
{
bool done = false;
await GetArticoli();
FiltArticoli();
}
protected async Task GetArticoli()
{
if (!ListArtDisabled)
{
string ApiUrl = $"{BaseAddr}api/ListSelect/GetDictArticoli?SearchArt={SearchVal}";
@@ -81,7 +102,13 @@
{
ListArticoliAll = rawData;
}
}
}
protected void FiltArticoli()
{
bool done = false;
if (!ListArtDisabled)
{
if (ListArticoliAll != null)
{
TotalCount = ListArticoliAll.Count;
@@ -119,12 +146,6 @@
get => string.IsNullOrEmpty(CodArtSel);
}
protected async Task FixDisplay()
{
await InvokeAsync(StateHasChanged);
}
protected string SearchVal
{
get => searchVal;
@@ -133,27 +154,18 @@
if (searchVal != value)
{
searchVal = value;
try
{
var pUpd = Task.Run(async () =>
{
await ReloadArticoli();
});
pUpd.Wait();
}
catch (Exception exc)
{
Log.Error($"SearchVal{Environment.NewLine}{exc}");
}
// // var pUpd = Task.Run(async () =>
// // {
// // await ReloadArticoli();
// // FiltArticoli();
// // });
// // pUpd.Wait();
// ReloadArticoli().ConfigureAwait(false);
}
}
}
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
private string searchVal { get; set; } = "";
protected string CodArtSel
{
get => codArtSel;
@@ -162,64 +174,42 @@
if (codArtSel != value)
{
codArtSel = value;
// try
// {
var pUpd = Task.Run(async () =>
{
await ReloadMacchine();
});
pUpd.Wait();
// }
// catch (Exception exc)
// {
// Log.Error($"CodArtSel{Environment.NewLine}{exc}");
// }
// var pUpd = Task.Run(async () =>
// {
// await ReloadMacchine();
// });
// pUpd.Wait();
ReloadMacchine().ConfigureAwait(false);
// StateHasChanged();
}
}
}
protected int Num2Displ
{
get => num2Displ;
set
{
if (num2Displ != value)
{
num2Displ = value;
FiltArticoli();
}
}
}
protected string IdxMaccSel { get; set; } = "";
private string codArtSel { get; set; } = "";
protected Dictionary<string, string> ListMacchineAll { get; set; } = new Dictionary<string, string>();
protected Dictionary<string, string> ListArticoliAll { get; set; } = new Dictionary<string, string>();
protected Dictionary<string, string>? ListArticoli { get; set; } = null;
[Parameter]
public int SearchMinChar { get; set; }
[Parameter]
public EventCallback<string> E_SearchUpd { get; set; }
[Parameter]
public int MatrOpr { get; set; } = 102;
[Parameter]
public string Title { get; set; } = "TC History";
protected int Num2Displ { get; set; } = 50;
protected int TotalCount { get; set; } = 0;
protected int DisplayCount { get; set; } = 0;
protected void LoadMore()
{
ListArticoli = null;
// await Task.Delay(1);
Num2Displ += 10;
Num2Displ = Num2Displ < TotalCount ? Num2Displ : TotalCount;
// ListArticoli = ListArticoliAll.Take(Num2Displ).ToList();
}
private string searchVal { get; set; } = "";
private string codArtSel { get; set; } = "";
private int num2Displ { get; set; } = 20;
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
}
+9 -30
View File
@@ -1,46 +1,25 @@
@* @attribute [RenderModeAuto] *@
@attribute [RenderModeServer]
@attribute [RenderModeAuto]
@* @attribute [RenderModeServer] *@
<div class="card">
<div class="card-header">
<MP_TAB.Client.Components.HistTCFilt Title="Storico Tempi Ciclo" SearchMinChar="@SearchMinChar" E_SearchUpd="RepSearchUpd"></MP_TAB.Client.Components.HistTCFilt>
<MP_TAB.Client.Components.TcHistoryFilter Title="Storico Tempi Ciclo" SearchMinChar="@SearchMinChar" E_SearchUpd="RepSearchUpd" MatrOpr="@MatrOpr"></MP_TAB.Client.Components.TcHistoryFilter>
</div>
<div class="card-body">
@if (ListArticoli != null)
{
<b>griglia risultati</b>
@* <div style="height: 200px;overflow-y:scroll">
<Virtualize Items="@ListArticoli" OverscanCount="6" ItemSize="10">
<ItemContent>
<p>@context.CodArticolo | @context.DescArticolo</p>
</ItemContent>
<Placeholder>
<p>Loading...</p>
</Placeholder>
<EmptyContent>
<p>
There are no strings to display.
</p>
</EmptyContent>
</Virtualize>
</div> *@
}
<b>griglia risultati</b>
</div>
</div>
@code {
[Parameter]
public List<AnagArticoli>? ListArticoli { get; set; }
public int MatrOpr { get; set; } = 0;
[Parameter]
public int SearchMinChar { get; set; }
[Parameter]
public EventCallback<string> E_FiltSearchUpd { get; set; }
protected int SearchMinChar = 3;
protected async Task RepSearchUpd(string newSearch)
{
await E_FiltSearchUpd.InvokeAsync(newSearch);
await Task.Delay(1);
// await E_FiltSearchUpd.InvokeAsync(newSearch);
}
}
+13 -1
View File
@@ -1,4 +1,16 @@
@page "/tc-history"
@using MP_TAB.Data
@inject UserServ UDataServ
<MP_TAB.Client.Pages.TCHistory></MP_TAB.Client.Pages.TCHistory>
<MP_TAB.Client.Pages.TCHistory MatrOpr="@MatrOpr"></MP_TAB.Client.Pages.TCHistory>
@code{
private int MatrOpr { get; set; } = 0;
protected override void OnInitialized()
{
MatrOpr = UDataServ.MatrOpr;
}
}
+12
View File
@@ -0,0 +1,12 @@
namespace MP_TAB.Data
{
public class UserServ
{
/// <summary>
/// Matricola operatore corrente (x filtraggio dati)
/// ToDo: gestire login!!!
/// </summary>
public int MatrOpr = 102;
}
}
+2
View File
@@ -2,6 +2,7 @@ using MP_TAB.Components;
using MP.Data.Services;
using StackExchange.Redis;
using Microsoft.Net.Http.Headers;
using MP_TAB.Data;
var builder = WebApplication.CreateBuilder(args);
ConfigurationManager configuration = builder.Configuration;
@@ -16,6 +17,7 @@ var redisMultiplexer = ConnectionMultiplexer.Connect(connStringRedis);
builder.Services.AddSingleton<IConnectionMultiplexer>(redisMultiplexer);
builder.Services.AddSingleton<StatusData>();
builder.Services.AddSingleton<ListSelectDataSrv>();
builder.Services.AddScoped<UserServ>();
// nuova versione contenuti...
builder.Services.AddRazorComponents()
+1 -2
View File
@@ -183,10 +183,9 @@ namespace MP.Data.Controllers
using (var dbCtx = new MoonProContext(_configuration))
{
dbResult = dbCtx
.DbSetArticoli
.DbSetArticoli
.AsNoTracking()
.Where(x => (azienda == "*" || x.Azienda == azienda ) && (string.IsNullOrEmpty(searchVal) || x.CodArticolo.Contains(searchVal) || x.DescArticolo.Contains(searchVal) || x.Disegno.Contains(searchVal) ))
//.AsNoTracking()
.OrderBy(x => x.CodArticolo)
.Take(numRecord)
.ToList();