fix: mismo patron store+textContent para JSON de pre-servicios

This commit is contained in:
Lizandro Guarnizo
2026-07-10 21:35:45 -05:00
parent e6860a6957
commit a47e0a843a
+11 -4
View File
@@ -218,18 +218,22 @@ async function previewAutomation() {
const psTable = document.getElementById('preview-ps-table'); const psTable = document.getElementById('preview-ps-table');
const psSection = document.getElementById('preservicios-section'); const psSection = document.getElementById('preservicios-section');
if (data.preservicios_preview && data.preservicios_preview.length > 0) { if (data.preservicios_preview && data.preservicios_preview.length > 0) {
psTable.innerHTML = data.preservicios_preview.map((ps, i) => ` psTable.innerHTML = data.preservicios_preview.map((ps, i) => {
const key = `ps-json-${i}`;
_rdaJsonStore[key] = ps.json;
return `
<div class="divide-y divide-orange-50"> <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" <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)"> onclick="togglePs('${key}', this)">
<i class="fas fa-chevron-right text-orange-300 text-xs transition-transform duration-150" id="pschev-${i}"></i> <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="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-500 w-24 text-xs">${ps.fecha}</span>
<span class="text-gray-600 flex-1 text-xs">Pac. ${ps.paciente}</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> <span class="text-xs text-orange-500">${ps.examenes} examen(es)</span>
</div> </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 id="${key}" class="hidden bg-gray-900 text-green-300 text-xs font-mono p-4 overflow-x-auto whitespace-pre"></div>
</div>`).join(''); </div>`;
}).join('');
psSection.classList.remove('hidden'); psSection.classList.remove('hidden');
} else { } else {
psSection.classList.add('hidden'); psSection.classList.add('hidden');
@@ -394,6 +398,9 @@ function togglePs(id, row) {
const div = document.getElementById(id); const div = document.getElementById(id);
const chev = row.querySelector('[id^="pschev-"]'); const chev = row.querySelector('[id^="pschev-"]');
const hidden = div.classList.contains('hidden'); const hidden = div.classList.contains('hidden');
if (hidden && _rdaJsonStore[id]) {
div.textContent = JSON.stringify(_rdaJsonStore[id], null, 2);
}
div.classList.toggle('hidden', !hidden); div.classList.toggle('hidden', !hidden);
if (chev) chev.style.transform = hidden ? 'rotate(90deg)' : ''; if (chev) chev.style.transform = hidden ? 'rotate(90deg)' : '';
} }