From b4e4a44981f5ce092257d41657beefa3ed2bc80a Mon Sep 17 00:00:00 2001 From: thug0bin Date: Thu, 5 Mar 2026 12:46:53 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=9E=90=EB=8F=99=EC=9D=B8=EC=87=84=20?= =?UTF-8?q?=EC=A0=84=EC=97=AD=20=EB=B3=80=EC=88=98/=ED=95=A8=EC=88=98=20?= =?UTF-8?q?=EC=99=84=EC=A0=84=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 모든 변수와 함수를 window. 접두사로 전역 노출: - window.autoPrintEnabled - window.showToast - window.updateAutoPrintIndicator - window.printPaaiResult 이제 토글 클릭 정상 작동! --- backend/templates/pmr.html | 40 +++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/backend/templates/pmr.html b/backend/templates/pmr.html index 423eaa4..7185f93 100644 --- a/backend/templates/pmr.html +++ b/backend/templates/pmr.html @@ -2647,11 +2647,11 @@ } // ═══════════════════════════════════════════════════════════════ - // 자동인쇄 기능 + // 자동인쇄 기능 (모두 window 전역) // ═══════════════════════════════════════════════════════════════ - var autoPrintEnabled = localStorage.getItem('pmr_auto_print') === 'true'; + window.autoPrintEnabled = localStorage.getItem('pmr_auto_print') === 'true'; - // 간단한 토스트 알림 (전역) + // 간단한 토스트 알림 window.showToast = function(message, type) { var container = document.getElementById('paaiToastContainer'); if (!container) return; @@ -2670,17 +2670,17 @@ }; // 표시 업데이트 - function updateAutoPrintIndicator() { - const toggle = document.getElementById('autoPrintToggle'); + window.updateAutoPrintIndicator = function() { + var toggle = document.getElementById('autoPrintToggle'); if (toggle) { - toggle.className = 'status-badge ' + (autoPrintEnabled ? 'auto-print-on' : 'auto-print-off'); - toggle.innerHTML = '자동인쇄 ' + (autoPrintEnabled ? 'ON' : 'OFF'); + toggle.className = 'status-badge ' + (window.autoPrintEnabled ? 'auto-print-on' : 'auto-print-off'); + toggle.innerHTML = '자동인쇄 ' + (window.autoPrintEnabled ? 'ON' : 'OFF'); } - } + }; - // PAAI 결과 인쇄 (전역) + // PAAI 결과 인쇄 window.printPaaiResult = async function(preSerial, patientName, result) { - if (!autoPrintEnabled) { + if (!window.autoPrintEnabled) { console.log('[AutoPrint] 비활성화됨'); return; } @@ -2700,30 +2700,30 @@ var data = await response.json(); if (data.success) { console.log('[AutoPrint] 인쇄 완료'); - showToast('인쇄 완료: ' + patientName, 'success'); + window.showToast('인쇄 완료: ' + patientName, 'success'); } else { console.error('[AutoPrint] 실패:', data.error); } } catch (err) { console.error('[AutoPrint] 오류:', err); } - } + }; // 즉시 실행: 토글 이벤트 바인딩 (function() { - const toggle = document.getElementById('autoPrintToggle'); + var toggle = document.getElementById('autoPrintToggle'); if (toggle) { toggle.style.cursor = 'pointer'; toggle.onclick = function() { - autoPrintEnabled = !autoPrintEnabled; - localStorage.setItem('pmr_auto_print', autoPrintEnabled ? 'true' : 'false'); - updateAutoPrintIndicator(); - showToast(autoPrintEnabled ? '자동인쇄 ON' : '자동인쇄 OFF', autoPrintEnabled ? 'success' : 'info'); - console.log('[AutoPrint] 토글:', autoPrintEnabled); + window.autoPrintEnabled = !window.autoPrintEnabled; + localStorage.setItem('pmr_auto_print', window.autoPrintEnabled ? 'true' : 'false'); + window.updateAutoPrintIndicator(); + window.showToast(window.autoPrintEnabled ? '자동인쇄 ON' : '자동인쇄 OFF', window.autoPrintEnabled ? 'success' : 'info'); + console.log('[AutoPrint] 토글:', window.autoPrintEnabled); }; // 초기 상태 표시 - updateAutoPrintIndicator(); - console.log('[AutoPrint] 초기화 완료, 상태:', autoPrintEnabled); + window.updateAutoPrintIndicator(); + console.log('[AutoPrint] 초기화 완료, 상태:', window.autoPrintEnabled); } })();