Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Luciano Barletta
/
Pruebas-RTO
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit 4e1e29ea
authored
2024-11-02 13:31:12 -0300
by
Tu Nombre
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Agrego ovbservador
1 parent
e7e708dd
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
78 additions
and
2 deletions
protected_static/cargarapida.js
protected_static/snaper.js
static/src/carbone.js
templates/form.html
protected_static/cargarapida.js
View file @
4e1e29e
...
...
@@ -18,6 +18,7 @@ window.onload = function() {
console
.
log
(
'Valor de planilla_cent:'
,
planillaCentValue
);
// Llama a otra función con el valor del parámetro
usePlanillaCentValue
(
planillaCentValue
);
window
.
watchForChanges
();
//Desde snaper observo si cambia algun dato y marco para guardar
}
};
...
...
@@ -79,7 +80,7 @@ function llendoTentativo(data) {
};
}
function
LLenarDatosAuxiliareas
(
data
,
inspeccion
)
{
//
console.log(data)
console
.
log
(
data
)
let
linea
=
JSON
.
parse
(
data
.
linea_excel
);
let
conbustible
=
"Gas Oil"
;
console
.
log
(
inspeccion
)
...
...
@@ -90,6 +91,7 @@ function LLenarDatosAuxiliareas(data,inspeccion) {
EscribirValores
(
'input[name="vehiculo_tipo"]'
,
data
.
categoria
);
EscribirValores
(
'input[name="CodigoTaller"]'
,
linea
.
codigoTaller
);
EscribirValores
(
'input[name="numeroplanilla"]'
,
data
.
numeroplanilla
);
EscribirValores
(
'input[name="peso_estatico"]'
,
inspeccion
.
frenos
.
pesoTotalFreno
);
ControlEjesCantidad
();
//const ejes = document.querySelectorAll('input[name="cantidad_ejes"]');
...
...
protected_static/snaper.js
0 → 100644
View file @
4e1e29e
window
.
allFieldsToJson
=
function
allFieldsToJson
()
{
const
data
=
{};
const
fields
=
document
.
querySelectorAll
(
'input, select, textarea'
);
fields
.
forEach
(
field
=>
{
const
key
=
field
.
name
;
// || field.id; // Usa el nombre del campo, o su ID si no tiene nombre
const
value
=
field
.
value
;
// Si la clave ya existe (por ejemplo, en caso de checkboxes o radios con el mismo nombre)
if
(
data
.
hasOwnProperty
(
key
))
{
if
(
Array
.
isArray
(
data
[
key
]))
{
data
[
key
].
push
(
value
);
}
else
{
data
[
key
]
=
[
data
[
key
],
value
];
}
}
else
{
data
[
key
]
=
value
;
}
});
return
JSON
.
stringify
(
data
);
}
window
.
populateFieldsFromJson
=
function
populateFieldsFromJson
(
data
)
{
Object
.
keys
(
data
).
forEach
(
key
=>
{
const
fields
=
document
.
querySelectorAll
(
`[name="
${
key
}
"], [id="
${
key
}
"]`
);
fields
.
forEach
(
field
=>
{
const
value
=
data
[
key
];
if
(
field
.
type
===
'checkbox'
||
field
.
type
===
'radio'
)
{
// Marcar checkboxes/radios según el valor (asumimos booleano o comparación de string)
field
.
checked
=
Array
.
isArray
(
value
)
?
value
.
includes
(
field
.
value
)
:
field
.
value
===
String
(
value
);
}
else
if
(
field
.
tagName
===
'SELECT'
&&
Array
.
isArray
(
value
))
{
// Seleccionar múltiples opciones si es un select múltiple
Array
.
from
(
field
.
options
).
forEach
(
option
=>
{
option
.
selected
=
value
.
includes
(
option
.
value
);
});
}
else
{
// Asignar valor a otros tipos de campos
field
.
value
=
value
;
}
});
});
}
window
.
watchForChanges
=
function
watchForChanges
()
{
console
.
log
(
"Observando"
)
// Selecciona todos los campos de entrada, selectores y áreas de texto en el documento
const
fields
=
document
.
querySelectorAll
(
'input, select, textarea'
);
const
snapearField
=
document
.
getElementById
(
'snapear'
);
// Verifica si existe el campo "snapear" en el documento
if
(
!
snapearField
)
{
console
.
warn
(
'El campo con id="snapear" no existe en el documento.'
);
return
;
}
fields
.
forEach
(
field
=>
{
// Agrega un evento 'change' a cada campo
field
.
addEventListener
(
'change'
,
()
=>
{
snapearField
.
value
=
"1"
;
console
.
log
(
"Se encontro cambio se programa generer snap"
)
});
});
}
static/src/carbone.js
View file @
4e1e29e
...
...
@@ -38,6 +38,7 @@ function generarReporteTemplate (template) {
agregarCampoAObjeto
(
'cantidad_ejes'
,
'ejes'
,
solicitud
);
agregarCampoAObjeto
(
'eje_delantero'
,
'ed'
,
solicitud
);
agregarCampoAObjeto
(
'eje_trazero'
,
'et'
,
solicitud
);
agregarCampoAObjeto
(
'peso_estatico'
,
'PT'
,
solicitud
);
//Suspencion
//eje Delantera
agregarCampoAObjeto
(
'rendimiento_izquierdo_1'
,
'DiE'
,
solicitud
);
...
...
@@ -94,6 +95,7 @@ function generarReporteTemplate (template) {
};
//console.log(datos)
//InFormar al snap
fetch
(
'https://reporte.hgt.com.ar/consulta/carbone'
,
{
method
:
'POST'
,
...
...
templates/form.html
View file @
4e1e29e
...
...
@@ -9,7 +9,8 @@
<script
src=
"{{ url_for('static', filename = 'src/div.js') }}"
></script>
<script
src=
"{{ url_for('static', filename = 'src/carbone.js') }}"
></script>
<script
src=
"{{ url_for('static', filename = 'src/forms.js') }}"
></script>
<script
src=
"/protected_static/cargarapida.js"
></script>
<script
src=
"/protected_static/snaper.js"
></script>
<script
src=
"/protected_static/cargarapida.js"
defer
></script>
<link
rel=
"stylesheet"
href=
"{{ url_for('static', filename = 'styles/general.css') }}"
>
<!--INCLUIMOS LA FUENTE
<link rel="stylesheet" media="screen" href="https://fontlibrary.org/face/cmu-typewriter" type="text/css" />
...
...
@@ -43,12 +44,15 @@
<br>
Reporte
<input
sub=
"header"
type=
"text"
name=
"ReporteInspeccion"
id=
"ReporteInspeccion"
readonly=
"1"
>
<br>
Numero Planilla
<input
sub=
"header"
type=
"text"
name=
"numeroplanilla"
id=
"numeroplanilla"
>
<br>
Cantidad Ejes
<select
type=
"text"
sub=
"alineador"
id=
"cantidad_ejes"
name=
"cantidad_ejes"
>
<option
value=
"2"
selected
>
2
</option>
<option
value=
"3"
>
3
</option>
<option
value=
"4"
>
4
</option>
<option
value=
"5"
>
5
</option>
</select>
<br>
Peso Total
<input
sub=
"trasero"
type=
"text"
name=
"peso_estatico"
id=
"peso_estatico_general"
>
...
...
@@ -243,6 +247,7 @@
</div>
</div>
<!--<script src="{{ url_for('static', filename = 'src/report.js') }}"></script>-->
<input
type=
"hidden"
id=
"snapear"
value=
"0"
>
</body>
</html>
\ No newline at end of file
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment