From f82927643113ea12fb4d8b697dec1659b00e227c Mon Sep 17 00:00:00 2001 From: thug0bin Date: Wed, 4 Mar 2026 20:48:47 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=9D=B8=EC=87=84=EC=97=90=20=ED=88=AC?= =?UTF-8?q?=EC=95=BD=EC=A3=BC=EA=B8=B0/=EB=B3=91=EC=9A=A9=EC=95=BD=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20+=20=EC=9D=B8=EC=87=84=20=ED=94=BC?= =?UTF-8?q?=EB=93=9C=EB=B0=B1=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 인쇄 API: component_guide JOIN 추가 - 영수증에 ★ 투약 주기 ★ / ★ 함께 투약 권장 ★ 섹션 추가 - 인쇄 버튼: 로딩 중 → 인쇄 완료! 피드백 - 이모지 대신 ★ 사용 (프린터 호환) --- backend/app.py | 50 +++++++++++++++++++++------ backend/templates/admin_products.html | 16 +++++++-- 2 files changed, 53 insertions(+), 13 deletions(-) diff --git a/backend/app.py b/backend/app.py index 392e5fa..316c7b0 100644 --- a/backend/app.py +++ b/backend/app.py @@ -6446,17 +6446,24 @@ def api_animal_drug_info_print(): with pg_engine.connect() as conn: result = conn.execute(text(""" SELECT - product_name, - company_name, - main_ingredient, - efficacy_effect, - dosage_instructions, - precautions, - weight_min_kg, - weight_max_kg, - pet_size_label - FROM apc - WHERE apc = :apc + a.product_name, + a.company_name, + a.main_ingredient, + a.efficacy_effect, + a.dosage_instructions, + a.precautions, + a.weight_min_kg, + a.weight_max_kg, + a.pet_size_label, + a.component_code, + g.component_name_ko, + g.dosing_interval_adult, + g.dosing_interval_high_risk, + g.dosing_interval_puppy, + g.companion_drugs + FROM apc a + LEFT JOIN component_guide g ON a.component_code = g.component_code + WHERE a.apc = :apc LIMIT 1 """), {'apc': apc}) row = result.fetchone() @@ -6591,6 +6598,27 @@ def api_animal_drug_info_print(): for line in wrap_text(para.strip(), 44): message += f" {line}\n" + # 투약 주기 (component_guide JOIN) + if row.dosing_interval_adult: + message += f""" +{THIN} +★ 투약 주기 ★ +""" + message += f" 일반: {row.dosing_interval_adult}\n" + if row.dosing_interval_high_risk: + message += f" 고위험: {row.dosing_interval_high_risk}\n" + if row.dosing_interval_puppy: + message += f" 새끼: {row.dosing_interval_puppy}\n" + + # 병용약 권장 (component_guide JOIN) + if row.companion_drugs: + message += f""" +{THIN} +★ 함께 투약 권장 ★ +""" + for line in wrap_text(row.companion_drugs, 44): + message += f" {line}\n" + message += f""" {LINE} 청 춘 약 국 diff --git a/backend/templates/admin_products.html b/backend/templates/admin_products.html index 3660d5a..0ccada7 100644 --- a/backend/templates/admin_products.html +++ b/backend/templates/admin_products.html @@ -1191,6 +1191,11 @@ } async function printAnimalDrugSheet(apc) { + const btn = event.target; + const originalText = btn.innerHTML; + btn.disabled = true; + btn.innerHTML = '인쇄 중...'; + try { const res = await fetch('/api/animal-drug-info/print', { method: 'POST', @@ -1200,13 +1205,20 @@ const data = await res.json(); if (data.success) { - alert('인쇄 완료!'); - document.getElementById('animalDrugModal').remove(); + btn.innerHTML = '✓ 인쇄 완료!'; + btn.style.background = '#059669'; + setTimeout(() => { + document.getElementById('animalDrugModal')?.remove(); + }, 1500); } else { alert(`인쇄 실패: ${data.error}`); + btn.innerHTML = originalText; + btn.disabled = false; } } catch (err) { alert(`인쇄 오류: ${err.message}`); + btn.innerHTML = originalText; + btn.disabled = false; } }