PCRB webassembly
This commit is contained in:
@ -4,10 +4,11 @@
|
||||
|
||||
<MudDialog>
|
||||
<DialogContent>
|
||||
<MudPaper Class="p-2">
|
||||
<MudPaper Class="m-2 p-2">
|
||||
<MudForm @bind-Errors="@errors">
|
||||
<MudSelect T="string"
|
||||
Label="Action"
|
||||
Disabled="@(!string.IsNullOrWhiteSpace(mrbAction.Action))"
|
||||
Required="true"
|
||||
RequiredError="You must select an action!"
|
||||
@bind-Value="@mrbAction.Action"
|
||||
@ -19,29 +20,61 @@
|
||||
<MudSelectItem Value="@("Unblock")" />
|
||||
<MudSelectItem Value="@("Waiver")" />
|
||||
</MudSelect>
|
||||
@if (mrbAction.Action.Equals("Convert")) {
|
||||
<MudTextField @bind-Value="@mrbAction.ConvertFrom"
|
||||
Label="Convert From"
|
||||
@if (mrbAction.Action.Equals("Convert", StringComparison.InvariantCultureIgnoreCase)) {
|
||||
<MudSelect T="string"
|
||||
Label="Convert From Customer"
|
||||
Required
|
||||
Variant="Variant.Outlined"
|
||||
AnchorOrigin="Origin.BottomCenter"
|
||||
@bind-Value=convertFromCustomer
|
||||
Text="@convertFromCustomer">
|
||||
@foreach (string customer in customerNames) {
|
||||
<MudSelectItem Value="@(customer)" />
|
||||
}
|
||||
</MudSelect>
|
||||
<MudTextField @bind-Value="@convertFromPart"
|
||||
Label="Convert From Part Number"
|
||||
Required
|
||||
RequiredError="Conversion value required!"
|
||||
Text="@mrbAction.ConvertFrom" />
|
||||
<MudTextField @bind-Value="@mrbAction.ConvertTo"
|
||||
Label="Convert To"
|
||||
RequiredError="Part number required!"
|
||||
Text="@convertFromPart" />
|
||||
<MudSelect T="string"
|
||||
Label="Convert To Customer"
|
||||
Required
|
||||
Variant="Variant.Outlined"
|
||||
AnchorOrigin="Origin.BottomCenter"
|
||||
@bind-Value=convertToCustomer
|
||||
Text="@convertToCustomer">
|
||||
@foreach (string customer in customerNames) {
|
||||
<MudSelectItem Value="@(customer)" />
|
||||
}
|
||||
</MudSelect>
|
||||
<MudTextField @bind-Value="@convertToPart"
|
||||
Label="Convert To Part Number"
|
||||
Required
|
||||
RequiredError="Conversion value required!"
|
||||
Text="@mrbAction.ConvertTo" />
|
||||
RequiredError="Part number required!"
|
||||
Text="@convertToPart" />
|
||||
} else {
|
||||
<MudSelect T="string"
|
||||
Label="Affected Customer"
|
||||
Required
|
||||
Variant="Variant.Outlined"
|
||||
AnchorOrigin="Origin.BottomCenter"
|
||||
@bind-Value=mrbAction.Customer
|
||||
Text="@mrbAction.Customer">
|
||||
@foreach (string customer in customerNames) {
|
||||
<MudSelectItem Value="@(customer)" />
|
||||
}
|
||||
</MudSelect>
|
||||
<MudAutocomplete T="string"
|
||||
Label="Part Number"
|
||||
Variant="Variant.Outlined"
|
||||
AnchorOrigin="Origin.BottomCenter"
|
||||
@bind-Value=mrbAction.PartNumber
|
||||
Text="@mrbAction.PartNumber"
|
||||
SearchFunc="@PartNumberSearch"
|
||||
ResetValueOnEmptyText
|
||||
CoerceText />
|
||||
}
|
||||
<MudSelect T="string"
|
||||
Label="Affected Customer"
|
||||
Required
|
||||
Variant="Variant.Outlined"
|
||||
AnchorOrigin="Origin.BottomCenter"
|
||||
@bind-Value=mrbAction.Customer
|
||||
Text="@mrbAction.Customer">
|
||||
@foreach (string customer in customerNames) {
|
||||
<MudSelectItem Value="@(customer)" />
|
||||
}
|
||||
</MudSelect>
|
||||
<MudTextField T="int"
|
||||
InputType="@InputType.Number"
|
||||
Label="Qty"
|
||||
@ -49,15 +82,6 @@
|
||||
RequiredError="You must supply a quantity!"
|
||||
@bind-Value=mrbAction.Quantity
|
||||
Text="@mrbAction.Quantity.ToString()" />
|
||||
<MudAutocomplete T="string"
|
||||
Label="Part Number"
|
||||
Variant="Variant.Outlined"
|
||||
AnchorOrigin="Origin.BottomCenter"
|
||||
@bind-Value=mrbAction.PartNumber
|
||||
Text="@mrbAction.PartNumber"
|
||||
SearchFunc="@PartNumberSearch"
|
||||
ResetValueOnEmptyText
|
||||
CoerceText />
|
||||
<MudAutocomplete T="string"
|
||||
Label="Batch Number / Lot Number"
|
||||
Variant="Variant.Outlined"
|
||||
@ -130,6 +154,11 @@
|
||||
|
||||
private IEnumerable<string> customerNames = new List<string>();
|
||||
|
||||
private string convertFromCustomer = string.Empty;
|
||||
private string convertFromPart = string.Empty;
|
||||
private string convertToCustomer = string.Empty;
|
||||
private string convertToPart = string.Empty;
|
||||
|
||||
private bool isVisible { get; set; }
|
||||
private string[] errors = { };
|
||||
private bool processingSave = false;
|
||||
@ -145,10 +174,34 @@
|
||||
actions = (await mrbService.GetMRBActionsForMRB(mrbAction.MRBNumber, false)).OrderByDescending(a => a.ActionID);
|
||||
|
||||
if (actions is not null && actions.Count() > 0) {
|
||||
if (string.IsNullOrWhiteSpace(mrbAction.Action))
|
||||
mrbAction.Action = actions.First().Action;
|
||||
if (string.IsNullOrWhiteSpace(mrbAction.Customer))
|
||||
mrbAction.Customer = actions.First().Customer;
|
||||
if (string.IsNullOrWhiteSpace(mrbAction.LotNumber))
|
||||
mrbAction.LotNumber = actions.First().LotNumber;
|
||||
if (string.IsNullOrWhiteSpace(mrbAction.PartNumber))
|
||||
mrbAction.PartNumber = actions.First().PartNumber;
|
||||
if (string.IsNullOrWhiteSpace(mrbAction.Justification))
|
||||
mrbAction.Justification = actions.First().Justification;
|
||||
if (mrbAction.Quantity == 0)
|
||||
mrbAction.Quantity = actions.First().Quantity;
|
||||
|
||||
if (mrbAction.Action.Equals("Convert", StringComparison.InvariantCultureIgnoreCase)) {
|
||||
string[] convertFrom = actions.First().ConvertFrom.Split(" ");
|
||||
if (convertFrom.Length > 1) {
|
||||
convertFromCustomer = convertFrom[0];
|
||||
foreach (string partStr in convertFrom.Skip(1))
|
||||
convertFromPart += partStr;
|
||||
}
|
||||
|
||||
string[] convertTo = actions.First().ConvertTo.Split(" ");
|
||||
if (convertTo.Length > 1) {
|
||||
convertToCustomer = convertTo[0];
|
||||
foreach (string partStr in convertTo.Skip(1))
|
||||
convertToPart += partStr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -165,9 +218,17 @@
|
||||
actionIsValid = actionIsValid && !string.IsNullOrWhiteSpace(mrbAction.Customer) &&
|
||||
!string.IsNullOrWhiteSpace(mrbAction.PartNumber) &&
|
||||
!string.IsNullOrWhiteSpace(mrbAction.LotNumber);
|
||||
actionIsValid = actionIsValid && mrbAction.Quantity > 0;
|
||||
|
||||
if (mrbAction.Action.Equals("Scrap"))
|
||||
return actionIsValid && !string.IsNullOrWhiteSpace(mrbAction.Justification);
|
||||
if (mrbAction.Action.Equals("Convert", StringComparison.InvariantCultureIgnoreCase)) {
|
||||
actionIsValid = actionIsValid && !string.IsNullOrWhiteSpace(convertFromCustomer) &&
|
||||
!string.IsNullOrWhiteSpace(convertFromPart) &&
|
||||
!string.IsNullOrWhiteSpace(convertToCustomer) &&
|
||||
!string.IsNullOrWhiteSpace(convertToPart);
|
||||
}
|
||||
|
||||
if (mrbAction.Action.Equals("Scrap", StringComparison.InvariantCultureIgnoreCase))
|
||||
actionIsValid = actionIsValid && !string.IsNullOrWhiteSpace(mrbAction.Justification);
|
||||
|
||||
return actionIsValid;
|
||||
}
|
||||
@ -177,6 +238,11 @@
|
||||
try {
|
||||
if (!FormIsValid()) throw new Exception("You must complete the form before saving!");
|
||||
|
||||
if (mrbAction.Action.Equals("Convert", StringComparison.InvariantCultureIgnoreCase)) {
|
||||
mrbAction.ConvertFrom = $"{convertFromCustomer} {convertFromPart}";
|
||||
mrbAction.ConvertTo = $"{convertToCustomer} {convertToPart}";
|
||||
}
|
||||
|
||||
if (mrbAction.MRBNumber > 0) {
|
||||
if (mrbAction.ActionID <= 0) {
|
||||
await mrbService.CreateMRBAction(mrbAction);
|
||||
|
Reference in New Issue
Block a user