@ -90,21 +90,23 @@ public class MantenimientoView extends VerticalLayout implements BeforeEnterObse
tipoMantt . addValueChangeListener ( event - > {
tipoMantt . addValueChangeListener ( event - > {
String tipoSeleccionado = event . getValue ( ) ;
String tipoSeleccionado = event . getValue ( ) ;
if ( tipoSeleccionado ! = null ) {
if ( tipoSeleccionado ! = null ) {
/ / Actualizar nomenclatura dependiendo a l tipo de mantenimiento
/ / Actualizar nomenclatura dependiendo de l tipo de mantenimiento
String nomenclaturaValue = databaseService . getNomenclatura ( tipoSeleccionado ) ;
String nomenclaturaValue = databaseService . getNomenclatura ( tipoSeleccionado ) ;
nomenclatura . setValue ( nomenclaturaValue ) ;
nomenclatura . setValue ( nomenclaturaValue ) ;
/ / Si el tipo es preventivo se establecera la fecha automa ticamente a la fecha del sistema
if ( "PREVENTIVO " . equals ( tipoSeleccionado ) ) {
/ / Si el tipo es preventivo se establecerá la fecha automá ticamente a la fecha del sistema
if ( "1 " . equals ( tipoSeleccionado ) ) { / / 1 es para PREVENTIVO
this . fecha . setValue ( LocalDate . now ( ) ) ;
this . fecha . setValue ( LocalDate . now ( ) ) ;
etiquetaLayout . setVisible ( false ) ;
etiquetaLayout . setVisible ( false ) ;
} else {
} else if ( "2" . equals ( tipoSeleccionado ) ) { / / 2 es para CORRECTIVO
this . fecha . clear ( ) ;
this . fecha . clear ( ) ;
etiquetaLayout . setVisible ( true ) ;
etiquetaLayout . setVisible ( true ) ;
correctivoLayout ( ) ;
}
}
} else {
} else {
nomenclatura . clear ( ) ;
nomenclatura . clear ( ) ;
this . fecha . clear ( ) ;
this . fecha . clear ( ) ;
etiquetaLayout . setVisible ( false ) ;
}
}
} ) ;
} ) ;
fechaLayout . add ( this . fecha ) ;
fechaLayout . add ( this . fecha ) ;
@ -290,48 +292,50 @@ public class MantenimientoView extends VerticalLayout implements BeforeEnterObse
}
}
private void correctivoLayout ( ) {
/* Formulario para cuando el mnatenimiento es de tipo CORRECTIVO */
private void correctivoLayout ( ) {
Span Titulo = new Span ( "Reparación Realizada al Equipo: " ) ;
Span Titulo = new Span ( "Reparación Realizada al Equipo: " ) ;
TextField txtModelo = new TextField ( ) ;
txtModelo . setPlaceholder ( "Modelo" ) ;
txtModelo . setWidth ( "240px" ) ;
NumberField txtSerie = new NumberField ( ) ;
txtSerie . setPlaceholder ( "No. Serie" ) ;
txtSerie . setWidth ( "240px" ) ;
TextField txtSoft = new TextField ( ) ;
txtSoft . setPlaceholder ( "Instalación de Software" ) ;
txtSoft . setWidth ( "500px" ) ;
TextField txtRepHard = new TextField ( ) ;
txtRepHard . setPlaceholder ( "Reparación de Hardware" ) ;
txtRepHard . setWidth ( "500px" ) ;
TextField txtCamDisp = new TextField ( ) ;
txtCamDisp . setPlaceholder ( "Cambio de Dispositivo" ) ;
txtCamDisp . setWidth ( "500px" ) ;
HorizontalLayout model = new HorizontalLayout ( ) ;
model . add ( txtModelo , txtSerie , txtSoft ) ;
model . setSizeFull ( ) ;
HorizontalLayout hard = new HorizontalLayout ( ) ;
hard . add ( txtRepHard , txtCamDisp ) ;
hard . setSizeFull ( ) ;
etiquetaLayout . setVisible ( false ) ;
etiquetaLayout . add ( Titulo , model , hard ) ;
/ / Verificar el ID del tipo de mantenimiento
String tipoMantId = tipoMantt . getValue ( ) ;
if ( "2" . equals ( tipoMantId ) ) { / / Solo si el tipo es CORRECTIVO
TextField txtModelo = new TextField ( ) ;
txtModelo . setPlaceholder ( "Modelo" ) ;
txtModelo . setWidth ( "240px" ) ;
NumberField txtSerie = new NumberField ( ) ;
txtSerie . setPlaceholder ( "No. Serie" ) ;
txtSerie . setWidth ( "240px" ) ;
TextField txtSoft = new TextField ( ) ;
txtSoft . setPlaceholder ( "Instalación de Software" ) ;
txtSoft . setWidth ( "500px" ) ;
TextField txtRepHard = new TextField ( ) ;
txtRepHard . setPlaceholder ( "Reparación de Hardware" ) ;
txtRepHard . setWidth ( "500px" ) ;
TextField txtCamDisp = new TextField ( ) ;
txtCamDisp . setPlaceholder ( "Cambio de Dispositivo" ) ;
txtCamDisp . setWidth ( "500px" ) ;
HorizontalLayout model = new HorizontalLayout ( ) ;
model . add ( txtModelo , txtSerie , txtSoft ) ;
model . setSizeFull ( ) ;
HorizontalLayout hard = new HorizontalLayout ( ) ;
hard . add ( txtRepHard , txtCamDisp ) ;
hard . setSizeFull ( ) ;
etiquetaLayout . add ( Titulo , model , hard ) ;
etiquetaLayout . setVisible ( true ) ; / / Asegúrate de que el layout esté visible
} else {
etiquetaLayout . setVisible ( false ) ; / / Ocultar si no es correctivo
}
}
}
private void signLayout ( ) {
private void signLayout ( ) {
VerticalLayout userSignLayout = new VerticalLayout ( ) ;
VerticalLayout userSignLayout = new VerticalLayout ( ) ;
SignaturePad userSignPad = new SignaturePad ( ) ;
SignaturePad userSignPad = new SignaturePad ( ) ;
@ -392,8 +396,7 @@ public class MantenimientoView extends VerticalLayout implements BeforeEnterObse
String departamentoId = area . getValue ( ) ;
String departamentoId = area . getValue ( ) ;
String empleadoId = usuario . getValue ( ) ;
String empleadoId = usuario . getValue ( ) ;
/ / AQUI SE MANEJA LA OPCION SELECIONADA EN LA FORMA DE MANTENIMIENTO ( REMOTA o MANUAL )
/ / AQUI SE MANEJA LA OPCION SELECCIONADA EN LA FORMA DE MANTENIMIENTO ( REMOTA o MANUAL )
String formaSeleccionada = formaGroup . getValue ( ) ;
String formaSeleccionada = formaGroup . getValue ( ) ;
String formaMantt = null ;
String formaMantt = null ;
@ -403,7 +406,6 @@ public class MantenimientoView extends VerticalLayout implements BeforeEnterObse
formaMantt = "M" ;
formaMantt = "M" ;
}
}
/ / VALIDACION PARA QUE TODOS LOS CAMPOS OBLIGATORIOS SEAN LLENADOS
/ / VALIDACION PARA QUE TODOS LOS CAMPOS OBLIGATORIOS SEAN LLENADOS
if ( fechaSeleccionada = = null | | tipoMantId = = null | | departamentoId = = null | | empleadoId = = null | | formaMantt = = null ) {
if ( fechaSeleccionada = = null | | tipoMantId = = null | | departamentoId = = null | | empleadoId = = null | | formaMantt = = null ) {
Notification . show ( "Por favor, completa todos los campos requeridos" , 4000 , Notification . Position . MIDDLE ) ;
Notification . show ( "Por favor, completa todos los campos requeridos" , 4000 , Notification . Position . MIDDLE ) ;
@ -414,7 +416,6 @@ public class MantenimientoView extends VerticalLayout implements BeforeEnterObse
/ / AQUI SE MANEJA LA INSERCION DE LOS DETALLES DE HARDWARE ( TIPO DE HARDWARE , NO . DE SERIE , MODELO , PLACA )
/ / AQUI SE MANEJA LA INSERCION DE LOS DETALLES DE HARDWARE ( TIPO DE HARDWARE , NO . DE SERIE , MODELO , PLACA )
if ( isInserted > 0 ) {
if ( isInserted > 0 ) {
int mantenimientoId = databaseService . getUltimoMantenimientoId ( ) ;
int mantenimientoId = databaseService . getUltimoMantenimientoId ( ) ;
for ( HorizontalLayout layout : hardwareLayouts ) {
for ( HorizontalLayout layout : hardwareLayouts ) {
@ -450,7 +451,6 @@ public class MantenimientoView extends VerticalLayout implements BeforeEnterObse
}
}
}
}
/ / AQUI MANEJO LA INSERCION DE LOS DATOS DE LOS CHECKBOXES DE ACTUALIZACIONES DE SEGURIDAD ! ! !
/ / AQUI MANEJO LA INSERCION DE LOS DATOS DE LOS CHECKBOXES DE ACTUALIZACIONES DE SEGURIDAD ! ! !
for ( String actualizacionSelecionada : actualizaciones . getSelectedItems ( ) ) {
for ( String actualizacionSelecionada : actualizaciones . getSelectedItems ( ) ) {
boolean isActualizacionInserted = databaseService . insertActualizacionSeg ( actualizacionSelecionada , null , mantenimientoId ) ;
boolean isActualizacionInserted = databaseService . insertActualizacionSeg ( actualizacionSelecionada , null , mantenimientoId ) ;
@ -474,7 +474,6 @@ public class MantenimientoView extends VerticalLayout implements BeforeEnterObse
}
}
}
}
/ / NOTIFICACION DE GUARDADO EXITOSO Y LIMPIEZA DE LOS CAMPOS ! ! !
/ / NOTIFICACION DE GUARDADO EXITOSO Y LIMPIEZA DE LOS CAMPOS ! ! !
Notification . show ( "!!Mantenimiento guardado exitosamente!!" , 4000 , Notification . Position . MIDDLE ) ;
Notification . show ( "!!Mantenimiento guardado exitosamente!!" , 4000 , Notification . Position . MIDDLE ) ;
fecha . clear ( ) ;
fecha . clear ( ) ;
@ -490,6 +489,7 @@ public class MantenimientoView extends VerticalLayout implements BeforeEnterObse
}
}
} ) ;
} ) ;
buttonsLayout . setSizeFull ( ) ;
buttonsLayout . setSizeFull ( ) ;
buttonsLayout . add ( btnGuardar ) ;
buttonsLayout . add ( btnGuardar ) ;
botonesLayout . add ( buttonsLayout ) ;
botonesLayout . add ( buttonsLayout ) ;
@ -515,8 +515,12 @@ public class MantenimientoView extends VerticalLayout implements BeforeEnterObse
}
}
}
}
if ( "PREVENTIVO" . equalsIgnoreCase ( tipoParam ) ) {
tipoMantt . setValue ( "PREVENTIVO" ) ;
/ / Cambiamos el valor por el ID
if ( "1" . equals ( tipoParam ) ) { / / 1 es para PREVENTIVO
tipoMantt . setValue ( "1" ) ; / / Establecemos el ID en el ComboBox
tipoMantt . setReadOnly ( true ) ;
} else if ( "2" . equals ( tipoParam ) ) { / / 2 es para CORRECTIVO
tipoMantt . setValue ( "2" ) ;
tipoMantt . setReadOnly ( true ) ;
tipoMantt . setReadOnly ( true ) ;
}
}
}
}