diff options
| author | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-06-13 07:22:04 +0000 |
|---|---|---|
| committer | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-06-13 07:22:04 +0000 |
| commit | 9f3b8915ab20f177edafd3c4a4cc1ca0da0fc766 (patch) | |
| tree | df110ca4a654bc3b3d0bd02b68cba45a25a7c39e /lib/items-tech/table/ship | |
| parent | 0fddf148402fd6b99a1b3800d73679899bcb2ed3 (diff) | |
(최겸) 기술영업 아이템 수정(컬럼명 및 item table FK 삭제, rfq에서 사용하는 service 수정)
Diffstat (limited to 'lib/items-tech/table/ship')
5 files changed, 37 insertions, 91 deletions
diff --git a/lib/items-tech/table/ship/Items-ship-table.tsx b/lib/items-tech/table/ship/Items-ship-table.tsx index 61e8d8b4..feab288a 100644 --- a/lib/items-tech/table/ship/Items-ship-table.tsx +++ b/lib/items-tech/table/ship/Items-ship-table.tsx @@ -24,7 +24,7 @@ type ShipbuildingItem = { shipTypes: string;
itemCode: string;
itemName: string;
- itemList: string | null;
+ itemList: string | null;
description: string | null;
createdAt: Date;
updatedAt: Date;
@@ -110,7 +110,7 @@ export function ItemsShipTable({ promises }: ItemsTableProps) { label: "아이템 리스트",
type: "text",
},
- ]
+ ]
const { table } = useDataTable({
data: data as ShipbuildingItem[],
diff --git a/lib/items-tech/table/ship/import-item-handler.tsx b/lib/items-tech/table/ship/import-item-handler.tsx index 77bed4f0..a47e451b 100644 --- a/lib/items-tech/table/ship/import-item-handler.tsx +++ b/lib/items-tech/table/ship/import-item-handler.tsx @@ -3,14 +3,13 @@ import { z } from "zod" import { createShipbuildingImportItem } from "../../service" // 아이템 생성 서버 액션 -const SHIP_TYPES = ['A-MAX', 'S-MAX', 'LNGC', 'VLCC', 'CONT'] as const; - // 아이템 데이터 검증을 위한 Zod 스키마 const itemSchema = z.object({ itemCode: z.string().min(1, "아이템 코드는 필수입니다"), workType: z.enum(["기장", "전장", "선실", "배관", "철의"], { required_error: "기능(공종)은 필수입니다", }), + shipTypes: z.string().nullable().optional(), itemList: z.string().nullable().optional(), }); @@ -58,16 +57,16 @@ export async function processFileImport( try { // 필드 매핑 (한글/영문 필드명 모두 지원) - const itemCode = row["아이템 코드"] || row["itemCode"] || ""; - const itemName = row["아이템 명"] || row["itemName"] || "기술영업"; // 기본값 설정 + const itemCode = row["자재 그룹"] || row["itemCode"] || ""; const workType = row["기능(공종)"] || row["workType"] || ""; - const itemList = row["아이템 리스트"] || row["itemList"] || null; + const shipTypes = row["선종"] || row["shipTypes"] || null; + const itemList = row["자재명"] || row["itemList"] || null; // 데이터 정제 const cleanedRow = { itemCode: typeof itemCode === 'string' ? itemCode.trim() : String(itemCode).trim(), - itemName: typeof itemName === 'string' ? itemName.trim() : String(itemName).trim(), workType: typeof workType === 'string' ? workType.trim() : String(workType).trim(), + shipTypes: shipTypes ? (typeof shipTypes === 'string' ? shipTypes.trim() : String(shipTypes).trim()) : null, itemList: itemList ? (typeof itemList === 'string' ? itemList : String(itemList)) : null, }; @@ -84,57 +83,24 @@ export async function processFileImport( continue; } - // 선종 데이터 처리 - const shipTypeEntries = SHIP_TYPES.map(type => ({ - type, - value: row[type] ? String(row[type]).toUpperCase() === 'O' : false - })).filter(entry => entry.value); - console.log('shipTypeEntries:', shipTypeEntries); - - // 선종이 없는 경우에 "option" 값을 사용 - if (shipTypeEntries.length === 0) { - // "option" 값으로 아이템 생성 - const result = await createShipbuildingImportItem({ - itemCode: cleanedRow.itemCode, - itemName: cleanedRow.itemName, // Excel에서 가져온 값 또는 기본값 사용 - workType: cleanedRow.workType as "기장" | "전장" | "선실" | "배관" | "철의", - shipTypes: { "OPTION": true }, - description: null, - itemList: cleanedRow.itemList, - }); - - if (result.success || !result.error) { - successCount++; - } else { - errors.push({ - row: rowIndex, - message: `OPTION: ${result.message || result.error || "알 수 없는 오류"}` - }); - errorCount++; - } + // 아이템 생성 + const result = await createShipbuildingImportItem({ + itemCode: cleanedRow.itemCode, + workType: cleanedRow.workType as "기장" | "전장" | "선실" | "배관" | "철의", + shipTypes: cleanedRow.shipTypes, + itemList: cleanedRow.itemList, + }); + + if (result.success || !result.error) { + successCount++; } else { - // 각 선종에 대해 아이템 생성 - for (const { type } of shipTypeEntries) { - const result = await createShipbuildingImportItem({ - itemCode: cleanedRow.itemCode, - itemName: cleanedRow.itemName, // Excel에서 가져온 값 또는 기본값 사용 - workType: cleanedRow.workType as "기장" | "전장" | "선실" | "배관" | "철의", - shipTypes: { [type]: true }, - description: null, - itemList: cleanedRow.itemList, - }); - - if (result.success || !result.error) { - successCount++; - } else { - errors.push({ - row: rowIndex, - message: `${type}: ${result.message || result.error || "알 수 없는 오류"}` - }); - errorCount++; - } - } + errors.push({ + row: rowIndex, + message: result.message || result.error || "알 수 없는 오류" + }); + errorCount++; } + } catch (error) { console.error(`${rowIndex}행 처리 오류:`, error); errors.push({ diff --git a/lib/items-tech/table/ship/item-excel-template.tsx b/lib/items-tech/table/ship/item-excel-template.tsx index f6b20b6d..401fb911 100644 --- a/lib/items-tech/table/ship/item-excel-template.tsx +++ b/lib/items-tech/table/ship/item-excel-template.tsx @@ -1,8 +1,6 @@ import * as ExcelJS from 'exceljs'; import { saveAs } from "file-saver"; -const SHIP_TYPES = ['A-MAX', 'S-MAX', 'LNGC', 'VLCC', 'CONT'] as const; - /** * 조선 아이템 데이터 가져오기를 위한 Excel 템플릿 파일 생성 및 다운로드 */ @@ -17,14 +15,10 @@ export async function exportItemTemplate() { // 컬럼 헤더 정의 및 스타일 적용 worksheet.columns = [ - { header: '아이템 코드', key: 'itemCode', width: 15 }, + { header: '자재 그룹', key: 'itemCode', width: 15 }, { header: '기능(공종)', key: 'workType', width: 15 }, - { header: '아이템 리스트', key: 'itemList', width: 30 }, - ...SHIP_TYPES.map(type => ({ - header: type, - key: type, - width: 10 - })) + { header: '선종', key: 'shipTypes', width: 15 }, + { header: '자재명', key: 'itemList', width: 30 }, ]; // 헤더 스타일 적용 @@ -52,32 +46,20 @@ export async function exportItemTemplate() { { itemCode: 'BG0001', workType: '기장', - itemList: '아이템 리스트 내용', - 'A-MAX': 'O', - 'S-MAX': 'O', - 'LNGC': 'O', - 'VLCC': ' ', - 'CONT': ' ' + shipTypes: 'A-MAX', + itemList: '자재명', }, { itemCode: 'BG0002', workType: '전장', - itemList: '아이템 리스트 내용 2', - 'A-MAX': 'O', - 'S-MAX': ' ', - 'LNGC': 'O', - 'VLCC': 'O', - 'CONT': ' ' + shipTypes: 'LNGC', + itemList: '자재명', }, { itemCode: 'BG0003', workType: '선실', - itemList: '선종 없는 아이템', - 'A-MAX': ' ', - 'S-MAX': ' ', - 'LNGC': ' ', - 'VLCC': ' ', - 'CONT': ' ' + shipTypes: 'VLCC', + itemList: '자재명', } ]; diff --git a/lib/items-tech/table/ship/items-ship-table-columns.tsx b/lib/items-tech/table/ship/items-ship-table-columns.tsx index 29e1d503..13ba2480 100644 --- a/lib/items-tech/table/ship/items-ship-table-columns.tsx +++ b/lib/items-tech/table/ship/items-ship-table-columns.tsx @@ -115,13 +115,13 @@ export function getShipbuildingColumns({ setRowAction }: GetColumnsProps): Colum {
accessorKey: "itemCode",
header: ({ column }) => (
- <DataTableColumnHeaderSimple column={column} title="Material Group" />
+ <DataTableColumnHeaderSimple column={column} title="자재 그룹" />
),
cell: ({ row }) => <div>{row.original.itemCode}</div>,
enableSorting: true,
enableHiding: true,
meta: {
- excelHeader: "Material Group",
+ excelHeader: "자재 그룹",
},
},
{
@@ -151,13 +151,13 @@ export function getShipbuildingColumns({ setRowAction }: GetColumnsProps): Colum {
accessorKey: "itemList",
header: ({ column }) => (
- <DataTableColumnHeaderSimple column={column} title="아이템 리스트" />
+ <DataTableColumnHeaderSimple column={column} title="자재명" />
),
cell: ({ row }) => <div>{row.original.itemList || "-"}</div>,
enableSorting: true,
enableHiding: true,
meta: {
- excelHeader: "아이템 리스트",
+ excelHeader: "자재명",
},
},
{
diff --git a/lib/items-tech/table/ship/items-table-toolbar-actions.tsx b/lib/items-tech/table/ship/items-table-toolbar-actions.tsx index 677173d1..e58ba135 100644 --- a/lib/items-tech/table/ship/items-table-toolbar-actions.tsx +++ b/lib/items-tech/table/ship/items-table-toolbar-actions.tsx @@ -134,9 +134,7 @@ export function ItemsTableToolbarActions({ table }: ItemsTableToolbarActionsProp {/* 선택된 로우가 있으면 삭제 다이얼로그 */} {table.getFilteredSelectedRowModel().rows.length > 0 ? ( <DeleteItemsDialog - items={table - .getFilteredSelectedRowModel() - .rows.map((row) => row.original)} + items={table.getFilteredSelectedRowModel().rows.map((row) => row.original) as any} onSuccess={() => table.toggleAllRowsSelected(false)} itemType="shipbuilding" /> |
