-
-
-
-
-
- PANEL OPERATIVO
-Tablero Kanban de gestión de expedientes.
-
+
+
-
-
-
-
Sin Asignar / En Pausa
+
+
-
+
-
+
+ + PANEL OPERATIVO +
+Tablero Kanban de gestión de expedientes.
-
-
-
@@ -212,15 +232,65 @@
headers: { "Authorization": `Bearer ${localStorage.getItem("token")}` }
});
const data = await res.json();
- if (data.ok) { localData = data.services; renderLists(); }
+ if (data.ok) {
+ localData = data.services;
+ updateOperatorFilter(); // Actualiza el select de operarios
+ renderLists();
+ }
} catch (e) { console.error(e); }
}
+ function updateOperatorFilter() {
+ const opSelect = document.getElementById('opFilter');
+ const currentValue = opSelect.value;
+
+ // Extraer nombres únicos de operarios asignados en este panel
+ const uniqueOps = [...new Set(localData.map(s => s.assigned_name).filter(Boolean))].sort();
+
+ let html = '';
+ uniqueOps.forEach(op => {
+ html += ``;
+ });
+
+ opSelect.innerHTML = html;
+ // Restaurar la selección previa si sigue existiendo
+ if (html.includes(`value="${currentValue}"`)) {
+ opSelect.value = currentValue;
+ }
+ }
+
function renderLists() {
+ const searchTerm = document.getElementById('searchFilter').value.toLowerCase();
+ const selectedOp = document.getElementById('opFilter').value;
+
+ // FILTRO DE DATOS
+ const filteredData = localData.filter(s => {
+ const raw = s.raw_data;
+ const name = (raw["Nombre Cliente"] || raw["CLIENTE"] || "").toLowerCase();
+ const addr = (raw["Dirección"] || raw["DOMICILIO"] || "").toLowerCase();
+ const pop = (raw["Población"] || raw["POBLACION-PROVINCIA"] || "").toLowerCase();
+ const phone = (raw["Teléfono"] || raw["TELEFONO"] || "").toLowerCase();
+ const ref = (s.service_ref || "").toLowerCase();
+ const assigned = s.assigned_name || "";
+
+ // Buscar texto (Nombre, Ref, Dirección, Población, Teléfono)
+ const matchesSearch = searchTerm === "" ||
+ name.includes(searchTerm) ||
+ ref.includes(searchTerm) ||
+ addr.includes(searchTerm) ||
+ pop.includes(searchTerm) ||
+ phone.includes(searchTerm);
+
+ // Buscar Operario
+ const matchesOp = selectedOp === "ALL" || assigned === selectedOp;
+
+ return matchesSearch && matchesOp;
+ });
+
// Lógica inteligente de 3 columnas apoyada en el raw_data
- const unassigned = localData.filter(s => !s.assigned_name || s.raw_data.status_operativo === 'sin_asignar');
- const pending = localData.filter(s => s.assigned_name && (!s.raw_data.scheduled_date || s.raw_data.scheduled_date === "") && s.raw_data.status_operativo !== 'sin_asignar');
- const assigned = localData.filter(s => s.raw_data.scheduled_date && s.raw_data.scheduled_date !== "" && s.raw_data.status_operativo !== 'sin_asignar');
+ const unassigned = filteredData.filter(s => !s.assigned_name || s.raw_data.status_operativo === 'sin_asignar');
+ const pending = filteredData.filter(s => s.assigned_name && (!s.raw_data.scheduled_date || s.raw_data.scheduled_date === "") && s.raw_data.status_operativo !== 'sin_asignar');
+ const assigned = filteredData.filter(s => s.raw_data.scheduled_date && s.raw_data.scheduled_date !== "" && s.raw_data.status_operativo !== 'sin_asignar');
document.getElementById('unassigned-list').innerHTML = unassigned.length > 0
? unassigned.map(s => cardTemplate(s, 'rose', s.assigned_name ? 'Pausado' : 'Sin Asignar')).join('')
@@ -281,7 +351,6 @@
document.getElementById('detId').value = s.id;
document.getElementById('detRef').innerText = s.service_ref;
- // COMPAÑÍA ASEGURADORA
const companyName = raw['Compañía'] || raw['COMPAÑIA'] || raw['Procedencia'] || "Particular";
document.getElementById('detCompany').innerText = companyName;
@@ -301,7 +370,6 @@
document.getElementById('dateInput').value = raw.scheduled_date || "";
document.getElementById('timeInput').value = raw.scheduled_time || "";
- // Si no tiene estado previo guardado, mostramos "citado" por defecto o "sin asignar" si procede.
let defaultStatus = raw.status_operativo;
if (!defaultStatus) {
defaultStatus = (!s.assigned_name) ? 'sin_asignar' : 'citado';
Asignados (Falta Fecha)
+
+
-
+
+
+
+
+
+
-
-
-
-
Citados / En Curso
+
+
+
+
+
-
-
+
+
+
Sin Asignar / En Pausa
+
+
+
+
+
+
+
+ Asignados (Falta Fecha)
+
+
+
+
+
+
+
+