feat: 동물약만 보기 체크박스 필터 추가
- 검색창 옆에 '🐾 동물약만 보기' 체크박스
- animal_only 파라미터로 API 필터링
- POS_BOON='010103' 기준 필터
This commit is contained in:
parent
197ded3806
commit
d106db64f3
@ -2650,6 +2650,7 @@ def api_products():
|
|||||||
"""
|
"""
|
||||||
search = request.args.get('search', '').strip()
|
search = request.args.get('search', '').strip()
|
||||||
limit = int(request.args.get('limit', 100))
|
limit = int(request.args.get('limit', 100))
|
||||||
|
animal_only = request.args.get('animal_only', '0') == '1'
|
||||||
|
|
||||||
if not search or len(search) < 2:
|
if not search or len(search) < 2:
|
||||||
return jsonify({'success': False, 'error': '검색어는 2글자 이상 입력하세요'})
|
return jsonify({'success': False, 'error': '검색어는 2글자 이상 입력하세요'})
|
||||||
@ -2700,6 +2701,12 @@ def api_products():
|
|||||||
|
|
||||||
items = []
|
items = []
|
||||||
for row in rows:
|
for row in rows:
|
||||||
|
is_animal = row.pos_boon == '010103'
|
||||||
|
|
||||||
|
# 동물약만 필터링
|
||||||
|
if animal_only and not is_animal:
|
||||||
|
continue
|
||||||
|
|
||||||
items.append({
|
items.append({
|
||||||
'drug_code': row.drug_code or '',
|
'drug_code': row.drug_code or '',
|
||||||
'product_name': row.product_name 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,
|
'cost_price': float(row.cost_price) if row.cost_price else 0,
|
||||||
'supplier': row.supplier or '',
|
'supplier': row.supplier or '',
|
||||||
'is_set': bool(row.is_set),
|
'is_set': bool(row.is_set),
|
||||||
'is_animal_drug': row.pos_boon == '010103'
|
'is_animal_drug': is_animal
|
||||||
})
|
})
|
||||||
|
|
||||||
return jsonify({
|
return jsonify({
|
||||||
|
|||||||
@ -356,8 +356,16 @@
|
|||||||
onkeypress="if(event.key==='Enter')searchProducts()">
|
onkeypress="if(event.key==='Enter')searchProducts()">
|
||||||
<button class="search-btn" onclick="searchProducts()">🔍 검색</button>
|
<button class="search-btn" onclick="searchProducts()">🔍 검색</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="search-hint">
|
<div style="display: flex; justify-content: space-between; align-items: center; margin-top: 12px;">
|
||||||
<span>예시</span> 타이레놀, 벤포파워, 8806418067510, LB000001423
|
<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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -441,7 +449,8 @@
|
|||||||
const tbody = document.getElementById('productsTableBody');
|
const tbody = document.getElementById('productsTableBody');
|
||||||
tbody.innerHTML = '<tr><td colspan="5" class="empty-state"><p>검색 중...</p></td></tr>';
|
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(res => res.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user