Actualizar proveedores.html

This commit is contained in:
2026-02-16 23:42:11 +00:00
parent 7f443e164d
commit c73346fe3f

View File

@@ -357,31 +357,53 @@
let isLocked = false; let isLocked = false;
let lockedMsg = ''; let lockedMsg = '';
// LÓGICA DE ACTUALIZACIÓN DE ESTADO // LÓGICA DE ACTUALIZACIÓN DE ESTADO ROBUSTA
// Si el servicio se marca como 'imported' o tiene 'assigned_to', significa que ya no está disponible en el buzón const autoStatus = (svc.automation_status || '').toLowerCase();
const sysStatus = (svc.status || '').toLowerCase();
const linkedStatus = (raw['estado'] || raw['status'] || '').toLowerCase();
if (!isArchived) { if (!isArchived) {
if (svc.automation_status === 'in_progress') { // 1. EN BOLSA / EN COLA
bgClass = 'bg-amber-50/40 border-amber-200'; if (autoStatus.includes('bolsa') || autoStatus === 'in_progress' || sysStatus.includes('bolsa') || linkedStatus.includes('bolsa')) {
bgClass = 'bg-orange-50/40 border-orange-200 hover:border-orange-400';
isLocked = true; isLocked = true;
lockedMsg = 'Enviado por WhatsApp. Esperando aceptación.'; lockedMsg = 'Este servicio está en la BOLSA buscando operario.';
badgeEstado = ` badgeEstado = `
<div class="flex flex-col items-end gap-1"> <div class="flex flex-col items-end gap-1">
<span class="bg-amber-100 text-amber-700 px-3 py-1 rounded-full text-[10px] font-black uppercase flex items-center gap-1.5 border border-amber-200 shadow-sm"> <span class="bg-orange-100 text-orange-700 px-3 py-1 rounded-full text-[10px] font-black uppercase flex items-center gap-1.5 border border-orange-200 shadow-sm">
<span class="w-1.5 h-1.5 bg-amber-500 rounded-full pulse-slow"></span> En Cola / Bolsa <span class="w-1.5 h-1.5 bg-orange-500 rounded-full pulse-slow"></span> En Bolsa
</span> </span>
<span class="text-[9px] font-bold text-slate-500 max-w-[120px] truncate text-right">Sin Asignar</span>
</div>`; </div>`;
} else if (svc.status === 'imported' || raw['assigned_to']) { }
bgClass = 'bg-emerald-50/40 border-emerald-200'; // 2. ASIGNADO A UN OPERARIO
else if (raw['assigned_to'] || (sysStatus === 'imported' && opName)) {
bgClass = 'bg-emerald-50/40 border-emerald-200 hover:border-emerald-400';
isLocked = true; isLocked = true;
lockedMsg = 'Servicio AUTO-ASIGNADO o traspasado.'; lockedMsg = 'Servicio ASIGNADO. Ve al Panel Operativo para gestionarlo.';
badgeEstado = ` badgeEstado = `
<div class="flex flex-col items-end gap-1"> <div class="flex flex-col items-end gap-1">
<span class="bg-emerald-100 text-emerald-700 px-3 py-1 rounded-full text-[10px] font-black uppercase flex items-center gap-1.5 border border-emerald-200 shadow-sm"> <span class="bg-emerald-100 text-emerald-700 px-3 py-1 rounded-full text-[10px] font-black uppercase flex items-center gap-1.5 border border-emerald-200 shadow-sm">
<i data-lucide="check-circle-2" class="w-3 h-3"></i> Asignado <i data-lucide="check-circle-2" class="w-3 h-3"></i> Asignado
</span> </span>
<span class="text-[9px] font-bold text-slate-500 max-w-[120px] truncate text-right">${opName || 'Gestionado'}</span> <span class="text-[9px] font-bold text-slate-500 max-w-[120px] truncate text-right">${opName || 'Operario'}</span>
</div>`; </div>`;
} else { }
// 3. TRASPASADO AL PANEL, PERO SIN BOLSA NI OPERARIO (Pausa/Manual)
else if (sysStatus === 'imported') {
bgClass = 'bg-blue-50/40 border-blue-200 hover:border-blue-400';
isLocked = true;
lockedMsg = 'Este servicio ya se traspasó al Panel Operativo.';
badgeEstado = `
<div class="flex flex-col items-end gap-1">
<span class="bg-blue-100 text-blue-700 px-3 py-1 rounded-full text-[10px] font-black uppercase flex items-center gap-1.5 border border-blue-200 shadow-sm">
<i data-lucide="clipboard-list" class="w-3 h-3"></i> En Panel
</span>
<span class="text-[9px] font-bold text-slate-500 max-w-[120px] truncate text-right">Esperando acción</span>
</div>`;
}
// 4. NUEVO EN EL BUZÓN (Gris)
else {
bgClass = 'bg-white border-slate-200'; bgClass = 'bg-white border-slate-200';
badgeEstado = ` badgeEstado = `
<div class="flex flex-col items-end gap-1"> <div class="flex flex-col items-end gap-1">
@@ -438,7 +460,6 @@
lucide.createIcons(); lucide.createIcons();
} }
// --- EL RESTO DE FUNCIONES (openEditor, saveDraft, sendToQueue, etc.) se mantienen IGUAL ---
async function openEditor(id) { async function openEditor(id) {
const svc = scrapedData.find(s => s.id === id); const svc = scrapedData.find(s => s.id === id);
if(!svc) return; if(!svc) return;