Compare commits
2 Commits
8c00e7f7cc
...
5326d87a6d
| Author | SHA1 | Date | |
|---|---|---|---|
| 5326d87a6d | |||
| 83fbcbe80f |
@@ -121,6 +121,16 @@
|
||||
|
||||
</div>
|
||||
</li>
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" style="font-family:'Satoshi'; color:white" href="#" id="tabFichMaestros" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">AVANZADO</a>
|
||||
<div class="dropdown-menu" id="dropFicherosMaestros" style="font-family: 'Satoshi';" aria-labelledby="dropFicherosMaestros">
|
||||
<a class="dropdown-item" href="/GruposEnumeraciones">Enumeraciones</a>
|
||||
<a class="dropdown-item" href="/Grupos de Usuarios">Grupos de Usuarios</a>
|
||||
<a class="dropdown-item" href="/Plantillas">Plantillas</a>
|
||||
<a class="dropdown-item" href="/Usuarios">Usuarios</a>
|
||||
<a class="dropdown-item" href="/Permisos">Permisos</a>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -0,0 +1,306 @@
|
||||
@page "/Enumeraciones/"
|
||||
@page "/Enumeraciones/{cl}"
|
||||
@using System.Net.Http.Headers
|
||||
@using System.Linq.Expressions
|
||||
@using Microsoft.AspNetCore.WebUtilities
|
||||
@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
|
||||
|
||||
<Toasts class="p-3 font-weight-bold" Style="color:white;" AutoHide="true" Delay="4000" Messages="mensajes" Placement="ToastsPlacement.BottomCenter" />
|
||||
<div class="pagina">
|
||||
<div class="d-flex">
|
||||
<div class="cabecera">
|
||||
<h6 style="padding-top: 13px;padding-right: 15px;">
|
||||
<b>Enumeración</b>
|
||||
</h6>
|
||||
</div>
|
||||
<button @onclick="@(() => abrirPopupModificacion(new ENUMERACIONES(), true))" class="btnOAAFAzul">Nuevo </button>
|
||||
</div>
|
||||
|
||||
@if (lEnumeraciones == null)
|
||||
{
|
||||
<div id="cargando" class="loadingFrame">
|
||||
<div class="loadingImg"></div>
|
||||
</div>
|
||||
}
|
||||
else if (!lEnumeraciones.Any())
|
||||
{
|
||||
<p>No se encontraron datos para mostrar.</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="botonera col-12 gap-1" style="display:flex;" role="group">
|
||||
</div>
|
||||
<div style="display:flex; justify-content:start; gap:15px;width:100%"></div>
|
||||
|
||||
<div style="overflow-x:auto;" class="">
|
||||
<Grid TItem="ENUMERACIONES"
|
||||
Class="table tablaRegPers"
|
||||
Data="@lEnumeraciones"
|
||||
AllowFiltering="false"
|
||||
AllowPaging="false"
|
||||
AllowSorting="true"
|
||||
EmptyText="No se han encontrado datos"
|
||||
Height="80"
|
||||
PageSizeSelectorVisible="false"
|
||||
Responsive="true"
|
||||
PaginationItemsTextFormat="{0} - {1} de {2} elementos">
|
||||
<GridColumns>
|
||||
<GridColumn TItem="ENUMERACIONES" HeaderText="">
|
||||
<button @onclick="@(() => abrirPopupModificacion(@context, false))" class="btnOAAFAzul">Editar</button>
|
||||
</GridColumn>
|
||||
<GridColumn TItem="ENUMERACIONES" HeaderText="Código" PropertyName="CODIGO" FilterButtonCSSClass="hidden" SortKeySelector="item => item.CODIGO">
|
||||
@context.CODIGO
|
||||
</GridColumn>
|
||||
<GridColumn TItem="ENUMERACIONES" HeaderText="Descripción" PropertyName="DESCRIPCION" FilterButtonCSSClass="hidden" SortKeySelector="item => item.DESCRIPCION">
|
||||
@context.DESCRIPCION
|
||||
</GridColumn>
|
||||
<GridColumn TItem="ENUMERACIONES" HeaderText="Descripción" PropertyName="VALORNUMERICO1" FilterButtonCSSClass="hidden" SortKeySelector="item => item.VALORNUMERICO1">
|
||||
@context.VALORNUMERICO1
|
||||
</GridColumn>
|
||||
<GridColumn TItem="ENUMERACIONES" HeaderText="Descripción" PropertyName="VALORNUMERICO2" FilterButtonCSSClass="hidden" SortKeySelector="item => item.VALORNUMERICO2">
|
||||
@context.VALORNUMERICO2
|
||||
</GridColumn>
|
||||
<GridColumn TItem="ENUMERACIONES" HeaderText="Descripción" PropertyName="VALORNUMERICO3" FilterButtonCSSClass="hidden" SortKeySelector="item => item.VALORNUMERICO3">
|
||||
@context.VALORNUMERICO3
|
||||
</GridColumn>
|
||||
<GridColumn TItem="ENUMERACIONES" HeaderText="Descripción" PropertyName="VALORNUMERICO4" FilterButtonCSSClass="hidden" SortKeySelector="item => item.VALORNUMERICO4">
|
||||
@context.VALORNUMERICO4
|
||||
</GridColumn>
|
||||
<GridColumn TItem="ENUMERACIONES" HeaderText="Descripción" PropertyName="VALORALFABETICO1" FilterButtonCSSClass="hidden" SortKeySelector="item => item.VALORALFABETICO1">
|
||||
@context.VALORALFABETICO1
|
||||
</GridColumn>
|
||||
<GridColumn TItem="ENUMERACIONES" HeaderText="Descripción" PropertyName="VALORALFABETICO2" FilterButtonCSSClass="hidden" SortKeySelector="item => item.VALORALFABETICO2">
|
||||
@context.VALORALFABETICO2
|
||||
</GridColumn>
|
||||
<GridColumn TItem="ENUMERACIONES" HeaderText="Descripción" PropertyName="VALORALFABETICO3" FilterButtonCSSClass="hidden" SortKeySelector="item => item.VALORALFABETICO3">
|
||||
@context.VALORALFABETICO3
|
||||
</GridColumn>
|
||||
<GridColumn TItem="ENUMERACIONES" HeaderText="Descripción" PropertyName="VALORALFABETICO4" FilterButtonCSSClass="hidden" SortKeySelector="item => item.VALORALFABETICO4">
|
||||
@context.VALORALFABETICO4
|
||||
</GridColumn>
|
||||
<GridColumn TItem="ENUMERACIONES" HeaderText="Descripción" PropertyName="VALORALFABETICOLARGO" FilterButtonCSSClass="hidden" SortKeySelector="item => item.VALORALFABETICOLARGO">
|
||||
@context.VALORALFABETICOLARGO
|
||||
</GridColumn>
|
||||
</GridColumns>
|
||||
</Grid>
|
||||
</div>
|
||||
|
||||
<!-- Vista móvil -->
|
||||
|
||||
}
|
||||
</div>
|
||||
<!--Popup de edicion-->
|
||||
<EditForm EditContext="@editContext" OnValidSubmit="GuardarCambiosPopup" OnInvalidSubmit="@MostrarErroresPopup" FormName="fiestasForm">
|
||||
<DataAnnotationsValidator></DataAnnotationsValidator>
|
||||
<Modal @ref="popupGestionDatos" title="@tituloPopup" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||
<BodyTemplate>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<label for="txtEDescripcion" class="fw-bold">Código: </label>
|
||||
<input class="form-control" id="txtEDescripcion" @bind-value="@ItemEnEdicion.CODIGO" />
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<label for="txtEDescripcion" class="fw-bold">Descripcion: </label>
|
||||
<input class="form-control" id="txtEDescripcion" @bind-value="@ItemEnEdicion.DESCRIPCION" />
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="txtEDescripcion" class="fw-bold">Valor Numérico 1: </label>
|
||||
<input class="form-control" id="txtEDescripcion" @bind-value="@ItemEnEdicion.VALORNUMERICO1" />
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="txtEDescripcion" class="fw-bold">Valor Numérico 2: </label>
|
||||
<input class="form-control" id="txtEDescripcion" @bind-value="@ItemEnEdicion.VALORNUMERICO2" />
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="txtEDescripcion" class="fw-bold">Valor Numérico 3: </label>
|
||||
<input class="form-control" id="txtEDescripcion" @bind-value="@ItemEnEdicion.VALORNUMERICO3" />
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="txtEDescripcion" class="fw-bold">Valor Numérico 4: </label>
|
||||
<input class="form-control" id="txtEDescripcion" @bind-value="@ItemEnEdicion.VALORNUMERICO4" />
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="txtEDescripcion" class="fw-bold">Valor Alfabético 1: </label>
|
||||
<input class="form-control" id="txtEDescripcion" @bind-value="@ItemEnEdicion.VALORALFABETICO1" />
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="txtEDescripcion" class="fw-bold">Valor Alfabético 2: </label>
|
||||
<input class="form-control" id="txtEDescripcion" @bind-value="@ItemEnEdicion.VALORALFABETICO2" />
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="txtEDescripcion" class="fw-bold">Valor Alfabético 3: </label>
|
||||
<input class="form-control" id="txtEDescripcion" @bind-value="@ItemEnEdicion.VALORALFABETICO3" />
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="txtEDescripcion" class="fw-bold">Valor Alfabético 4: </label>
|
||||
<input class="form-control" id="txtEDescripcion" @bind-value="@ItemEnEdicion.VALORALFABETICO4" />
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<label for="txtEDescripcion" class="fw-bold">Valor Alfabético Largo: </label>
|
||||
<input class="form-control" id="txtEDescripcion" @bind-value="@ItemEnEdicion.VALORALFABETICOLARGO" />
|
||||
</div>
|
||||
</div>
|
||||
</BodyTemplate>
|
||||
<FooterTemplate>
|
||||
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupModificacion">Cerrar</Button>
|
||||
<Button Type="ButtonType.Submit" Color="ButtonColor.Primary">@(EsItemNuevo ? "Añadir" : "Modificar")</Button>
|
||||
</FooterTemplate>
|
||||
</Modal>
|
||||
</EditForm>
|
||||
@code {
|
||||
[Parameter]
|
||||
public string? cl { get; set; } = "";
|
||||
GRUPOSENUMERACIONES grupo = new GRUPOSENUMERACIONES();
|
||||
List<ENUMERACIONES> lEnumeraciones = new List<ENUMERACIONES>();
|
||||
private string _filter = "";
|
||||
|
||||
private string tituloPopup = "";
|
||||
private Modal popupGestionDatos = default;
|
||||
private bool EsItemNuevo = false;
|
||||
private ENUMERACIONES ItemEnEdicion { get; set; } = new ENUMERACIONES();
|
||||
|
||||
private EditContext? editContext;
|
||||
List<ToastMessage> mensajes = new List<ToastMessage>();
|
||||
|
||||
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
var url = NavigationManager.ToAbsoluteUri(NavigationManager.Uri);
|
||||
var token = UserState.Token;
|
||||
var cliente = Utilidades.ObtenerCliente(UserState.Token, HttpClientFactory);
|
||||
editContext = new EditContext(lEnumeraciones);
|
||||
|
||||
if (QueryHelpers.ParseQuery(url.Query).TryGetValue("cl", out var clValue))
|
||||
{
|
||||
cl = clValue;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(cl))
|
||||
{
|
||||
//iContrato = new CONTRATOS();
|
||||
//mostrarBtn = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
string idDesencriptado = Utilidades.Desencriptar(cl);
|
||||
int id = int.Parse(idDesencriptado);
|
||||
|
||||
var response = await cliente.GetAsync($"/api/GRUPOSENUMERACIONES/{id}");
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
throw new Exception($"Error al obtener los datos. Código: {response.StatusCode}");
|
||||
}
|
||||
var resultContent = await response.Content.ReadAsStringAsync();
|
||||
grupo = JsonConvert.DeserializeObject<GRUPOSENUMERACIONES>(resultContent) ?? throw new Exception("Error al deserializar los datos.");
|
||||
|
||||
lEnumeraciones = await Utilidades.ObtenerObjeto<List<ENUMERACIONES>>(cliente, "/api/ENUMERACIONES/EnumeracionesGrupo/"+grupo.GRUPO);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private async Task abrirPopupModificacion(ENUMERACIONES objeto, bool esNuevo)
|
||||
{
|
||||
ItemEnEdicion = Utilidades.ClonarObjeto(objeto);
|
||||
EsItemNuevo = esNuevo;
|
||||
if (!EsItemNuevo)
|
||||
{
|
||||
tituloPopup = "Modificando Enumeracion";
|
||||
}
|
||||
else
|
||||
{
|
||||
tituloPopup = "Nueva Enumeracion";
|
||||
}
|
||||
|
||||
await popupGestionDatos.ShowAsync();
|
||||
}
|
||||
private async Task cerrarPopupModificacion()
|
||||
{
|
||||
await popupGestionDatos.HideAsync();
|
||||
}
|
||||
private async Task GuardarCambiosPopup()
|
||||
{
|
||||
try
|
||||
{
|
||||
ValidarDatos();
|
||||
|
||||
if (!editContext!.GetValidationMessages().Any())
|
||||
{
|
||||
string accion = EsItemNuevo ? "create" : "update";
|
||||
await GestionarDatos(accion);
|
||||
}
|
||||
else
|
||||
{
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Warning,
|
||||
Message = $"Debe rellenar los campos obligatorios.",
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Danger,
|
||||
Message = $"Error al guardar.",
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
private async Task GestionarDatos(string accion)
|
||||
{
|
||||
var cliente = Utilidades.ObtenerCliente(UserState.Token, HttpClientFactory);
|
||||
var copia = new List<ENUMERACIONES>(lEnumeraciones);
|
||||
cliente = Utilidades.ObtenerCliente(UserState.Token, HttpClientFactory);
|
||||
|
||||
switch (accion)
|
||||
{
|
||||
case "update":
|
||||
int indice = copia.FindIndex(x => x.IDENUMERACION == ItemEnEdicion.IDENUMERACION);
|
||||
if (indice > -1)
|
||||
{
|
||||
copia[indice] = ItemEnEdicion;
|
||||
}
|
||||
var response = await Utilidades.ActualizarObjeto(cliente, "/api/ENUMERACIONES/" + ItemEnEdicion.IDENUMERACION, ItemEnEdicion, mensajes);
|
||||
|
||||
break;
|
||||
case "create":
|
||||
copia.Add(ItemEnEdicion);
|
||||
var responsec = await Utilidades.NuevoObjeto(cliente, "/api/ENUMERACIONES/", ItemEnEdicion, mensajes);
|
||||
break;
|
||||
case "delete":
|
||||
|
||||
break;
|
||||
}
|
||||
cerrarPopupModificacion();
|
||||
lEnumeraciones = copia.ToList();
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
private void ValidarDatos()
|
||||
{
|
||||
|
||||
}
|
||||
private void MostrarErroresPopup()
|
||||
{
|
||||
// messageStore?.Clear();
|
||||
// foreach (var field in new[] { nameof(descripcionItem) })
|
||||
// {
|
||||
// ValidarYActualizar(new ChangeEventArgs { Value = typeof(enumeraciones).GetProperty(field)?.GetValue(itemSeleccionado) }, field);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
@page "/GruposEnumeraciones"
|
||||
@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
|
||||
|
||||
<Toasts class="p-3 font-weight-bold" Style="color:white;" AutoHide="true" Delay="4000" Messages="mensajes" Placement="ToastsPlacement.BottomCenter" />
|
||||
<div class="pagina">
|
||||
<div class="d-flex">
|
||||
<div class="cabecera">
|
||||
<h6 style="padding-top: 13px;padding-right: 15px;">
|
||||
<b>Grupos Enumeraciones</b>
|
||||
</h6>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (lGrupoEnumeraciones == null)
|
||||
{
|
||||
<div id="cargando" class="loadingFrame">
|
||||
<div class="loadingImg"></div>
|
||||
</div>
|
||||
}
|
||||
else if (!lGrupoEnumeraciones.Any())
|
||||
{
|
||||
<p>No se encontraron datos para mostrar.</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="botonera col-12 gap-1" style="display:flex;" role="group">
|
||||
</div>
|
||||
<div style="display:flex; justify-content:start; gap:15px;width:100%"></div>
|
||||
|
||||
<div style="overflow-x:auto;" class="">
|
||||
<Grid TItem="GRUPOSENUMERACIONES"
|
||||
Class="table tablaRegPers"
|
||||
Data="@lGrupoEnumeraciones"
|
||||
AllowFiltering="false"
|
||||
AllowPaging="false"
|
||||
AllowSorting="true"
|
||||
EmptyText="No se han encontrado datos"
|
||||
Height="80"
|
||||
PageSizeSelectorVisible="false"
|
||||
Responsive="true"
|
||||
PaginationItemsTextFormat="{0} - {1} de {2} elementos">
|
||||
<GridColumns>
|
||||
<GridColumn TItem="GRUPOSENUMERACIONES" HeaderText="Grupo" PropertyName="GRUPO" FilterButtonCSSClass="hidden" SortKeySelector="item => item.GRUPO">
|
||||
<NavLink class="btn btn-link" href="@HashRed(context.IDGRUPOENUMERACION.ToString())">@context.GRUPO</NavLink>
|
||||
</GridColumn>
|
||||
<GridColumn TItem="GRUPOSENUMERACIONES" HeaderText="Descripcion" PropertyName="DESCRIPCION" FilterButtonCSSClass="hidden" SortKeySelector="item => item.DESCRIPCION">
|
||||
@context.DESCRIPCION
|
||||
</GridColumn>
|
||||
</GridColumns>
|
||||
</Grid>
|
||||
</div>
|
||||
|
||||
<!-- Vista móvil -->
|
||||
}
|
||||
</div>
|
||||
@code {
|
||||
List<GRUPOSENUMERACIONES> lGrupoEnumeraciones = new List<GRUPOSENUMERACIONES>();
|
||||
// Bandera que indica si se está en modo "Ver Todos"
|
||||
private bool verTodosActive = false;
|
||||
List<ToastMessage> mensajes = new List<ToastMessage>();
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
verTodosActive = false;
|
||||
var token = UserState.Token;
|
||||
var cliente = Utilidades.ObtenerCliente(UserState.Token, HttpClientFactory);
|
||||
|
||||
var resultPersonas = await cliente.GetAsync("/api/GRUPOSENUMERACIONES");
|
||||
var resultContent = await resultPersonas.Content.ReadAsStringAsync();
|
||||
lGrupoEnumeraciones = JsonConvert.DeserializeObject<List<GRUPOSENUMERACIONES>>(resultContent) ?? new List<GRUPOSENUMERACIONES>(); ;
|
||||
}
|
||||
|
||||
private string HashRed(string id)
|
||||
{
|
||||
string link = "/Enumeraciones?cl=" + tsUtilidades.crypt.FEncS(
|
||||
id,
|
||||
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*",
|
||||
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.:/-*",
|
||||
875421649);
|
||||
return link;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user