From cf8dac0c6490469dab88a560004b0c07dbd48612 Mon Sep 17 00:00:00 2001 From: dujinkim Date: Thu, 18 Sep 2025 00:23:40 +0000 Subject: (대표님) rfq, 계약, 서명 등 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/itb/table/items-dialog.tsx | 167 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 167 insertions(+) create mode 100644 lib/itb/table/items-dialog.tsx (limited to 'lib/itb/table/items-dialog.tsx') diff --git a/lib/itb/table/items-dialog.tsx b/lib/itb/table/items-dialog.tsx new file mode 100644 index 00000000..dd688ce9 --- /dev/null +++ b/lib/itb/table/items-dialog.tsx @@ -0,0 +1,167 @@ +// components/purchase-requests/items-dialog.tsx +"use client"; + +import * as React from "react"; +import { + Dialog, + DialogContent, + DialogDescription, + DialogHeader, + DialogTitle, +} from "@/components/ui/dialog"; +import { + Table, + TableBody, + TableCell, + TableHead, + TableHeader, + TableRow, + TableFooter, +} from "@/components/ui/table"; +import { Badge } from "@/components/ui/badge"; +import { Package } from "lucide-react"; + +interface Item { + id: string; + itemCode: string; + itemName: string; + specification: string; + quantity: number; + unit: string; + estimatedUnitPrice?: number; + remarks?: string; +} + +interface ItemsDialogProps { + requestId: number; + requestCode: string; + items: Item[] | any; + open: boolean; + onOpenChange: (open: boolean) => void; +} + +export function ItemsDialog({ + requestId, + requestCode, + items, + open, + onOpenChange, +}: ItemsDialogProps) { + // items가 없거나 배열이 아닌 경우 처리 + const itemList = React.useMemo(() => { + if (!items || !Array.isArray(items)) return []; + return items; + }, [items]); + + // 총액 계산 + const totalAmount = React.useMemo(() => { + return itemList.reduce((sum, item) => { + const subtotal = (item.quantity || 0) * (item.estimatedUnitPrice || 0); + return sum + subtotal; + }, 0); + }, [itemList]); + + // 총 수량 계산 + const totalQuantity = React.useMemo(() => { + return itemList.reduce((sum, item) => sum + (item.quantity || 0), 0); + }, [itemList]); + + return ( + + + + + + 품목 상세 정보 + + + 요청번호: {requestCode} | 총 {itemList.length}개 품목 + + + +
+ {itemList.length === 0 ? ( +
+

등록된 품목이 없습니다.

+
+ ) : ( + + + + 번호 + 아이템 코드 + 아이템명 + 사양 + 수량 + 단위 + 예상 단가 + 예상 금액 + 비고 + + + + {itemList.map((item, index) => { + const subtotal = (item.quantity || 0) * (item.estimatedUnitPrice || 0); + return ( + + + {index + 1} + + + {item.itemCode} + + + {item.itemName} + + + {item.specification || "-"} + + + {item.quantity?.toLocaleString('ko-KR')} + + + {item.unit} + + + {item.estimatedUnitPrice + ? new Intl.NumberFormat('ko-KR').format(item.estimatedUnitPrice) + : "-"} + + + {subtotal > 0 + ? new Intl.NumberFormat('ko-KR').format(subtotal) + : "-"} + + + {item.remarks || "-"} + + + ); + })} + + + + + 합계 + + + {totalQuantity.toLocaleString('ko-KR')} + + + + + {new Intl.NumberFormat('ko-KR', { + style: 'currency', + currency: 'KRW' + }).format(totalAmount)} + + + + +
+ )} +
+
+
+ ); +} \ No newline at end of file -- cgit v1.2.3