cambios en como se ve las horas en herramietna casa y agregado en conf fases urban y arreglado que se duplica
This commit is contained in:
@@ -38,14 +38,20 @@
|
||||
</Content>
|
||||
</Tab>
|
||||
|
||||
<Tab Title="Fases" Name="tabFases">
|
||||
<Tab Title="Fases CASA" Name="tabFases">
|
||||
<Content>
|
||||
<div class="CajaTab p-2">
|
||||
<HerramientaCASA.Components.Pages.ConfiguracionPages.EnumeracionesTabs.FasesConf></HerramientaCASA.Components.Pages.ConfiguracionPages.EnumeracionesTabs.FasesConf>
|
||||
</div>
|
||||
</Content>
|
||||
</Tab>
|
||||
|
||||
<Tab Title="Fases URBAN" Name="tabFases">
|
||||
<Content>
|
||||
<div class="CajaTab p-2">
|
||||
<HerramientaCASA.Components.Pages.ConfiguracionPages.EnumeracionesTabs.FasesURBANConf></HerramientaCASA.Components.Pages.ConfiguracionPages.EnumeracionesTabs.FasesURBANConf>
|
||||
</div>
|
||||
</Content>
|
||||
</Tab>
|
||||
<Tab Title="Costes Variables" Name="tabCosteVariable">
|
||||
<Content>
|
||||
<div class="CajaTab p-2">
|
||||
|
||||
@@ -0,0 +1,425 @@
|
||||
@inject NavigationManager Navigation
|
||||
@layout ConfiguracionLayout
|
||||
@using BlazorBootstrap
|
||||
@using System.Globalization
|
||||
@using bdHerramientaCACOA.db
|
||||
|
||||
<Toasts class="p-3 font-weight-bold" Style="color:white;" AutoHide="true" Delay="4000" Messages="mensajes" Placement="ToastsPlacement.BottomCenter" />
|
||||
|
||||
<Modal @ref="popupConfirmarBorrado" title="" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||
<BodyTemplate>
|
||||
<div class="col-12 formatoCampos">
|
||||
¿Estás seguro que desea eliminarlo?
|
||||
</div>
|
||||
</BodyTemplate>
|
||||
<FooterTemplate>
|
||||
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupConfirmarBorrado">Cerrar</Button>
|
||||
<Button @onclick="@(() => BorrarItem())" Color="ButtonColor.Danger">Eliminar</Button>
|
||||
</FooterTemplate>
|
||||
</Modal>
|
||||
|
||||
<EditForm EditContext="@editContext" OnValidSubmit="guardarFormulario" OnInvalidSubmit="@MostrarErrores" FormName="PeriodosForm">
|
||||
<DataAnnotationsValidator></DataAnnotationsValidator>
|
||||
<Modal @ref="popupGestionDatos" title="@tituloPopup" IsVerticallyCentered="true" UseStaticBackdrop="true" CloseOnEscape="false">
|
||||
<BodyTemplate>
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Descripción:</label>
|
||||
<InputText MaxLength="40" @bind-Value="descripcionItem" @oninput="e => ValidarYActualizar(e, nameof(descripcionItem))" class="inputForm"></InputText>
|
||||
</div>
|
||||
<div class="validation-message">@GetExternalValidationMessage(nameof(descripcionItem))</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-6 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Valor numérico:</label>
|
||||
<InputNumber TValue="double?" @bind-Value="valorNumericoItem"
|
||||
step="any"
|
||||
@oninput="e => ValidarYActualizar(e, nameof(valorNumericoItem))"
|
||||
class="inputForm" />
|
||||
|
||||
</div>
|
||||
<div class="validation-message">@GetExternalValidationMessage(nameof(valorNumericoItem))</div>
|
||||
|
||||
<div class="col-6 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Plazos:</label>
|
||||
<InputNumber TValue="double?" @bind-Value="plazosItem"
|
||||
step="any"
|
||||
@oninput="e => ValidarYActualizar(e, nameof(plazosItem))"
|
||||
class="inputForm" />
|
||||
|
||||
</div>
|
||||
<div class="validation-message">@GetExternalValidationMessage(nameof(plazosItem))</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12 formatoCampos pt-2">
|
||||
<label class="tituloLbl">Orden:</label>
|
||||
<InputNumber TValue="int?" @bind-Value="ordenItem"
|
||||
step="any"
|
||||
class="inputForm" />
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</BodyTemplate>
|
||||
<FooterTemplate>
|
||||
<Button Color="ButtonColor.Secondary" @onclick="cerrarPopupGestionDatos">Cerrar</Button>
|
||||
<Button Type="ButtonType.Submit" Color="ButtonColor.Primary">@(nuevoElemento ? "Añadir" : "Modificar")</Button>
|
||||
</FooterTemplate>
|
||||
</Modal>
|
||||
</EditForm>
|
||||
|
||||
|
||||
|
||||
<div>
|
||||
|
||||
<div class="d-flex justify-content-between mt-3">
|
||||
<p><b class="Fuente2"></b> </p>
|
||||
<button @onclick="@(() => abrirPopupGestionDatos(new enumeraciones(), true))" class="btnBlue d-flex align-items-center"> <i class="fas fa-plus-square pe-1"></i> Nueva fase</button>
|
||||
</div>
|
||||
|
||||
<Grid TItem="enumeraciones"
|
||||
Class="tablaCACOA table"
|
||||
Data="listadoFases"
|
||||
AllowFiltering="false"
|
||||
PageSize="10"
|
||||
FixedHeader="true"
|
||||
Height="750"
|
||||
Unit="Unit.Px"
|
||||
EmptyText="No hay registros."
|
||||
PageSizeSelectorVisible="false"
|
||||
Responsive="true">
|
||||
<GridColumns>
|
||||
<GridColumn TItem="enumeraciones" HeaderTextAlignment="Alignment.Center" HeaderText="Descripción">
|
||||
<span>@context.ValorAlfabetico1</span>
|
||||
</GridColumn>
|
||||
|
||||
<GridColumn TItem="enumeraciones" HeaderTextAlignment="Alignment.Center" Class="columna20Ancho text-end" HeaderText="Valor Numérico">
|
||||
<span>@context.ValorNumerico1</span>
|
||||
</GridColumn>
|
||||
|
||||
<GridColumn TItem="enumeraciones" Class="columna10Ancho text-end" HeaderTextAlignment="Alignment.Center" HeaderText="Plazos">
|
||||
<span>@context.ValorNumerico2</span>
|
||||
</GridColumn>
|
||||
<GridColumn TItem="enumeraciones" HeaderTextAlignment="Alignment.Center" Class="columna10Ancho text-end" HeaderText="Orden">
|
||||
<span>@context.Orden</span>
|
||||
</GridColumn>
|
||||
<GridColumn TItem="enumeraciones" Class="botonesTabla" HeaderText="">
|
||||
<div class="btnTablasEspaciado">
|
||||
<span @onclick="@(() => abrirPopupGestionDatos(@context, false))" class="btnBorrarGuardar">
|
||||
<Icon CustomIconName="fas fa-edit"></Icon>
|
||||
</span>
|
||||
<span @onclick="@(() => abrirPopupConfirmarBorrado(@context))" class="btnBorrarGuardar">
|
||||
<Icon CustomIconName="fas fa-trash"></Icon>
|
||||
</span>
|
||||
</div>
|
||||
</GridColumn>
|
||||
</GridColumns>
|
||||
</Grid>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
|
||||
public List<enumeraciones> listadoFases { get; set; } = new List<enumeraciones>();
|
||||
|
||||
[SupplyParameterFromForm]
|
||||
private enumeraciones itemSeleccionado { get; set; } = new enumeraciones();
|
||||
|
||||
private string tituloPopup = "";
|
||||
private Modal popupGestionDatos = default!;
|
||||
private Modal popupConfirmarBorrado = default!;
|
||||
|
||||
private double? valorNumericoOriginal;
|
||||
|
||||
private bool nuevoElemento;
|
||||
|
||||
private string descripcionItem = "";
|
||||
private int? ordenItem = 0;
|
||||
private double? valorNumericoItem = 0;
|
||||
private double? plazosItem = 0;
|
||||
|
||||
List<ToastMessage> mensajes = new List<ToastMessage>();
|
||||
|
||||
private EditContext? editContext;
|
||||
private ValidationMessageStore? messageStore;
|
||||
public tsHerramientasCACOA bd;
|
||||
private string codigoEnumeracion = "FASURB";
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
bd = tsHerramientasCACOA.NuevoContexto(SoloLectura: false);
|
||||
|
||||
editContext = new EditContext(itemSeleccionado);
|
||||
messageStore = new ValidationMessageStore(editContext);
|
||||
|
||||
listadoFases = UtilidadesCASA.devolverListadoOrdenadoEnumeracion(bd, codigoEnumeracion);
|
||||
}
|
||||
|
||||
|
||||
private async Task abrirPopupGestionDatos(enumeraciones objeto, bool esNuevo)
|
||||
{
|
||||
valorNumericoOriginal = objeto.ValorNumerico1;
|
||||
itemSeleccionado = objeto;
|
||||
|
||||
if (esNuevo)
|
||||
{
|
||||
nuevoElemento = true;
|
||||
|
||||
|
||||
descripcionItem = "";
|
||||
ordenItem = 0;
|
||||
valorNumericoItem = 0;
|
||||
plazosItem = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
nuevoElemento = false;
|
||||
|
||||
descripcionItem = objeto.ValorAlfabetico1;
|
||||
ordenItem = objeto.Orden;
|
||||
valorNumericoItem = objeto.ValorNumerico1;
|
||||
plazosItem = objeto.ValorNumerico2;
|
||||
}
|
||||
|
||||
if (!nuevoElemento)
|
||||
{
|
||||
tituloPopup = "Modificar fase";
|
||||
}
|
||||
else
|
||||
{
|
||||
tituloPopup = "Nueva fase";
|
||||
}
|
||||
|
||||
await popupGestionDatos.ShowAsync();
|
||||
}
|
||||
private async Task cerrarPopupGestionDatos()
|
||||
{
|
||||
await popupGestionDatos.HideAsync();
|
||||
}
|
||||
|
||||
private void ValidarYActualizar(ChangeEventArgs e, string fieldName)
|
||||
{
|
||||
var value = e.Value?.ToString();
|
||||
var field = new FieldIdentifier(itemSeleccionado, fieldName);
|
||||
|
||||
switch (fieldName)
|
||||
{
|
||||
case nameof(descripcionItem):
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
|
||||
descripcionItem = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
descripcionItem = "";
|
||||
}
|
||||
break;
|
||||
|
||||
case nameof(valorNumericoItem):
|
||||
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
|
||||
string parseado = value.Replace(",", ".");
|
||||
valorNumericoItem = double.Parse(parseado, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
break;
|
||||
case nameof(plazosItem):
|
||||
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
|
||||
string parseado = value.Replace(",", ".");
|
||||
plazosItem = double.Parse(parseado, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
messageStore?.Clear(field);
|
||||
if (fieldName == nameof(descripcionItem) && descripcionItem == "")
|
||||
{
|
||||
messageStore?.Add(field, "La descripción no puede estar vacía.");
|
||||
}
|
||||
|
||||
if (fieldName == nameof(valorNumericoItem) && valorNumericoItem == null)
|
||||
{
|
||||
messageStore?.Add(field, "El valor numérico no puede estar vacío.");
|
||||
}
|
||||
|
||||
editContext?.NotifyValidationStateChanged();
|
||||
}
|
||||
|
||||
|
||||
private void ValidarTodo()
|
||||
{
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = descripcionItem }, nameof(descripcionItem));
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = valorNumericoItem }, nameof(valorNumericoItem));
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = plazosItem }, nameof(plazosItem));
|
||||
}
|
||||
|
||||
private string GetExternalValidationMessage(string fieldName)
|
||||
{
|
||||
var field = new FieldIdentifier(itemSeleccionado, fieldName);
|
||||
return messageStore?[field].FirstOrDefault() ?? string.Empty;
|
||||
}
|
||||
|
||||
private async Task GestionarDatos(string accion)
|
||||
{
|
||||
|
||||
var enumObtenido = bd.enumeraciones.Where(x => x.idEnumeracion == itemSeleccionado.idEnumeracion).FirstOrDefault();
|
||||
|
||||
itemSeleccionado.ValorAlfabetico1 = descripcionItem;
|
||||
itemSeleccionado.Orden = ordenItem;
|
||||
itemSeleccionado.ValorNumerico1 = valorNumericoItem;
|
||||
itemSeleccionado.ValorNumerico2 = plazosItem;
|
||||
|
||||
|
||||
switch (accion)
|
||||
{
|
||||
case "update":
|
||||
UtilidadesCASA.guardarEnumeracion(bd, itemSeleccionado, codigoEnumeracion, nuevoElemento, enumObtenido);
|
||||
|
||||
await cerrarPopupGestionDatos();
|
||||
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Actualizado correctamente.",
|
||||
});
|
||||
|
||||
break;
|
||||
|
||||
case "create":
|
||||
UtilidadesCASA.guardarEnumeracion(bd, itemSeleccionado, codigoEnumeracion, nuevoElemento);
|
||||
|
||||
await cerrarPopupGestionDatos();
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Guardado correctamente.",
|
||||
});
|
||||
break;
|
||||
|
||||
case "delete":
|
||||
UtilidadesCASA.eliminarEnumeracion(bd, enumObtenido);
|
||||
|
||||
await cerrarPopupConfirmarBorrado();
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Primary,
|
||||
Message = $"Eliminado correctamente.",
|
||||
});
|
||||
break;
|
||||
}
|
||||
bd.SaveChanges();
|
||||
listadoFases = UtilidadesCASA.devolverListadoOrdenadoEnumeracion(bd, codigoEnumeracion);
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
|
||||
private async Task BorrarItem()
|
||||
{
|
||||
await GestionarDatos("delete");
|
||||
}
|
||||
//////// PopUp eliminar registro
|
||||
private async Task abrirPopupConfirmarBorrado(enumeraciones objeto)
|
||||
{
|
||||
itemSeleccionado = objeto;
|
||||
await popupConfirmarBorrado.ShowAsync();
|
||||
}
|
||||
private async Task cerrarPopupConfirmarBorrado()
|
||||
{
|
||||
await popupConfirmarBorrado.HideAsync();
|
||||
}
|
||||
|
||||
// GUARDAR
|
||||
private async Task guardarFormulario()
|
||||
{
|
||||
try
|
||||
{
|
||||
ValidarTodo();
|
||||
|
||||
if (!editContext!.GetValidationMessages().Any())
|
||||
{
|
||||
string accion = nuevoElemento ? "create" : "update";
|
||||
bool porcentajeMenosCien = comprobarPorcentaje();
|
||||
|
||||
if (porcentajeMenosCien)
|
||||
{
|
||||
await GestionarDatos(accion);
|
||||
}
|
||||
else
|
||||
{
|
||||
await cerrarPopupGestionDatos();
|
||||
itemSeleccionado.ValorNumerico1 = valorNumericoOriginal;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
mensajes.Add(new ToastMessage
|
||||
{
|
||||
Type = ToastType.Warning,
|
||||
Message = $"El porcentaje total no puede ser mayor de 100.",
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
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 void MostrarErrores()
|
||||
{
|
||||
messageStore?.Clear();
|
||||
foreach (var field in new[] { nameof(descripcionItem), nameof(valorNumericoItem) })
|
||||
{
|
||||
ValidarYActualizar(new ChangeEventArgs { Value = typeof(enumeraciones).GetProperty(field)?.GetValue(itemSeleccionado) }, field);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private bool comprobarPorcentaje()
|
||||
{
|
||||
bool menorCien = false;
|
||||
|
||||
var porcentajeTotal = listadoFases.Sum(x => x.ValorNumerico1);
|
||||
|
||||
if (!nuevoElemento)
|
||||
{
|
||||
if (porcentajeTotal <= 100)
|
||||
{
|
||||
menorCien = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (porcentajeTotal + valorNumericoItem <= 100)
|
||||
{
|
||||
menorCien = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return menorCien;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -83,7 +83,7 @@
|
||||
<table class="table tablaCACOA tablaCACOA2 mb-0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="colorB fw-bold">Trabajos</th>
|
||||
<th class="colorB fw-bold" style="width:80%">Trabajos</th>
|
||||
<th class="colorB fw-bold">Horas</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -95,12 +95,25 @@
|
||||
|
||||
<tr>
|
||||
<td class="colorB text-end">Horas de documentación en Despacho Profesional</td>
|
||||
<td class="text-end">@objetoCASA.CostesProduccion.HorasProduccionDespachoElabDocumentacion.MilesYDecimales() h</td>
|
||||
<td class="text-start">
|
||||
<div class="text-end" style="width:70px;">
|
||||
<span>
|
||||
@objetoCASA.CostesProduccion.HorasProduccionDespachoElabDocumentacion.MilesYDecimales()
|
||||
</span>
|
||||
<span>
|
||||
h
|
||||
</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="colorB text-end">Horas de documentación mediante externalización</td>
|
||||
<td class="text-end">@objetoCASA.CostesProduccion.NumHorasMinimoExt.MilesYDecimales() h</td>
|
||||
<td class="text-start">
|
||||
<div style="max-width:70px;" class="text-end">
|
||||
@objetoCASA.CostesProduccion.NumHorasMinimoExt.MilesYDecimales() h
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
|
||||
@@ -145,17 +145,36 @@ namespace bdHerramientaCACOA
|
||||
var listaFases = bd.enumeraciones.Where(x => x.idGrupoEnumeracion == grupoFases.idGrupoEnumeracion).ToList();
|
||||
foreach (enumeraciones enu in listaFases)
|
||||
{
|
||||
FasesURBAN ft = new FasesURBAN();
|
||||
ft.idFase = enu.idEnumeracion;
|
||||
ft.Codigo = enu.Codigo;
|
||||
ft.Denominacion = enu.ValorAlfabetico1;
|
||||
ft.Porcentaje = (double)enu.ValorNumerico1;
|
||||
if (!TrabajoProfesional.FasesTrabajoProfesional.Any(x => x.idFase == enu.idEnumeracion))
|
||||
{
|
||||
FasesURBAN ft = new FasesURBAN();
|
||||
ft.idFase = enu.idEnumeracion;
|
||||
ft.Codigo = enu.Codigo;
|
||||
ft.Denominacion = enu.ValorAlfabetico1;
|
||||
ft.Porcentaje = (double)enu.ValorNumerico1;
|
||||
|
||||
TrabajoProfesional.FasesTrabajoProfesional.Add(ft);
|
||||
TrabajoProfesional.FasesTrabajoProfesional.Add(ft);
|
||||
}
|
||||
}
|
||||
|
||||
checkListFasesURBAN(listaFases);
|
||||
|
||||
|
||||
Enumerados.FasesTrabajo = JsonSerializer.Deserialize<List<FasesURBAN>>(JsonSerializer.Serialize(TrabajoProfesional.FasesTrabajoProfesional));
|
||||
}
|
||||
|
||||
private void checkListFasesURBAN(List<enumeraciones> listaFases)
|
||||
{
|
||||
var itemsAEliminar = TrabajoProfesional.FasesTrabajoProfesional
|
||||
.Where(item => !listaFases.Any(x => x.idEnumeracion == item.idFase))
|
||||
.ToList();
|
||||
|
||||
foreach (var item in itemsAEliminar)
|
||||
{
|
||||
TrabajoProfesional.FasesTrabajoProfesional.Remove(item);
|
||||
}
|
||||
}
|
||||
|
||||
public void CalcularLicitacion() {
|
||||
var horasAnualesDes = Math.Round(TrabajoProfesional.horasTrabProfesional * 12 / PlazoPresentacionDocumentos,2,MidpointRounding.AwayFromZero);
|
||||
var CD = ObtenerCDTabla(horasAnualesDes);
|
||||
|
||||
Reference in New Issue
Block a user