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 || []);
|
if (res.data?.success) optMap[col] = flatten(res.data.data || []);
|
||||||
} catch { /* skip */ }
|
} 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);
|
setCategoryOptions(optMap);
|
||||||
|
|
||||||
const priceOpts: Record<string, { code: string; label: string }[]> = {};
|
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 || [];
|
const allItems = res.data?.data?.data || res.data?.data?.rows || [];
|
||||||
setItemTotalCount(allItems.length);
|
setItemTotalCount(allItems.length);
|
||||||
const existingItemIds = new Set(priceItems.map((p: any) => p.item_id || p.item_number));
|
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) => {
|
setItemSearchResults(allItems.filter((item: any) => {
|
||||||
if (existingItemIds.has(item.item_number) || existingItemIds.has(item.id)) return false;
|
if (existingItemIds.has(item.item_number) || existingItemIds.has(item.id)) return false;
|
||||||
const divCodes = (item.division || "").split(",").map((c: string) => c.trim());
|
if (!purchaseCode) return true;
|
||||||
return divCodes.some((code: string) => PURCHASE_CODES.includes(code));
|
const div = item.division || "";
|
||||||
|
return div.includes(purchaseCode);
|
||||||
}));
|
}));
|
||||||
} catch { /* skip */ } finally { setItemSearchLoading(false); }
|
} catch { /* skip */ } finally { setItemSearchLoading(false); }
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -195,6 +195,10 @@ export default function CustomerManagementPage() {
|
|||||||
if (res.data?.success) optMap[col] = flatten(res.data.data || []);
|
if (res.data?.success) optMap[col] = flatten(res.data.data || []);
|
||||||
} catch { /* skip */ }
|
} 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);
|
setCategoryOptions(optMap);
|
||||||
|
|
||||||
const priceOpts: Record<string, { code: string; label: string }[]> = {};
|
const priceOpts: Record<string, { code: string; label: string }[]> = {};
|
||||||
@@ -811,7 +815,7 @@ export default function CustomerManagementPage() {
|
|||||||
const searchItems = async () => {
|
const searchItems = async () => {
|
||||||
setItemSearchLoading(true);
|
setItemSearchLoading(true);
|
||||||
try {
|
try {
|
||||||
const salesCode = categoryOptions["division"]?.find((o) => o.label === "영업관리")?.code;
|
const salesCode = categoryOptions["item_division"]?.find((o) => o.label === "영업관리")?.code;
|
||||||
const filters: any[] = salesCode
|
const filters: any[] = salesCode
|
||||||
? [{ columnName: "division", operator: "contains", value: salesCode }]
|
? [{ columnName: "division", operator: "contains", value: salesCode }]
|
||||||
: [];
|
: [];
|
||||||
|
|||||||
@@ -195,6 +195,10 @@ export default function SupplierManagementPage() {
|
|||||||
if (res.data?.success) optMap[col] = flatten(res.data.data || []);
|
if (res.data?.success) optMap[col] = flatten(res.data.data || []);
|
||||||
} catch { /* skip */ }
|
} 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);
|
setCategoryOptions(optMap);
|
||||||
|
|
||||||
const priceOpts: Record<string, { code: string; label: string }[]> = {};
|
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 || [];
|
const allItems = res.data?.data?.data || res.data?.data?.rows || [];
|
||||||
setItemTotalCount(allItems.length);
|
setItemTotalCount(allItems.length);
|
||||||
const existingItemIds = new Set(priceItems.map((p: any) => p.item_id || p.item_number));
|
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) => {
|
setItemSearchResults(allItems.filter((item: any) => {
|
||||||
if (existingItemIds.has(item.item_number) || existingItemIds.has(item.id)) return false;
|
if (existingItemIds.has(item.item_number) || existingItemIds.has(item.id)) return false;
|
||||||
const divCodes = (item.division || "").split(",").map((c: string) => c.trim());
|
if (!purchaseCode) return true;
|
||||||
return divCodes.some((code: string) => PURCHASE_CODES.includes(code));
|
const div = item.division || "";
|
||||||
|
return div.includes(purchaseCode);
|
||||||
}));
|
}));
|
||||||
} catch { /* skip */ } finally { setItemSearchLoading(false); }
|
} catch { /* skip */ } finally { setItemSearchLoading(false); }
|
||||||
}, [itemSearchKeyword, priceItems]);
|
}, [itemSearchKeyword, priceItems]);
|
||||||
|
|||||||
@@ -195,6 +195,10 @@ export default function CustomerManagementPage() {
|
|||||||
if (res.data?.success) optMap[col] = flatten(res.data.data || []);
|
if (res.data?.success) optMap[col] = flatten(res.data.data || []);
|
||||||
} catch { /* skip */ }
|
} 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);
|
setCategoryOptions(optMap);
|
||||||
|
|
||||||
const priceOpts: Record<string, { code: string; label: string }[]> = {};
|
const priceOpts: Record<string, { code: string; label: string }[]> = {};
|
||||||
@@ -811,7 +815,7 @@ export default function CustomerManagementPage() {
|
|||||||
const searchItems = useCallback(async () => {
|
const searchItems = useCallback(async () => {
|
||||||
setItemSearchLoading(true);
|
setItemSearchLoading(true);
|
||||||
try {
|
try {
|
||||||
const salesCode = categoryOptions["division"]?.find((o) => o.label === "영업관리")?.code;
|
const salesCode = categoryOptions["item_division"]?.find((o) => o.label === "영업관리")?.code;
|
||||||
const filters: any[] = salesCode
|
const filters: any[] = salesCode
|
||||||
? [{ columnName: "division", operator: "contains", value: salesCode }]
|
? [{ columnName: "division", operator: "contains", value: salesCode }]
|
||||||
: [];
|
: [];
|
||||||
|
|||||||
@@ -195,6 +195,10 @@ export default function SupplierManagementPage() {
|
|||||||
if (res.data?.success) optMap[col] = flatten(res.data.data || []);
|
if (res.data?.success) optMap[col] = flatten(res.data.data || []);
|
||||||
} catch { /* skip */ }
|
} 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);
|
setCategoryOptions(optMap);
|
||||||
|
|
||||||
const priceOpts: Record<string, { code: string; label: string }[]> = {};
|
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 || [];
|
const allItems = res.data?.data?.data || res.data?.data?.rows || [];
|
||||||
setItemTotalCount(allItems.length);
|
setItemTotalCount(allItems.length);
|
||||||
const existingItemIds = new Set(priceItems.map((p: any) => p.item_id || p.item_number));
|
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) => {
|
setItemSearchResults(allItems.filter((item: any) => {
|
||||||
if (existingItemIds.has(item.item_number) || existingItemIds.has(item.id)) return false;
|
if (existingItemIds.has(item.item_number) || existingItemIds.has(item.id)) return false;
|
||||||
const divCodes = (item.division || "").split(",").map((c: string) => c.trim());
|
if (!purchaseCode) return true;
|
||||||
return divCodes.some((code: string) => PURCHASE_CODES.includes(code));
|
const div = item.division || "";
|
||||||
|
return div.includes(purchaseCode);
|
||||||
}));
|
}));
|
||||||
} catch { /* skip */ } finally { setItemSearchLoading(false); }
|
} catch { /* skip */ } finally { setItemSearchLoading(false); }
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -195,6 +195,10 @@ export default function CustomerManagementPage() {
|
|||||||
if (res.data?.success) optMap[col] = flatten(res.data.data || []);
|
if (res.data?.success) optMap[col] = flatten(res.data.data || []);
|
||||||
} catch { /* skip */ }
|
} 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);
|
setCategoryOptions(optMap);
|
||||||
|
|
||||||
const priceOpts: Record<string, { code: string; label: string }[]> = {};
|
const priceOpts: Record<string, { code: string; label: string }[]> = {};
|
||||||
@@ -811,7 +815,7 @@ export default function CustomerManagementPage() {
|
|||||||
const searchItems = async () => {
|
const searchItems = async () => {
|
||||||
setItemSearchLoading(true);
|
setItemSearchLoading(true);
|
||||||
try {
|
try {
|
||||||
const salesCode = categoryOptions["division"]?.find((o) => o.label === "영업관리")?.code;
|
const salesCode = categoryOptions["item_division"]?.find((o) => o.label === "영업관리")?.code;
|
||||||
const filters: any[] = salesCode
|
const filters: any[] = salesCode
|
||||||
? [{ columnName: "division", operator: "contains", value: salesCode }]
|
? [{ columnName: "division", operator: "contains", value: salesCode }]
|
||||||
: [];
|
: [];
|
||||||
|
|||||||
@@ -195,6 +195,10 @@ export default function SupplierManagementPage() {
|
|||||||
if (res.data?.success) optMap[col] = flatten(res.data.data || []);
|
if (res.data?.success) optMap[col] = flatten(res.data.data || []);
|
||||||
} catch { /* skip */ }
|
} 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);
|
setCategoryOptions(optMap);
|
||||||
|
|
||||||
const priceOpts: Record<string, { code: string; label: string }[]> = {};
|
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 || [];
|
const allItems = res.data?.data?.data || res.data?.data?.rows || [];
|
||||||
setItemTotalCount(allItems.length);
|
setItemTotalCount(allItems.length);
|
||||||
const existingItemIds = new Set(priceItems.map((p: any) => p.item_id || p.item_number));
|
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) => {
|
setItemSearchResults(allItems.filter((item: any) => {
|
||||||
if (existingItemIds.has(item.item_number) || existingItemIds.has(item.id)) return false;
|
if (existingItemIds.has(item.item_number) || existingItemIds.has(item.id)) return false;
|
||||||
const divCodes = (item.division || "").split(",").map((c: string) => c.trim());
|
if (!purchaseCode) return true;
|
||||||
return divCodes.some((code: string) => PURCHASE_CODES.includes(code));
|
const div = item.division || "";
|
||||||
|
return div.includes(purchaseCode);
|
||||||
}));
|
}));
|
||||||
} catch { /* skip */ } finally { setItemSearchLoading(false); }
|
} catch { /* skip */ } finally { setItemSearchLoading(false); }
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -195,6 +195,10 @@ export default function CustomerManagementPage() {
|
|||||||
if (res.data?.success) optMap[col] = flatten(res.data.data || []);
|
if (res.data?.success) optMap[col] = flatten(res.data.data || []);
|
||||||
} catch { /* skip */ }
|
} 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);
|
setCategoryOptions(optMap);
|
||||||
|
|
||||||
const priceOpts: Record<string, { code: string; label: string }[]> = {};
|
const priceOpts: Record<string, { code: string; label: string }[]> = {};
|
||||||
@@ -811,7 +815,7 @@ export default function CustomerManagementPage() {
|
|||||||
const searchItems = async () => {
|
const searchItems = async () => {
|
||||||
setItemSearchLoading(true);
|
setItemSearchLoading(true);
|
||||||
try {
|
try {
|
||||||
const salesCode = categoryOptions["division"]?.find((o) => o.label === "영업관리")?.code;
|
const salesCode = categoryOptions["item_division"]?.find((o) => o.label === "영업관리")?.code;
|
||||||
const filters: any[] = salesCode
|
const filters: any[] = salesCode
|
||||||
? [{ columnName: "division", operator: "contains", value: salesCode }]
|
? [{ columnName: "division", operator: "contains", value: salesCode }]
|
||||||
: [];
|
: [];
|
||||||
|
|||||||
@@ -195,6 +195,10 @@ export default function SupplierManagementPage() {
|
|||||||
if (res.data?.success) optMap[col] = flatten(res.data.data || []);
|
if (res.data?.success) optMap[col] = flatten(res.data.data || []);
|
||||||
} catch { /* skip */ }
|
} 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);
|
setCategoryOptions(optMap);
|
||||||
|
|
||||||
const priceOpts: Record<string, { code: string; label: string }[]> = {};
|
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 || [];
|
const allItems = res.data?.data?.data || res.data?.data?.rows || [];
|
||||||
setItemTotalCount(allItems.length);
|
setItemTotalCount(allItems.length);
|
||||||
const existingItemIds = new Set(priceItems.map((p: any) => p.item_id || p.item_number));
|
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) => {
|
setItemSearchResults(allItems.filter((item: any) => {
|
||||||
if (existingItemIds.has(item.item_number) || existingItemIds.has(item.id)) return false;
|
if (existingItemIds.has(item.item_number) || existingItemIds.has(item.id)) return false;
|
||||||
const divCodes = (item.division || "").split(",").map((c: string) => c.trim());
|
if (!purchaseCode) return true;
|
||||||
return divCodes.some((code: string) => PURCHASE_CODES.includes(code));
|
const div = item.division || "";
|
||||||
|
return div.includes(purchaseCode);
|
||||||
}));
|
}));
|
||||||
} catch { /* skip */ } finally { setItemSearchLoading(false); }
|
} catch { /* skip */ } finally { setItemSearchLoading(false); }
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -195,6 +195,10 @@ export default function CustomerManagementPage() {
|
|||||||
if (res.data?.success) optMap[col] = flatten(res.data.data || []);
|
if (res.data?.success) optMap[col] = flatten(res.data.data || []);
|
||||||
} catch { /* skip */ }
|
} 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);
|
setCategoryOptions(optMap);
|
||||||
|
|
||||||
const priceOpts: Record<string, { code: string; label: string }[]> = {};
|
const priceOpts: Record<string, { code: string; label: string }[]> = {};
|
||||||
@@ -811,7 +815,7 @@ export default function CustomerManagementPage() {
|
|||||||
const searchItems = async () => {
|
const searchItems = async () => {
|
||||||
setItemSearchLoading(true);
|
setItemSearchLoading(true);
|
||||||
try {
|
try {
|
||||||
const salesCode = categoryOptions["division"]?.find((o) => o.label === "영업관리")?.code;
|
const salesCode = categoryOptions["item_division"]?.find((o) => o.label === "영업관리")?.code;
|
||||||
const filters: any[] = salesCode
|
const filters: any[] = salesCode
|
||||||
? [{ columnName: "division", operator: "contains", value: salesCode }]
|
? [{ columnName: "division", operator: "contains", value: salesCode }]
|
||||||
: [];
|
: [];
|
||||||
|
|||||||
@@ -195,6 +195,10 @@ export default function SupplierManagementPage() {
|
|||||||
if (res.data?.success) optMap[col] = flatten(res.data.data || []);
|
if (res.data?.success) optMap[col] = flatten(res.data.data || []);
|
||||||
} catch { /* skip */ }
|
} 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);
|
setCategoryOptions(optMap);
|
||||||
|
|
||||||
const priceOpts: Record<string, { code: string; label: string }[]> = {};
|
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 || [];
|
const allItems = res.data?.data?.data || res.data?.data?.rows || [];
|
||||||
setItemTotalCount(allItems.length);
|
setItemTotalCount(allItems.length);
|
||||||
const existingItemIds = new Set(priceItems.map((p: any) => p.item_id || p.item_number));
|
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) => {
|
setItemSearchResults(allItems.filter((item: any) => {
|
||||||
if (existingItemIds.has(item.item_number) || existingItemIds.has(item.id)) return false;
|
if (existingItemIds.has(item.item_number) || existingItemIds.has(item.id)) return false;
|
||||||
const divCodes = (item.division || "").split(",").map((c: string) => c.trim());
|
if (!purchaseCode) return true;
|
||||||
return divCodes.some((code: string) => PURCHASE_CODES.includes(code));
|
const div = item.division || "";
|
||||||
|
return div.includes(purchaseCode);
|
||||||
}));
|
}));
|
||||||
} catch { /* skip */ } finally { setItemSearchLoading(false); }
|
} catch { /* skip */ } finally { setItemSearchLoading(false); }
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -195,6 +195,10 @@ export default function CustomerManagementPage() {
|
|||||||
if (res.data?.success) optMap[col] = flatten(res.data.data || []);
|
if (res.data?.success) optMap[col] = flatten(res.data.data || []);
|
||||||
} catch { /* skip */ }
|
} 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);
|
setCategoryOptions(optMap);
|
||||||
|
|
||||||
const priceOpts: Record<string, { code: string; label: string }[]> = {};
|
const priceOpts: Record<string, { code: string; label: string }[]> = {};
|
||||||
@@ -811,7 +815,7 @@ export default function CustomerManagementPage() {
|
|||||||
const searchItems = async () => {
|
const searchItems = async () => {
|
||||||
setItemSearchLoading(true);
|
setItemSearchLoading(true);
|
||||||
try {
|
try {
|
||||||
const salesCode = categoryOptions["division"]?.find((o) => o.label === "영업관리")?.code;
|
const salesCode = categoryOptions["item_division"]?.find((o) => o.label === "영업관리")?.code;
|
||||||
const filters: any[] = salesCode
|
const filters: any[] = salesCode
|
||||||
? [{ columnName: "division", operator: "contains", value: salesCode }]
|
? [{ columnName: "division", operator: "contains", value: salesCode }]
|
||||||
: [];
|
: [];
|
||||||
|
|||||||
@@ -195,6 +195,10 @@ export default function SupplierManagementPage() {
|
|||||||
if (res.data?.success) optMap[col] = flatten(res.data.data || []);
|
if (res.data?.success) optMap[col] = flatten(res.data.data || []);
|
||||||
} catch { /* skip */ }
|
} 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);
|
setCategoryOptions(optMap);
|
||||||
|
|
||||||
const priceOpts: Record<string, { code: string; label: string }[]> = {};
|
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 || [];
|
const allItems = res.data?.data?.data || res.data?.data?.rows || [];
|
||||||
setItemTotalCount(allItems.length);
|
setItemTotalCount(allItems.length);
|
||||||
const existingItemIds = new Set(priceItems.map((p: any) => p.item_id || p.item_number));
|
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) => {
|
setItemSearchResults(allItems.filter((item: any) => {
|
||||||
if (existingItemIds.has(item.item_number) || existingItemIds.has(item.id)) return false;
|
if (existingItemIds.has(item.item_number) || existingItemIds.has(item.id)) return false;
|
||||||
const divCodes = (item.division || "").split(",").map((c: string) => c.trim());
|
if (!purchaseCode) return true;
|
||||||
return divCodes.some((code: string) => PURCHASE_CODES.includes(code));
|
const div = item.division || "";
|
||||||
|
return div.includes(purchaseCode);
|
||||||
}));
|
}));
|
||||||
} catch { /* skip */ } finally { setItemSearchLoading(false); }
|
} catch { /* skip */ } finally { setItemSearchLoading(false); }
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -195,6 +195,10 @@ export default function CustomerManagementPage() {
|
|||||||
if (res.data?.success) optMap[col] = flatten(res.data.data || []);
|
if (res.data?.success) optMap[col] = flatten(res.data.data || []);
|
||||||
} catch { /* skip */ }
|
} 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);
|
setCategoryOptions(optMap);
|
||||||
|
|
||||||
const priceOpts: Record<string, { code: string; label: string }[]> = {};
|
const priceOpts: Record<string, { code: string; label: string }[]> = {};
|
||||||
@@ -811,7 +815,7 @@ export default function CustomerManagementPage() {
|
|||||||
const searchItems = async () => {
|
const searchItems = async () => {
|
||||||
setItemSearchLoading(true);
|
setItemSearchLoading(true);
|
||||||
try {
|
try {
|
||||||
const salesCode = categoryOptions["division"]?.find((o) => o.label === "영업관리")?.code;
|
const salesCode = categoryOptions["item_division"]?.find((o) => o.label === "영업관리")?.code;
|
||||||
const filters: any[] = salesCode
|
const filters: any[] = salesCode
|
||||||
? [{ columnName: "division", operator: "contains", value: salesCode }]
|
? [{ columnName: "division", operator: "contains", value: salesCode }]
|
||||||
: [];
|
: [];
|
||||||
|
|||||||
Reference in New Issue
Block a user