actas: unidad HBOX completa seleccionable (3 piezas o ensamble aprobado) + revisión de daño por pieza

This commit is contained in:
Leopoldo Rodríguez 2026-09-30 11:32:38 -06:00
parent a6f4a4c943
commit 4104b90e8b

View File

@ -86,6 +86,7 @@
const flota = Array.isArray(cfg.unidades) && cfg.unidades.length > 0; const flota = Array.isArray(cfg.unidades) && cfg.unidades.length > 0;
const serieOtra = $('input', { type: 'text', id: 'f_serie_otra', placeholder: 'Escribe la etiqueta de la unidad tal como viene en la caja' }); const serieOtra = $('input', { type: 'text', id: 'f_serie_otra', placeholder: 'Escribe la etiqueta de la unidad tal como viene en la caja' });
const fichaUnidad = $('div', { class: 'ficha-unidad' }); const fichaUnidad = $('div', { class: 'ficha-unidad' });
const armar = $('div', { class: 'armar-hbox' }); const armarSel = {};
if (flota) { if (flota) {
serieSel.append($('option', { value: '', text: '— elegir unidad —' })); serieSel.append($('option', { value: '', text: '— elegir unidad —' }));
@ -97,9 +98,17 @@
serieSel.append(og); serieSel.append(og);
}); });
if (!cfg.sinEnsambladas) cargarEnsambladas(); if (!cfg.sinEnsambladas) cargarEnsambladas();
if (!cfg.sinEnsambladas) serieSel.insertBefore($('option', { value: '__HBOX__', text: '🧩 Unidad HBOX completa — elegir sus 3 piezas' }), serieSel.children[1] || null);
serieSel.append($('option', { value: '__OTRA__', text: '➕ Otra unidad (no está en la lista)' })); serieSel.append($('option', { value: '__OTRA__', text: '➕ Otra unidad (no está en la lista)' }));
serieSel.append($('option', { value: 'CAMPO-PRUEBA', text: '⚙ PRUEBA (no cuenta)' })); serieSel.append($('option', { value: 'CAMPO-PRUEBA', text: '⚙ PRUEBA (no cuenta)' }));
const dS = $('div'); dS.append($('label', { text: cfg.etiquetaSerie || 'Unidad' }), serieSel, serieOtra, fichaUnidad); // Unidad HBOX completa armada a mano: tarjeta + ArduSimple + módem → misma serie que el acta de ensamble.
[['einar', 'Tarjeta EinarBoard', 'V5', 2], ['ard', 'ArduSimple', 'ARD', 3], ['modem', 'Módem 4G', 'RTK', 4]].forEach(([k, t, pre, pad]) => {
const sel = $('select'); opciones(sel, pre, 1, 30, pad); armarSel[k] = sel;
const d = $('div'); d.append($('label', { text: t }), sel); armar.append(d);
sel.addEventListener('change', () => loadSerie());
});
armar.style.display = 'none';
const dS = $('div'); dS.append($('label', { text: cfg.etiquetaSerie || 'Unidad' }), serieSel, serieOtra, armar, fichaUnidad);
serieOtra.style.display = 'none'; serieOtra.style.marginTop = '8px'; serieOtra.style.display = 'none'; serieOtra.style.marginTop = '8px';
const dT = $('div'); dT.append($('label', { text: 'Técnico' }), tecnico); const dT = $('div'); dT.append($('label', { text: 'Técnico' }), tecnico);
datos.append(dS, dT); datos.append(dS, dT);
@ -193,12 +202,24 @@
function seleccion() { const s = {}; for (const k in compSel) s[k] = compSel[k].value; return s; } function seleccion() { const s = {}; for (const k in compSel) s[k] = compSel[k].value; return s; }
function unidadSel() { function unidadSel() {
if (!flota) return null; if (!flota) return null;
if (serieSel.value === '__HBOX__') {
const c = {}; for (const k in armarSel) c[k] = armarSel[k].value;
const piezas = Object.values(c).filter(Boolean).join(' · ');
return { terminal: 'Unidades HBOX completas', componentes: c, etiqueta: 'HBOX completa (' + piezas + ')',
nota: 'Unidad completa' + (piezas ? ': ' + piezas : '') + '.' };
}
return (cfg.unidades || []).find(u => u.serie === serieSel.value) || null; return (cfg.unidades || []).find(u => u.serie === serieSel.value) || null;
} }
function serieActual() { function serieActual() {
if (flota) { if (flota) {
if (serieSel.value === '__OTRA__') if (serieSel.value === '__OTRA__')
return String(serieOtra.value || '').trim().toUpperCase().replace(/[^A-Z0-9_-]/g, '-').slice(0, 24); return String(serieOtra.value || '').trim().toUpperCase().replace(/[^A-Z0-9_-]/g, '-').slice(0, 24);
if (serieSel.value === '__HBOX__') {
const c = {}; for (const k in armarSel) c[k] = armarSel[k].value;
if (Object.values(c).some(v => !v)) return '';
if (Object.values(c).some(esPrueba)) return 'HBOX5-PRUEBA';
return 'HBOX5-E' + num(c.einar) + '-A' + num(c.ard) + '-R' + num(c.modem);
}
return serieSel.value; return serieSel.value;
} }
if (!compuesta) return serieSel.value; if (!compuesta) return serieSel.value;
@ -646,7 +667,8 @@
for (const k in guardaEn) if (v[k] !== undefined && v[k] !== '') d[guardaEn[k]] = v[k]; for (const k in guardaEn) if (v[k] !== undefined && v[k] !== '') d[guardaEn[k]] = v[k];
if (flota) { if (flota) {
const u = unidadSel(); const u = unidadSel();
if (u) { d.maquina = u.maquina || ''; d.terminal = u.terminal || ''; d.unidad = u.etiqueta || ''; } if (u) { d.maquina = u.maquina || ''; d.terminal = u.terminal || ''; d.unidad = u.etiqueta || '';
if (u.componentes) d.componentes = u.componentes; }
else if (serieSel.value === '__OTRA__') d.unidad = 'no listada'; else if (serieSel.value === '__OTRA__') d.unidad = 'no listada';
} }
return d; return d;
@ -670,6 +692,7 @@
msg.className = 'msg'; locked = false; msg.className = 'msg'; locked = false;
if (flota) { if (flota) {
serieOtra.style.display = serieSel.value === '__OTRA__' ? '' : 'none'; serieOtra.style.display = serieSel.value === '__OTRA__' ? '' : 'none';
armar.style.display = serieSel.value === '__HBOX__' ? '' : 'none';
const u = unidadSel(); const u = unidadSel();
fichaUnidad.innerHTML = u && u.componentes ? u.nota : u fichaUnidad.innerHTML = u && u.componentes ? u.nota : u
? '<b>' + (u.maquina || '—') + '</b> · ' + (u.terminal || '—') + (u.nota ? '<br>' + u.nota : '') ? '<b>' + (u.maquina || '—') + '</b> · ' + (u.terminal || '—') + (u.nota ? '<br>' + u.nota : '')
@ -682,7 +705,7 @@
if (cfg.repetible) cargarHistorial(); if (cfg.repetible) cargarHistorial();
consultarMarca(); consultarMarca();
if (!s) { if (!s) {
estado.textContent = compuesta ? 'Elige los tres módulos' : (flota ? 'Elige la unidad' : 'Elige el número de serie'); estado.textContent = compuesta ? 'Elige los tres módulos' : (flota ? (serieSel.value === '__HBOX__' ? 'Elige las 3 piezas' : 'Elige la unidad') : 'Elige el número de serie');
aplicarCondiciones(); return; aplicarCondiciones(); return;
} }
if (esPrueba(s)) { cargarLocal(); aplicarCondiciones(); estado.textContent = 'Modo prueba (no cuenta)'; return; } if (esPrueba(s)) { cargarLocal(); aplicarCondiciones(); estado.textContent = 'Modo prueba (no cuenta)'; return; }