From fd4909bba7be8abc1eeab9ae1b4621c66a61604a Mon Sep 17 00:00:00 2001
From: joonhoekim <26rote@gmail.com>
Date: Sun, 23 Nov 2025 16:40:37 +0900
Subject: (김준회) 돌체 재개발 - 1차 (다운로드 오류 수정 필요)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 lib/dolce/table/gtt-drawing-list-columns.tsx | 166 +++++++++++++++++++++++++++
 1 file changed, 166 insertions(+)
 create mode 100644 lib/dolce/table/gtt-drawing-list-columns.tsx

(limited to 'lib/dolce/table/gtt-drawing-list-columns.tsx')

diff --git a/lib/dolce/table/gtt-drawing-list-columns.tsx b/lib/dolce/table/gtt-drawing-list-columns.tsx
new file mode 100644
index 00000000..2ff2d7e2
--- /dev/null
+++ b/lib/dolce/table/gtt-drawing-list-columns.tsx
@@ -0,0 +1,166 @@
+"use client";
+
+import { ColumnDef } from "@tanstack/react-table";
+import { GttDwgReceiptItem } from "../actions";
+
+// 날짜 포맷 헬퍼
+function formatDate(dateStr: string | null): string | null {
+  if (!dateStr || dateStr.length !== 8) return null;
+  return `${dateStr.substring(0, 4)}-${dateStr.substring(4, 6)}-${dateStr.substring(6, 8)}`;
+}
+
+// Document Type 필터
+export type DocumentType = "ALL" | "GTT_DELIVERABLES" | "SHI_INPUT";
+
+interface GttDrawingListColumnsOptions {
+  documentType: DocumentType;
+}
+
+export function createGttDrawingListColumns({
+  documentType,
+}: GttDrawingListColumnsOptions): ColumnDef<GttDwgReceiptItem>[] {
+  const baseColumns: ColumnDef<GttDwgReceiptItem>[] = [
+    {
+      accessorKey: "DrawingNo",
+      header: "도면번호",
+      minSize: 200,
+      cell: ({ row }) => {
+        return <div className="font-medium">{row.getValue("DrawingNo")}</div>;
+      },
+    },
+    {
+      accessorKey: "DrawingName",
+      header: "도면명",
+      minSize: 400,
+      cell: ({ row }) => {
+        return <div>{row.getValue("DrawingName")}</div>;
+      },
+    },
+    {
+      accessorKey: "Discipline",
+      header: "설계공종",
+      minSize: 80,
+    },
+    {
+      accessorKey: "Manager",
+      header: "담당자명",
+      minSize: 200,
+      cell: ({ row }) => {
+        const managerENM = row.original.ManagerENM;
+        const manager = row.getValue("Manager");
+        return <div>{managerENM || manager}</div>;
+      },
+    },
+    {
+      accessorKey: "DrawingMoveGbn",
+      header: "구분",
+      minSize: 120,
+    },
+  ];
+
+  // Document Type에 따른 날짜 컬럼
+  const dateColumns: ColumnDef<GttDwgReceiptItem>[] = [];
+
+  // ALL: 모든 컬럼 표시
+  if (documentType === "ALL") {
+    dateColumns.push(
+      {
+        accessorKey: "GTTInput_PlanDate",
+        header: "GTT Input 예정일",
+        minSize: 150,
+        cell: ({ row }) => formatDate(row.getValue("GTTInput_PlanDate")),
+      },
+      {
+        accessorKey: "GTTInput_ResultDate",
+        header: "GTT Input 결과일",
+        minSize: 150,
+        cell: ({ row }) => formatDate(row.getValue("GTTInput_ResultDate")),
+      },
+      {
+        accessorKey: "GTTPreDwg_PlanDate",
+        header: "GTT Pre 예정일",
+        minSize: 140,
+        cell: ({ row }) => formatDate(row.getValue("GTTPreDwg_PlanDate")),
+      },
+      {
+        accessorKey: "GTTPreDwg_ResultDate",
+        header: "GTT Pre 결과일",
+        minSize: 140,
+        cell: ({ row }) => formatDate(row.getValue("GTTPreDwg_ResultDate")),
+      },
+      {
+        accessorKey: "GTTWorkingDwg_PlanDate",
+        header: "GTT Working 예정일",
+        minSize: 160,
+        cell: ({ row }) => formatDate(row.getValue("GTTWorkingDwg_PlanDate")),
+      },
+      {
+        accessorKey: "GTTWorkingDwg_ResultDate",
+        header: "GTT Working 결과일",
+        minSize: 160,
+        cell: ({ row }) => formatDate(row.getValue("GTTWorkingDwg_ResultDate")),
+      }
+    );
+  }
+  // SHI_INPUT: 도면제출 (GTTInput만)
+  else if (documentType === "SHI_INPUT") {
+    dateColumns.push(
+      {
+        accessorKey: "GTTInput_PlanDate",
+        header: "Input 예정일",
+        minSize: 120,
+        cell: ({ row }) => formatDate(row.getValue("GTTInput_PlanDate")),
+      },
+      {
+        accessorKey: "GTTInput_ResultDate",
+        header: "Input 결과일",
+        minSize: 120,
+        cell: ({ row }) => formatDate(row.getValue("GTTInput_ResultDate")),
+      }
+    );
+  }
+  // GTT_DELIVERABLES: 도면입수 (Pre, Working)
+  else if (documentType === "GTT_DELIVERABLES") {
+    dateColumns.push(
+      {
+        accessorKey: "GTTPreDwg_PlanDate",
+        header: "Pre 예정일",
+        minSize: 120,
+        cell: ({ row }) => formatDate(row.getValue("GTTPreDwg_PlanDate")),
+      },
+      {
+        accessorKey: "GTTPreDwg_ResultDate",
+        header: "Pre 결과일",
+        minSize: 120,
+        cell: ({ row }) => formatDate(row.getValue("GTTPreDwg_ResultDate")),
+      },
+      {
+        accessorKey: "GTTWorkingDwg_PlanDate",
+        header: "Working 예정일",
+        minSize: 130,
+        cell: ({ row }) => formatDate(row.getValue("GTTWorkingDwg_PlanDate")),
+      },
+      {
+        accessorKey: "GTTWorkingDwg_ResultDate",
+        header: "Working 결과일",
+        minSize: 130,
+        cell: ({ row }) => formatDate(row.getValue("GTTWorkingDwg_ResultDate")),
+      }
+    );
+  }
+
+  // 생성일시 컬럼
+  const endColumns: ColumnDef<GttDwgReceiptItem>[] = [
+    {
+      accessorKey: "CreateDt",
+      header: "생성일시",
+      minSize: 200,
+      cell: ({ row }) => {
+        return <div className="text-sm text-muted-foreground">{row.getValue("CreateDt")}</div>;
+      },
+    },
+  ];
+
+  return [...baseColumns, ...dateColumns, ...endColumns];
+}
+
-- 
cgit v1.2.3

