From bf2db28586569499e44b58999f2e0f33ed4cdeb5 Mon Sep 17 00:00:00 2001
From: joonhoekim <26rote@gmail.com>
Date: Wed, 24 Sep 2025 17:36:08 +0900
Subject: (김준회) 구매 요청사항 반영 - vendor-pool 및 avl detail (이진용 프로)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 lib/avl/table/project-avl-table.tsx | 33 +++++++++++++++++++++++++++++++--
 1 file changed, 31 insertions(+), 2 deletions(-)

(limited to 'lib/avl/table/project-avl-table.tsx')

diff --git a/lib/avl/table/project-avl-table.tsx b/lib/avl/table/project-avl-table.tsx
index 9584c6f9..ad72b221 100644
--- a/lib/avl/table/project-avl-table.tsx
+++ b/lib/avl/table/project-avl-table.tsx
@@ -177,12 +177,40 @@ export const ProjectAvlTable = forwardRef<ProjectAvlTableRef, ProjectAvlTablePro
       const projectData = await getProjectInfoByCode(projectCode.trim(), 'both')
 
       if (projectData) {
+        // constructionSector 동적 결정
+        let constructionSector = "해양" // 기본값
+        if (projectData.source === 'projects') {
+          // projects 테이블의 경우: type='ship'이면 '조선', 그 외는 '해양'
+          constructionSector = projectData.type === 'ship' ? "조선" : "해양"
+        } else if (projectData.source === 'biddingProjects') {
+          // biddingProjects 테이블의 경우: sector가 'S'이면 '조선', 'M'이면 '해양'
+          constructionSector = projectData.sector === 'S' ? "조선" : "해양"
+        }
+
+        // htDivision 동적 결정
+        let htDivision = "" // 기본값
+        if (constructionSector === "조선") {
+          // constructionSector가 '조선'인 경우는 항상 H
+          htDivision = "H"
+        } else if (projectData.source === 'projects') {
+          // projects에서는 TYPE_MDG 컬럼이 Top이면 T, Hull이면 H
+          htDivision = projectData.typeMdg === 'Top' ? "T" : "H"
+        } else if (projectData.source === 'biddingProjects') {
+          if (projectData.sector === 'S') {
+            // biddingProjects에서 sector가 S이면 HtDivision은 항상 H
+            htDivision = "H"
+          } else if (projectData.sector === 'M') {
+            // biddingProjects에서 sector가 M인 경우: pjtType이 TOP이면 'T', HULL이면 'H'
+            htDivision = projectData.pjtType === 'TOP' ? "T" : "H"
+          }
+        }
+
         // 프로젝트 정보 설정
         setProjectInfo({
           projectName: projectData.projectName || "",
-          constructionSector: "조선", // 기본값으로 조선 설정 (필요시 로직 변경)
+          constructionSector: constructionSector,
           shipType: projectData.shipType || projectData.projectMsrm || "",
-          htDivision: projectData.projectHtDivision || ""
+          htDivision: htDivision
         })
 
         // 검색 상태 설정
@@ -307,6 +335,7 @@ export const ProjectAvlTable = forwardRef<ProjectAvlTableRef, ProjectAvlTablePro
     getFilteredRowModel: getFilteredRowModel(),
     manualPagination: true,
     pageCount,
+    columnResizeMode: "onChange",
     state: {
       pagination,
     },
-- 
cgit v1.2.3

