From c72d0897f7b37843109c86f61d97eba05ba3ca0d Mon Sep 17 00:00:00 2001 From: dujinkim Date: Fri, 13 Jun 2025 07:08:01 +0000 Subject: (대표님) 20250613 16시 08분 b-rfq, document 등 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/b-rfq/attachment/attachment-columns.tsx | 290 ++++++++++++++++++++++++++++ 1 file changed, 290 insertions(+) create mode 100644 lib/b-rfq/attachment/attachment-columns.tsx (limited to 'lib/b-rfq/attachment/attachment-columns.tsx') diff --git a/lib/b-rfq/attachment/attachment-columns.tsx b/lib/b-rfq/attachment/attachment-columns.tsx new file mode 100644 index 00000000..c611e06c --- /dev/null +++ b/lib/b-rfq/attachment/attachment-columns.tsx @@ -0,0 +1,290 @@ +"use client" + +import * as React from "react" +import { type ColumnDef } from "@tanstack/react-table" +import { + Ellipsis, FileText, Download, Eye, + MessageSquare, Upload +} from "lucide-react" + +import { formatDate, formatBytes } 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, DropdownMenuTrigger +} from "@/components/ui/dropdown-menu" +import { Progress } from "@/components/ui/progress" +import { RevisionDialog } from "./revision-dialog" +import { DataTableColumnHeaderSimple } from "@/components/data-table/data-table-column-simple-header" +import { AddRevisionDialog } from "./add-revision-dialog" + +interface GetAttachmentColumnsProps { + onSelectAttachment: (attachment: any) => void +} + +export function getAttachmentColumns({ + onSelectAttachment +}: GetAttachmentColumnsProps): 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, + }, + + /** ───────────── 문서 정보 ───────────── */ + { + accessorKey: "serialNo", + header: ({ column }) => ( + + ), + cell: ({ row }) => ( + + ), + size: 100, + }, + { + accessorKey: "attachmentType", + header: ({ column }) => ( + + ), + cell: ({ row }) => { + const type = row.getValue("attachmentType") as string + return ( + + {type} + + ) + }, + size:100 + }, + { + accessorKey: "originalFileName", + header: ({ column }) => ( + + ), + cell: ({ row }) => { + const fileName = row.getValue("originalFileName") as string + return ( +
+ +
+
+ {fileName} +
+
+
+ ) + }, + size:250 + }, + { + id: "currentRevision", + header: ({ column }) => ( + + ), + cell: ({ row }) => ( + + ), + size: 100, + }, + { + accessorKey: "description", + header: ({ column }) => ( + + ), + cell: ({ row }) => { + const description = row.getValue("description") as string + return description + ?
{description}
+ : - + }, + }, + + /** ───────────── 파일 정보 ───────────── */ + // { + // accessorKey: "fileSize", + // header: ({ column }) => ( + // + // ), + // cell: ({ row }) => { + // const size = row.getValue("fileSize") as number + // return size ? formatBytes(size) : "-" + // }, + // }, + { + accessorKey: "createdAt", + header: ({ column }) => ( + + ), + cell: ({ row }) => { + const created = row.getValue("createdAt") as Date + const updated = row.original.updatedAt as Date + return ( +
+
{formatDate(created)}
+
+ {row.original.createdByName} +
+ {updated && new Date(updated) > new Date(created) && ( +
+ 수정: {formatDate(updated)} +
+ )} +
+ ) + }, + maxSize:150 + }, + + /** ───────────── 벤더 응답 현황 ───────────── */ + { + id: "vendorCount", + header: ({ column }) => ( + + ), + cell: ({ row }) => { + const stats = row.original.responseStats + return stats + ? ( +
+
{stats.totalVendors}
+
+ 활성: {stats.totalVendors - stats.waivedCount} +
+
+ ) + : - + }, + }, + { + id: "responseStatus", + header: ({ column }) => ( + + ), + cell: ({ row }) => { + const stats = row.original.responseStats + return stats + ? ( +
+
+
+ +
+ + {stats.responseRate}% + +
+
+ + 응답: {stats.respondedCount} + + + 대기: {stats.pendingCount} + + {stats.waivedCount > 0 && ( + + 면제: {stats.waivedCount} + + )} +
+
+ ) + : - + }, + }, + + /** ───────────── 액션 ───────────── */ + { + id: "actions", + enableHiding: false, + cell: ({ row }) => { + const [isAddRevisionOpen, setIsAddRevisionOpen] = React.useState(false) + + return ( + <> + + + + + + onSelectAttachment(row.original)}> + + 벤더 응답 보기 + + + + 미리보기 + + row.original.filePath && window.open(row.original.filePath, "_blank")} + > + + 다운로드 + + + setIsAddRevisionOpen(true)}> + + 새 리비전 추가 + + + 삭제 + + + + + window.location.reload()} + /> + + ) + }, + size: 40, + }, + ] +} -- cgit v1.2.3