From 14f61e24947fb92dd71ec0a7196a6e815f8e66da Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Mon, 21 Jul 2025 07:54:26 +0000
Subject: (최겸)기술영업 RFQ 담당자 초대, 요구사항 반영
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../table/possible-items-table-columns.tsx         | 147 ++++++++++++++++++---
 1 file changed, 132 insertions(+), 15 deletions(-)

(limited to 'lib/tech-vendor-possible-items/table/possible-items-table-columns.tsx')

diff --git a/lib/tech-vendor-possible-items/table/possible-items-table-columns.tsx b/lib/tech-vendor-possible-items/table/possible-items-table-columns.tsx
index 520c089e..7fdcc900 100644
--- a/lib/tech-vendor-possible-items/table/possible-items-table-columns.tsx
+++ b/lib/tech-vendor-possible-items/table/possible-items-table-columns.tsx
@@ -11,7 +11,12 @@ type TechVendorPossibleItemsData = {
   vendorCode: string | null;
   vendorName: string;
   techVendorType: string;
+  vendorStatus: string;
   itemCode: string;
+  itemList: string | null;
+  workType: string | null;
+  shipTypes: string | null;
+  subItemList: string | null;
   createdAt: Date;
   updatedAt: Date;
 };
@@ -55,6 +60,70 @@ export function getColumns(): ColumnDef<TechVendorPossibleItemsData>[] {
         return <div className="font-medium">{itemCode}</div>;
       },
     },
+    {
+      accessorKey: "itemList",
+      header: ({ column }) => (
+        <DataTableColumnHeaderSimple column={column} title="아이템리스트" />
+      ),
+      cell: ({ row }) => {
+        const itemList = row.getValue("itemList") as string | null;
+        return <div className="max-w-[200px] truncate">{itemList || "-"}</div>;
+      },
+      filterFn: (row, id, value) => {
+        const itemList = row.getValue(id) as string | null;
+        if (!value) return true;
+        if (!itemList) return false;
+        return itemList.toLowerCase().includes(value.toLowerCase());
+      },
+    },
+    {
+      accessorKey: "workType",
+      header: ({ column }) => (
+        <DataTableColumnHeaderSimple column={column} title="공종" />
+      ),
+      cell: ({ row }) => {
+        const workType = row.getValue("workType") as string | null;
+        return <div className="font-medium">{workType || "-"}</div>;
+      },
+      filterFn: (row, id, value) => {
+        const workType = row.getValue(id) as string | null;
+        if (!value) return true;
+        if (!workType) return false;
+        return workType.toLowerCase().includes(value.toLowerCase());
+      },
+    },
+    {
+      accessorKey: "shipTypes",
+      header: ({ column }) => (
+        <DataTableColumnHeaderSimple column={column} title="선종" />
+      ),
+      cell: ({ row }) => {
+        const shipTypes = row.getValue("shipTypes") as string | null;
+        return <div className="font-medium">{shipTypes || "-"}</div>;
+      },
+      filterFn: (row, id, value) => {
+        const shipTypes = row.getValue(id) as string | null;
+        if (!value) return true;
+        if (!shipTypes) return false;
+        return shipTypes.toLowerCase().includes(value.toLowerCase());
+      },
+    },
+    {
+      accessorKey: "subItemList",
+      header: ({ column }) => (
+        <DataTableColumnHeaderSimple column={column} title="서브아이템리스트" />
+      ),
+      cell: ({ row }) => {
+        const subItemList = row.getValue("subItemList") as string | null;
+        return <div className="max-w-[200px] truncate">{subItemList || "-"}</div>;
+      },
+      filterFn: (row, id, value) => {
+        const subItemList = row.getValue(id) as string | null;
+        if (!value) return true;
+        if (!subItemList) return false;
+        return subItemList.toLowerCase().includes(value.toLowerCase());
+      },
+    },
     {
       accessorKey: "vendorCode",
       header: ({ column }) => (
@@ -91,37 +160,85 @@ export function getColumns(): ColumnDef<TechVendorPossibleItemsData>[] {
       cell: ({ row }) => {
         const techVendorType = row.getValue("techVendorType") as string;
         
-        // JSON 배열인지 확인하고 파싱
+        // 벤더 타입 파싱 개선
         let types: string[] = [];
-        try {
-          const parsed = JSON.parse(techVendorType || "[]");
-          types = Array.isArray(parsed) ? parsed : [techVendorType];
-        } catch {
-          types = [techVendorType];
+        if (!techVendorType) {
+          types = [];
+        } else if (techVendorType.startsWith('[') && techVendorType.endsWith(']')) {
+          // JSON 배열 형태
+          try {
+            const parsed = JSON.parse(techVendorType);
+            types = Array.isArray(parsed) ? parsed.filter(Boolean) : [techVendorType];
+          } catch {
+            types = [techVendorType];
+          }
+        } else if (techVendorType.includes(',')) {
+          // 콤마로 구분된 문자열
+          types = techVendorType.split(',').map(t => t.trim()).filter(Boolean);
+        } else {
+          // 단일 문자열
+          types = [techVendorType.trim()].filter(Boolean);
         }
 
         return (
           <div className="flex flex-wrap gap-1">
-            {types.map((type, index) => (
-              <Badge key={index} variant="secondary" className="text-xs">
+            {types.length > 0 ? types.map((type, index) => (
+              <Badge key={`${type}-${index}`} variant="secondary" className="text-xs">
                 {type}
               </Badge>
-            ))}
+            )) : (
+              <span className="text-muted-foreground">-</span>
+            )}
           </div>
         );
       },
       filterFn: (row, id, value) => {
         const techVendorType = row.getValue(id) as string;
-        try {
-          const parsed = JSON.parse(techVendorType || "[]");
-          const types = Array.isArray(parsed) ? parsed : [techVendorType];
-          return types.some(type => type.includes(value));
-        } catch {
-          return techVendorType?.includes(value) || false;
+        if (!techVendorType || !value) return false;
+        
+        let types: string[] = [];
+        if (techVendorType.startsWith('[') && techVendorType.endsWith(']')) {
+          try {
+            const parsed = JSON.parse(techVendorType);
+            types = Array.isArray(parsed) ? parsed : [techVendorType];
+          } catch {
+            types = [techVendorType];
+          }
+        } else if (techVendorType.includes(',')) {
+          types = techVendorType.split(',').map(t => t.trim());
+        } else {
+          types = [techVendorType.trim()];
         }
+        
+        return types.some(type => 
+          type.toLowerCase().includes(value.toLowerCase())
+        );
       },
     },
 
+    {
+      accessorKey: "vendorStatus",
+      header: ({ column }) => (
+        <DataTableColumnHeaderSimple column={column} title="벤더상태" />
+      ),
+      cell: ({ row }) => {
+        const vendorStatus = row.getValue("vendorStatus") as string;
+        const getStatusColor = (status: string) => {
+          switch (status) {
+            case "ACTIVE": return "bg-green-100 text-green-800";
+            case "PENDING_INVITE": return "bg-yellow-100 text-yellow-800";
+            case "PENDING_REVIEW": return "bg-blue-100 text-blue-800";
+            case "INACTIVE": return "bg-gray-100 text-gray-800";
+            default: return "bg-gray-100 text-gray-800";
+          }
+        };
+        return (
+          <Badge className={getStatusColor(vendorStatus)}>
+            {vendorStatus}
+          </Badge>
+        );
+      },
+    },
     {
       accessorKey: "createdAt",
       header: ({ column }) => (
-- 
cgit v1.2.3

