cambios importates
This commit is contained in:
+34
-2
@@ -963,7 +963,7 @@ async function cargarNotasDetalle(domId) {
|
||||
html += `<div class="p-2 rounded mb-2" style="background:#f8fafc;border:1px solid #e2e8f0">
|
||||
<div class="fw-semibold small">${esc(n.titulo||'Sin título')}</div>
|
||||
<div class="small mt-1" style="white-space:pre-line">${n.cuerpo||''}</div>
|
||||
${n.imagen_path ? `<img src="uploads/media/${esc(n.imagen_path)}" class="img-fluid rounded mt-1" style="max-height:160px;cursor:zoom-in" onclick="window.open('uploads/media/${esc(n.imagen_path)}','_blank')">` : ''}
|
||||
${_renderArchivosAdmin(n)}
|
||||
<div class="text-muted mt-1" style="font-size:.7rem">${esc(n.created_at||'')}</div>
|
||||
</div>`;
|
||||
});
|
||||
@@ -1054,7 +1054,8 @@ async function verInformeDom() {
|
||||
`<div class="mb-2 p-2 rounded" style="background:#f8fafc;border:1px solid #e2e8f0">
|
||||
<div class="fw-semibold small">${esc(n.titulo||'Sin título')}</div>
|
||||
<div class="small mt-1" style="white-space:pre-line">${n.cuerpo||''}</div>
|
||||
${n.imagen_path ? `<img src="uploads/media/${esc(n.imagen_path)}" class="img-fluid rounded mt-1" style="max-height:120px;cursor:zoom-in" onclick="window.open('uploads/media/${esc(n.imagen_path)}','_blank')">` : ''}
|
||||
${_renderArchivosAdmin(n)}
|
||||
<div class="text-muted mt-1" style="font-size:.68rem">${esc(n.enfermera_nombre||'')}${n.created_at ? ' · ' + esc(n.created_at) : ''}</div>
|
||||
</div>`
|
||||
).join('');
|
||||
} else {
|
||||
@@ -1332,6 +1333,37 @@ function exportarDomicilios() {
|
||||
|
||||
// ── Utils ──────────────────────────────────────────────────────────────────
|
||||
const esc = s => String(s||'').replace(/[<>&"]/g, c => ({'<':'<','>':'>','&':'&','"':'"'}[c]));
|
||||
|
||||
// Renderiza los archivos adjuntos de una nota (soporta nuevo campo `archivos` JSON
|
||||
// y el campo legacy `imagen_path`).
|
||||
function _renderArchivosAdmin(n) {
|
||||
let lista = [];
|
||||
if (n.archivos) {
|
||||
try { lista = typeof n.archivos === 'string' ? JSON.parse(n.archivos) : n.archivos; } catch(e) {}
|
||||
}
|
||||
if (!lista.length && n.imagen_path) {
|
||||
lista = [{ nombre: n.imagen_path, path: n.imagen_path, mime: 'image/jpeg', size: 0 }];
|
||||
}
|
||||
if (!lista.length) return '';
|
||||
|
||||
return '<div class="d-flex flex-wrap gap-2 mt-2">' + lista.map(a => {
|
||||
const src = `uploads/media/${esc(a.path)}`;
|
||||
const esImg = (a.mime || '').startsWith('image/');
|
||||
if (esImg) {
|
||||
return `<img src="${src}" class="rounded" style="height:80px;width:80px;object-fit:cover;cursor:pointer"
|
||||
onclick="window.open('${src}','_blank')" title="${esc(a.nombre)}">`;
|
||||
}
|
||||
const icon = (a.mime||'').includes('pdf') ? 'fa-file-pdf text-danger'
|
||||
: (a.mime||'').includes('word') ? 'fa-file-word text-primary'
|
||||
: (a.mime||'').includes('excel') || (a.mime||'').includes('sheet') ? 'fa-file-excel text-success'
|
||||
: 'fa-file text-secondary';
|
||||
return `<a href="${src}" target="_blank" class="border rounded p-1 text-center text-decoration-none"
|
||||
style="width:80px;height:80px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;color:inherit">
|
||||
<i class="fas ${icon} fa-lg"></i>
|
||||
<div style="font-size:.6rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:74px">${esc(a.nombre)}</div>
|
||||
</a>`;
|
||||
}).join('') + '</div>';
|
||||
}
|
||||
function formatFechaNac(fnac) {
|
||||
if (!fnac) return '—';
|
||||
const d = new Date(fnac + 'T00:00:00');
|
||||
|
||||
Reference in New Issue
Block a user