FruitBankHybridApp/FruitBankHybrid.Shared/Pages/MeasuringIn.razor

252 lines
12 KiB
Plaintext

@page "/MeasuringIn"
@using AyCode.Utils.Extensions
@using DevExpress.Blazor
@using DevExpress.Blazor.Internal
@using FruitBank.Common.Entities
@using FruitBankHybrid.Shared.Services
@using Mango.Nop.Core.Dtos
<h3>Bejövő mérés</h3>
<div style="margin-top: 50px;">
<DxFormLayout CaptionPosition="CaptionPosition.Vertical" CssClass="w-100">
<DxFormLayoutItem Caption="Érkezés dátuma" ColSpanMd="2" CaptionCssClass="@(SelectedShipping != null && _shippingDates.Where(x => DaysEqual(x.DateTime, SelectedShipping.ShippingDate)).All(x => x.IsMeasured) ? "text-success" : "")">
<DxDateEdit CssClass="cw-320"
DisplayFormat="m"
Format="m"
Context="ctxShippingDate"
Date="@(SelectedShipping?.ShippingDate.Date ?? DateTime.Now.Date)"
CustomDisabledDate="@OnCustomDisabledDate"
DateChanged="@((DateTime newValue) => OnSelectedShippingDateChanged(newValue))"
InputId="deDisabledDates">
<DayCellTemplate>
@{
var cssClass = GetShippingDateCssClassNames(ctxShippingDate);
if (!cssClass.IsNullOrWhiteSpace())
{
<a class="@GetShippingDateCssClassNames(ctxShippingDate)">@ctxShippingDate.Day.ToString()</a>
}
else
{
<a>@ctxShippingDate.Day.ToString()</a>
}
}
</DayCellTemplate>
</DxDateEdit>
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Kamion rendszáma:" ColSpanMd="2" CaptionCssClass="@(SelectedShipping?.IsAllMeasured == true ? "text-success" : "")">
<DxComboBox Data="@NotMeasuredShippings"
@bind-Value="@SelectedShipping"
Text="Select licence plate"
ValueFieldName="@nameof(Shipping.Id)"
TextFieldName="@nameof(Shipping.LicencePlate)"
CssClass="cw-480"
Context="ctxShipping"
SelectedDataItemChanged="@((SelectedDataItemChangedEventArgs<Shipping> args) => OnSelectedShippingChanged(args))"
InputId="cbNotMeasuredShippings">
<ItemDisplayTemplate>
<span class="@(ctxShipping.DataItem.IsAllMeasured ? "text-success" : "")">@ctxShipping.DisplayText</span>
</ItemDisplayTemplate>
</DxComboBox>
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Partner:" ColSpanMd="3" CaptionCssClass="@(SelectedShippingDocument?.IsAllMeasured == true ? "text-success" : "")">
<DxComboBox Data="@SelectedShipping?.ShippingDocuments"
@bind-Value="@SelectedShippingDocument"
Text="Select partner"
ValueFieldName="@nameof(ShippingDocument.Id)"
TextFieldName="@(nameof(ShippingDocument.Partner) + '.' + nameof(Partner.Name))"
CssClass="cw-480"
Context="ctxShippingDocument"
SelectedDataItemChanged="@((SelectedDataItemChangedEventArgs<ShippingDocument> args) => OnSelectedShippingDocumentChanged(args))"
InputId="cbShippingDocument">
<ItemDisplayTemplate>
<span class="@(ctxShippingDocument.DataItem.IsAllMeasured ? "text-success" : "")">@ctxShippingDocument.DisplayText</span>
</ItemDisplayTemplate>
</DxComboBox>
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Termék:" ColSpanMd="5" CaptionCssClass="@(SelectedShippingItem?.IsMeasured == true ? "text-success" : "")">
<DxComboBox Data="@SelectedShippingDocument?.ShippingItems"
@bind-Value="@SelectedShippingItem"
Text="Select item"
ValueFieldName="@nameof(ShippingItem.Id)"
TextFieldName="@(nameof(ShippingItem.Name))"
CssClass="cw-480"
Context="ctxShippingitem"
SelectedDataItemChanged="@((SelectedDataItemChangedEventArgs<ShippingItem> args) => OnSelectedShippingItemChanged(args))"
InputId="cbShippingItem">
<ItemDisplayTemplate>
@* <div class="combobox-item-template">
<img src="/images/ok_green_lt.jpg" alt="" />
<span class="icon counter-icon" aria-hidden="true"></span>
<div class="combobox-item-template-text">
<span>@ctxShippingitem.DisplayText</span>
</div>
</div>
*@
<span class="@(ctxShippingitem.DataItem.IsMeasured ? "text-success" : "")">@ctxShippingitem.DisplayText)</span>
</ItemDisplayTemplate>
</DxComboBox>
</DxFormLayoutItem>
</DxFormLayout>
</div>
<div style="margin-top: 50px;">
@if (SelectedShippingItem != null)
{
<h3 style="margin-bottom: 30px;" class="@(SelectedShippingItem.IsMeasured && SelectedShippingItem.ShippingItemPallets!.All(x => x.IsMeasuredAndValid(SelectedShippingItem.IsMeasurable)) ? "text-success" : "")">
@SelectedShippingItem.Name
</h3>
<EditForm Model="@SelectedShippingItem" Context="FrmContext"
OnValidSubmit="@HandleValidSubmit"
OnInvalidSubmit="@HandleInvalidSubmit">
@* <DataAnnotationsValidator /> *@
<DxFormLayout Data="@SelectedShippingItem" CaptionPosition="CaptionPosition.Vertical" CssClass="w-100" ItemUpdating="@((pair) => OnItemUpdating(pair.Key, pair.Value))">
@* <DxFormLayoutItem CaptionCssClass="@(SelectedShippingItem.IsMeasured ? "text-success" : "")" Field="@nameof(ShippingItem.Name)" Caption="Item Name:" Enabled="false" ColSpanMd="8" />
<DxFormLayoutItem Visible="false" CaptionCssClass="@(SelectedShippingItem.IsMeasured ? "text-success" : "")" Field="@nameof(ShippingItem.GrossWeightOnDocument)" Caption="GrossWeightOnDocument:" Enabled="false" ColSpanMd="3" />
<DxFormLayoutItem Visible="false" CaptionCssClass="@(SelectedShippingItem.IsMeasured ? "text-success" : "")" Field="@nameof(ShippingItem.NetWeightOnDocument)" Caption="NetWeightOnDocument:" Enabled="false" ColSpanMd="3" />
<DxFormLayoutItem CaptionCssClass="@(SelectedShippingItem.IsMeasured ? "text-success" : "")"
Field="@nameof(ShippingItem.PalletsOnDocument)"
Enabled="@(SelectedShippingItem.ProductId.GetValueOrDefault(0) > 0)"
Caption="Pallets:" ColSpanMd="2" BeginRow="false">
</DxFormLayoutItem>
<DxFormLayoutItem Visible="true" CaptionCssClass="@(SelectedShippingItem.IsMeasured ? "text-success" : "")"
Field="@nameof(ShippingItem.IsMeasured)"
Enabled="false" Caption="Sikeres mérés:" ColSpanMd="2">
</DxFormLayoutItem>
<DxFormLayoutItem ColSpanMd="3" BeginRow="true" />
<DxFormLayoutItem CaptionCssClass="@(SelectedShippingItem.IsMeasured ? "text-success" : "")"
Field="@nameof(ShippingItem.MeasuredQuantity)"
Enabled="@(SelectedShippingItem.ProductId.GetValueOrDefault(0) > 0)"
Caption="MeasuredQuantity:" ColSpanMd="3" BeginRow="false">
</DxFormLayoutItem>
<DxFormLayoutItem CaptionCssClass="@(SelectedShippingItem.IsMeasured ? "text-success" : "")"
Field="@nameof(ShippingItem.MeasuredNetWeight)"
Enabled="@(SelectedShippingItem.IsMeasurable && SelectedShippingItem.ProductId.GetValueOrDefault(0) > 0)"
Caption="MeasuredNetWeight:" ColSpanMd="3">
</DxFormLayoutItem>
<DxFormLayoutItem CaptionCssClass="@(SelectedShippingItem.IsMeasured ? "text-success" : "")"
Field="@nameof(ShippingItem.MeasuredGrossWeight)"
Enabled="@(SelectedShippingItem.IsMeasurable && SelectedShippingItem.ProductId.GetValueOrDefault(0) > 0)"
Caption="MeasuredGrossWeight:" ColSpanMd="3">
</DxFormLayoutItem> *@
<DxFormLayoutItem Context="dfsdf" ColSpanMd="12">
@for (var index = 0; index < SelectedShippingItem.ShippingItemPallets!.Count; index++)
{
var localI = index + 1;
var currentShippingItemPallet = SelectedShippingItem.ShippingItemPallets![index];
<DxFormLayout Data="@currentShippingItemPallet" CaptionPosition="CaptionPosition.Vertical" CssClass="w-100 measuring-form-layout"
ItemUpdating="@((pair) => OnItemUpdating2(pair.Key, pair.Value, currentShippingItemPallet))">
<DxFormLayoutItem ColSpanMd="1" BeginRow="true">
<text>@(localI).mérés</text>
</DxFormLayoutItem>
<DxFormLayoutItem CaptionCssClass="@(GetShippingPalletsCssClassNames(nameof(ShippingItemPallet.PalletWeight), currentShippingItemPallet))"
Field="@nameof(ShippingItemPallet.PalletWeight)"
Enabled="@(SelectedShippingItem.IsMeasurable && SelectedShippingItem.ProductId.GetValueOrDefault(0) > 0)"
Caption="Rakl.súly(kg)" ColSpanMd="2"/>
<DxFormLayoutItem ColSpanMd="1"/>
<DxFormLayoutItem CaptionCssClass="@(GetShippingPalletsCssClassNames(nameof(ShippingItemPallet.TareWeight), currentShippingItemPallet))"
Field="@nameof(ShippingItemPallet.TareWeight)"
Enabled="@(SelectedShippingItem.IsMeasurable && SelectedShippingItem.ProductId.GetValueOrDefault(0) > 0)"
Caption="Tára.súly(kg)" ColSpanMd="2"/>
<DxFormLayoutItem CaptionCssClass="@(GetShippingPalletsCssClassNames(nameof(ShippingItemPallet.Quantity), currentShippingItemPallet))"
Field="@nameof(ShippingItemPallet.Quantity)"
Enabled="@(SelectedShippingItem.ProductId.GetValueOrDefault(0) > 0)"
Caption="Rekesz/csomag" ColSpanMd="2"/>
<DxFormLayoutItem CaptionCssClass="@(GetShippingPalletsCssClassNames(nameof(ShippingItemPallet.GrossWeight), currentShippingItemPallet))"
Field="@nameof(ShippingItemPallet.GrossWeight)"
Enabled="@(SelectedShippingItem.IsMeasurable && SelectedShippingItem.ProductId.GetValueOrDefault(0) > 0)"
Caption="Br.súly(kg)" ColSpanMd="2">
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Net.súly(kg)" ColSpanMd="1" CaptionCssClass="@(GetShippingPalletsCssClassNames(nameof(ShippingItemPallet.NetWeight), currentShippingItemPallet))">
<text>@(currentShippingItemPallet.NetWeight) kg.</text>
</DxFormLayoutItem>
<DxFormLayoutItem ColSpanMd="1">
<DxButton Text="@(currentShippingItemPallet.Id == 0 ? "Mentés" : "Módosítás")" Click="() => OnShippingItemPalletSaveClick(currentShippingItemPallet)" CssClass="w-100"/>
</DxFormLayoutItem>
</DxFormLayout>
}
</DxFormLayoutItem>
<DxFormLayoutItem Context="vfdfgfd" ColSpanMd="12" BeginRow="true">
<DxFormLayout CssClass="w-100">
<DxFormLayoutItem ColSpanMd="1" BeginRow="false"><strong>TOTAL:</strong></DxFormLayoutItem>
<DxFormLayoutItem ColSpanMd="2" BeginRow="false" />
<DxFormLayoutItem ColSpanMd="1" BeginRow="false" />
<DxFormLayoutItem ColSpanMd="2" BeginRow="false" />
<DxFormLayoutItem ColSpanMd="2" BeginRow="false"><strong>@(SelectedShippingItem.MeasuredQuantity) db</strong></DxFormLayoutItem>
<DxFormLayoutItem ColSpanMd="2" BeginRow="false"><strong>@(SelectedShippingItem.MeasuredGrossWeight) kg</strong></DxFormLayoutItem>
<DxFormLayoutItem ColSpanMd="1" BeginRow="false"><strong>@(SelectedShippingItem.MeasuredNetWeight) kg</strong></DxFormLayoutItem>
<DxFormLayoutItem ColSpanMd="1" BeginRow="false" />
</DxFormLayout>
</DxFormLayoutItem>
<DxFormLayoutItem ColSpanMd="12" BeginRow="true">
<ValidationSummary />
</DxFormLayoutItem>
@* @if (SelectedShippingItem.ProductId.GetValueOrDefault(0) > 0)
{
<DxFormLayoutItem ColSpanMd="12" BeginRow="true">
<DxButton Text="@(SelectedShippingItem.IsMeasured ? "Befejezett mérés módosítása" : "Mérés befejezése")"
Enabled="@BtnSaveEnabled"
SubmitFormOnClick="true" CssClass="w-100" />
</DxFormLayoutItem>
}
else
{
_errorText = "Nem végezhető el a mérés, nincs megadva a ProductId! Jelezze a vezetőségnek...";
}
*@
@if (!_errorText.IsNullOrWhiteSpace())
{
<DxFormLayoutItem ColSpanMd="12" BeginRow="true">
<text>HIBA! @_errorText</text>
</DxFormLayoutItem>
//_errorText = string.Empty;
}
</DxFormLayout>
</EditForm>
}
</div>
@*
<div class="row w-100" style="margin-top: 100px;">
<div class="col-md-12">
<input @bind="_userName" placeholder="Your name" />
<input @bind="_message" placeholder="Partner ID..." />
<button @onclick="GetPartner">Get partner</button>
</div>
</div>
<div class="row w-100">
<div class="col-md-12">
<ul>
@foreach (var m in _messages)
{
<li><b>@m.User:</b> @m.Text</li>
}
</ul>
</div>
</div>
*@