Actualizar servicios.html
This commit is contained in:
@@ -458,7 +458,7 @@
|
||||
|
||||
const searchTerm = document.getElementById('searchFilter').value.toLowerCase();
|
||||
const selectedOp = document.getElementById('opFilter').value;
|
||||
const weekValue = document.getElementById('weekFilter').value; // Ej: "2023-W12"
|
||||
const weekValue = document.getElementById('weekFilter').value;
|
||||
|
||||
let kpiUnassigned = 0;
|
||||
let kpiScheduled = 0;
|
||||
@@ -479,55 +479,54 @@
|
||||
const stateInfo = getServiceStateInfo(s);
|
||||
s._stateInfo = stateInfo;
|
||||
|
||||
// --- NUEVO REPARTO DE KPIs ---
|
||||
// --- CÁLCULO DE KPIs (Solo para los bloques de colores superiores) ---
|
||||
const stName = stateInfo.name.toLowerCase();
|
||||
|
||||
// 1. SIN ASIGNAR
|
||||
if (stateInfo.id === 'bolsa' || stName.includes('pendiente de asignar') || stName.includes('desasignado')) {
|
||||
kpiUnassigned++;
|
||||
}
|
||||
// 2. INCIDENCIA (Roba prioridad a Terminados en el dashboard)
|
||||
else if (stName.includes('incidencia') || stName.includes('pausa')) {
|
||||
} else if (stName.includes('incidencia') || stName.includes('pausa')) {
|
||||
kpiIncident++;
|
||||
}
|
||||
// 3. AGENDADOS (Debe tener fecha)
|
||||
else if (dateRaw !== "") {
|
||||
} else if (dateRaw !== "") {
|
||||
kpiScheduled++;
|
||||
}
|
||||
// 4. ESPERA CLIENTE / EN CURSO (Tiene operario pero no fecha)
|
||||
else if (!stateInfo.is_final && !stName.includes('terminado')) {
|
||||
} else if (!stateInfo.is_final && !stName.includes('terminado')) {
|
||||
kpiWaiting++;
|
||||
}
|
||||
|
||||
// --- FILTROS VISUALES (Buscador, Operario, Semana, Estado) ---
|
||||
// --- FILTROS DE BÚSQUEDA ---
|
||||
const matchesSearch = searchTerm === "" || name.includes(searchTerm) || ref.includes(searchTerm) || addr.includes(searchTerm) || pop.includes(searchTerm) || phone.includes(searchTerm) || comp.includes(searchTerm);
|
||||
const matchesOp = selectedOp === "ALL" || assigned === selectedOp;
|
||||
|
||||
// --- FILTRO DE SEMANAS ---
|
||||
let matchesWeek = true;
|
||||
if (weekValue !== "") {
|
||||
// Si hemos filtrado por semana, mostramos los de esa semana O los que no tengan fecha para no perderlos de vista
|
||||
if (dateRaw) {
|
||||
matchesWeek = isDateInWeekString(dateRaw, weekValue);
|
||||
} else {
|
||||
matchesWeek = false; // Si hay filtro de semana y no tiene fecha, lo ocultamos
|
||||
}
|
||||
}
|
||||
|
||||
// --- FILTRO DE ESTADOS (El culpable arreglado) ---
|
||||
let matchesStatus = false;
|
||||
// 👇 ESTA ES LA REGLA CAMBIADA 👇
|
||||
|
||||
if (activeStatusFilter === "ALL") {
|
||||
matchesStatus = true; // AHORA MUESTRA ABSOLUTAMENTE TODO SIN EXCEPCIÓN
|
||||
// MODO DIOS: Si estás en "TODOS", muestra TODO.
|
||||
matchesStatus = true;
|
||||
} else {
|
||||
// Si pinchas un filtro concreto, comprueba que el ID coincida
|
||||
matchesStatus = String(stateInfo.id) === activeStatusFilter;
|
||||
}
|
||||
|
||||
return matchesSearch && matchesOp && matchesWeek && matchesStatus;
|
||||
});
|
||||
|
||||
// Actualizamos Dashboards Superiores
|
||||
// Pintar contadores
|
||||
document.getElementById('kpi-unassigned').innerText = kpiUnassigned;
|
||||
document.getElementById('kpi-scheduled').innerText = kpiScheduled;
|
||||
document.getElementById('kpi-waiting').innerText = kpiWaiting;
|
||||
document.getElementById('kpi-incident').innerText = kpiIncident;
|
||||
|
||||
// Pintar Tarjetas
|
||||
const grid = document.getElementById('servicesGrid');
|
||||
grid.innerHTML = filteredData.length > 0
|
||||
? filteredData.map(s => buildGridCard(s)).join('')
|
||||
|
||||
Reference in New Issue
Block a user