Actualizar servicios.html
This commit is contained in:
@@ -664,21 +664,29 @@ async function searchClientByPhone(phone) {
|
||||
setTimeout(() => { toast.classList.add('hidden'); }, 3500);
|
||||
}
|
||||
|
||||
function openDetail(id) {
|
||||
function openDetail(id, startInEditMode = false) {
|
||||
const s = localData.find(x => x.id === id);
|
||||
if (!s) return;
|
||||
const raw = s.raw_data;
|
||||
|
||||
// 1. IDs y Referencias
|
||||
document.getElementById('detId').value = s.id;
|
||||
document.getElementById('detRef').innerText = s.service_ref;
|
||||
document.getElementById('detCp').value = raw["Código Postal"] || "00000";
|
||||
|
||||
const companyName = raw['Compañía'] || raw['COMPAÑIA'] || raw['Procedencia'] || "Particular";
|
||||
document.getElementById('detCompany').innerText = companyName;
|
||||
document.getElementById('detName').innerText = raw["Nombre Cliente"] || raw["CLIENTE"] || "Asegurado Sin Nombre";
|
||||
|
||||
// 2. RELLENAR CAMPOS EDITABLES (NUEVO)
|
||||
// Rellenamos tanto los visuales como los que usaremos para editar
|
||||
const clientName = raw["Nombre Cliente"] || raw["CLIENTE"] || "Asegurado Sin Nombre";
|
||||
document.getElementById('detName').innerText = clientName;
|
||||
if(document.getElementById('editName')) document.getElementById('editName').value = clientName;
|
||||
|
||||
const rawPhone = raw["Teléfono"] || raw["TELEFONOS"] || raw["TELEFONO"] || "";
|
||||
const matchPhone = rawPhone.toString().match(/[6789]\d{8}/);
|
||||
const singlePhone = matchPhone ? matchPhone[0] : "";
|
||||
if(document.getElementById('editPhone')) document.getElementById('editPhone').value = singlePhone;
|
||||
|
||||
if (singlePhone) {
|
||||
document.getElementById('detPhone').innerText = singlePhone;
|
||||
@@ -692,11 +700,16 @@ async function searchClientByPhone(phone) {
|
||||
document.getElementById('detPhoneLink').classList.add('text-slate-400', 'pointer-events-none');
|
||||
}
|
||||
|
||||
document.getElementById('detAddrText').innerText = `${raw["Dirección"] || "Dirección no especificada"} ${raw["Población"] || ""}`;
|
||||
document.getElementById('detDesc').innerHTML = (raw["Descripción"] || raw["DESCRIPCION"] || "Sin notas.").replace(/\n/g, '<br>');
|
||||
const fullAddr = `${raw["Dirección"] || ""} ${raw["Población"] || ""}`.trim();
|
||||
document.getElementById('detAddrText').innerText = fullAddr || "Dirección no especificada";
|
||||
if(document.getElementById('editAddr')) document.getElementById('editAddr').value = raw["Dirección"] || "";
|
||||
|
||||
const descContent = raw["Descripción"] || raw["DESCRIPCION"] || "Sin notas.";
|
||||
document.getElementById('detDesc').innerHTML = descContent.replace(/\n/g, '<br>');
|
||||
if(document.getElementById('editDesc')) document.getElementById('editDesc').value = descContent;
|
||||
|
||||
// 3. Lógica de Paneles (Asignación/Bolsa)
|
||||
const stateInfo = s._stateInfo;
|
||||
|
||||
if (s.automation_status === 'in_progress') {
|
||||
document.getElementById('panelEnBolsa').classList.remove('hidden');
|
||||
document.getElementById('panelAsignado').classList.add('hidden');
|
||||
@@ -726,7 +739,15 @@ async function searchClientByPhone(phone) {
|
||||
}
|
||||
}
|
||||
|
||||
// 4. ACTIVAR MODO EDICIÓN SI SE PULSÓ EL LÁPIZ (NUEVO)
|
||||
document.getElementById('detailModal').classList.remove('hidden');
|
||||
|
||||
if (startInEditMode) {
|
||||
enableEditing();
|
||||
} else {
|
||||
cancelEditing(); // Resetear a modo lectura
|
||||
}
|
||||
|
||||
lucide.createIcons();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user