/** * 계약히스토리 테이블 컬럼 설정 * * * 컬럼목록: * - 선택 * - PO/계약번호 * - Rev. / 품번 * - 계약상태 * - 프로젝트 * - PKG No. * - PKG 명 * - 자재그룹코드 * - 자재그룹명 * - 지불조건 * - Incoterms * - 선적지 * - 계약납기일 * - L/C No. * - 연동제대상 * - 통화 * - 계약금액 * - 선급금 * - 납품대금 * - 유보금 * - PO/계약발송일 * - PO/계약체결일 * - 계약서 * - 계약담당자 * - 계약상세 */ "use client" import * as React from "react" import { type DataTableRowAction } from "@/types/table" import { type ColumnDef } from "@tanstack/react-table" import { Ellipsis, FileText, User, Eye } from "lucide-react" import { formatDate } from "@/lib/utils" import { Badge } from "@/components/ui/badge" import { Button } from "@/components/ui/button" import { Checkbox } from "@/components/ui/checkbox" import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu" import { ContractDetailParsed } from "@/db/schema/contract" import { DataTableColumnHeaderSimple } from "@/components/data-table/data-table-column-simple-header" // 간단한 숫자 포맷팅 함수 const formatNumber = (value: number): string => { return new Intl.NumberFormat('ko-KR').format(value) } interface GetColumnsProps { setRowAction: React.Dispatch | null>>; } /** * 계약 히스토리 테이블 컬럼 정의 (간단 버전) */ export function getColumns({ setRowAction }: GetColumnsProps): ColumnDef[] { return [ // 선택 { id: "select", header: ({ table }) => ( table.toggleAllPageRowsSelected(!!value)} aria-label="Select all" className="translate-y-0.5" /> ), cell: ({ row }) => ( row.toggleSelected(!!value)} aria-label="Select row" className="translate-y-0.5" /> ), size: 40, enableSorting: false, enableHiding: false, }, // PO/계약번호 { accessorKey: "contractNo", header: ({ column }) => ( ), cell: ({ cell }) => cell.getValue() ?? "", }, // Rev. / 품번 (contract.contractVersion 사용) { accessorKey: "contractVersion", header: ({ column }) => ( ), cell: ({ cell }) => { const value = cell.getValue() return value ? `Rev.${value}` : - }, }, // 계약상태 { accessorKey: "status", header: ({ column }) => ( ), cell: ({ cell }) => cell.getValue() ?? "", }, // 프로젝트 { accessorKey: "projectName", header: ({ column }) => ( ), cell: ({ row }) => (
{row.original.projectName} {row.original.projectCode}
), }, // PKG No. { accessorKey: "projectCode", header: ({ column }) => ( ), cell: ({ row }) => row.original.projectCode ? {row.original.projectCode} : -, }, // 벤더명 { accessorKey: "vendorName", header: ({ column }) => ( ), cell: ({ cell }) => cell.getValue() ?? "", }, // 계약명 { accessorKey: "contractName", header: ({ column }) => ( ), cell: ({ cell }) => cell.getValue() ?? "", }, // 자재그룹코드 (지원되지 않음) { accessorKey: "materialGroupCode", header: ({ column }) => ( ), cell: () => -, }, // 자재그룹명 (지원되지 않음) { accessorKey: "materialGroupName", header: ({ column }) => ( ), cell: () => -, }, // 지불조건 { accessorKey: "paymentTerms", header: ({ column }) => ( ), cell: ({ cell }) => cell.getValue() ?? "", }, // Incoterms { accessorKey: "deliveryTerms", header: ({ column }) => ( ), cell: ({ cell }) => cell.getValue() ?? "", }, // 선적지 { accessorKey: "shippmentPlace", header: ({ column }) => ( ), cell: ({ cell }) => cell.getValue() ?? "", }, // 계약납기일 { accessorKey: "deliveryDate", header: ({ column }) => ( ), cell: ({ cell }) => { const value = cell.getValue() if (value instanceof Date) return formatDate(value, "KR") if (typeof value === "string") return formatDate(new Date(value), "KR") return "" }, }, // L/C No. { accessorKey: "lcNo", header: ({ column }) => ( ), cell: () => -, }, // 연동제대상 { accessorKey: "priceIndexYn", header: ({ column }) => ( ), cell: ({ cell }) => cell.getValue() ?? "", }, // 통화 { accessorKey: "currency", header: ({ column }) => ( ), cell: ({ cell }) => cell.getValue() ?? "", }, // 계약금액 { accessorKey: "totalAmount", header: ({ column }) => ( ), cell: ({ cell }) => { const value = cell.getValue() return typeof value === "number" ? formatNumber(value) : value ?? "" }, }, // 선급금 { accessorKey: "advancePaymentYn", header: ({ column }) => ( ), cell: ({ cell }) => cell.getValue() ?? "", }, // 납품장소 { accessorKey: "deliveryLocation", header: ({ column }) => ( ), cell: ({ cell }) => cell.getValue() ?? "", }, // 유보금 { accessorKey: "retentionAmount", header: ({ column }) => ( ), cell: () => -, }, // PO/계약발송일 { accessorKey: "startDate", header: ({ column }) => ( ), cell: ({ cell }) => { const value = cell.getValue() if (value instanceof Date) return formatDate(value, "KR") if (typeof value === "string") return formatDate(new Date(value), "KR") return "" }, }, // PO/계약체결일 { accessorKey: "electronicApprovalDate", header: ({ column }) => ( ), cell: ({ cell }) => { const value = cell.getValue() if (value instanceof Date) return formatDate(value, "KR") if (typeof value === "string") return formatDate(new Date(value), "KR") return "" }, }, // 전자서명상태 { accessorKey: "hasSignature", header: ({ column }) => ( ), cell: ({ cell }) => { const hasSignature = cell.getValue() return hasSignature ? 서명완료 : 미서명 }, }, // 계약서 (지원되지 않음) { accessorKey: "contractDocument", header: ({ column }) => ( ), cell: () => ( ), }, // 계약담당자 (지원되지 않음) { accessorKey: "contractManager", header: ({ column }) => ( ), cell: () => (
-
), }, // 계약상세 (Actions) { accessorKey: "contractDetail", header: ({ column }) => ( ), cell: ({ row }) => ( setRowAction({ row, type: "view" })} > 상세보기 setRowAction({ row, type: "update" })} > 수정 setRowAction({ row, type: "delete" })} > 삭제 ⌘⌫ ), size: 40, enableSorting: false, enableHiding: false, }, ] }