feat: Enhance entity options retrieval with additional fields support
- Updated the `getEntityOptions` function to accept an optional `fields` parameter, allowing clients to specify additional columns to be retrieved. - Implemented logic to dynamically include extra columns in the SQL query based on the provided `fields`, improving flexibility in data retrieval. - Enhanced the response to indicate whether extra fields were included, facilitating better client-side handling of the data. - Added logging for authentication failures in the `AuthGuard` component to improve debugging and user experience. - Integrated auto-fill functionality in the `V2Select` component to automatically populate fields based on selected entity references, enhancing user interaction. - Updated the `ItemSearchModal` to support multi-selection of items, improving usability in item management scenarios.
This commit is contained in:
@@ -84,30 +84,45 @@ export function BomTreeComponent({
|
||||
return null;
|
||||
}, [formData, selectedRowsData]);
|
||||
|
||||
// 선택된 BOM 헤더 정보 추출
|
||||
// 선택된 BOM 헤더 정보 추출 (조인 필드명 매핑 포함)
|
||||
const selectedHeaderData = useMemo(() => {
|
||||
if (selectedRowsData && selectedRowsData.length > 0) {
|
||||
return selectedRowsData[0] as BomHeaderInfo;
|
||||
}
|
||||
if (formData?.id) return formData as unknown as BomHeaderInfo;
|
||||
return null;
|
||||
const raw = selectedRowsData?.[0] || (formData?.id ? formData : null);
|
||||
if (!raw) return null;
|
||||
return {
|
||||
...raw,
|
||||
item_name: raw.item_id_item_name || raw.item_name || "",
|
||||
item_code: raw.item_id_item_number || raw.item_code || "",
|
||||
item_type: raw.item_id_division || raw.item_id_type || raw.item_type || "",
|
||||
} as BomHeaderInfo;
|
||||
}, [formData, selectedRowsData]);
|
||||
|
||||
// BOM 디테일 데이터 로드
|
||||
const detailTable = config.detailTable || "bom_detail";
|
||||
const foreignKey = config.foreignKey || "bom_id";
|
||||
const sourceFk = "child_item_id";
|
||||
|
||||
const loadBomDetails = useCallback(async (bomId: string) => {
|
||||
if (!bomId) return;
|
||||
setLoading(true);
|
||||
try {
|
||||
const result = await entityJoinApi.getTableDataWithJoins("bom_detail", {
|
||||
const result = await entityJoinApi.getTableDataWithJoins(detailTable, {
|
||||
page: 1,
|
||||
size: 500,
|
||||
search: { bom_id: bomId },
|
||||
search: { [foreignKey]: bomId },
|
||||
sortBy: "seq_no",
|
||||
sortOrder: "asc",
|
||||
enableEntityJoin: true,
|
||||
});
|
||||
|
||||
const rows = result.data || [];
|
||||
const rows = (result.data || []).map((row: Record<string, any>) => {
|
||||
const mapped = { ...row };
|
||||
// 엔티티 조인 필드 매핑: child_item_id_item_name → child_item_name 등
|
||||
mapped.child_item_name = row[`${sourceFk}_item_name`] || row.child_item_name || "";
|
||||
mapped.child_item_code = row[`${sourceFk}_item_number`] || row.child_item_code || "";
|
||||
mapped.child_item_type = row[`${sourceFk}_type`] || row[`${sourceFk}_division`] || row.child_item_type || "";
|
||||
return mapped;
|
||||
});
|
||||
|
||||
const tree = buildTree(rows);
|
||||
setTreeData(tree);
|
||||
const firstLevelIds = new Set<string>(tree.map((n: BomTreeNode) => n.id));
|
||||
@@ -117,7 +132,7 @@ export function BomTreeComponent({
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}, []);
|
||||
}, [detailTable, foreignKey]);
|
||||
|
||||
// 평면 데이터 -> 트리 구조 변환
|
||||
const buildTree = (flatData: any[]): BomTreeNode[] => {
|
||||
|
||||
Reference in New Issue
Block a user