From ff902243a658067fae858a615c0629aa2e0a4837 Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Wed, 11 Jun 2025 12:18:38 +0000
Subject: (대표님) 20250611 21시 15분 OCR 등
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../table/enhanced-doc-table-columns.tsx           | 222 ++++++++++++---------
 1 file changed, 128 insertions(+), 94 deletions(-)

(limited to 'lib/vendor-document-list/table/enhanced-doc-table-columns.tsx')

diff --git a/lib/vendor-document-list/table/enhanced-doc-table-columns.tsx b/lib/vendor-document-list/table/enhanced-doc-table-columns.tsx
index c8487d82..191ce3e2 100644
--- a/lib/vendor-document-list/table/enhanced-doc-table-columns.tsx
+++ b/lib/vendor-document-list/table/enhanced-doc-table-columns.tsx
@@ -1,4 +1,4 @@
-// updated-enhanced-doc-table-columns.tsx
+// enhanced-doc-table-columns-with-b4.tsx
 "use client"
 
 import * as React from "react"
@@ -32,13 +32,15 @@ import {
   Edit,
   Trash2,
   Building,
-  Code
+  Code,
+  Settings
 } from "lucide-react"
 import { cn } from "@/lib/utils"
 
 interface GetColumnsProps {
   setRowAction: React.Dispatch<React.SetStateAction<DataTableRowAction<EnhancedDocumentsView> | null>>
   projectType: string | null
+  drawingKindFilter?: string // ✅ 추가
 }
 
 // 유틸리티 함수들
