From d49ad5dee1e5a504e1321f6db802b647497ee9ff Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Thu, 23 Oct 2025 10:06:08 +0000
Subject: (임수민) TBE pr item 컬럼 표기 수정
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 lib/tbe-last/table/tbe-last-table-columns.tsx | 55 +++++++++++++++++++++++++--
 1 file changed, 51 insertions(+), 4 deletions(-)

(limited to 'lib/tbe-last/table/tbe-last-table-columns.tsx')

diff --git a/lib/tbe-last/table/tbe-last-table-columns.tsx b/lib/tbe-last/table/tbe-last-table-columns.tsx
index b18e51c0..886a41ba 100644
--- a/lib/tbe-last/table/tbe-last-table-columns.tsx
+++ b/lib/tbe-last/table/tbe-last-table-columns.tsx
@@ -15,8 +15,9 @@ import { TbeLastView } from "@/db/schema/tbeLastView"
 interface GetColumnsProps {
   onOpenSessionDetail: (sessionId: number) => void;
   onOpenDocuments: (sessionId: number) => void;
-  onOpenPrItems: (rfqId: number) => void;
+  onOpenPrItems: (sessionId: number) => void;
   onOpenEvaluation: (session: TbeLastView) => void;
+  getPrCountsOverride?: (sessionId: number) => { total: number, major: number } | undefined;
 }
 
 export function getColumns({
@@ -24,6 +25,7 @@ export function getColumns({
   onOpenDocuments,
   onOpenPrItems,
   onOpenEvaluation,
+  getPrCountsOverride,
 }: GetColumnsProps): ColumnDef<TbeLastView>[] {
   
   const columns: ColumnDef<TbeLastView>[] = [
@@ -60,6 +62,9 @@ export function getColumns({
       header: ({ column }) => (
         <DataTableColumnHeaderSimple column={column} title="TBE Code" />
       ),
+      meta: {
+        excelHeader: "TBE Code"
+      },
       cell: ({ row }) => {
         const sessionId = row.original.tbeSessionId;
         const sessionCode = row.original.sessionCode;
@@ -85,6 +90,9 @@ export function getColumns({
       ),
       cell: ({ row }) => row.original.rfqCode,
       size: 120,
+      meta: {
+        excelHeader: "RFQ Code"
+      },
     },
 
     {
@@ -144,6 +152,9 @@ export function getColumns({
       ),
       cell: ({ row }) => row.original.rfqTitle || "-",
       size: 200,
+      meta: {
+        excelHeader: "RFQ Title"
+      },
     },
     
     // RFQ Due Date
@@ -157,6 +168,9 @@ export function getColumns({
         return date ? formatDate(date, "KR") : "-";
       },
       size: 100,
+      meta: {
+        excelHeader: "Due Date"
+      },
     },
     
     // Package No
@@ -181,6 +195,9 @@ export function getColumns({
         );
       },
       size: 150,
+      meta: {
+        excelHeader: "Package No"
+      },
     },
     
     // Project
@@ -205,6 +222,9 @@ export function getColumns({
         );
       },
       size: 150,
+      meta: {
+        excelHeader: "Project"
+      },
     },
     
     // Vendor Code
@@ -215,6 +235,9 @@ export function getColumns({
       ),
       cell: ({ row }) => row.original.vendorCode || "-",
       size: 100,
+      meta: {
+        excelHeader: "Vendor Code"
+      },
     },
     
     // Vendor Name
@@ -225,6 +248,9 @@ export function getColumns({
       ),
       cell: ({ row }) => row.original.vendorName,
       size: 200,
+      meta: {
+        excelHeader: "Vendor Name"
+      },
     },
     
     // 구매담당자 (PIC Name)
@@ -235,6 +261,9 @@ export function getColumns({
       ),
       cell: ({ row }) => row.original.picName || "-",
       size: 120,
+      meta: {
+        excelHeader: "구매담당자"
+      },
     },
     
     // 설계담당자 (Engineering PIC Name)
@@ -245,6 +274,9 @@ export function getColumns({
       ),
       cell: ({ row }) => row.original.EngPicName || "-",
       size: 120,
+      meta: {
+        excelHeader: "설계담당자"
+      },
     },
     
     // TBE Status
@@ -253,6 +285,9 @@ export function getColumns({
       header: ({ column }) => (
         <DataTableColumnHeaderSimple column={column} title="Status" />
       ),
+      meta: {
+        excelHeader: "Status"
+      },
       cell: ({ row }) => {
         const status = row.original.sessionStatus;
         
@@ -287,6 +322,9 @@ export function getColumns({
       header: ({ column }) => (
         <DataTableColumnHeaderSimple column={column} title="Result" />
       ),
+      meta: {
+        excelHeader: "Result"
+      },
       cell: ({ row }) => {
         const result = row.original.evaluationResult;
         const session = row.original;
@@ -340,17 +378,23 @@ export function getColumns({
       header: ({ column }) => (
         <DataTableColumnHeaderSimple column={column} title="PR Items" />
       ),
+      meta: {
+        excelHeader: "PR Items"
+      },
       cell: ({ row }) => {
+        const sessionId = row.original.tbeSessionId;
         const rfqId = row.original.rfqId;
-        const totalCount = row.original.prItemsCount;
-        const majorCount = row.original.majorItemsCount;
+        const override = getPrCountsOverride?.(sessionId)
+        const totalCount = override?.total ?? row.original.prItemsCount;
+        const majorCount = override?.major ?? row.original.majorItemsCount;
+        // counts rendered from override when available
         
         return (
           <Button
             variant="ghost"
             size="sm"
             className="h-8 px-2"
-            onClick={() => onOpenPrItems(rfqId)}
+            onClick={() => onOpenPrItems(sessionId)}
           >
             <ListChecks className="h-4 w-4 mr-1" />
             <span className="text-xs">
@@ -369,6 +413,9 @@ export function getColumns({
       header: ({ column }) => (
         <DataTableColumnHeaderSimple column={column} title="Documents" />
       ),
+      meta: {
+        excelHeader: "Documents"
+      },
       cell: ({ row }) => {
         const sessionId = row.original.tbeSessionId;
         const buyerDocs = Number(row.original.buyerDocumentsCount);
-- 
cgit v1.2.3

