141 lines
4.2 KiB
C#
141 lines
4.2 KiB
C#
using EgwCoreLib.Lux.Data.DbModel.Warehouse;
|
|
using static Lux.UI.Components.Compo.Warehouse.MatReqGroup;
|
|
|
|
namespace Lux.UI.Components.Compo.Warehouse
|
|
{
|
|
public partial class MatReqList
|
|
{
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public List<MatReqModel> AllRecords { get; set; } = null!;
|
|
|
|
[Parameter]
|
|
public EventCallback<Dictionary<string, List<int>>> EC_Updated { get; set; }
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected override void OnParametersSet()
|
|
{
|
|
UpdateDetail();
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private Dictionary<string, List<MatReqModel>> GroupDict = new();
|
|
|
|
private Dictionary<string, List<int>> SelectDict = new();
|
|
private List<string> AvailOrdList = new();
|
|
private List<string> AvailOrdRowList = new();
|
|
|
|
|
|
#endregion Private Fields
|
|
|
|
private string searchVal { get; set; } = string.Empty;
|
|
|
|
private string SearchVal
|
|
{
|
|
get => searchVal;
|
|
set
|
|
{
|
|
if (searchVal != value)
|
|
{
|
|
searchVal = value;
|
|
UpdateDetail();
|
|
}
|
|
}
|
|
}
|
|
private string btnResetCss
|
|
{
|
|
get => string.IsNullOrEmpty(searchVal) ? "btn-outline-secondary" : "btn-primary";
|
|
}
|
|
|
|
#region Private Methods
|
|
|
|
private Task ReportUpdate(GrpSelect currData)
|
|
{
|
|
// sistemo il dizionario selezioni
|
|
if (SelectDict.ContainsKey(currData.GroupName))
|
|
{
|
|
if (currData.ListItemIds.Count > 0)
|
|
{
|
|
SelectDict[currData.GroupName] = currData.ListItemIds;
|
|
}
|
|
else
|
|
{
|
|
SelectDict.Remove(currData.GroupName);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
SelectDict.Add(currData.GroupName, currData.ListItemIds);
|
|
}
|
|
return EC_Updated.InvokeAsync(SelectDict);
|
|
}
|
|
|
|
private void UpdateDetail()
|
|
{
|
|
// calcolo liste ordini e righeOrd disponibili...
|
|
AvailOrdList = AllRecords.Select(x => x.OrderNav!.OrderCode).Distinct().ToList();
|
|
AvailOrdRowList = AllRecords.Select(x => x.OrderRowNav!.OrderRowCode).Distinct().ToList();
|
|
IEnumerable<MatReqModel> query = AllRecords;
|
|
|
|
// filtro ordini
|
|
if (!string.IsNullOrEmpty(selOrd))
|
|
{
|
|
query = query.Where(x => x.OrderNav!.OrderCode == selOrd);
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(searchVal) && searchVal.Length >= 3)
|
|
{
|
|
if (searchVal.StartsWith("POR"))
|
|
{
|
|
query = query.Where(x => x.OrderRowNav!.OrderRowCode.Equals(searchVal, StringComparison.OrdinalIgnoreCase));
|
|
}
|
|
else if (searchVal.StartsWith("PO"))
|
|
{
|
|
query = query.Where(x => x.OrderNav!.OrderCode.Equals(searchVal, StringComparison.OrdinalIgnoreCase));
|
|
}
|
|
else
|
|
{
|
|
query = query.Where(x => x.ItemCode.Contains(searchVal, StringComparison.OrdinalIgnoreCase) || (x.ItemID != null && x.ItemNav.Description.Contains(searchVal, StringComparison.OrdinalIgnoreCase)));
|
|
}
|
|
}
|
|
// effettuo search
|
|
var searchRecords = query.ToList();
|
|
|
|
// calcolo dati derivati
|
|
GroupDict = searchRecords
|
|
.GroupBy(x => x.CodGroup)
|
|
.ToDictionary(g => g.Key, g => g.ToList());
|
|
}
|
|
private void ResetSearch()
|
|
{
|
|
SearchVal = "";
|
|
}
|
|
|
|
private string selOrd = "";
|
|
|
|
private string SelOrder
|
|
{
|
|
get
|
|
{
|
|
return selOrd;
|
|
}
|
|
set
|
|
{
|
|
if(selOrd != value)
|
|
{
|
|
selOrd = value;
|
|
UpdateDetail();
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |