Add Mock Importacion Masiva de Productos
All checks were successful
CI/CD Pipeline / Build and Deploy with Docker Compose (push) Successful in 2m27s

This commit is contained in:
Leandro Hernan Rojas 2025-07-03 13:08:13 -03:00
parent 1be33c37b5
commit d60238f5eb
2 changed files with 111 additions and 2 deletions

View File

@ -80,7 +80,7 @@
<button class="btn btn-primary rounded-pill" @onclick="Buscar">
<i class="fas fa-binoculars me-1"></i> Buscar
</button>
<button class="btn btn-success rounded-pill" disabled="1" @onclick="Nuevo">
<button class="btn btn-success rounded-pill" @onclick="Nuevo">
<i class="fas fa-plus me-1"></i> Nuevo
</button>
<button class="btn btn-success rounded-pill" @onclick="ExportarExcel">
@ -246,7 +246,7 @@
}
}
private void Nuevo() => Navigation.NavigateTo("/stock/productform/");
private void Nuevo() => Navigation.NavigateTo("/stock/productimport");
private void Cancelar() => Navigation.NavigateTo("/DashboardPanel");
private int TotalPaginas => PagedResult is null ? 1 : (int)Math.Ceiling(PagedResult.TotalItems / (double)SearchParams.PageSize);

View File

@ -0,0 +1,109 @@
@page "/stock/productimport"
@inject IJSRuntime JS
@inject NavigationManager Navigation
<h3 class="mb-4">Importación masiva de productos</h3>
<div class="mb-3">
<button class="btn btn-primary" @onclick="DownloadTemplate">Descargar plantilla Excel</button>
</div>
<div class="mb-4">
<label for="fileUpload" class="form-label fw-semibold">Seleccionar archivo Excel</label>
<div class="input-group">
<label class="input-group-text bg-light border-secondary" for="fileUpload">📎</label>
<InputFile id="fileUpload" class="form-control" OnChange="HandleFileSelected" accept=".xlsx" />
</div>
</div>
@if (PreviewItems != null)
{
<h5 class="mt-4">Vista previa</h5>
<table class="table table-sm table-bordered">
<thead>
<tr>
<th>Cód. Fábrica</th>
<th>Nombre</th>
<th>Descripción</th>
<th>Tipo</th>
<th>Trazabilidad</th>
<th>División</th>
<th>Unidad</th>
<th>Plus</th>
<th>Cód. Ext.</th>
<th>Errores</th>
</tr>
</thead>
<tbody>
@foreach (var item in PreviewItems)
{
<tr class="@(item.HasError ? "table-danger" : null)">
<td>@item.FactoryCode</td>
<td>@item.Name</td>
<td>@item.Description</td>
<td>@item.ProductType</td>
<td>@item.TraceabilityType</td>
<td>@item.DivisionCode</td>
<td>@item.UnitCode</td>
<td>@(item.PlusProcess ? "Sí" : "No")</td>
<td>@item.ExternalCode</td>
<td>@item.ErrorMessage</td>
</tr>
}
</tbody>
</table>
<div class="mt-3 d-flex justify-content-end gap-2">
<button class="btn btn-outline-secondary" @onclick="SimulateImport">Simular importación</button>
<button class="btn btn-success" @onclick="ConfirmImport" disabled="@(PreviewItems.All(x => x.HasError))">Importar productos</button>
</div>
}
@code {
private List<ProductImportPreviewDto>? PreviewItems;
protected override void OnInitialized()
{
PreviewItems = new List<ProductImportPreviewDto>
{
new() { FactoryCode = "ZIM001", Name = "Clavo tibial largo", Description = "Clavo para tibia", ProductType = 1, TraceabilityType = 3, DivisionCode = "ZIM", UnitCode = "UN", PlusProcess = true, ExternalCode = "EXT001" },
new() { FactoryCode = "ZIM002", Name = "Tornillo esponjoso", Description = "Tornillo de 6.5mm", ProductType = 1, TraceabilityType = 3, DivisionCode = "ZIM", UnitCode = "UN", PlusProcess = false, ExternalCode = "EXT002" },
new() { FactoryCode = "ZIM003", Name = "Placa de compresión", Description = "Placa DCP 4.5", ProductType = 1, TraceabilityType = 2, DivisionCode = "ZIM", UnitCode = "UN", PlusProcess = false, ExternalCode = "EXT003" },
new() { FactoryCode = "ZIM004", Name = "Caja instrumental", Description = "Caja para implantes", ProductType = 2, TraceabilityType = 1, DivisionCode = "ZIM", UnitCode = "CJ", PlusProcess = false, ExternalCode = "EXT004", ErrorMessage = "Unidad no reconocida" },
new() { FactoryCode = "ZIM005", Name = "Perno cortical", Description = "Perno de fijación", ProductType = 1, TraceabilityType = 3, DivisionCode = "ZIM", UnitCode = "UN", PlusProcess = true, ExternalCode = "EXT005" }
};
}
private async Task DownloadTemplate()
{
Navigation.NavigateTo("api/LSProductImport/download-template", forceLoad: true);
}
private async Task HandleFileSelected(InputFileChangeEventArgs e)
{
// Lógica futura para parsear y enviar archivo al backend
}
private async Task SimulateImport()
{
// Lógica futura para simular importación
}
private async Task ConfirmImport()
{
// Lógica futura para guardar los productos
}
public class ProductImportPreviewDto
{
public string FactoryCode { get; set; } = string.Empty;
public string Name { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
public int ProductType { get; set; }
public int TraceabilityType { get; set; }
public string DivisionCode { get; set; } = string.Empty;
public string UnitCode { get; set; } = string.Empty;
public bool PlusProcess { get; set; }
public string ExternalCode { get; set; } = string.Empty;
public string? ErrorMessage { get; set; }
public bool HasError => !string.IsNullOrWhiteSpace(ErrorMessage);
}
}