148 lines
5.4 KiB
Plaintext
148 lines
5.4 KiB
Plaintext
@using System.Net.Http.Headers
|
|
@using System.Linq.Expressions
|
|
@using Newtonsoft.Json
|
|
@using System.Text
|
|
@using Serialize.Linq.Serializers
|
|
@using GestionPersonalWeb.Models
|
|
@using BlazorBootstrap
|
|
@using bdAntifraude.db
|
|
@using Microsoft.AspNetCore.Components
|
|
@rendermode InteractiveServer
|
|
@inject IJSRuntime JS
|
|
@inject NavigationManager NavigationManager
|
|
@inject IHttpClientFactory HttpClientFactory
|
|
@inject IHttpContextAccessor HttpContextAccessor
|
|
@inject UserState UserState
|
|
|
|
<div class="tablaTabLateral">
|
|
<input type="button" value="Nueva Reducción de Jornada" @onclick="@(() => abrirPopupModificacion(new TRABAJADORTIEMPOPARCIAL(), true))" class="mb-2 btnOAAFBlack" />
|
|
<div style="overflow-x:auto;" class="tablaDesk">
|
|
<Grid TItem="TRABAJADORTIEMPOPARCIAL"
|
|
Class="table tablaRegPers"
|
|
Data="itmList"
|
|
AllowFiltering="false"
|
|
PageSize="10"
|
|
AllowPaging="true"
|
|
AllowSorting="true"
|
|
EmptyText="No se han encontrado datos"
|
|
Height="100"
|
|
PageSizeSelectorVisible="false"
|
|
PageSizeSelectorItems="@(new int[] { 5, 10, 20, 50 })"
|
|
Responsive="true"
|
|
PaginationItemsTextFormat="{0} - {1} de {2} elementos">
|
|
|
|
<GridColumns>
|
|
<GridColumn TItem="TRABAJADORTIEMPOPARCIAL" HeaderText="Editar" FilterButtonCSSClass="hidden">
|
|
|
|
<button @onclick="@(() => abrirPopupModificacion(context, false))" class="btnOAAFAzul">Editar</button>
|
|
|
|
</GridColumn>
|
|
<GridColumn TItem="TRABAJADORTIEMPOPARCIAL" HeaderText="Fecha Inicio">
|
|
@context.FECHAINICIO?.ToString("dd/MM/yyyy")
|
|
</GridColumn>
|
|
<GridColumn TItem="TRABAJADORTIEMPOPARCIAL" HeaderText="Fecha Fin">
|
|
@context.FECHAFIN?.ToString("dd/MM/yyyy")
|
|
</GridColumn>
|
|
<GridColumn TItem="TRABAJADORTIEMPOPARCIAL" HeaderText="% Parcialidad">
|
|
@context.PORCENTAJEPARCIALIDAD
|
|
</GridColumn>
|
|
</GridColumns>
|
|
</Grid>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<Modal @ref="popupGestionDatos" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
|
<BodyTemplate>
|
|
<div class="row">
|
|
|
|
<div class="col-md-6 mb-2">
|
|
<label class="fw-bold">Fecha Inicio</label>
|
|
<input class="form-control" type="date" @bind-value="ItemEnEdicion.FECHAINICIO" />
|
|
</div>
|
|
<div class="col-md-6 mb-2">
|
|
<label class="fw-bold">Fecha Fin</label>
|
|
<input class="form-control" type="date" @bind-value="ItemEnEdicion.FECHAFIN" />
|
|
</div>
|
|
<div class="col-md-12 mb-2">
|
|
<label for="txtEDesc" class="fw-bold">% Parcialidad</label>
|
|
<input class="form-control" type="number" @bind-value="@ItemEnEdicion.PORCENTAJEPARCIALIDAD" />
|
|
</div>
|
|
</div>
|
|
</BodyTemplate>
|
|
<FooterTemplate>
|
|
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupModificacion">Cerrar</Button>
|
|
@if (ItemEnEdicion.IDTRABAJADORTIEMPOPARCIAL != 0)
|
|
{
|
|
<Button Type="ButtonType.Submit" Color="ButtonColor.Primary" @onclick="@(() => GestionarDatos(false))">Modificar</Button>
|
|
}
|
|
else
|
|
{
|
|
<Button Type="ButtonType.Submit" Color="ButtonColor.Primary" @onclick="@(() => GestionarDatos(true))">Crear</Button>
|
|
}
|
|
</FooterTemplate>
|
|
</Modal>
|
|
|
|
|
|
@code {
|
|
private Modal popupGestionDatos = default;
|
|
private TRABAJADORTIEMPOPARCIAL ItemEnEdicion { get; set; } = new TRABAJADORTIEMPOPARCIAL();
|
|
[Parameter]
|
|
public PERSONAS Persona { get; set; } = new PERSONAS();
|
|
private HttpClient cliente = new HttpClient();
|
|
[Parameter]
|
|
public EventCallback OnPersonaActualizada { get; set; }
|
|
private List<TRABAJADORTIEMPOPARCIAL> itmList = new List<TRABAJADORTIEMPOPARCIAL>();
|
|
protected override void OnParametersSet() => itmList = Persona.TRABAJADORTIEMPOPARCIAL?.ToList() ?? new();
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
|
|
cliente = Utilidades.ObtenerCliente(UserState.Token, HttpClientFactory);
|
|
await CargarListas();
|
|
await OnPersonaActualizada.InvokeAsync();
|
|
|
|
|
|
}
|
|
private async Task CargarListas()
|
|
{
|
|
try
|
|
{
|
|
var listnom = Persona.TRABAJADORTIEMPOPARCIAL;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Console.WriteLine($"Error al obtener los datos: {e.Message}");
|
|
}
|
|
}
|
|
private async Task cerrarPopupModificacion()
|
|
{
|
|
await popupGestionDatos.HideAsync();
|
|
}
|
|
private async Task abrirPopupModificacion(TRABAJADORTIEMPOPARCIAL objeto, bool esNuevo)
|
|
{
|
|
ItemEnEdicion = objeto;
|
|
|
|
await popupGestionDatos.ShowAsync();
|
|
}
|
|
private async Task GestionarDatos(bool tipo)
|
|
{
|
|
var inci = ItemEnEdicion;
|
|
if (tipo == true)
|
|
{
|
|
inci.IDTRABAJADORTIEMPOPARCIAL = 0;
|
|
inci.IDPERSONA = Persona.IDPERSONA;
|
|
}
|
|
|
|
if (inci.IDTRABAJADORTIEMPOPARCIAL != 0)
|
|
{
|
|
var response = await Utilidades.ActualizarObjeto(cliente, "/api/TRABAJADORTIEMPOPARCIAL/" + inci.IDTRABAJADORTIEMPOPARCIAL, inci);
|
|
}
|
|
else
|
|
{
|
|
var response = await Utilidades.NuevoObjeto(cliente, "/api/TRABAJADORTIEMPOPARCIAL/", inci);
|
|
}
|
|
await cerrarPopupModificacion();
|
|
}
|
|
}
|