Add Document Secction in CustomerForm
Some checks failed
CI/CD Pipeline / Build and Deploy with Docker Compose (push) Failing after 2m5s
Some checks failed
CI/CD Pipeline / Build and Deploy with Docker Compose (push) Failing after 2m5s
This commit is contained in:
parent
8271d399f4
commit
0c7ec75e9d
@ -61,14 +61,55 @@
|
||||
<InputCheckbox id="Active" @bind-Value="customer.Active" />
|
||||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
<h5>Documentos</h5>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<label for="ExternalCode">Código Externo (opcional):</label>
|
||||
<InputText id="ExternalCode" @bind-Value="customer.ExternalCode" class="form-control" />
|
||||
<div class="row align-items-end">
|
||||
<div class="col-sm-4">
|
||||
<label for="TipoDocumento">Tipo:</label>
|
||||
<InputSelect id="TipoDocumento" class="form-control" @bind-Value="nuevoDocumento.TipoDocumentoId">
|
||||
<option value="">Seleccione</option>
|
||||
@foreach (var tipo in documentTypes)
|
||||
{
|
||||
<option value="@tipo.Id">@tipo.Nombre</option>
|
||||
}
|
||||
</InputSelect>
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<label for="NumeroDocumento">Número:</label>
|
||||
<InputText id="NumeroDocumento" class="form-control" @bind-Value="nuevoDocumento.Numero" />
|
||||
</div>
|
||||
<div class="col-sm-2">
|
||||
<button type="button" class="btn btn-success" @onclick="AgregarDocumento">Agregar</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<br />
|
||||
|
||||
@if (customer.PhSCustomerDocuments?.Any() == true)
|
||||
{
|
||||
<table class="table table-sm table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Tipo</th>
|
||||
<th>Número</th>
|
||||
<th style="width:50px;"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var doc in customer.PhSCustomerDocuments)
|
||||
{
|
||||
<tr>
|
||||
<td>@documentTypes.FirstOrDefault(t => t.Id == doc.DocumenttypesId)?.Name</td>
|
||||
<td>@doc.DocumentNumber</td>
|
||||
<td>
|
||||
<button class="btn btn-sm btn-danger" @onclick="() => RemoveCustomerDocument(doc)">🗑</button>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</EditForm>
|
||||
|
||||
@code {
|
||||
@ -78,6 +119,8 @@
|
||||
private ECustomer customer { get; set; } = new();
|
||||
private List<EAccountType> accountTypes = new();
|
||||
private List<ETaxCondition> taxConditions = new();
|
||||
private List<EDocumentType> documentTypes = new();
|
||||
private ECustomerDocument documentFormModel = new();
|
||||
|
||||
private string returnUrl = "/sales/customers";
|
||||
|
||||
@ -96,11 +139,28 @@
|
||||
{
|
||||
accountTypes = await accountTypeService.GetAllAsync();
|
||||
}
|
||||
|
||||
private async Task LoadTaxConditions()
|
||||
{
|
||||
taxConditions = await taxConditionService.GetAllAsync();
|
||||
}
|
||||
private async Task LoadDocumentTypes()
|
||||
{
|
||||
var result = await _httpClient.GetFromJsonAsync<List<EDocumentType>>("/api/DocumentType/GetAll");
|
||||
documentTypes = result ?? new();
|
||||
}
|
||||
|
||||
private void AddCustomerDocument()
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(documentFormModel.DocumentNumber))
|
||||
{
|
||||
customer.PhSCustomerDocuments.Add(documentFormModel);
|
||||
documentFormModel = new();
|
||||
}
|
||||
}
|
||||
private void RemoveCustomerDocument(ECustomerDocument document)
|
||||
{
|
||||
customer.PhSCustomerDocuments.Remove(document);
|
||||
}
|
||||
|
||||
private async Task HandleValidSubmit()
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user