126 lines
5.3 KiB
Plaintext
126 lines
5.3 KiB
Plaintext
@page "/Warehouse"
|
|
|
|
@using Syncfusion.Blazor.Cards
|
|
@using Syncfusion.Blazor.Grids
|
|
@using SytelineSaAppEfDataModel.Dtos
|
|
@using Syncfusion.Blazor.DropDowns
|
|
@using FilterType = Syncfusion.Blazor.Grids.FilterType
|
|
@using SelectionMode = Syncfusion.Blazor.Grids.SelectionMode
|
|
@using Syncfusion.Blazor.Navigations
|
|
|
|
@inject WarehouseService WarehouseService
|
|
|
|
<div class="h-100 d-flex justify-content-center align-items-start">
|
|
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;">
|
|
<CardHeader>
|
|
<h3 class="text-primary">Dokumenty WZ na Magazynie</h3>
|
|
</CardHeader>
|
|
<CardContent>
|
|
<h5 class="text-primary mb-3">Klient</h5>
|
|
<SfDropDownList TValue="Guid?" TItem="WzClientDto" DataSource="@_clients" Placeholder="Wybierz Klienta">
|
|
<DropDownListFieldSettings Value="ID" Text="Name"/>
|
|
<DropDownListEvents TValue="Guid?" TItem="WzClientDto" ValueChange="OnValueChange"/>
|
|
</SfDropDownList>
|
|
@if (_isVisible)
|
|
{
|
|
<h5 class="text-primary mb-3">Dokumenty WZ</h5>
|
|
<SfGrid @ref="_grid"
|
|
AllowFiltering="true"
|
|
AllowPaging="true"
|
|
AllowSorting="true"
|
|
AllowSelection="true"
|
|
TValue="MaterialTransactionDto"
|
|
DataSource="@_materialTransactions"
|
|
EnableAdaptiveUI="true">
|
|
<GridColumns>
|
|
<GridColumn Field=@nameof(MaterialTransactionDto.MTGroupNum) HeaderText="Numer WZ" TextAlign="TextAlign.Center" Width="110"></GridColumn>
|
|
<GridColumn Field=@nameof(MaterialTransactionDto.Item) HeaderText="Indeks" TextAlign="TextAlign.Center" Width="80"></GridColumn>
|
|
<GridColumn Field=@nameof(MaterialTransactionDto.Qty) HeaderText="Ilość sztuk" TextAlign="TextAlign.Right" Width="90"></GridColumn>
|
|
<GridColumn Field=@nameof(MaterialTransactionDto.CreateDate) HeaderText="Data utworzenia" TextAlign="TextAlign.Center" Width="100"></GridColumn>
|
|
<GridColumn Field=@nameof(MaterialTransactionDto.RefNum) HeaderText="Numer zamówienia" TextAlign="TextAlign.Center" Width="110"></GridColumn>
|
|
</GridColumns>
|
|
<SfToolbar>
|
|
<ToolbarItems>
|
|
<ToolbarItem Type="ItemType.Button" Text="Utwórz Packing List" Id="CreatePackingList"
|
|
PrefixIcon="e-icons e-save" OnClick="CreatePackingList"/>
|
|
</ToolbarItems>
|
|
</SfToolbar>
|
|
<GridFilterSettings Type="FilterType.Excel"/>
|
|
<GridPageSettings PageSize="10" PageSizes="@(new[] { 10, 20, 50, 100 })"/>
|
|
<GridSelectionSettings Mode="SelectionMode.Row" Type="SelectionType.Multiple"/>
|
|
@* <GridEvents TValue="EdiCustomerOrderDto" OnRecordDoubleClick="OnRowDoubleClick" RowSelected="RowSelected"/> *@
|
|
</SfGrid>
|
|
}
|
|
</CardContent>
|
|
<CardFooter>
|
|
<small class="text-muted">FA Krosno Manager © @(DateTime.Now.Year)</small>
|
|
</CardFooter>
|
|
</SfCard>
|
|
</div>
|
|
|
|
@code {
|
|
private SfGrid<MaterialTransactionDto> _grid;
|
|
IEnumerable<WzClientDto> _clients = new List<WzClientDto>();
|
|
IEnumerable<MaterialTransactionDto> _materialTransactions = new List<MaterialTransactionDto>();
|
|
|
|
WzClientDto? _selectedClient;
|
|
|
|
bool _isVisible = false;
|
|
|
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
|
{
|
|
if (firstRender)
|
|
{
|
|
_clients = await WarehouseService.GetAllClientsAsync();
|
|
StateHasChanged();
|
|
}
|
|
}
|
|
|
|
private async Task OnValueChange(ChangeEventArgs<Guid?, WzClientDto> args)
|
|
{
|
|
if (args.Value.HasValue)
|
|
{
|
|
_selectedClient = args.ItemData;
|
|
_isVisible = true;
|
|
_materialTransactions = await WarehouseService.GetAllClientWzsAsync(_selectedClient.CustomerNumber, _selectedClient.CustomerSequence ?? 0);
|
|
}
|
|
else
|
|
{
|
|
_selectedClient = null;
|
|
_isVisible = false;
|
|
}
|
|
|
|
StateHasChanged();
|
|
}
|
|
|
|
private async Task CreatePackingList()
|
|
{
|
|
var selectedRecords = await _grid.GetSelectedRecordsAsync();
|
|
if (selectedRecords.Any())
|
|
{
|
|
WzHeaderDto wzHeader = new WzHeaderDto
|
|
{
|
|
ID = Guid.NewGuid(),
|
|
FK_Client = _selectedClient?.ID
|
|
};
|
|
|
|
await WarehouseService.CreateWzHeaderAsync(wzHeader);
|
|
|
|
switch (_selectedClient?.Name.ToUpper())
|
|
{
|
|
case "MEYLE":
|
|
IList<WzRowMeyleDto> rows = new List<WzRowMeyleDto>();
|
|
foreach (MaterialTransactionDto materialTransactionDto in selectedRecords)
|
|
{
|
|
rows.Add(new WzRowMeyleDto
|
|
{
|
|
ID = Guid.NewGuid(),
|
|
Quantity = Math.Abs((int?)materialTransactionDto.Qty ?? 0),
|
|
//ItemNumber =
|
|
});
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
} |