feat: ESC/POS 영수증 프린터로 특이사항 인쇄 기능

- pos_printer.py: ESC/POS 유틸리티 (192.168.0.174:9100)
- POST /api/print/cusetc API 추가
- admin.html: 특이사항 옆 [🖨️ 인쇄] 버튼 추가
- EUC-KR 인코딩으로 한글 지원
This commit is contained in:
thug0bin
2026-03-04 11:46:46 +09:00
parent 50825c597e
commit 5074adce20
3 changed files with 275 additions and 0 deletions

View File

@@ -943,6 +943,34 @@
const editBtn = document.querySelector('#cusetc-view').parentElement.querySelector('button');
if (editBtn) editBtn.style.display = 'inline-block';
}
// 특이사항 인쇄
async function printCusetc(customerName, cusetc, phone) {
if (!confirm(`${customerName}님의 특이사항을 인쇄하시겠습니까?`)) {
return;
}
try {
const res = await fetch('/api/print/cusetc', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
customer_name: customerName,
cusetc: cusetc,
phone: phone
})
});
const data = await res.json();
if (data.success) {
alert('🖨️ ' + data.message);
} else {
alert('❌ 인쇄 실패: ' + (data.error || '알 수 없는 오류'));
}
} catch (err) {
alert('❌ 오류: ' + err.message);
}
}
function renderUserDetail(data) {
// 전역 변수에 데이터 저장
@@ -987,6 +1015,7 @@
<div style="display: flex; align-items: center; gap: 8px; margin-bottom: 6px;">
<span style="color: #d97706; font-size: 13px;">⚠️ 특이사항</span>
<button onclick="editCusetc('${data.pos_customer.cuscode}', this)" style="background: none; border: 1px solid #d97706; color: #d97706; font-size: 11px; padding: 2px 8px; border-radius: 4px; cursor: pointer;">✏️ 수정</button>
${data.pos_customer.cusetc ? `<button onclick="printCusetc('${data.pos_customer.name}', '${(data.pos_customer.cusetc || '').replace(/'/g, "\\'")}', '${user.phone || ''}')" style="background: none; border: 1px solid #6b7280; color: #6b7280; font-size: 11px; padding: 2px 8px; border-radius: 4px; cursor: pointer;">🖨️ 인쇄</button>` : ''}
</div>
<div id="cusetc-view" onclick="toggleCusetc(this)" style="color: #92400e; font-size: 14px; font-weight: 500; cursor: ${(data.pos_customer.cusetc || '').length > 30 ? 'pointer' : 'default'}; ${(data.pos_customer.cusetc || '').length > 30 ? 'max-height: 40px; overflow: hidden;' : ''}" title="${(data.pos_customer.cusetc || '').length > 30 ? '클릭하여 펼치기' : ''}">
${data.pos_customer.cusetc || '<span style="color: #9ca3af; font-weight: normal;">없음</span>'}