Files
lux/Lux.UI/Components/Compo/WorkLoad/RawPartSelector.razor.cs
T

135 lines
3.6 KiB
C#

using EgwCoreLib.Lux.Core.Generic;
using EgwCoreLib.Lux.Core.RestPayload;
using EgwCoreLib.Lux.Data.DbModel.Config;
using EgwCoreLib.Lux.Data.DbModel.Items;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
namespace Lux.UI.Components.Compo.WorkLoad
{
public partial class RawPartSelector
{
#region Public Properties
[Parameter]
public List<BomItemDTO> BomListAll { get; set; } = null!;
#if false
protected List<BomItemDTO>? ListRecords = null;
#endif
[Parameter]
public Dictionary<string, List<ItemRawDTO>> ItemAvailDict { get; set; } = null!;
[Parameter]
public EventCallback<OdlAssignDto> EC_ReqCalcProd { get; set; }
[Parameter]
public EventCallback<bool> EC_ReqClose { get; set; }
#endregion Public Properties
#region Protected Fields
protected List<ItemGroupModel> ListItemGroup = new List<ItemGroupModel>();
protected Dictionary<string, List<ItemRawDTO>>? ListRecords = null;
#endregion Protected Fields
#region Protected Properties
protected ItemSel.FiltSelect CurrFilt { get; set; } = new ItemSel.FiltSelect();
#endregion Protected Properties
#region Protected Methods
/// <summary>
/// Selezione record x inserimento barre da impiegare
/// </summary>
/// <param name="selRec"></param>
protected void DoSelect(string selKey)
{
CurrFilt = new ItemSel.FiltSelect()
{
//SelCodGroup = selRec.ClassCode,
SearchVal = selKey
};
CurrBomItem = selKey;
}
protected override void OnParametersSet()
{
isLoading = true;
UpdateTable();
}
protected void SaveNumRec(int newNum)
{
isLoading = true;
numRecord = newNum;
UpdateTable();
}
protected void SavePage(int newNum)
{
isLoading = true;
currPage = newNum;
UpdateTable();
}
protected void UpdateTable()
{
totalCount = ItemAvailDict.Count;
ListRecords = ItemAvailDict
.OrderBy(x => x.Key)
.Skip(numRecord * (currPage - 1))
.Take(numRecord)
.ToDictionary(x => x.Key, x => x.Value);
#if false
totalCount = BomListAll.Count;
ListRecords = BomListAll
.Skip(numRecord * (currPage - 1))
.Take(numRecord)
.ToList();
#endif
isLoading = false;
}
#endregion Protected Methods
private string checkSel(string curKey)
{
string answ = !string.IsNullOrEmpty(CurrBomItem) && CurrBomItem == curKey ? "table-info" : "";
return answ;
}
#region Private Fields
#if false
private BomItemDTO? CurrBomItem = null;
#endif
private string? CurrBomItem = null;
private int currPage = 1;
private bool isLoading = false;
private int numRecord = 10;
private int totalCount = 0;
#endregion Private Fields
#region Private Properties
private string mainColCss => CurrBomItem == null ? "col-12" : "col-3";
#endregion Private Properties
#region Private Methods
private async Task DoClose(MouseEventArgs args)
{
await EC_ReqClose.InvokeAsync(true);
}
#endregion Private Methods
}
}