From f93493f68c9f368e10f1c3379f1c1384068e3b14 Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Mon, 8 Sep 2025 10:29:19 +0000
Subject: (대표님, 최겸) rfqLast, bidding, prequote
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../vendor/components/pr-items-pricing-table.tsx   | 23 +++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

(limited to 'lib/bidding/vendor/components/pr-items-pricing-table.tsx')

diff --git a/lib/bidding/vendor/components/pr-items-pricing-table.tsx b/lib/bidding/vendor/components/pr-items-pricing-table.tsx
index 01885f7a..1dee7adb 100644
--- a/lib/bidding/vendor/components/pr-items-pricing-table.tsx
+++ b/lib/bidding/vendor/components/pr-items-pricing-table.tsx
@@ -39,6 +39,8 @@ interface PrItem {
   materialDescription: string | null
   quantity: string | null
   quantityUnit: string | null
+  totalWeight: string | null
+  weightUnit: string | null
   currency: string | null
   requestedDeliveryDate: string | null
   hasSpecDocument: boolean | null
@@ -221,11 +223,20 @@ export function PrItemsPricingTable({
       if (q.prItemId === prItemId) {
         const updated = { ...q, [field]: value }
         
-        // 단가나 수량이 변경되면 금액 자동 계산
+        // 단가가 변경되면 금액 자동 계산 (수량 우선, 없으면 중량 사용)
         if (field === 'bidUnitPrice') {
           const prItem = prItems.find(item => item.id === prItemId)
-          const quantity = parseFloat(prItem?.quantity || '1')
-          updated.bidAmount = updated.bidUnitPrice * quantity
+          let multiplier = 1
+          
+          if (prItem?.quantity && parseFloat(prItem.quantity) > 0) {
+            // 수량이 있으면 수량 기준
+            multiplier = parseFloat(prItem.quantity)
+          } else if (prItem?.totalWeight && parseFloat(prItem.totalWeight) > 0) {
+            // 수량이 없으면 중량 기준
+            multiplier = parseFloat(prItem.totalWeight)
+          }
+          
+          updated.bidAmount = updated.bidUnitPrice * multiplier
         }
         
         return updated
@@ -273,6 +284,8 @@ export function PrItemsPricingTable({
                   <TableHead>자재내역</TableHead>
                   <TableHead>수량</TableHead>
                   <TableHead>단위</TableHead>
+                  <TableHead>중량</TableHead>
+                  <TableHead>중량단위</TableHead>
                   <TableHead>견적단가</TableHead>
                   <TableHead>견적금액</TableHead>
                   <TableHead>납품예정일</TableHead>
@@ -310,6 +323,10 @@ export function PrItemsPricingTable({
                         {item.quantity ? parseFloat(item.quantity).toLocaleString() : '-'}
                       </TableCell>
                       <TableCell>{item.quantityUnit || '-'}</TableCell>
+                      <TableCell className="text-right">
+                        {item.totalWeight ? parseFloat(item.totalWeight).toLocaleString() : '-'}
+                      </TableCell>
+                      <TableCell>{item.weightUnit || '-'}</TableCell>
                       <TableCell>
                         {readOnly ? (
                           <span className="font-medium">
-- 
cgit v1.2.3