@@ -140,11 +142,12 @@ const DueDateInfo = ({
 
 export function getUpdatedEnhancedColumns({
   setRowAction,
-  projectType
+  projectType,
+  drawingKindFilter = "all" // ✅ 추가
 }: GetColumnsProps): ColumnDef<EnhancedDocumentsView>[] {
   const isPlantProject = projectType === "plant"
+  const showB4Columns = drawingKindFilter === "B4" // ✅ B4 컬럼 표시 여부
 
-  
   // 기본 컬럼들
   const baseColumns: ColumnDef<EnhancedDocumentsView>[] = [
     // 체크박스 선택
@@ -174,7 +177,7 @@ export function getUpdatedEnhancedColumns({
       enableHiding: false,
     },
 
-    // 문서번호 + 우선순위
+    // 문서번호 + Drawing Kind
     {
       accessorKey: "docNumber",
       header: ({ column }) => (
@@ -185,6 +188,11 @@ export function getUpdatedEnhancedColumns({
         return (
           <div className="flex flex-col gap-1 items-start">
             <span className="font-mono text-sm font-medium">{doc.docNumber}</span>
+            {doc.drawingKind && (
+              <Badge variant="outline" className="text-xs">
+                {doc.drawingKind}
+              </Badge>
+            )}
           </div>
         )
       },
@@ -196,7 +204,7 @@ export function getUpdatedEnhancedColumns({
     },
   ]
 
-  // ✅ Ship 프로젝트용 추가 컬럼들
+  // ✅ Plant 프로젝트용 추가 컬럼들
   const plantColumns: ColumnDef<EnhancedDocumentsView>[] = isPlantProject ? [
     // 벤더 문서번호
     {
@@ -233,7 +241,6 @@ export function getUpdatedEnhancedColumns({
         const doc = row.original
         return (
           <div className="flex items-center gap-2">
-            {/* <Code className="w-4 h-4 text-gray-500" /> */}
             <span className="font-mono text-sm font-medium text-gray-700">
               {doc.projectCode || '-'}
             </span>
@@ -258,7 +265,6 @@ export function getUpdatedEnhancedColumns({
         return (
           <div className="flex flex-col gap-1 items-start">
             <div className="flex items-center gap-2">
-              {/* <Building className="w-4 h-4 text-gray-500" /> */}
               <span className="text-sm font-medium text-gray-900">
                 {doc.vendorName || '-'}
               </span>
@@ -279,6 +285,116 @@ export function getUpdatedEnhancedColumns({
     },
   ] : []
 
+  // ✅ B4 전용 컬럼들 (B4 필터 선택 시에만 표시)
+  const b4Columns: ColumnDef<EnhancedDocumentsView>[] = showB4Columns ? [
+    {
+      accessorKey: "cGbn",
+      header: ({ column }) => (
+        <DataTableColumnHeaderSimple column={column} title="cGbn" />
+      ),
+      cell: ({ row }) => {
+        const doc = row.original
+        return (
+          <div className="flex items-center gap-2">
+            <Badge variant="secondary" className="text-xs">
+              {doc.cGbn || '-'}
+            </Badge>
+          </div>
+        )
+      },
+      size: 100,
+      enableResizing: true,
+      meta: {
+        excelHeader: "cGbn"
+      },
+    },
+    {
+      accessorKey: "dGbn",
+      header: ({ column }) => (
+        <DataTableColumnHeaderSimple column={column} title="dGbn" />
+      ),
+      cell: ({ row }) => {
+        const doc = row.original
+        return (
+          <div className="flex items-center gap-2">
+            <Badge variant="secondary" className="text-xs">
+              {doc.dGbn || '-'}
+            </Badge>
+          </div>
+        )
+      },
+      size: 100,
+      enableResizing: true,
+      meta: {
+        excelHeader: "dGbn"
+      },
+    },
+    {
+      accessorKey: "degreeGbn",
+      header: ({ column }) => (
+        <DataTableColumnHeaderSimple column={column} title="degreeGbn" />
+      ),
+      cell: ({ row }) => {
+        const doc = row.original
+        return (
+          <div className="flex items-center gap-2">
+            <Badge variant="secondary" className="text-xs">
+              {doc.degreeGbn || '-'}
+            </Badge>
+          </div>
+        )
+      },
+      size: 100,
+      enableResizing: true,
+      meta: {
+        excelHeader: "degreeGbn"
+      },
+    },
+    {
+      accessorKey: "deptGbn",
+      header: ({ column }) => (
+        <DataTableColumnHeaderSimple column={column} title="deptGbn" />
+      ),
+      cell: ({ row }) => {
+        const doc = row.original
+        return (
+          <div className="flex items-center gap-2">
+            <Badge variant="secondary" className="text-xs">
+              {doc.deptGbn || '-'}
+            </Badge>
+          </div>
+        )
+      },
+      size: 100,
+      enableResizing: true,
+      meta: {
+        excelHeader: "deptGbn"
+      },
+    },
+    {
+      accessorKey: "sGbn",
+      header: ({ column }) => (
+        <DataTableColumnHeaderSimple column={column} title="sGbn" />
+      ),
+      cell: ({ row }) => {
+        const doc = row.original
+        return (
+          <div className="flex items-center gap-2">
+            <Badge variant="secondary" className="text-xs">
+              {doc.sGbn || '-'}
+            </Badge>
+          </div>
+        )
+      },
+      size: 100,
+      enableResizing: true,
+      meta: {
+        excelHeader: "sGbn"
+      },
+    },
+
+  ] : []
+
   // 나머지 공통 컬럼들
   const commonColumns: ColumnDef<EnhancedDocumentsView>[] = [
     // 문서명 + 담당자
@@ -310,7 +426,7 @@ export function getUpdatedEnhancedColumns({
           </div>
         )
       },
-      size: isPlantProject ? 200 : 250, // Ship 프로젝트일 때는 너비 조정
+      size: showB4Columns ? 180 : (isPlantProject ? 200 : 250), // ✅ B4 컬럼이 있을 때 너비 조정
       enableResizing: true,
       meta: {
         excelHeader: "문서명"
@@ -378,7 +494,7 @@ export function getUpdatedEnhancedColumns({
       size: 140,
       enableResizing: true,
       meta: {
-        excelHeader: "계획일"
+        excelHeader: "일정"
       },
     },
 
@@ -476,7 +592,6 @@ export function getUpdatedEnhancedColumns({
         const canApprove = doc.currentStageStatus === 'SUBMITTED'
         const isPlantProject = projectType === "plant"
 
-        // 메뉴 아이템들을 그룹별로 정의
         const viewActions = [
           {
             key: "view",
@@ -519,7 +634,6 @@ export function getUpdatedEnhancedColumns({
           }
         ]
 
-        // 각 그룹에서 표시될 아이템이 있는지 확인
         const hasEditActions = editActions.some(action => action.show)
         const hasFileActions = fileActions.some(action => action.show)
         const hasDangerActions = dangerActions.some(action => action.show)
@@ -536,7 +650,6 @@ export function getUpdatedEnhancedColumns({
               </Button>
             </DropdownMenuTrigger>
             <DropdownMenuContent align="end" className="w-48">
-              {/* 기본 액션 그룹 */}
               {viewActions.map(action => action.show && (
                 <DropdownMenuItem
                   key={action.key}
@@ -551,7 +664,6 @@ export function getUpdatedEnhancedColumns({
                 </DropdownMenuItem>
               ))}
 
-              {/* 편집 액션 그룹 */}
               {hasEditActions && (
                 <>
                   <DropdownMenuSeparator />
@@ -571,7 +683,6 @@ export function getUpdatedEnhancedColumns({
                 </>
               )}
 
-              {/* 파일 액션 그룹 */}
               {hasFileActions && (
                 <>
                   <DropdownMenuSeparator />
@@ -591,7 +702,6 @@ export function getUpdatedEnhancedColumns({
                 </>
               )}
 
-              {/* 위험한 액션 그룹 */}
               {hasDangerActions && (
                 <>
                   <DropdownMenuSeparator />
@@ -621,84 +731,8 @@ export function getUpdatedEnhancedColumns({
   // ✅ 모든 컬럼을 순서대로 결합
   return [
     ...baseColumns,      // 체크박스, 문서번호
-    ...plantColumns,      // Ship 전용 컬럼들 (조건부)
+    ...plantColumns,     // Plant 전용 컬럼들 (조건부)
+    ...b4Columns,        // B4 전용 컬럼들 (조건부)
     ...commonColumns     // 나머지 공통 컬럼들
   ]
-}
-
-// 확장된 행 컨텐츠 컴포넌트 (업데이트된 버전)
-export const UpdatedExpandedRowContent = ({
-  document
-}: {
-  document: EnhancedDocumentsView
-}) => {
-  if (!document.allStages || document.allStages.length === 0) {
-    return (
-      <div className="p-4 text-sm text-gray-500 italic">
-        스테이지 정보가 없습니다.
-      </div>
-    )
-  }
-
-  return (
-    <div className="p-4 w-1/2">
-      <h4 className="font-medium mb-3 flex items-center gap-2">
-        <FileText className="w-4 h-4" />
-        전체 스테이지 현황
-      </h4>
-
-      <div className="grid gap-3">
-        {document.allStages.map((stage, index) => (
-          <div key={stage.id} className="flex items-center justify-between p-3 bg-white rounded-lg border">
-            <div className="flex items-center gap-3">
-              <div className="flex items-center gap-2">
-                <div className="w-6 h-6 rounded-full bg-gray-100 flex items-center justify-center text-xs font-medium">
-                  {stage.stageOrder || index + 1}
-                </div>
-                <div className={cn(
-                  "w-3 h-3 rounded-full",
-                  stage.stageStatus === 'COMPLETED' ? 'bg-green-500' :
-                    stage.stageStatus === 'IN_PROGRESS' ? 'bg-blue-500' :
-                      stage.stageStatus === 'SUBMITTED' ? 'bg-purple-500' :
-                        'bg-gray-300'
-                )} />
-              </div>
-
-              <div>
-                <div className="font-medium text-sm">{stage.stageName}</div>
-                {stage.assigneeName && (
-                  <div className="text-xs text-gray-500 flex items-center gap-1 mt-1">
-                    <User className="w-3 h-3" />
-                    {stage.assigneeName}
-                  </div>
-                )}
-              </div>
-            </div>
-
-            <div className="flex items-center gap-4 text-sm">
-              <div>
-                <span className="text-gray-500">계획: </span>
-                <span>{formatDate(stage.planDate)}</span>
-              </div>
-              {stage.actualDate && (
-                <div>
-                  <span className="text-gray-500">완료: </span>
-                  <span>{formatDate(stage.actualDate)}</span>
-                </div>
-              )}
-
-              <div className="flex items-center gap-2">
-                <Badge variant={getPriorityColor(stage.priority)} className="text-xs">
-                  {getPriorityText(stage.priority)}
-                </Badge>
-                <Badge variant={getStatusColor(stage.stageStatus)} className="text-xs">
-                  {getStatusText(stage.stageStatus)}
-                </Badge>
-              </div>
-            </div>
-          </div>
-        ))}
-      </div>
-    </div>
-  )
 }
\ No newline at end of file
-- 
cgit v1.2.3

