diff options
Diffstat (limited to 'lib/techsales-rfq/table/rfq-table-column.tsx')
| -rw-r--r-- | lib/techsales-rfq/table/rfq-table-column.tsx | 269 |
1 files changed, 124 insertions, 145 deletions
diff --git a/lib/techsales-rfq/table/rfq-table-column.tsx b/lib/techsales-rfq/table/rfq-table-column.tsx index 2740170b..51c143a4 100644 --- a/lib/techsales-rfq/table/rfq-table-column.tsx +++ b/lib/techsales-rfq/table/rfq-table-column.tsx @@ -6,16 +6,13 @@ import { formatDate, formatDateTime } from "@/lib/utils" import { Checkbox } from "@/components/ui/checkbox" import { DataTableColumnHeaderSimple } from "@/components/data-table/data-table-column-simple-header" import { DataTableRowAction } from "@/types/table" -import { Paperclip } from "lucide-react" +import { Paperclip, Package } from "lucide-react" import { Button } from "@/components/ui/button" // 기본적인 RFQ 타입 정의 (rfq-table.tsx 파일과 일치해야 함) type TechSalesRfq = { id: number rfqCode: string | null - itemId: number - itemName: string | null - materialCode: string | null dueDate: Date rfqSendDate: Date | null status: "RFQ Created" | "RFQ Vendor Assignned" | "RFQ Sent" | "Quotation Analysis" | "Closed" @@ -30,40 +27,6 @@ type TechSalesRfq = { updatedByName: string sentBy: number | null sentByName: string | null - // 스키마와 일치하도록 타입 수정 - projectSnapshot: { - pspid: string; - projNm?: string; - sector?: string; - projMsrm?: number; - kunnr?: string; - kunnrNm?: string; - cls1?: string; - cls1Nm?: string; - ptype?: string; - ptypeNm?: string; - pmodelCd?: string; - pmodelNm?: string; - pmodelSz?: string; - pmodelUom?: string; - txt04?: string; - txt30?: string; - estmPm?: string; - pspCreatedAt?: Date | string; - pspUpdatedAt?: Date | string; - } | Record<string, unknown> // legacy 호환성을 위해 유지 - seriesSnapshot: Array<{ - pspid: string; - sersNo: string; - scDt?: string; - klDt?: string; - lcDt?: string; - dlDt?: string; - dockNo?: string; - dockNm?: string; - projNo?: string; - post1?: string; - }> | Record<string, unknown> // legacy 호환성을 위해 유지 pspid: string projNm: string sector: string @@ -71,6 +34,7 @@ type TechSalesRfq = { ptypeNm: string attachmentCount: number quotationCount: number + itemCount: number // 나머지 필드는 사용할 때마다 추가 [key: string]: unknown } @@ -78,11 +42,13 @@ type TechSalesRfq = { interface GetColumnsProps { setRowAction: React.Dispatch<React.SetStateAction<DataTableRowAction<TechSalesRfq> | null>>; openAttachmentsSheet: (rfqId: number) => void; + openItemsDialog: (rfq: TechSalesRfq) => void; } export function getColumns({ setRowAction, openAttachmentsSheet, + openItemsDialog, }: GetColumnsProps): ColumnDef<TechSalesRfq>[] { return [ { @@ -144,34 +110,6 @@ export function getColumns({ size: 120, }, { - accessorKey: "materialCode", - header: ({ column }) => ( - <DataTableColumnHeaderSimple column={column} title="자재코드" /> - ), - cell: ({ row }) => <div>{row.getValue("materialCode")}</div>, - meta: { - excelHeader: "자재코드" - }, - enableResizing: true, - minSize: 80, - size: 250, - }, - { - accessorKey: "itemName", - header: ({ column }) => ( - <DataTableColumnHeaderSimple column={column} title="자재명" /> - ), - cell: ({ row }) => { - const itemName = row.getValue("itemName") as string | null; - return <div>{itemName || "자재명 없음"}</div>; - }, - meta: { - excelHeader: "자재명" - }, - enableResizing: true, - size: 250, - }, - { accessorKey: "projNm", header: ({ column }) => ( <DataTableColumnHeaderSimple column={column} title="프로젝트명" /> @@ -194,85 +132,43 @@ export function getColumns({ enableResizing: true, size: 160, }, - { - accessorKey: "projMsrm", - header: ({ column }) => ( - <DataTableColumnHeaderSimple column={column} title="척수" /> - ), - cell: ({ row }) => <div>{row.getValue("projMsrm")}</div>, - meta: { - excelHeader: "척수" - }, - enableResizing: true, - minSize: 60, - size: 80, - }, - { - accessorKey: "ptypeNm", - header: ({ column }) => ( - <DataTableColumnHeaderSimple column={column} title="선종" /> - ), - cell: ({ row }) => <div>{row.getValue("ptypeNm")}</div>, - meta: { - excelHeader: "선종" - }, - enableResizing: true, - size: 120, - }, - { - accessorKey: "quotationCount", - header: ({ column }) => ( - <DataTableColumnHeaderSimple column={column} title="견적수" /> - ), - cell: ({ row }) => <div>{row.getValue("quotationCount")}</div>, - meta: { - excelHeader: "견적수" - }, - enableResizing: true, - size: 80, - }, - { - id: "attachments", - header: ({ column }) => ( - <DataTableColumnHeaderSimple column={column} title="첨부파일" /> - ), - cell: ({ row }) => { - const rfq = row.original - const attachmentCount = rfq.attachmentCount || 0 - - const handleClick = () => { - openAttachmentsSheet(rfq.id) - } - - return ( - <Button - variant="ghost" - size="sm" - className="relative h-8 w-8 p-0 group" - onClick={handleClick} - aria-label={ - attachmentCount > 0 ? `View ${attachmentCount} attachments` : "Add attachments" - } - > - <Paperclip className="h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors" /> - {attachmentCount > 0 && ( - <span className="pointer-events-none absolute -top-1 -right-1 inline-flex h-4 min-w-[1rem] items-center justify-center rounded-full bg-primary px-1 text-[0.625rem] font-medium leading-none text-primary-foreground"> - {attachmentCount} - </span> - )} - <span className="sr-only"> - {attachmentCount > 0 ? `${attachmentCount} 첨부파일` : "첨부파일 추가"} - </span> - </Button> - ) - }, - enableSorting: false, - enableResizing: true, - size: 80, - meta: { - excelHeader: "첨부파일" - }, - }, + // { + // accessorKey: "projMsrm", + // header: ({ column }) => ( + // <DataTableColumnHeaderSimple column={column} title="척수" /> + // ), + // cell: ({ row }) => <div>{row.getValue("projMsrm")}</div>, + // meta: { + // excelHeader: "척수" + // }, + // enableResizing: true, + // minSize: 60, + // size: 80, + // }, + // { + // accessorKey: "ptypeNm", + // header: ({ column }) => ( + // <DataTableColumnHeaderSimple column={column} title="선종" /> + // ), + // cell: ({ row }) => <div>{row.getValue("ptypeNm")}</div>, + // meta: { + // excelHeader: "선종" + // }, + // enableResizing: true, + // size: 120, + // }, + // { + // accessorKey: "quotationCount", + // header: ({ column }) => ( + // <DataTableColumnHeaderSimple column={column} title="견적수" /> + // ), + // cell: ({ row }) => <div>{row.getValue("quotationCount")}</div>, + // meta: { + // excelHeader: "견적수" + // }, + // enableResizing: true, + // size: 80, + // }, { accessorKey: "rfqSendDate", header: ({ column }) => ( @@ -346,5 +242,88 @@ export function getColumns({ enableResizing: true, size: 160, }, + // 우측 고정 컬럼들 + { + id: "items", + header: ({ column }) => ( + <DataTableColumnHeaderSimple column={column} title="아이템" /> + ), + cell: ({ row }) => { + const rfq = row.original + const itemCount = rfq.itemCount || 0 + + const handleClick = () => { + openItemsDialog(rfq) + } + + return ( + <Button + variant="ghost" + size="sm" + className="relative h-8 w-8 p-0 group" + onClick={handleClick} + aria-label={`View ${itemCount} items`} + > + <Package className="h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors" /> + {itemCount > 0 && ( + <span className="pointer-events-none absolute -top-1 -right-1 inline-flex h-4 min-w-[1rem] items-center justify-center rounded-full bg-primary px-1 text-[0.625rem] font-medium leading-none text-primary-foreground"> + {itemCount} + </span> + )} + <span className="sr-only"> + {itemCount > 0 ? `${itemCount} 아이템` : "아이템 없음"} + </span> + </Button> + ) + }, + enableSorting: false, + enableResizing: false, + size: 80, + meta: { + excelHeader: "아이템" + }, + }, + { + id: "attachments", + header: ({ column }) => ( + <DataTableColumnHeaderSimple column={column} title="첨부파일" /> + ), + cell: ({ row }) => { + const rfq = row.original + const attachmentCount = rfq.attachmentCount || 0 + + const handleClick = () => { + openAttachmentsSheet(rfq.id) + } + + return ( + <Button + variant="ghost" + size="sm" + className="relative h-8 w-8 p-0 group" + onClick={handleClick} + aria-label={ + attachmentCount > 0 ? `View ${attachmentCount} attachments` : "Add attachments" + } + > + <Paperclip className="h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors" /> + {attachmentCount > 0 && ( + <span className="pointer-events-none absolute -top-1 -right-1 inline-flex h-4 min-w-[1rem] items-center justify-center rounded-full bg-primary px-1 text-[0.625rem] font-medium leading-none text-primary-foreground"> + {attachmentCount} + </span> + )} + <span className="sr-only"> + {attachmentCount > 0 ? `${attachmentCount} 첨부파일` : "첨부파일 추가"} + </span> + </Button> + ) + }, + enableSorting: false, + enableResizing: false, + size: 80, + meta: { + excelHeader: "첨부파일" + }, + }, ] }
\ No newline at end of file |
