feat: 단위바코드 갯수 뱃지 + QR 바코드 우선순위 수정

화면 표시:
- 대표바코드 옆 빨간 뱃지로 단위바코드 갯수 표시 (카톡 스타일)
- APC 없어도 단위바코드 있으면 POS 판매 가능함을 표시

QR 인쇄 우선순위:
1. 대표바코드 (있으면)
2. 단위바코드 첫 번째 (대표 없으면)
3. drug_code (fallback)

쿼리 추가:
- UNIT_FIRST: 단위바코드 첫 번째 (조건 없이)
- UNIT_CNT: 단위바코드 갯수
This commit is contained in:
thug0bin
2026-03-04 16:29:23 +09:00
parent 1c2bfd473b
commit 77c667e1f6
2 changed files with 75 additions and 10 deletions

View File

@@ -402,6 +402,21 @@
color: #dc2626;
border: 1px dashed #fca5a5;
}
.unit-badge {
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 18px;
height: 18px;
padding: 0 5px;
margin-left: 4px;
background: #ef4444;
color: #fff;
font-size: 11px;
font-weight: 600;
border-radius: 9px;
vertical-align: middle;
}
.code-na {
background: #f1f5f9;
color: #94a3b8;
@@ -1053,7 +1068,9 @@
</td>
<td><span class="code code-drug">${item.drug_code}</span></td>
<td>${item.is_animal_drug
? `<div>${item.barcode ? `<span class="code code-barcode">${item.barcode}</span>` : `<span class="code code-na">없음</span>`}</div>
? `<div>${item.barcode
? `<span class="code code-barcode">${item.barcode}</span>`
: `<span class="code code-na">없음</span>`}${item.unit_barcode_count > 0 ? `<span class="unit-badge" title="단위바코드 ${item.unit_barcode_count}개">${item.unit_barcode_count}</span>` : ''}</div>
<div style="margin-top:4px;">${item.apc ? `<span class="code code-apc">${item.apc}</span>` : `<span class="code code-apc-na">APC미지정</span>`}</div>`
: (item.barcode ? `<span class="code code-barcode">${item.barcode}</span>` : `<span class="code code-na">없음</span>`)}</td>
<td>${item.location
@@ -1089,11 +1106,14 @@
const preview = document.getElementById('qrPreview');
const info = document.getElementById('qrInfo');
// QR에 들어갈 바코드 우선순위: 대표바코드 > 단위바코드 > 제품코드
const qrBarcode = selectedItem.barcode || selectedItem.unit_barcode || selectedItem.drug_code || '';
preview.innerHTML = '<p style="color:#64748b;">미리보기 로딩 중...</p>';
info.innerHTML = `
<strong>${escapeHtml(selectedItem.product_name)}</strong><br>
<span style="color:#64748b;font-size:13px;">
바코드: ${selectedItem.barcode || selectedItem.drug_code || 'N/A'}<br>
바코드: ${qrBarcode || 'N/A'}<br>
가격: ${formatPrice(selectedItem.sale_price)}
</span>
`;
@@ -1105,7 +1125,7 @@
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
drug_name: selectedItem.product_name,
barcode: selectedItem.barcode || '',
barcode: qrBarcode,
drug_code: selectedItem.drug_code || '',
sale_price: selectedItem.sale_price || 0
})
@@ -1143,12 +1163,15 @@
btn.textContent = `인쇄 중... (${i + 1}/${totalQty})`;
try {
// QR에 들어갈 바코드 우선순위: 대표바코드 > 단위바코드 > 제품코드
const qrBarcode = selectedItem.barcode || selectedItem.unit_barcode || selectedItem.drug_code || '';
const res = await fetch('/api/qr-print', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
drug_name: selectedItem.product_name,
barcode: selectedItem.barcode || '',
barcode: qrBarcode,
drug_code: selectedItem.drug_code || '',
sale_price: selectedItem.sale_price || 0
})