feat(drug-usage): 환자 뱃지 + limit 5000 + 현재고 IM_total

- 조제목록에 환자 뱃지 표시 (3명 이하: 전체, 3명 초과: 최근 3명 + 외 N명)
- API에 unique_patients, recent_patients 필드 추가
- limit 1000 → 5000 증가
- 현재고: 계산 방식 → IM_total.IM_QT_sale_debit (실제 DB 값)
This commit is contained in:
thug0bin
2026-03-11 20:25:42 +09:00
parent 6db31785fa
commit 88a23c26c1
2 changed files with 79 additions and 11 deletions

View File

@@ -371,6 +371,25 @@
color: #10b981;
font-weight: 500;
}
.patient-info {
display: inline-flex;
gap: 4px;
margin-left: 8px;
flex-wrap: wrap;
}
.patient-badge {
display: inline-block;
padding: 2px 8px;
font-size: 11px;
font-weight: 500;
background: #e0f2fe;
color: #0369a1;
border-radius: 12px;
}
.patient-badge.more {
background: #fef3c7;
color: #92400e;
}
.detail-table {
width: 100%;
border-collapse: separate;
@@ -508,11 +527,12 @@
<th class="sortable" data-sort="import_count">입고건수</th>
<th class="sortable" data-sort="rx_total_qty">조제량</th>
<th class="sortable" data-sort="import_total_qty">입고량</th>
<th class="sortable" data-sort="current_stock">현재고</th>
</tr>
</thead>
<tbody id="drugUsageBody">
<tr>
<td colspan="7" class="empty-state">
<td colspan="8" class="empty-state">
<div class="icon">📊</div>
<p>기간을 선택하고 조회 버튼을 클릭하세요</p>
</td>
@@ -584,7 +604,7 @@
btn.textContent = '조회 중...';
tbody.innerHTML = `
<tr>
<td colspan="7" class="loading-state">
<td colspan="8" class="loading-state">
<div class="loading-spinner"></div>
<p>데이터를 불러오는 중...</p>
</td>
@@ -596,7 +616,7 @@
start_date: startDate.replace(/-/g, ''),
end_date: endDate.replace(/-/g, ''),
date_type: dateType,
limit: 1000 // 전체 조회 후 클라이언트에서 페이징
limit: 5000 // 전체 조회 후 클라이언트에서 페이징
});
if (search) params.append('search', search);
@@ -621,7 +641,7 @@
} else {
tbody.innerHTML = `
<tr>
<td colspan="7" class="empty-state">
<td colspan="8" class="empty-state">
<div class="icon">⚠️</div>
<p>오류: ${escapeHtml(data.error || '알 수 없는 오류')}</p>
</td>
@@ -631,7 +651,7 @@
} catch (err) {
tbody.innerHTML = `
<tr>
<td colspan="7" class="empty-state">
<td colspan="8" class="empty-state">
<div class="icon">❌</div>
<p>조회 실패: ${escapeHtml(err.message)}</p>
</td>
@@ -700,7 +720,7 @@
if (filteredData.length === 0) {
tbody.innerHTML = `
<tr>
<td colspan="7" class="empty-state">
<td colspan="8" class="empty-state">
<div class="icon">📭</div>
<p>조회 결과가 없습니다</p>
</td>
@@ -725,9 +745,10 @@
<td class="num-cell num-secondary">${formatNumber(item.import_count)}</td>
<td class="num-cell num-highlight">${formatNumber(item.rx_total_qty)}</td>
<td class="num-cell num-secondary">${formatNumber(item.import_total_qty)}</td>
<td class="num-cell">${formatNumber(item.current_stock)}</td>
</tr>
<tr class="detail-row" id="detail-${escapeHtml(item.drug_code)}" style="display:${expandedDrugCode === item.drug_code ? 'table-row' : 'none'};">
<td colspan="7">
<td colspan="8">
<div class="detail-panel">
<div class="detail-left" id="imports-${escapeHtml(item.drug_code)}">
<h4>📦 입고목록 <span class="count"></span></h4>
@@ -846,8 +867,25 @@
const data = await res.json();
if (data.success && data.items.length > 0) {
// 환자 뱃지 생성
const uniqueCount = data.unique_patients || 0;
const recentPatients = data.recent_patients || [];
let patientBadges = '';
if (uniqueCount <= 3) {
// 3명 이하: 전체 표시
patientBadges = recentPatients.map(p =>
`<span class="patient-badge">${escapeHtml(p)}</span>`
).join('');
} else {
// 3명 초과: 최근 3명 + 외 N명
patientBadges = recentPatients.map(p =>
`<span class="patient-badge">${escapeHtml(p)}</span>`
).join('') + `<span class="patient-badge more">외 ${uniqueCount - 3}명</span>`;
}
container.innerHTML = `
<h4>💊 조제목록 <span class="count">(${data.total_count}건)</span></h4>
<h4>💊 조제목록 <span class="count">(${data.total_count}건)</span> <span class="patient-info">${patientBadges}</span></h4>
<table class="detail-table" style="table-layout:fixed;">
<colgroup>
<col style="width:65px;">