refactor: Update item division handling in supplier and customer management pages
- Added loading of item division categories to enhance filtering capabilities in supplier and customer management pages. - Updated filtering logic to dynamically use item division codes for improved item search results. - Ensured consistent handling of division codes across multiple company pages. These changes aim to improve the user experience and data management in supplier and customer processes across various companies.
This commit is contained in:
@@ -195,6 +195,10 @@ export default function SupplierManagementPage() {
|
||||
if (res.data?.success) optMap[col] = flatten(res.data.data || []);
|
||||
} catch { /* skip */ }
|
||||
}
|
||||
try {
|
||||
const res = await apiClient.get(`/table-categories/item_info/division/values`);
|
||||
if (res.data?.success) optMap["item_division"] = flatten(res.data.data || []);
|
||||
} catch { /* skip */ }
|
||||
setCategoryOptions(optMap);
|
||||
|
||||
const priceOpts: Record<string, { code: string; label: string }[]> = {};
|
||||
@@ -820,11 +824,12 @@ export default function SupplierManagementPage() {
|
||||
const allItems = res.data?.data?.data || res.data?.data?.rows || [];
|
||||
setItemTotalCount(allItems.length);
|
||||
const existingItemIds = new Set(priceItems.map((p: any) => p.item_id || p.item_number));
|
||||
const PURCHASE_CODES = ["s"]; // 구매관리 카테고리 코드
|
||||
const purchaseCode = categoryOptions["item_division"]?.find((o) => o.label === "구매관리")?.code;
|
||||
setItemSearchResults(allItems.filter((item: any) => {
|
||||
if (existingItemIds.has(item.item_number) || existingItemIds.has(item.id)) return false;
|
||||
const divCodes = (item.division || "").split(",").map((c: string) => c.trim());
|
||||
return divCodes.some((code: string) => PURCHASE_CODES.includes(code));
|
||||
if (!purchaseCode) return true;
|
||||
const div = item.division || "";
|
||||
return div.includes(purchaseCode);
|
||||
}));
|
||||
} catch { /* skip */ } finally { setItemSearchLoading(false); }
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user