feat: preview muestra lista de pre-servicios con JSON expandible
- Agrega preservicios_preview al endpoint /preview con el JSON generado por cada RCXC/SC - Muestra sección naranja debajo de pacientes con factura, fecha, paciente y exámenes - Clic en cada fila despliega el JSON completo que se enviará a TNS Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
c2a092c0e7
commit
648a0a1910
@@ -71,6 +71,10 @@
|
||||
<p class="text-xs font-medium text-gray-600 mb-2">Pacientes — clic para ver sus recepciones:</p>
|
||||
<div id="preview-table" class="border border-gray-100 rounded-lg overflow-hidden text-sm"></div>
|
||||
</div>
|
||||
<div id="preservicios-section" class="hidden">
|
||||
<p class="text-xs font-medium text-orange-600 mb-2 mt-2">Pre-servicios RCXC / SC — clic para ver JSON:</p>
|
||||
<div id="preview-ps-table" class="border border-orange-100 rounded-lg overflow-hidden text-sm"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -206,6 +210,26 @@ async function previewAutomation() {
|
||||
document.getElementById('cnt-preservicios').textContent = data.preservicios || 0;
|
||||
document.getElementById('preview-fecha').textContent = data.fecha;
|
||||
|
||||
const psTable = document.getElementById('preview-ps-table');
|
||||
const psSection = document.getElementById('preservicios-section');
|
||||
if (data.preservicios_preview && data.preservicios_preview.length > 0) {
|
||||
psTable.innerHTML = data.preservicios_preview.map((ps, i) => `
|
||||
<div class="divide-y divide-orange-50">
|
||||
<div class="flex items-center gap-3 px-4 py-2.5 hover:bg-orange-50 cursor-pointer select-none"
|
||||
onclick="togglePs('ps-json-${i}', this)">
|
||||
<i class="fas fa-chevron-right text-orange-300 text-xs transition-transform duration-150" id="pschev-${i}"></i>
|
||||
<span class="font-mono text-orange-700 font-medium w-32">${ps.factura}</span>
|
||||
<span class="text-gray-500 w-24 text-xs">${ps.fecha}</span>
|
||||
<span class="text-gray-600 flex-1 text-xs">Pac. ${ps.paciente}</span>
|
||||
<span class="text-xs text-orange-500">${ps.examenes} examen(es)</span>
|
||||
</div>
|
||||
<div id="ps-json-${i}" class="hidden bg-gray-900 text-green-300 text-xs font-mono p-4 overflow-x-auto whitespace-pre">${JSON.stringify(ps.json, null, 2)}</div>
|
||||
</div>`).join('');
|
||||
psSection.classList.remove('hidden');
|
||||
} else {
|
||||
psSection.classList.add('hidden');
|
||||
}
|
||||
|
||||
const table = document.getElementById('preview-table');
|
||||
if (data.pacientes === 0) {
|
||||
table.innerHTML = '<div class="p-4 text-gray-400 text-center">No hay pacientes para esta fecha</div>';
|
||||
@@ -340,6 +364,14 @@ function toggleRda(id, row) {
|
||||
if (chev) chev.style.transform = hidden ? 'rotate(90deg)' : '';
|
||||
}
|
||||
|
||||
function togglePs(id, row) {
|
||||
const div = document.getElementById(id);
|
||||
const chev = row.querySelector('[id^="pschev-"]');
|
||||
const hidden = div.classList.contains('hidden');
|
||||
div.classList.toggle('hidden', !hidden);
|
||||
if (chev) chev.style.transform = hidden ? 'rotate(90deg)' : '';
|
||||
}
|
||||
|
||||
function renderBadge(id, enviados, errores) {
|
||||
const el = document.getElementById(id);
|
||||
if (errores === 0) {
|
||||
|
||||
Reference in New Issue
Block a user