Some checks failed
CI/CD Pipeline / Build and Deploy with Docker Compose (push) Failing after 15m47s
124 lines
3.7 KiB
Plaintext
124 lines
3.7 KiB
Plaintext
@using Blazored.Modal
|
|
@using Blazored.Modal.Services
|
|
@using Domain.Dtos.Stock
|
|
@inject IStockScanService StockScanService
|
|
|
|
@inherits LayoutComponentBase
|
|
|
|
<div class="modal-header bg-primary text-white">
|
|
<h5 class="modal-title">Escaneo de producto</h5>
|
|
<button type="button" class="btn-close" @onclick="Cancel"></button>
|
|
</div>
|
|
|
|
<div class="modal-body">
|
|
<div class="mb-3">
|
|
<label for="scan" class="form-label">Escanear o ingresar código</label>
|
|
@* <InputText id="scan"
|
|
class="form-control"
|
|
@bind-Value="ScanInput" /> *@
|
|
<input @bind="ScanInput"
|
|
@bind:event="oninput"
|
|
class="form-control form-control-sm"
|
|
placeholder="Scannear..."
|
|
style="width: 250px;" />
|
|
@* <button class="btn btn-secondary mt-2" @onclick="HandleScan">Buscar</button> *@
|
|
</div>
|
|
|
|
@if (!string.IsNullOrWhiteSpace(ErrorMessage))
|
|
{
|
|
<div class="alert alert-danger">@ErrorMessage</div>
|
|
}
|
|
|
|
@if (ScanResults.Any())
|
|
{
|
|
<table class="table table-sm table-bordered">
|
|
<thead class="table-light">
|
|
<tr>
|
|
<th>Producto</th>
|
|
<th>Lote</th>
|
|
<th>Vencimiento</th>
|
|
<th>Disponible</th>
|
|
<th>Cantidad a usar</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach (var item in ScanResults)
|
|
{
|
|
<tr>
|
|
<td>@item.ProductName</td>
|
|
<td>@item.Batch</td>
|
|
<td>@item.Expiration?.ToShortDateString()</td>
|
|
<td>@item.Quantity</td>
|
|
<td>
|
|
<InputNumber @bind-Value="item.Quantity"
|
|
class="form-control form-control-sm"
|
|
min="0" />
|
|
</td>
|
|
</tr>
|
|
}
|
|
</tbody>
|
|
</table>
|
|
}
|
|
</div>
|
|
|
|
<div class="modal-footer">
|
|
<button class="btn btn-secondary" @onclick="Cancel">Cancelar</button>
|
|
<button class="btn btn-primary" @onclick="ConfirmSelection" disabled="@(!ScanResults.Any(r => r.Quantity > 0))">Agregar</button>
|
|
</div>
|
|
|
|
@code {
|
|
[CascadingParameter] BlazoredModalInstance ModalInstance { get; set; }
|
|
|
|
[Parameter] public int? LocationId { get; set; }
|
|
private string SearchAddress { get; set; } = string.Empty;
|
|
|
|
private string ScanInput { get; set; } = string.Empty;
|
|
private string ErrorMessage { get; set; } = string.Empty;
|
|
|
|
private List<StockItemSelectionDto> ScanResults { get; set; } = new();
|
|
|
|
private async Task HandleScan()
|
|
{
|
|
ErrorMessage = string.Empty;
|
|
ScanResults.Clear();
|
|
|
|
if (string.IsNullOrWhiteSpace(ScanInput))
|
|
{
|
|
ErrorMessage = "Ingrese un código válido.";
|
|
return;
|
|
}
|
|
|
|
if (LocationId is null)
|
|
{
|
|
ErrorMessage = "Falta el depósito para escanear correctamente.";
|
|
return;
|
|
}
|
|
|
|
try
|
|
{
|
|
var result = await StockScanService.ParseAndMatchAsync(ScanInput, LocationId.Value);
|
|
|
|
if (result is not null)
|
|
{
|
|
ScanResults.Add(result);
|
|
}
|
|
else
|
|
{
|
|
ErrorMessage = "No se encontró stock coincidente.";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ErrorMessage = $"Error: {ex.Message}";
|
|
}
|
|
}
|
|
|
|
private void Cancel() => ModalInstance.CancelAsync();
|
|
|
|
private void ConfirmSelection()
|
|
{
|
|
var selected = ScanResults.Where(r => r.Quantity > 0).ToList();
|
|
ModalInstance.CloseAsync(ModalResult.Ok(selected));
|
|
}
|
|
}
|