using EgwCoreLib.Lux.Core.Generic; namespace Lux.UI.Components.Compo.WorkLoad { public partial class RawPartSelector { #region Public Properties [Parameter] public List BomListAll { get; set; } = null!; #if false protected List? ListRecords = null; #endif [Parameter] public Dictionary> ItemAvailDict { get; set; } = null!; [Parameter] public EventCallback>> EC_ReqCalcProd { get; set; } [Parameter] public EventCallback EC_ReqClose { get; set; } [Parameter] public List DefaultValSet { get; set; } = null!; #endregion Public Properties #region Protected Fields protected List ListItemGroup = new List(); protected Dictionary>? ListRecords = null; #endregion Protected Fields #region Protected Properties protected ItemSel.FiltSelect CurrFilt { get; set; } = new ItemSel.FiltSelect(); #endregion Protected Properties #region Protected Methods /// /// Selezione record x inserimento tipo RawMat da impiegare /// /// private void DoSelect(KeyValuePair> selEntry) { CurrFilt = new ItemSel.FiltSelect() { //SelCodGroup = selRec.ClassCode, SearchVal = selEntry.Key }; CurrBomItem = selEntry; } /// /// Aggiunge un set standard /// /// private async Task DoAddStdSet(KeyValuePair> selEntry) { // aggiungo se mancassero... int cLenght = 0; foreach (var item in DefaultValSet) { int.TryParse(item.ValString, out cLenght); if (cLenght > 0) { if (!selEntry.Value.Any(x => x.Lenght == cLenght)) { selEntry.Value.Add(new ItemRawDTO() { Lenght = cLenght, Qty = 999 }); } } } } /// /// Aggiunta set std x tutti i record /// private async Task DoAddStdSetAll() { // aggiungo se mancassero... int cLenght = 0; foreach (var selEntry in ItemAvailDict) { foreach (var item in DefaultValSet) { int.TryParse(item.ValString, out cLenght); if (cLenght > 0) { if (!selEntry.Value.Any(x => x.Lenght == cLenght)) { selEntry.Value.Add(new ItemRawDTO() { Lenght = cLenght, Qty = 999 }); } } } } } /// /// Rimozione della misura indicata /// /// /// private void DoRemoveSize(string iKey, ItemRawDTO currItem) { // seleziono da key... CurrBomItem = ItemAvailDict.FirstOrDefault(x => x.Key == iKey); if (CurrBomItem.HasValue) { // cerco obj... var reqObj = CurrBomItem.Value.Value.FirstOrDefault(x => (x.ItemID == currItem.ItemID && currItem.ItemID > 0) || (x.Lenght == currItem.Lenght)); if (reqObj != null) { CurrBomItem.Value.Value.Remove(reqObj); } UpdateTable(); } CurrBomItem = null; } 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 = CurrBomItem != null && CurrBomItem.Value.Key == curKey ? "table-info" : ""; return answ; } #region Private Fields #if false private BomItemDTO? CurrBomItem = null; #endif private KeyValuePair>? CurrBomItem = null; private int currPage = 1; private bool isLoading = false; private int numRecord = 10; private int totalCount = 0; protected bool canSend { get => ItemAvailDict.Any(x => x.Value.Any(y => y.Qty > 0)); } #endregion Private Fields #region Private Properties private string mainColCss => CurrBomItem == null ? "col-12" : "col-6"; #endregion Private Properties #region Private Methods private async Task DoClose(MouseEventArgs args) { await EC_ReqClose.InvokeAsync(true); } private async Task DoSendCalc(MouseEventArgs args) { await EC_ReqCalcProd.InvokeAsync(ItemAvailDict); } #endregion Private Methods } }