Actualizar aceptar.html

This commit is contained in:
2026-03-15 18:03:25 +00:00
parent 35caef0cd0
commit a251ad50d5

View File

@@ -51,11 +51,11 @@
<div class="flex items-start gap-3">
<div class="bg-rose-50 p-2.5 rounded-xl text-rose-500 shrink-0">
<i data-lucide="alert-circle" class="w-5 h-5"></i>
<i data-lucide="sparkles" class="w-5 h-5"></i>
</div>
<div>
<p class="text-[10px] font-black text-slate-400 uppercase tracking-widest mb-0.5">Resumen del Siniestro</p>
<p id="desc" class="text-sm text-slate-700 leading-snug font-bold uppercase">--</p>
<p class="text-[10px] font-black text-slate-400 uppercase tracking-widest mb-0.5">Resumen Inteligente</p>
<p id="desc" class="text-sm text-slate-700 leading-snug font-medium">--</p>
</div>
</div>
</div>
@@ -102,29 +102,40 @@
});
// ==========================================
// LÓGICA DE RESUMEN INTELIGENTE (IA JS)
// 🧠 LÓGICA DE RESUMEN INTELIGENTE TIPO "IA"
// ==========================================
function smartSummarize(text) {
if (!text || text.trim() === "") return "REVISAR AVERÍA";
if (!text || text.trim() === "") return "Se requiere asistencia técnica en el domicilio.";
// 1. Quitamos saltos de línea y forzamos minúsculas
let clean = text.replace(/(\r\n|\n|\r)/gm, " ").toLowerCase();
// 1. Limpiamos basura, dobles espacios y saltos de línea
let clean = text.replace(/(\r\n|\n|\r)/gm, " ").replace(/\s+/g, " ").trim();
// 2. Cortamos si detectamos que empiezan las notas administrativas
const cutIndex = clean.search(/(\bmo\b|\bm\.o\b|\bmaterial\b|\basegurado\b|\btelefono\b|\burgente\b|\bobservaciones\b)/i);
if (cutIndex > 5) clean = clean.substring(0, cutIndex);
// 3. Separamos por palabras y filtramos las palabras vacías/comunes
const stopWords = ['el', 'la', 'los', 'las', 'un', 'una', 'unos', 'unas', 'de', 'del', 'a', 'ante', 'con', 'para', 'por', 'y', 'e', 'o', 'u', 'en', 'que', 'su', 'se', 'ha', 'al', 'es'];
let words = clean.replace(/[^\w\sáéíóúüñ]/gi, '').split(/\s+/); // Quitamos comas y puntos
let keywords = words.filter(w => w.length > 2 && !stopWords.includes(w));
// 4. Tomamos solo las primeras 5 palabras clave
if (keywords.length > 5) {
return keywords.slice(0, 5).join(' ') + "...";
// 2. Cortamos el texto justo antes de que empiecen las notas administrativas (teléfonos, pólizas, asegurados)
const cutPattern = /\b(mo\b|m\.o\b|material:|asegurado:|telefono:|teléfono:|urgente:|observaciones:|franquicia:|poliza:|tramitador:)/i;
const cutIndex = clean.search(cutPattern);
if (cutIndex > 10) {
clean = clean.substring(0, cutIndex).trim();
}
return keywords.join(' ') || "REVISAR AVERÍA";
// 3. Le damos formato Humano (Primera letra mayúscula, el resto normal para que sea legible)
clean = clean.charAt(0).toUpperCase() + clean.slice(1).toLowerCase();
// 4. Extracción de frases clave: Separamos por puntos y cogemos máximo 2 frases
let sentences = clean.match(/[^.!?]+[.!?]+/g);
if (!sentences) {
// Si no había puntos, cortamos elegantemente a los 130 caracteres sin partir palabras
if (clean.length > 130) {
let cutText = clean.substring(0, 130);
return cutText.substring(0, cutText.lastIndexOf(" ")) + "...";
}
return clean + (clean.endsWith('.') ? '' : '.');
}
if (sentences.length >= 2) {
return sentences.slice(0, 2).join(' ').trim() + " ...";
}
return sentences[0].trim();
}
async function loadAssignmentData() {
@@ -139,18 +150,23 @@
document.getElementById('guild').innerText = raw["Gremio"] || "Servicio General";
document.getElementById('ref').innerText = raw["Expediente"] || "Sin Ref";
// 2. PROCESADO DE DIRECCIÓN (Solo calle, corta antes del número)
// 2. PROCESADO DE DIRECCIÓN ESTRICTO (Corta en el primer número)
const fullAddress = raw["Dirección"] || raw["DOMICILIO"] || "";
let streetOnly = fullAddress;
// Busca el primer dígito y corta el string justo antes
const streetMatch = fullAddress.match(/^([^0-9]+)/);
if (streetMatch && streetMatch[1]) {
streetOnly = streetMatch[1].replace(/[,/-]+$/, '').trim(); // Quita comas finales
// Buscamos dónde empieza el número de la calle
const numberIndex = fullAddress.search(/\d/);
if (numberIndex > 3) { // Si el número está después de la 3ra letra (ej: Calle 2)
streetOnly = fullAddress.substring(0, numberIndex).replace(/[,/-]+$/, '').trim();
} else if (numberIndex === -1) {
// Si es una dirección rara sin números, la dejamos tal cual pero la limpiamos
streetOnly = fullAddress.trim();
}
if(!streetOnly) streetOnly = "Dirección Oculta";
// Si nos hemos cargado la calle por error, devolvemos un texto seguro
if(!streetOnly || streetOnly.length < 3) streetOnly = "Calle Oculta";
const city = raw["Población"] || "Ciudad sin especificar";
const city = raw["Población"] || "Localidad sin especificar";
const cp = raw["Código Postal"] || "---";
document.getElementById('location-street').innerText = streetOnly;