From 95866a13ba4e1c235373834460aa284b763fe0d9 Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Mon, 23 Jun 2025 09:03:29 +0000
Subject: (최겸) 기술영업 RFQ 개발(0620 요구사항, 첨부파일, REV 등)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 lib/techsales-rfq/table/rfq-table.tsx | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

(limited to 'lib/techsales-rfq/table/rfq-table.tsx')

diff --git a/lib/techsales-rfq/table/rfq-table.tsx b/lib/techsales-rfq/table/rfq-table.tsx
index 424ca70e..615753cd 100644
--- a/lib/techsales-rfq/table/rfq-table.tsx
+++ b/lib/techsales-rfq/table/rfq-table.tsx
@@ -57,6 +57,7 @@ interface TechSalesRfq {
   ptypeNm: string
   attachmentCount: number
   quotationCount: number
+  rfqType: "SHIP" | "TOP" | "HULL" | null
   // 필요에 따라 다른 필드들 추가
   [key: string]: unknown
 }
@@ -135,7 +136,7 @@ export function RFQListTable({
     to: searchParams?.get('to') || undefined,
     columnVisibility: {},
     columnOrder: [],
-    pinnedColumns: { left: [], right: ["items", "attachments"] },
+    pinnedColumns: { left: [], right: ["items", "attachments", "tbe-attachments", "cbe-attachments"] },
     groupBy: [],
     expandedRows: []
   }), [searchParams])
@@ -170,6 +171,7 @@ export function RFQListTable({
           setSelectedRfq({
             id: rfqData.id,
             rfqCode: rfqData.rfqCode,
+            rfqType: rfqData.rfqType, // 빠뜨린 rfqType 필드 추가
             biddingProjectId: rfqData.biddingProjectId,
             materialCode: rfqData.materialCode,
             dueDate: rfqData.dueDate,
@@ -201,6 +203,7 @@ export function RFQListTable({
           setProjectDetailRfq({
             id: projectRfqData.id,
             rfqCode: projectRfqData.rfqCode,
+            rfqType: projectRfqData.rfqType, // 빠뜨린 rfqType 필드 추가
             biddingProjectId: projectRfqData.biddingProjectId,
             materialCode: projectRfqData.materialCode,
             dueDate: projectRfqData.dueDate,
@@ -238,8 +241,11 @@ export function RFQListTable({
     }
   }, [rowAction])
   
+  // 첨부파일 시트 상태에 타입 추가
+  const [attachmentType, setAttachmentType] = React.useState<"RFQ_COMMON" | "TBE_RESULT" | "CBE_RESULT">("RFQ_COMMON")
+
   // 첨부파일 시트 열기 함수
-  const openAttachmentsSheet = React.useCallback(async (rfqId: number) => {
+  const openAttachmentsSheet = React.useCallback(async (rfqId: number, attachmentType: 'RFQ_COMMON'  | 'TBE_RESULT' | 'CBE_RESULT' = 'RFQ_COMMON') => {
     try {
       // 선택된 RFQ 찾기
       const rfq = tableData?.data?.find(r => r.id === rfqId)
@@ -248,6 +254,9 @@ export function RFQListTable({
         return
       }
 
+      // attachmentType을 RFQ_COMMON, TBE_RESULT, CBE_RESULT 중 하나로 변환
+      const validAttachmentType=attachmentType as "RFQ_COMMON" | "TBE_RESULT" | "CBE_RESULT"
+
       // 실제 첨부파일 목록 조회 API 호출
       const result = await getTechSalesRfqAttachments(rfqId)
       
@@ -256,8 +265,11 @@ export function RFQListTable({
         return
       }
 
+      // 해당 타입의 첨부파일만 필터링
+      const filteredAttachments = result.data.filter(att => att.attachmentType === validAttachmentType)
+
       // API 응답을 ExistingTechSalesAttachment 형식으로 변환
-      const attachments: ExistingTechSalesAttachment[] = result.data.map(att => ({
+      const attachments: ExistingTechSalesAttachment[] = filteredAttachments.map(att => ({
         id: att.id,
         techSalesRfqId: att.techSalesRfqId || rfqId, // null인 경우 rfqId 사용
         fileName: att.fileName,
@@ -265,12 +277,13 @@ export function RFQListTable({
         filePath: att.filePath,
         fileSize: att.fileSize || undefined,
         fileType: att.fileType || undefined,
-        attachmentType: att.attachmentType as "RFQ_COMMON" | "VENDOR_SPECIFIC",
+        attachmentType: att.attachmentType as "RFQ_COMMON" | "TBE_RESULT" | "CBE_RESULT",
         description: att.description || undefined,
         createdBy: att.createdBy,
         createdAt: att.createdAt,
       }))
       
+      setAttachmentType(validAttachmentType)
       setAttachmentsDefault(attachments)
       setSelectedRfqForAttachments(rfq as unknown as TechSalesRfq)
       setAttachmentsOpen(true)
@@ -561,6 +574,7 @@ export function RFQListTable({
         onOpenChange={setAttachmentsOpen}
         defaultAttachments={attachmentsDefault}
         rfq={selectedRfqForAttachments}
+        attachmentType={attachmentType}
         onAttachmentsUpdated={handleAttachmentsUpdated}
       />
 
-- 
cgit v1.2.3

