feat: 인쇄에 투약주기/병용약 추가 + 인쇄 피드백 개선
- 인쇄 API: component_guide JOIN 추가 - 영수증에 ★ 투약 주기 ★ / ★ 함께 투약 권장 ★ 섹션 추가 - 인쇄 버튼: 로딩 중 → 인쇄 완료! 피드백 - 이모지 대신 ★ 사용 (프린터 호환)
This commit is contained in:
parent
9ff25dcbce
commit
f829276431
@ -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}
|
||||
청 춘 약 국
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user