fix: mismo patron store+textContent para JSON de pre-servicios
This commit is contained in:
@@ -218,18 +218,22 @@ async function previewAutomation() {
|
||||
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) => `
|
||||
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="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>
|
||||
<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('');
|
||||
<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('');
|
||||
psSection.classList.remove('hidden');
|
||||
} else {
|
||||
psSection.classList.add('hidden');
|
||||
@@ -394,6 +398,9 @@ function togglePs(id, row) {
|
||||
const div = document.getElementById(id);
|
||||
const chev = row.querySelector('[id^="pschev-"]');
|
||||
const hidden = div.classList.contains('hidden');
|
||||
if (hidden && _rdaJsonStore[id]) {
|
||||
div.textContent = JSON.stringify(_rdaJsonStore[id], null, 2);
|
||||
}
|
||||
div.classList.toggle('hidden', !hidden);
|
||||
if (chev) chev.style.transform = hidden ? 'rotate(90deg)' : '';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user