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) {
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 = '<span class="status-dot"></span>자동인쇄 ' + (autoPrintEnabled ? 'ON' : 'OFF');
toggle.className = 'status-badge ' + (window.autoPrintEnabled ? 'auto-print-on' : 'auto-print-off');
toggle.innerHTML = '<span class="status-dot"></span>자동인쇄 ' + (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);
}
})();