feat(purchase): 구매신청 검색/직접입력/사진첨부/HEIC 지원/마스터 자동등록
- 소모품 select → 검색형 드롭다운 (debounce + 키보드 탐색) - 미등록 품목 직접 입력 + 분류 선택 지원 - 사진 첨부 (base64 업로드, HEIC→JPEG 프론트 변환) - 구매 처리 시 미등록 품목 소모품 마스터 자동 등록 - item_id NULL 허용, LEFT JOIN, custom_item_name/custom_category/photo_path 컬럼 - DB 마이그레이션 필요: ALTER TABLE purchase_requests Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -129,6 +129,27 @@ const PurchaseModel = {
|
||||
return rows;
|
||||
},
|
||||
|
||||
// 미등록 품목 → 소모품 마스터 등록
|
||||
async registerToMaster(customItemName, customCategory, maker) {
|
||||
const db = await getDb();
|
||||
|
||||
// 중복 확인
|
||||
const [existing] = await db.query(
|
||||
`SELECT item_id FROM consumable_items WHERE item_name = ? AND (maker = ? OR (maker IS NULL AND ? IS NULL))`,
|
||||
[customItemName, maker || null, maker || null]
|
||||
);
|
||||
if (existing.length > 0) {
|
||||
return existing[0].item_id;
|
||||
}
|
||||
|
||||
// 신규 등록 (photo_path = NULL)
|
||||
const [result] = await db.query(
|
||||
`INSERT INTO consumable_items (item_name, maker, category, is_active) VALUES (?, ?, ?, 1)`,
|
||||
[customItemName, maker || null, customCategory || 'consumable']
|
||||
);
|
||||
return result.insertId;
|
||||
},
|
||||
|
||||
// 가격 변동 이력
|
||||
async getPriceHistory(itemId) {
|
||||
const db = await getDb();
|
||||
|
||||
Reference in New Issue
Block a user