* Changed views to have them in the same layout

* Added Authorization
This commit is contained in:
2025-02-28 13:33:01 +01:00
parent aedb5810c2
commit b8fbb789ad
35 changed files with 1605 additions and 1306 deletions

View File

@@ -1,9 +1,11 @@
@page "/EdiCustomerOrders"
@rendermode InteractiveServer
@attribute [Authorize]
@inject EdiCustomerOrderService EdiCustomerOrderService
@inject NavigationManager NavigationManager
@inject CustomAuthenticationStateProvider CustomAuthenticationStateProvider
@using System.Security.Claims
@using Microsoft.AspNetCore.Authorization
@using OrdersManagement.Models
@using SytelineSaAppEfDataModel.Dtos
@@ -14,120 +16,115 @@
@using SelectionType = Syncfusion.Blazor.Grids.SelectionType
@inherits LayoutComponentBase
<div class="h-100 d-flex flex-column">
<h5>Zamówienia Klienta EDI</h5>
<div class="row">
<div class="col-md-12">
<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/>
@if (_isVisible)
{
<div class="row">
<div class="col-md-12">
<SfButton @onclick="SendOrderToSyteLine">@_text</SfButton>
<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">Zamówienia Klienta EDI</h3>
</CardHeader>
<CardContent>
<div class="row mb-4">
<div class="col-md-12 d-flex align-items-center">
<label for="checked" style="padding: 10px 10px 10px 0">Pokaż wszystkie</label>
<SfSwitch @bind-Checked="_filter" ValueChange="FilterChanged" TChecked="bool?"
OnLabel="Pokaż tylko Wysłane do SL" OffLabel="Pokaż wszystkie"/>
</div>
</div>
</div>
<br/>
}
<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>
}
</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))
{
foreach (ResponseModel? 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>
}
}
@if (_responses.Any(x => x.Status == 0))
{
foreach (ResponseModel? 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>
@if (_isVisible)
{
<div class="row mb-4">
<div class="col-md-12">
<SfButton CssClass="btn-primary" @onclick="SendOrderToSyteLine">@_text</SfButton>
</div>
</div>
}
<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 CssClass="mb-4">
<CardContent>
<div class="row">
<div class="col">
<u>Numer zamówienia EDI:</u> <b>@order?.CustomerOrderNumber</b><br/>
<u>Numer zamówienia Klienta:</u> <b>@order?.CustomerPoNumber</b><br/>
<u>Numer klienta:</u> <b>@order?.CustomerNumber</b><br/>
<u>Klient:</u> <b>@order?.CustomerName</b><br/>
<u>Numer odbiorcy:</u> <b>@(order?.CustomerSequence?.ToString() ?? "N/A")</b><br/>
<u>Data otrzymania:</u> <b>@(order?.RecivedDate?.ToString("dd.MM.yyyy") ?? "N/A")</b><br/>
<u>Wysłano do Syteline?:</u> <b>@((order?.Posted?.ToString() ?? "0") == "0" ? "NIE" : "TAK")</b><br/>
<u>Data wysyłki do Syteline:</u> <b>@(order?.PostedDate?.ToString("dd.MM.yyyy") ?? "N/A")</b><br/>
<u>Data zamówienia:</u> <b>@(order?.OrderDate?.ToString("dd.MM.yyyy") ?? "N/A")</b><br/>
</div>
<div class="col">
<u>Cena:</u> <b>@(order?.Price?.ToString("F2") ?? "N/A")</b><br/>
<u>Waga:</u> <b>@(order?.Weight?.ToString("F2") ?? "N/A")</b><br/>
<u>Magazyn:</u> <b>@order?.Warehouse</b><br/>
<u>Gate:</u> <b>@order?.Gate</b><br/>
<u>Kod odbiorcy:</u> <b>@order?.RecipientCode</b><br/>
<u>Kod wysyłającego:</u> <b>@order?.SenderCode</b><br/>
<u>Kod sprzedawcy:</u> <b>@order?.SellerCode</b><br/>
<u>Kod kupującego:</u> <b>@order?.BuyerCode</b><br/>
<u>Typ dokumentu:</u> <b>@order?.DocType</b><br/>
</div>
</div>
</CardContent>
</SfCard>
}
</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))
{
foreach (ResponseModel? 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>
}
}
@if (_responses.Any(x => x.Status == 0))
{
foreach (ResponseModel? 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>
</CardContent>
<CardFooter>
<small class="text-muted">FA Krosno Manager © @(DateTime.Now.Year)</small>
</CardFooter>
</SfCard>
</div>
@code {
@@ -145,9 +142,21 @@
private string _text = "Księguj bieżący";
protected override async Task OnInitializedAsync()
protected override async Task OnAfterRenderAsync(bool firstRender)
{
await LoadData();
if (firstRender)
{
ClaimsPrincipal currentUser = CustomAuthenticationStateProvider.GetCurrentUser();
if (currentUser.Identity?.IsAuthenticated == false)
{
NavigationManager.NavigateTo("/Unauthorized");
}
else
{
await LoadData();
}
}
}
private void OnRowDoubleClick(RecordDoubleClickEventArgs<EdiCustomerOrderDto> obj)