Actualizar automatizaciones.html
This commit is contained in:
@@ -15,14 +15,14 @@
|
||||
</head>
|
||||
<body class="bg-gray-50 text-gray-800 font-sans antialiased text-left">
|
||||
|
||||
<div class="flex h-screen overflow-hidden text-left">
|
||||
<div class="flex h-screen overflow-hidden">
|
||||
<div id="sidebar-container" class="h-full shrink-0"></div>
|
||||
|
||||
<div class="flex-1 flex flex-col overflow-hidden relative text-left">
|
||||
<div class="flex-1 flex flex-col overflow-hidden relative">
|
||||
<div id="header-container"></div>
|
||||
|
||||
<main class="flex-1 overflow-x-hidden overflow-y-auto p-4 md:p-8 fade-in text-left">
|
||||
<div class="flex justify-between items-center mb-8 text-left">
|
||||
<main class="flex-1 overflow-x-hidden overflow-y-auto p-4 md:p-8 fade-in">
|
||||
<div class="flex justify-between items-center mb-8">
|
||||
<div>
|
||||
<h2 class="text-2xl font-bold text-gray-800">Cola de Asignación Automática</h2>
|
||||
<p class="text-sm text-gray-500">Servicios buscando operario vía WhatsApp</p>
|
||||
@@ -33,23 +33,23 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="automation-list" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 text-left">
|
||||
<div class="animate-pulse bg-white h-48 rounded-xl border border-gray-200 text-left"></div>
|
||||
<div id="automation-list" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
<div class="animate-pulse bg-white h-48 rounded-xl border border-gray-200"></div>
|
||||
</div>
|
||||
|
||||
<div class="mt-12 text-left">
|
||||
<div class="mt-12">
|
||||
<h3 class="font-bold text-gray-400 uppercase text-xs tracking-widest mb-4 text-left">Automatismos Fallidos (Sin respuesta)</h3>
|
||||
<div class="bg-white rounded-xl shadow-sm border border-gray-100 overflow-hidden text-left">
|
||||
<table class="w-full text-left border-collapse text-left">
|
||||
<div class="bg-white rounded-xl shadow-sm border border-gray-100 overflow-hidden">
|
||||
<table class="w-full text-left border-collapse">
|
||||
<thead>
|
||||
<tr class="bg-gray-50 text-[10px] font-black uppercase text-gray-400 border-b text-left">
|
||||
<th class="p-4 text-left">Expediente / Cliente</th>
|
||||
<th class="p-4 text-left">Dirección y Contacto</th>
|
||||
<th class="p-4 text-left">Estado</th>
|
||||
<th class="p-4 text-right text-left">Acción</th>
|
||||
<tr class="bg-gray-50 text-[10px] font-black uppercase text-gray-400 border-b">
|
||||
<th class="p-4">Expediente / Cliente</th>
|
||||
<th class="p-4">Dirección y Contacto</th>
|
||||
<th class="p-4">Estado</th>
|
||||
<th class="p-4 text-right">Acción</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="failed-list" class="divide-y divide-gray-50 text-sm text-left"></tbody>
|
||||
<tbody id="failed-list" class="divide-y divide-gray-50 text-sm"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
@@ -58,36 +58,36 @@
|
||||
</div>
|
||||
|
||||
<div id="rescueModal" class="fixed inset-0 bg-slate-900/80 hidden z-[100] flex items-center justify-center backdrop-blur-sm p-4 text-left">
|
||||
<div class="bg-white rounded-[2rem] shadow-2xl w-full max-w-2xl flex flex-col max-h-[90vh] overflow-hidden border border-slate-200 fade-in text-left">
|
||||
<div class="px-6 py-4 border-b border-slate-100 flex justify-between items-center bg-slate-50/50 text-left">
|
||||
<h3 class="font-black text-slate-800 uppercase tracking-tight flex items-center gap-2 text-left">
|
||||
<div class="bg-white rounded-[2rem] shadow-2xl w-full max-w-2xl flex flex-col max-h-[90vh] overflow-hidden border border-slate-200 fade-in">
|
||||
<div class="px-6 py-4 border-b border-slate-100 flex justify-between items-center bg-slate-50/50">
|
||||
<h3 class="font-black text-slate-800 uppercase tracking-tight flex items-center gap-2">
|
||||
<i data-lucide="life-buoy" class="text-red-500 w-5 h-5"></i> Rescate Manual: #<span id="resRef">--</span>
|
||||
</h3>
|
||||
<button onclick="closeRescueModal()" class="text-slate-400 hover:text-red-500 transition-colors"><i data-lucide="x"></i></button>
|
||||
</div>
|
||||
<div class="p-6 overflow-y-auto space-y-6 no-scrollbar text-left">
|
||||
<div class="grid grid-cols-2 gap-4 text-left">
|
||||
<div class="bg-blue-50/50 p-4 rounded-2xl border border-blue-100 relative text-left">
|
||||
<div class="p-6 overflow-y-auto space-y-6 no-scrollbar">
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
<div class="bg-blue-50/50 p-4 rounded-2xl border border-blue-100 relative">
|
||||
<span class="text-[9px] font-black text-blue-400 uppercase absolute top-2 left-4">Asegurado</span>
|
||||
<p id="resName" class="font-black text-slate-800 uppercase mt-2 text-sm">--</p>
|
||||
<a id="resPhoneLink" href="#" class="text-emerald-600 font-black text-xs flex items-center gap-1 mt-1"><i data-lucide="phone" class="w-3 h-3"></i> <span id="resPhone">--</span></a>
|
||||
</div>
|
||||
<div class="bg-slate-50 p-4 rounded-2xl border border-slate-100 relative text-left">
|
||||
<span class="text-[9px] font-black text-slate-400 uppercase absolute top-2 left-4 text-left">Ubicación</span>
|
||||
<div class="bg-slate-50 p-4 rounded-2xl border border-slate-100 relative">
|
||||
<span class="text-[9px] font-black text-slate-400 uppercase absolute top-2 left-4">Ubicación</span>
|
||||
<p id="resAddr" class="font-bold text-slate-700 text-[11px] leading-tight mt-2 uppercase">--</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="space-y-1 text-left">
|
||||
<div class="space-y-1">
|
||||
<label class="text-[10px] font-black text-slate-400 uppercase ml-2">Avería del Expediente</label>
|
||||
<div id="resDesc" class="p-4 bg-slate-50 rounded-2xl text-xs font-medium text-slate-600 border border-slate-100">--</div>
|
||||
</div>
|
||||
<div class="space-y-3 text-left">
|
||||
<div class="space-y-3">
|
||||
<h4 class="text-[10px] font-black text-red-500 uppercase tracking-widest ml-2">Operarios contactados (Llamar para forzar)</h4>
|
||||
<div id="resWorkersList" class="space-y-2 text-left"></div>
|
||||
<div id="resWorkersList" class="space-y-2"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="p-4 bg-slate-50 border-t border-slate-100 flex gap-3 text-left">
|
||||
<button onclick="resetToManual()" class="bg-white border border-slate-200 text-slate-400 p-3 rounded-xl hover:text-amber-500 transition-colors" title="Quitar de esta lista y volver a proveedores">
|
||||
<div class="p-4 bg-slate-50 border-t border-slate-100 flex gap-3">
|
||||
<button onclick="resetToManual()" class="bg-white border border-slate-200 text-slate-400 p-3 rounded-xl hover:text-amber-500 transition-colors" title="Devolver a proveedores">
|
||||
<i data-lucide="trash-2"></i>
|
||||
</button>
|
||||
<button onclick="window.location.href='validar.html'" class="flex-1 bg-slate-900 text-white font-black py-4 rounded-2xl text-xs uppercase tracking-widest hover:bg-blue-600 transition-all flex justify-center items-center">Asignar Manualmente</button>
|
||||
@@ -95,10 +95,11 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="toast" class="fixed bottom-5 right-5 bg-slate-800 text-white px-6 py-3 rounded-lg shadow-2xl transform translate-y-20 opacity-0 transition-all duration-300 z-50 flex items-center gap-3 text-left"><span id="toastMsg">Mensaje</span></div>
|
||||
<div id="toast" class="fixed bottom-5 right-5 bg-slate-800 text-white px-6 py-3 rounded-lg shadow-2xl transform translate-y-20 opacity-0 transition-all duration-300 z-50 flex items-center gap-3"><span id="toastMsg">Mensaje</span></div>
|
||||
|
||||
<script src="js/layout.js"></script>
|
||||
<script>
|
||||
// API_URL se toma de layout.js
|
||||
let activeIntervals = [];
|
||||
let scrapedData = [];
|
||||
let currentRescueId = null;
|
||||
@@ -120,16 +121,8 @@
|
||||
activeIntervals.forEach(clearInterval);
|
||||
activeIntervals = [];
|
||||
|
||||
// FILTRO CORREGIDO: Solo mostramos lo que está en 'in_progress' o 'failed'
|
||||
// Al pasarlo a 'manual' con el botón de la papelera, desaparece de ambos filtros
|
||||
const inQueue = scrapedData.filter(s =>
|
||||
s.automation_status === 'in_progress' && s.current_worker_name !== null
|
||||
);
|
||||
|
||||
const failed = scrapedData.filter(s =>
|
||||
s.automation_status === 'failed' ||
|
||||
(s.automation_status === 'in_progress' && s.current_worker_name === null)
|
||||
);
|
||||
const inQueue = scrapedData.filter(s => s.automation_status === 'in_progress' && s.current_worker_name !== null);
|
||||
const failed = scrapedData.filter(s => s.automation_status === 'failed' || (s.automation_status === 'in_progress' && s.current_worker_name === null));
|
||||
|
||||
renderCards(inQueue);
|
||||
renderFailedTable(failed);
|
||||
@@ -174,7 +167,7 @@
|
||||
<span id="timer-${s.id}">--:--</span>
|
||||
</div>
|
||||
<div class="w-full bg-gray-100 h-1.5 rounded-full overflow-hidden">
|
||||
<div id="progress-${s.id}" class="bg-blue-500 h-full progress-bar" style="width: 100%"></div>
|
||||
<div id="progress-${s.id}" class="bg-blue-500 h-full progress-bar text-left" style="width: 100%"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -222,13 +215,13 @@
|
||||
const name = raw["Nombre Cliente"] || raw["CLIENTE"] || "Asegurado Desconocido";
|
||||
return `
|
||||
<tr onclick="openRescue(${s.id})" class="border-b border-gray-50 hover:bg-slate-50 transition-all cursor-pointer text-left">
|
||||
<td class="p-4 text-left">
|
||||
<td class="p-4">
|
||||
<div class="flex flex-col">
|
||||
<span class="font-black text-slate-700">#${s.service_ref}</span>
|
||||
<span class="text-[10px] text-blue-600 font-bold uppercase">${name}</span>
|
||||
</div>
|
||||
</td>
|
||||
<td class="p-4 text-left text-xs font-bold text-slate-600 uppercase">
|
||||
<td class="p-4 text-xs font-bold text-slate-600 uppercase">
|
||||
${raw["Dirección"] || 'S/D'} <br>
|
||||
<span class="text-[10px] text-gray-400 font-medium">${raw["Población"] || ''} ${raw["Código Postal"] || ''}</span>
|
||||
</td>
|
||||
@@ -278,18 +271,22 @@
|
||||
|
||||
function closeRescueModal() { document.getElementById('rescueModal').classList.add('hidden'); }
|
||||
|
||||
// ESTA FUNCIÓN AHORA SÍ COINCIDE CON TU BOTÓN
|
||||
async function resetToManual() {
|
||||
if(!confirm("¿Deseas devolver este servicio a Proveedores? (Desaparecerá de esta lista)")) return;
|
||||
try {
|
||||
const res = await fetch(`${API_URL}/providers/scraped/${currentRescueId}`, {
|
||||
method: 'PUT',
|
||||
headers: { "Content-Type": "application/json", "Authorization": `Bearer ${localStorage.getItem("token")}` },
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": `Bearer ${localStorage.getItem("token")}`
|
||||
},
|
||||
body: JSON.stringify({ automation_status: 'manual' })
|
||||
});
|
||||
if (res.ok) {
|
||||
closeRescueModal();
|
||||
loadAutomations(); // Esto recarga y aplica el filtro nuevo
|
||||
showToast("Devuelto al Buzón de Proveedores");
|
||||
loadAutomations();
|
||||
showToast("Enviado al Buzón de Proveedores");
|
||||
}
|
||||
} catch(e) { showToast("Error al resetear", true); }
|
||||
}
|
||||
@@ -299,7 +296,10 @@
|
||||
try {
|
||||
const res = await fetch(`${API_URL}/providers/scraped/${id}`, {
|
||||
method: 'PUT',
|
||||
headers: { "Content-Type": "application/json", "Authorization": `Bearer ${localStorage.getItem("token")}` },
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": `Bearer ${localStorage.getItem("token")}`
|
||||
},
|
||||
body: JSON.stringify({ automation_status: 'manual' })
|
||||
});
|
||||
if (res.ok) { showToast("Proceso detenido"); loadAutomations(); }
|
||||
|
||||
Reference in New Issue
Block a user