* Migrated EdiCo and Co views to Syncfusion

This commit is contained in:
2025-02-07 07:28:07 +01:00
parent 9c4df2a2ed
commit 6800781fdb
5 changed files with 333 additions and 332 deletions

View File

@@ -4,126 +4,146 @@
@inject NavigationManager NavigationManager
@using OrdersManagement.Dtos
@using SytelineSaAppEfDataModel.Dtos
@using BlazorBootstrap
@using Syncfusion.Blazor.Grids
@using Syncfusion.Blazor.Cards
@using Syncfusion.Blazor.Popups
@using Syncfusion.Blazor.Buttons
@using SelectionType = Syncfusion.Blazor.Grids.SelectionType
@inherits LayoutComponentBase
<div class="row">
<h3>Zamówienia Klienta EDI</h3>
</div>
<br />
<h5>Zamówienia Klienta EDI</h5>
<div class="row">
<div class="col-md-12">
<Switch ValueExpression="() => _filter" ValueChanged="FilterChanged" Label="Pokaż wszystkie" />
<label for="checked" style="padding: 10px 10px 10px 0">Pokaż wszystkie</label>
<SfSwitch @bind-Checked="_filter" ValueChange="FilterChanged" TChecked="bool?" OnLabel="Pokaż tylko Wysłanr do SL" OffLabel="Pokaż wszystkie" />
</div>
</div>
<br />
<br/>
@if (_isVisible)
{
<div class="row">
<div class="col-md-12">
<Button Color="ButtonColor.Primary" @onclick="SendOrderToSyteLine">@_text</Button>
<SfButton @onclick="SendOrderToSyteLine">@_text</SfButton>
</div>
</div>
<br/>
}
<br />
<div class="row">
<Grid @ref="_grid"
TItem="EdiCustomerOrderDto"
Class="table table-hover table-bordered table-striped"
DataProvider="EdiCustomerOrdersDataProvider"
AllowFiltering="true"
Responsive="true"
AllowPaging="true"
PageSize="10"
AllowSelection="true"
AllowRowClick="true"
SelectionMode="GridSelectionMode.Multiple"
OnRowDoubleClick="OnRowDoubleClick"
SelectedItemsChanged="SelectedItemsChanged">
<GridColumns>
<GridColumn TItem="EdiCustomerOrderDto" HeaderText="Numer Zamówienia" PropertyName="CustomerOrderNumber">
@context.CustomerOrderNumber
</GridColumn>
<GridColumn TItem="EdiCustomerOrderDto" HeaderText="Zamówienie Klienta" PropertyName="CustomerPoNumber">
@context.CustomerPoNumber
</GridColumn>
<GridColumn TItem="EdiCustomerOrderDto" HeaderText="Numer Klienta" PropertyName="CustomerNumber">
@context.CustomerNumber
</GridColumn>
<GridColumn TItem="EdiCustomerOrderDto" HeaderText="Klient" PropertyName="CustomerName">
@context.CustomerName
</GridColumn>
<GridColumn TItem="EdiCustomerOrderDto" HeaderText="Odbiorca" PropertyName="CustomerSequence">
@context.CustomerSequence
</GridColumn>
<GridColumn TItem="EdiCustomerOrderDto" HeaderText="Data Otrzymania" PropertyName="CreateDate">
@context.CreateDate
</GridColumn>
<GridColumn TItem="EdiCustomerOrderDto" HeaderText="Zamówienie SL" PropertyName="SlOrderNumber">
@context.SlOrderNumber
</GridColumn>
<GridColumn TItem="EdiCustomerOrderDto" HeaderText="Wysłane do SL" PropertyName="SentToSl">
@context.SentToSl
</GridColumn>
</GridColumns>
</Grid>
</div>
<Modal @ref="_modal" Title="@_text">
<BodyTemplate>
@if (_responses.Any(x => x.Status == 1))
{
foreach (ResponseDto response in _responses.Where(x => x.Status == 1))
{
<p>Zamówienie EDI @response.Identifier zostało poprawnie zaksięgowane w Zamówieniach klienta pod numerem '@response.ExternalIdentifier'</p>
<SfGrid @ref="_grid"
AllowFiltering="true"
AllowPaging="true"
AllowSorting="true"
AllowSelection="true"
TValue="EdiCustomerOrderDto"
DataSource="@_ediCustomerOrders"
EnableAdaptiveUI="true">
<GridTemplates>
<DetailTemplate>
@{
var order = context as EdiCustomerOrderDto;
<SfCard>
<CardContent>
<div class="row">
<div class="col">
<u>Numer zamówienia EDI:</u>&emsp;<b>@order?.CustomerOrderNumber</b><br/>
<u>Numer zamówienia Klienta:</u>&emsp;<b>@order?.CustomerPoNumber</b><br/>
<u>Numer klienta:</u>&emsp;<b>@order?.CustomerNumber</b><br/>
<u>Klient:</u>&emsp;<b>@order?.CustomerName</b><br/>
<u>Numer odbiorcy:</u>&emsp;<b>@(order?.CustomerSequence?.ToString() ?? "N/A")</b><br/>
<u>Data
otrzymania:</u>&emsp;<b>@(order?.RecivedDate?.ToString("dd.MM.yyyy") ?? "N/A")</b><br/>
<u>Wysłano do
Syteline?:</u>&emsp;<b>@((order?.Posted?.ToString() ?? "0") == "0" ? "NIE" : "TAK")</b><br/>
<u>Data wysyłki do
Syteline:</u>&emsp;<b>@(order?.PostedDate?.ToString("dd.MM.yyyy") ?? "N/A")</b><br/>
<u>Data zamówienia:</u>&emsp;<b>@(order?.OrderDate?.ToString("dd.MM.yyyy") ?? "N/A")</b><br/>
</div>
<div class="col">
<u>Cena:</u>&emsp;<b>@(order?.Price?.ToString("F2") ?? "N/A")</b><br/>
<u>Waga:</u>&emsp;<b>@(order?.Weight?.ToString("F2") ?? "N/A")</b><br/>
<u>Magazyn:</u>&emsp;<b>@order?.Warehouse</b><br/>
<u>Gate:</u>&emsp;<b>@order?.Gate</b><br/>
<u>Kod odbiorcy:</u>&emsp;<b>@order?.RecipientCode</b><br/>
<u>Kod wysyłającego:</u>&emsp;<b>@order?.SenderCode</b><br/>
<u>Kod sprzedawcy:</u>&emsp;<b>@order?.SellerCode</b><br/>
<u>Kod kupującego:</u>&emsp;<b>@order?.BuyerCode</b><br/>
<u>Typ dokumentu:</u>&emsp;<b>@order?.DocType</b><br/>
</div>
</div>
</CardContent>
</SfCard>
}
}
@if (_responses.Any(x => x.Status == 0))
{
foreach (ResponseDto response in _responses.Where(x => x.Status == 0))
</DetailTemplate>
</GridTemplates>
<GridColumns>
<GridColumn Field=@nameof(EdiCustomerOrderDto.CustomerOrderNumber) HeaderText="Numer Zamówienia"
Width="110"></GridColumn>
<GridColumn Field=@nameof(EdiCustomerOrderDto.CustomerPoNumber) HeaderText="Zamówienie Klienta"
Width="100"></GridColumn>
<GridColumn Field=@nameof(EdiCustomerOrderDto.CustomerNumber) HeaderText="Numer Klienta"
Width="90"></GridColumn>
<GridColumn Field=@nameof(EdiCustomerOrderDto.CustomerSequence) HeaderText="Odbiorca" Width="80"></GridColumn>
<GridColumn Field=@nameof(EdiCustomerOrderDto.CreateDate) HeaderText="Data Otrzymania"
TextAlign="TextAlign.Center" Width="110"></GridColumn>
<GridColumn Field=@nameof(EdiCustomerOrderDto.SlOrderNumber) HeaderText="Zamówienie SL"
Width="100"></GridColumn>
<GridColumn Field=@nameof(EdiCustomerOrderDto.SentToSl) HeaderText="Wysłane do SL"
TextAlign="TextAlign.Center" Width="80"></GridColumn>
</GridColumns>
<GridFilterSettings Type="FilterType.Excel"/>
<GridPageSettings PageSize="10"/>
<GridSelectionSettings Mode="SelectionMode.Row" Type="SelectionType.Multiple"/>
<GridEvents TValue="EdiCustomerOrderDto" OnRecordDoubleClick="OnRowDoubleClick" RowSelected="RowSelected" />
</SfGrid>
<SfDialog Width="500px" Title="@_text" IsModal="true" @bind-Visible="Visibility" AllowPrerender="true">
<DialogTemplates>
<Content>
@if (_responses.Any(x => x.Status == 1))
{
<p>Błąd: Zamówienie EDI @response.Identifier nie zostało poprawnie zaksięgowane w Zamówieniach klienta.<br/>Lista błędów:<br/>@response.Message</p>
foreach (ResponseDto response in _responses.Where(x => x.Status == 1))
{
<p>Zamówienie EDI @response.Identifier zostało poprawnie zaksięgowane w Zamówieniach klienta pod
numerem '@response.ExternalIdentifier'</p>
}
}
}
</BodyTemplate>
<FooterTemplate>
<Button Color="ButtonColor.Primary" @onclick="OnHideModalClick">OK</Button>
</FooterTemplate>
</Modal>
@if (_responses.Any(x => x.Status == 0))
{
foreach (ResponseDto response in _responses.Where(x => x.Status == 0))
{
<p>Błąd: Zamówienie EDI @response.Identifier nie zostało poprawnie zaksięgowane w Zamówieniach
klienta.<br/>Lista błędów:<br/>@response.Message</p>
}
}
</Content>
</DialogTemplates>
<DialogButtons>
<DialogButton Content="OK" IsPrimary="true" OnClick="@HideModal" />
</DialogButtons>
</SfDialog>
@code {
Grid<EdiCustomerOrderDto>? _grid;
private List<EdiCustomerOrderDto> _ediCustomerOrders = new();
private List<EdiCustomerOrderDto> _selectedEdiCustomerOrders = new();
private bool Visibility { get; set; }
private SfGrid<EdiCustomerOrderDto>? _grid;
private IEnumerable<EdiCustomerOrderDto> _ediCustomerOrders = [];
private List<EdiCustomerOrderDto> _selectedEdiCustomerOrders = new();
private List<ResponseDto> _responses = new();
private Modal _modal = null!;
private bool _isVisible;
private bool _filter;
private bool? _filter = false;
private string _text = "Księguj bieżący";
private async Task<GridDataProviderResult<EdiCustomerOrderDto>> EdiCustomerOrdersDataProvider(GridDataProviderRequest<EdiCustomerOrderDto> request)
protected override async Task OnInitializedAsync()
{
_ediCustomerOrders = (await EdiCustomerOrderService.GetEdiCustomerOrdersAsync() ?? new List<EdiCustomerOrderDto>()).ToList();
_ediCustomerOrders = _ediCustomerOrders.OrderByDescending(x => x.CreateDate).ToList();
if (!_filter)
{
_ediCustomerOrders = _ediCustomerOrders.Where(x => x.Posted == 0).ToList();
}
StateHasChanged();
return await Task.FromResult(request.ApplyTo(_ediCustomerOrders));
await LoadData();
}
private void OnRowDoubleClick(GridRowEventArgs<EdiCustomerOrderDto> obj)
private void OnRowDoubleClick(RecordDoubleClickEventArgs<EdiCustomerOrderDto> obj)
{
Guid customerOrderId = obj.Item.RowPointer;
Guid customerOrderId = obj.RowData.RowPointer;
NavigationManager.NavigateTo($"/EdiCustomerOrder/{customerOrderId}");
}
@@ -142,35 +162,57 @@
{
response.ExternalIdentifier = selectedEdiCustomerOrder.EdiCustomerOrderTranslates.FirstOrDefault()?.CoCoNum;
}
_responses.Add(response);
}
await _modal.ShowAsync();
_grid?.RefreshDataAsync();
Visibility = true;
await LoadData();
_grid?.Refresh();
_isVisible = false;
return true;
}
private void SelectedItemsChanged(HashSet<EdiCustomerOrderDto> obj)
private void HideModal()
{
Visibility = false;
}
private async Task RowSelected(RowSelectEventArgs<EdiCustomerOrderDto> obj)
{
List<EdiCustomerOrderDto> selectedRecords = await _grid.GetSelectedRecordsAsync();
_isVisible = false;
if (!obj.Any()) return;
_selectedEdiCustomerOrders = obj.ToList();
if (!selectedRecords.Any()) return;
_selectedEdiCustomerOrders = selectedRecords;
_isVisible = _selectedEdiCustomerOrders.Any(x => x.Posted == 0);
_text = obj.Count > 1 ? "Księguj zaznaczone" : "Księguj bieżący";
_text = selectedRecords.Count > 1 ? "Księguj zaznaczone" : "Księguj bieżący";
}
private async Task OnHideModalClick()
private async Task FilterChanged(ChangeEventArgs<bool?> obj)
{
await _modal.HideAsync();
_filter = obj.Checked;
await LoadData();
_grid?.Refresh();
}
private void FilterChanged(bool obj)
private async Task LoadData()
{
_filter = obj;
_grid?.RefreshDataAsync();
_ediCustomerOrders = await EdiCustomerOrderService.GetEdiCustomerOrdersAsync() ?? new List<EdiCustomerOrderDto>();
if (_filter == false)
{
_ediCustomerOrders = _ediCustomerOrders.Where(x => x.Posted == 0).ToList();
}
_ediCustomerOrders = _ediCustomerOrders.OrderByDescending(x => x.CreateDate).ToList();
StateHasChanged();
}
}