diff --git a/backend/templates/pmr.html b/backend/templates/pmr.html
index d96d466..cdb7407 100644
--- a/backend/templates/pmr.html
+++ b/backend/templates/pmr.html
@@ -999,7 +999,7 @@
자동감지 OFF
-
+
자동인쇄 OFF
@@ -2649,38 +2649,44 @@
// ═══════════════════════════════════════════════════════════════
// 자동인쇄 기능
// ═══════════════════════════════════════════════════════════════
- let autoPrintEnabled = localStorage.getItem('pmr_auto_print') === 'true';
+ var autoPrintEnabled = localStorage.getItem('pmr_auto_print') === 'true';
- // 초기화
- function initAutoPrint() {
- updateAutoPrintIndicator();
- }
-
- // 토글
- function toggleAutoPrint() {
- autoPrintEnabled = !autoPrintEnabled;
- localStorage.setItem('pmr_auto_print', autoPrintEnabled);
- updateAutoPrintIndicator();
- showToast(autoPrintEnabled ? '🖨️ 자동인쇄 ON' : '🖨️ 자동인쇄 OFF', autoPrintEnabled ? 'success' : 'info');
- }
+ // 간단한 토스트 알림 (전역)
+ window.showToast = function(message, type) {
+ var container = document.getElementById('paaiToastContainer');
+ if (!container) return;
+
+ var toast = document.createElement('div');
+ toast.className = 'paai-toast';
+ toast.style.background = type === 'success' ? 'linear-gradient(135deg, #10b981, #059669)' :
+ type === 'error' ? 'linear-gradient(135deg, #ef4444, #dc2626)' :
+ 'linear-gradient(135deg, #6b7280, #4b5563)';
+
+ toast.innerHTML = '
';
+ toast.onclick = function() { toast.remove(); };
+
+ container.appendChild(toast);
+ setTimeout(function() { toast.remove(); }, 3000);
+ };
// 표시 업데이트
function updateAutoPrintIndicator() {
const 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 ' + (autoPrintEnabled ? 'auto-print-on' : 'auto-print-off');
+ toggle.innerHTML = '
자동인쇄 ' + (autoPrintEnabled ? 'ON' : 'OFF');
}
}
// PAAI 결과 인쇄
async function printPaaiResult(preSerial, patientName, result) {
- if (!autoPrintEnabled) return;
+ if (!autoPrintEnabled) {
+ console.log('[AutoPrint] 비활성화됨');
+ return;
+ }
try {
+ console.log('[AutoPrint] 인쇄 요청:', preSerial);
const response = await fetch('/pmr/api/paai/print', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
@@ -2693,17 +2699,33 @@
const data = await response.json();
if (data.success) {
- console.log('[AutoPrint] 인쇄 완료:', preSerial);
+ console.log('[AutoPrint] 인쇄 완료');
+ showToast('인쇄 완료: ' + patientName, 'success');
} else {
- console.error('[AutoPrint] 인쇄 실패:', data.error);
+ console.error('[AutoPrint] 실패:', data.error);
}
} catch (err) {
console.error('[AutoPrint] 오류:', err);
}
}
- // 페이지 로드 시 초기화
- document.addEventListener('DOMContentLoaded', initAutoPrint);
+ // 즉시 실행: 토글 이벤트 바인딩
+ (function() {
+ const 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);
+ };
+ // 초기 상태 표시
+ updateAutoPrintIndicator();
+ console.log('[AutoPrint] 초기화 완료, 상태:', autoPrintEnabled);
+ }
+ })();
// 알림 소리
function playTriggerSound() {