From 58408c9f5c3f368f15dc6cd0f74b6ef2da008c76 Mon Sep 17 00:00:00 2001 From: thug0bin Date: Thu, 12 Mar 2026 14:19:59 +0900 Subject: [PATCH] =?UTF-8?q?fix(pmr):=20=EB=9D=BC=EB=B2=A8=20=EC=9D=B8?= =?UTF-8?q?=EC=87=84=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 가로/세로 모드 분기 추가 (orientation 파라미터) - 기본값 portrait (세로 모드, QR 라벨과 동일 방향) - 환자 이름 selector 수정 (#detailName) --- backend/pmr_api.py | 20 +++++++++++++++----- backend/templates/pmr.html | 2 +- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/backend/pmr_api.py b/backend/pmr_api.py index ad6b9ca..21f5fc3 100644 --- a/backend/pmr_api.py +++ b/backend/pmr_api.py @@ -640,6 +640,9 @@ def print_label(): - printer: 프린터 선택 (선택, 기본값 '168') - '121': QL-710W (192.168.0.121) - '168': QL-810W (192.168.0.168) + - orientation: 출력 방향 (선택, 기본값 'portrait') + - 'portrait': 세로 모드 (QR 라벨과 동일, 회전 없음) + - 'landscape': 가로 모드 (90도 회전) """ try: from brother_ql.raster import BrotherQLRaster @@ -657,6 +660,7 @@ def print_label(): unit = data.get('unit', '정') sung_code = data.get('sung_code', '') printer = data.get('printer', '168') # 기본값: QL-810W + orientation = data.get('orientation', 'portrait') # 기본값: 세로 모드 # 프린터 설정 if printer == '121': @@ -688,14 +692,19 @@ def print_label(): conversion_factor=conversion_factor ) - # 2. 이미지 90도 회전 (Brother QL이 세로 방향 기준이므로) - label_rotated = label_image.rotate(90, expand=True) + # 2. 방향 설정 (portrait: 회전 없음, landscape: 90도 회전) + if orientation == 'landscape': + # 가로 모드: 90도 회전 (기존 방식) + label_final = label_image.rotate(90, expand=True) + else: + # 세로 모드: 회전 없음 (QR 라벨과 동일) + label_final = label_image # 3. Brother QL 프린터로 전송 qlr = BrotherQLRaster(printer_model) instructions = convert( qlr=qlr, - images=[label_rotated], + images=[label_final], label='29', rotate='0', threshold=70.0, @@ -708,11 +717,12 @@ def print_label(): ) send(instructions, printer_identifier=f"tcp://{printer_ip}:9100") - logging.info(f"[SUCCESS] PMR 라벨 인쇄 성공: {med_name} → {printer_model}") + logging.info(f"[SUCCESS] PMR 라벨 인쇄 성공: {med_name} → {printer_model} ({orientation})") return jsonify({ 'success': True, 'message': f'{med_name} 라벨 인쇄 완료 ({printer_model})', - 'printer': printer_model + 'printer': printer_model, + 'orientation': orientation }) except ImportError as e: diff --git a/backend/templates/pmr.html b/backend/templates/pmr.html index 20bbd46..4071c15 100644 --- a/backend/templates/pmr.html +++ b/backend/templates/pmr.html @@ -2993,7 +2993,7 @@ return; } - const patientName = document.querySelector('.patient-info h2')?.textContent?.trim() || ''; + const patientName = document.getElementById('detailName')?.textContent?.trim() || ''; let printedCount = 0; let failedCount = 0;