Add Patch Customer View 1
All checks were successful
CI/CD Pipeline / Build and Deploy with Docker Compose (push) Successful in 5m23s
All checks were successful
CI/CD Pipeline / Build and Deploy with Docker Compose (push) Successful in 5m23s
This commit is contained in:
parent
97fb2d247f
commit
fbedcd5303
@ -1,22 +1,29 @@
|
|||||||
@page "/customers"
|
@page "/sales/customers"
|
||||||
@using phronCare.UIBlazor.Services.Sales
|
@using phronCare.UIBlazor.Services.Sales
|
||||||
@using phronCare.UIBlazor.Data
|
@using phronCare.UIBlazor.Data
|
||||||
@using Domain.Entities
|
@using Domain.Entities
|
||||||
@using Domain.Generics
|
@using Domain.Generics
|
||||||
|
@inject NavigationManager Navigation
|
||||||
|
|
||||||
@inject CustomerHttpService CustomerService
|
@inject CustomerHttpService CustomerService
|
||||||
|
|
||||||
<h3 class="text-xl font-bold mb-4">Buscar Clientes</h3>
|
|
||||||
|
|
||||||
<div class="mb-4 space-y-2">
|
<div class="card " style="zoom:90%">
|
||||||
|
<div class="card-header">
|
||||||
|
<h3 class="card-title">Listado de clientes</h3> @* wtf? *@
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
@* <h3 class="text-xl font-bold mb-4">Buscar Clientes</h3>*@
|
||||||
|
|
||||||
|
<div class="mb-4 space-y-2">
|
||||||
<input @bind="SearchParams.Name" placeholder="Nombre" class="border rounded p-1 w-full" />
|
<input @bind="SearchParams.Name" placeholder="Nombre" class="border rounded p-1 w-full" />
|
||||||
<input @bind="SearchParams.Email" placeholder="Email" class="border rounded p-1 w-full" />
|
<input @bind="SearchParams.Email" placeholder="Email" class="border rounded p-1 w-full" />
|
||||||
<input @bind="SearchParams.Document" placeholder="Documento" class="border rounded p-1 w-full" />
|
<input @bind="SearchParams.Document" placeholder="Documento" class="border rounded p-1 w-full" />
|
||||||
<button class="bg-blue-500 text-white px-4 py-2 rounded" @onclick="BuscarClientes">Buscar</button>
|
<button class="btn btn-primary" @onclick="BuscarClientes">Buscar</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@if (TablaClientes != null && TablaClientes.Any())
|
@if (TablaClientes != null && TablaClientes.Any())
|
||||||
{
|
{
|
||||||
<PhTable Columns="TableColumns"
|
<PhTable Columns="TableColumns"
|
||||||
Data="TablaClientes"
|
Data="TablaClientes"
|
||||||
RowsPerPage=SearchParams.PageSize
|
RowsPerPage=SearchParams.PageSize
|
||||||
@ -30,19 +37,31 @@
|
|||||||
<span>Página @SearchParams.Page de @TotalPaginas</span>
|
<span>Página @SearchParams.Page de @TotalPaginas</span>
|
||||||
<button class="bg-gray-300 px-4 py-2 rounded" @onclick="SiguientePagina" disabled="@(!PuedeAvanzar)">Siguiente</button>
|
<button class="bg-gray-300 px-4 py-2 rounded" @onclick="SiguientePagina" disabled="@(!PuedeAvanzar)">Siguiente</button>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<p>No hay resultados.</p>
|
<p>No hay resultados.</p>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="card-footer">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col">
|
||||||
|
<button type="button" class="btn btn-success" @onclick="XSLXExportar">
|
||||||
|
<i class="fas fa-file-excel"></i> Exportar a Excel
|
||||||
|
</button>
|
||||||
|
<button type="button" class="btn btn-secondary" @onclick="Cancel">Volver</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@code {
|
@code {
|
||||||
private CustomerSearchParams SearchParams = new();
|
private CustomerSearchParams SearchParams = new();
|
||||||
private PagedResult<ECustomer>? PagedResult;
|
private PagedResult<ECustomer>? PagedResult;
|
||||||
private List<Dictionary<string, object>> TablaClientes = new();
|
private List<Dictionary<string, object>> TablaClientes = new();
|
||||||
private List<string> TableColumns = new()
|
private List<string> TableColumns = new()
|
||||||
{
|
{
|
||||||
"Id", "Nombre", "Razon Social", "Activo", "Código Externo", "Crédito", "Límite",
|
"Id", "Nombre", "Razon Social", "Activo", "Crédito", "Límite",
|
||||||
"Email", "Teléfono", "Dirección", "Documento"
|
"Email", "Teléfono", "Dirección", "Documento"
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -67,38 +86,45 @@ else
|
|||||||
{ "Nombre", c.Name ?? string.Empty },
|
{ "Nombre", c.Name ?? string.Empty },
|
||||||
{ "Razon Social", c.BusinessName ?? string.Empty },
|
{ "Razon Social", c.BusinessName ?? string.Empty },
|
||||||
{ "Activo", c.Active ? "Sí" : "No" },
|
{ "Activo", c.Active ? "Sí" : "No" },
|
||||||
{ "Código Externo", c.ExternalCode },
|
|
||||||
{ "Crédito", c.HasCreditAccount ? "Sí" : "No" },
|
{ "Crédito", c.HasCreditAccount ? "Sí" : "No" },
|
||||||
{ "Límite", c.CreditLimit },
|
{ "Límite", c.CreditLimit },
|
||||||
{ "Email", addr?.Email ?? "" },
|
{ "Email", addr?.Email ?? "" },
|
||||||
{ "Teléfono", addr?.Phonenumber ?? "" },
|
{ "Teléfono", addr?.Phonenumber ?? "" },
|
||||||
{ "Dirección", $"{addr?.Streetaddress1} {addr?.Streetaddress2}, {addr?.City}, {addr?.Postalcode}, {addr?.Country}" },
|
{ "Dirección", $"{addr?.Streetaddress1} {addr?.Streetaddress2}, {addr?.City}, {addr?.Postalcode}, {addr?.Country}" },
|
||||||
{ "Documento", $"{doc?.DocumentNumber} | {doc?.IssueDate?.ToString("yyyy-MM-dd")} - {doc?.ExpiryDate?.ToString("yyyy-MM-dd")}" }
|
{ "Documento", $"{doc?.Documenttypes} | {doc?.DocumentNumber}" }
|
||||||
};
|
};
|
||||||
}).ToList();
|
}).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task SiguientePagina()
|
private async Task SiguientePagina() => await CambiarPagina(1);
|
||||||
|
private async Task AnteriorPagina() => await CambiarPagina(-1);
|
||||||
|
private async Task CambiarPagina(int delta)
|
||||||
{
|
{
|
||||||
if (PuedeAvanzar)
|
var nuevaPagina = SearchParams.Page + delta;
|
||||||
|
if (nuevaPagina >= 1 && nuevaPagina <= TotalPaginas)
|
||||||
{
|
{
|
||||||
SearchParams.Page++;
|
SearchParams.Page = nuevaPagina;
|
||||||
await CargarClientes();
|
await CargarClientes();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task AnteriorPagina()
|
private async Task XSLXExportar()
|
||||||
{
|
{
|
||||||
if (PuedeRetroceder)
|
// string endpoint = "/api/Ticket/ExportDashboardDetail";
|
||||||
{
|
// var response = await _httpClient.PostAsJsonAsync(endpoint, new { Param1 = Group, Param2 = "ASC" });
|
||||||
SearchParams.Page--;
|
// response.EnsureSuccessStatusCode();
|
||||||
await CargarClientes();
|
// var fileBytes = await response.Content.ReadAsByteArrayAsync();
|
||||||
}
|
// var currentDate = DateTime.Now.ToString("ddMMyyyyhhmmss");
|
||||||
|
// var filename = $"Tickets_{Group}_{currentDate}.xlsx";
|
||||||
|
// await js.InvokeAsync<object>("saveAsFile", filename, Convert.ToBase64String(fileBytes));
|
||||||
}
|
}
|
||||||
|
|
||||||
private int TotalPaginas => PagedResult is null ? 1 :
|
private int TotalPaginas => PagedResult is null ? 1 :
|
||||||
(int)Math.Ceiling((double)(PagedResult.TotalItems) / SearchParams.PageSize);
|
(int)Math.Ceiling((double)(PagedResult.TotalItems) / SearchParams.PageSize);
|
||||||
|
|
||||||
private bool PuedeAvanzar => PagedResult != null && SearchParams.Page < TotalPaginas;
|
private bool PuedeAvanzar => PagedResult != null && SearchParams.Page < TotalPaginas;
|
||||||
private bool PuedeRetroceder => PagedResult != null && SearchParams.Page > 1;
|
private bool PuedeRetroceder => PagedResult != null && SearchParams.Page > 1;
|
||||||
|
public void Cancel()
|
||||||
|
{
|
||||||
|
Navigation.NavigateTo("/DashboardPanel");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user