feat: 동물약만 보기 체크박스 필터 추가

- 검색창 옆에 '🐾 동물약만 보기' 체크박스
- animal_only 파라미터로 API 필터링
- POS_BOON='010103' 기준 필터
This commit is contained in:
thug0bin 2026-02-27 17:58:08 +09:00
parent 197ded3806
commit d106db64f3
2 changed files with 20 additions and 4 deletions

View File

@ -2650,6 +2650,7 @@ def api_products():
"""
search = request.args.get('search', '').strip()
limit = int(request.args.get('limit', 100))
animal_only = request.args.get('animal_only', '0') == '1'
if not search or len(search) < 2:
return jsonify({'success': False, 'error': '검색어는 2글자 이상 입력하세요'})
@ -2700,6 +2701,12 @@ def api_products():
items = []
for row in rows:
is_animal = row.pos_boon == '010103'
# 동물약만 필터링
if animal_only and not is_animal:
continue
items.append({
'drug_code': row.drug_code or '',
'product_name': row.product_name or '',
@ -2708,7 +2715,7 @@ def api_products():
'cost_price': float(row.cost_price) if row.cost_price else 0,
'supplier': row.supplier or '',
'is_set': bool(row.is_set),
'is_animal_drug': row.pos_boon == '010103'
'is_animal_drug': is_animal
})
return jsonify({

View File

@ -356,8 +356,16 @@
onkeypress="if(event.key==='Enter')searchProducts()">
<button class="search-btn" onclick="searchProducts()">🔍 검색</button>
</div>
<div class="search-hint">
<span>예시</span> 타이레놀, 벤포파워, 8806418067510, LB000001423
<div style="display: flex; justify-content: space-between; align-items: center; margin-top: 12px;">
<div class="search-hint">
<span>예시</span> 타이레놀, 벤포파워, 8806418067510, LB000001423
</div>
<label style="display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; color: #475569;">
<input type="checkbox" id="animalOnly" style="width: 18px; height: 18px; accent-color: #10b981; cursor: pointer;">
<span style="display: flex; align-items: center; gap: 4px;">
🐾 <strong style="color: #10b981;">동물약만</strong> 보기
</span>
</label>
</div>
</div>
@ -441,7 +449,8 @@
const tbody = document.getElementById('productsTableBody');
tbody.innerHTML = '<tr><td colspan="5" class="empty-state"><p>검색 중...</p></td></tr>';
fetch(`/api/products?search=${encodeURIComponent(search)}`)
const animalOnly = document.getElementById('animalOnly').checked;
fetch(`/api/products?search=${encodeURIComponent(search)}${animalOnly ? '&animal_only=1' : ''}`)
.then(res => res.json())
.then(data => {
if (data.success) {