fix: 자동인쇄 전역 변수/함수 완전 수정

모든 변수와 함수를 window. 접두사로 전역 노출:
- window.autoPrintEnabled
- window.showToast
- window.updateAutoPrintIndicator
- window.printPaaiResult

이제 토글 클릭 정상 작동!
This commit is contained in:
thug0bin 2026-03-05 12:46:53 +09:00
parent e33204f265
commit b4e4a44981

View File

@ -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) { window.showToast = function(message, type) {
var container = document.getElementById('paaiToastContainer'); var container = document.getElementById('paaiToastContainer');
if (!container) return; if (!container) return;
@ -2670,17 +2670,17 @@
}; };
// 표시 업데이트 // 표시 업데이트
function updateAutoPrintIndicator() { window.updateAutoPrintIndicator = function() {
const toggle = document.getElementById('autoPrintToggle'); var toggle = document.getElementById('autoPrintToggle');
if (toggle) { if (toggle) {
toggle.className = 'status-badge ' + (autoPrintEnabled ? 'auto-print-on' : 'auto-print-off'); toggle.className = 'status-badge ' + (window.autoPrintEnabled ? 'auto-print-on' : 'auto-print-off');
toggle.innerHTML = '<span class="status-dot"></span>자동인쇄 ' + (autoPrintEnabled ? 'ON' : 'OFF'); toggle.innerHTML = '<span class="status-dot"></span>자동인쇄 ' + (window.autoPrintEnabled ? 'ON' : 'OFF');
} }
} };
// PAAI 결과 인쇄 (전역) // PAAI 결과 인쇄
window.printPaaiResult = async function(preSerial, patientName, result) { window.printPaaiResult = async function(preSerial, patientName, result) {
if (!autoPrintEnabled) { if (!window.autoPrintEnabled) {
console.log('[AutoPrint] 비활성화됨'); console.log('[AutoPrint] 비활성화됨');
return; return;
} }
@ -2700,30 +2700,30 @@
var data = await response.json(); var data = await response.json();
if (data.success) { if (data.success) {
console.log('[AutoPrint] 인쇄 완료'); console.log('[AutoPrint] 인쇄 완료');
showToast('인쇄 완료: ' + patientName, 'success'); window.showToast('인쇄 완료: ' + patientName, 'success');
} else { } else {
console.error('[AutoPrint] 실패:', data.error); console.error('[AutoPrint] 실패:', data.error);
} }
} catch (err) { } catch (err) {
console.error('[AutoPrint] 오류:', err); console.error('[AutoPrint] 오류:', err);
} }
} };
// 즉시 실행: 토글 이벤트 바인딩 // 즉시 실행: 토글 이벤트 바인딩
(function() { (function() {
const toggle = document.getElementById('autoPrintToggle'); var toggle = document.getElementById('autoPrintToggle');
if (toggle) { if (toggle) {
toggle.style.cursor = 'pointer'; toggle.style.cursor = 'pointer';
toggle.onclick = function() { toggle.onclick = function() {
autoPrintEnabled = !autoPrintEnabled; window.autoPrintEnabled = !window.autoPrintEnabled;
localStorage.setItem('pmr_auto_print', autoPrintEnabled ? 'true' : 'false'); localStorage.setItem('pmr_auto_print', window.autoPrintEnabled ? 'true' : 'false');
updateAutoPrintIndicator(); window.updateAutoPrintIndicator();
showToast(autoPrintEnabled ? '자동인쇄 ON' : '자동인쇄 OFF', autoPrintEnabled ? 'success' : 'info'); window.showToast(window.autoPrintEnabled ? '자동인쇄 ON' : '자동인쇄 OFF', window.autoPrintEnabled ? 'success' : 'info');
console.log('[AutoPrint] 토글:', autoPrintEnabled); console.log('[AutoPrint] 토글:', window.autoPrintEnabled);
}; };
// 초기 상태 표시 // 초기 상태 표시
updateAutoPrintIndicator(); window.updateAutoPrintIndicator();
console.log('[AutoPrint] 초기화 완료, 상태:', autoPrintEnabled); console.log('[AutoPrint] 초기화 완료, 상태:', window.autoPrintEnabled);
} }
})(); })();