From 8e47b69266cbd322d020ea797fb2bf754c60bce4 Mon Sep 17 00:00:00 2001 From: basssy Date: Tue, 26 Nov 2024 15:05:50 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B2=AC=EC=A0=81=EC=84=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/estimate/Estimate.jsx | 39 +++++++++++-------- .../estimate/useEstimateController.js | 3 +- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/src/components/estimate/Estimate.jsx b/src/components/estimate/Estimate.jsx index 1846b2d5..94ad68ae 100644 --- a/src/components/estimate/Estimate.jsx +++ b/src/components/estimate/Estimate.jsx @@ -447,7 +447,6 @@ export default function Estimate({ params }) { }) //아이템들 중 조건에 맞는애들 뽑아서 상단 공급가액 부가세 총액 수정 setItemChangeYn(true) - } else { } } @@ -471,10 +470,15 @@ export default function Estimate({ params }) { updateList = estimateContextState.itemList.map((item) => { if (item.dispOrder === dispOrder) { return { ...item, ...updates } + } else if (item.paDispOrder === dispOrder) { + return { ...item, ...updates, amount: (item.bomAmount * amount?.replaceAll(',', '')).toLocaleString(), saleTotPrice: '0' } } else { return item } }) + + console.log('updateList::', updateList) + // return setEstimateContextState({ itemList: updateList, }) @@ -556,7 +560,6 @@ export default function Estimate({ params }) { return { ...item, ...updates } } else if (item.paDispOrder === dispOrder) { return { ...item, delFlg: '0' } - // return { ...item, delFlg: '1' } } else { return item } @@ -569,14 +572,16 @@ export default function Estimate({ params }) { bomItem.dispOrder = (index + 1 + maxItemDispOrder).toString() bomItem.paDispOrder = dispOrder bomItem.salePrice = '0' - //unitPrice는?? bomItem.saleTotPrice = '0' + bomItem.unitPrice = '0' + bomItem.amount = bomItem.bomAmount } else { bomItem.dispOrder = (index + 1 + Number(dispOrder)).toString() bomItem.paDispOrder = dispOrder bomItem.salePrice = '0' - //unitPrice는?? bomItem.saleTotPrice = '0' + bomItem.unitPrice = '0' + bomItem.amount = bomItem.bomAmount } bomItem.delFlg = '0' @@ -620,6 +625,8 @@ export default function Estimate({ params }) { } }) + console.log('updateList::', updateList) + let delCnt = 0 updateList.map((item) => { if (item.delFlg === '1') { @@ -696,15 +703,16 @@ export default function Estimate({ params }) { estimateContextState.itemList.map((item) => { if (item.delFlg === '0') { let amount = Number(item.amount?.replace(/[^0-9]/g, '').replaceAll(',', '')) - let price = Number(item.saleTotPrice?.replaceAll(',', '')) + console.log('amount::', amount) let salePrice = Number(item.salePrice?.replaceAll(',', '')) + let saleTotPrice = Number(item.saleTotPrice?.replaceAll(',', '')) if (isNaN(amount)) { amount = 0 } - if (isNaN(price)) { - price = 0 + if (isNaN(saleTotPrice)) { + saleTotPrice = 0 } if (isNaN(salePrice)) { @@ -715,9 +723,7 @@ export default function Estimate({ params }) { const volKw = (item.pnowW * amount) / 1000 totVolKw += volKw } - - // const price - supplyPrice += price + // const saleTotPrice totAmount += amount if (item.pkgMaterialFlg === '1') { const pkgPrice = amount * salePrice @@ -725,6 +731,7 @@ export default function Estimate({ params }) { //YJSS는 PKG제외상품들만(1) 모아서 수량 * 단가를 공급가액(supplyPrice)에 추가로 더해줌 addSupplyPrice += pkgPrice } + if (!item.paDispOrder) { //paDispOrder if (item.pkgMaterialFlg === '0') { @@ -735,7 +742,7 @@ export default function Estimate({ params }) { } }) - supplyPrice += addSupplyPrice + supplyPrice = addSupplyPrice + Number(estimateContextState.pkgTotPrice) vatPrice = supplyPrice * 0.1 totPrice = supplyPrice + vatPrice setEstimateContextState({ @@ -1145,15 +1152,15 @@ export default function Estimate({ params }) {
{getMessage('estimate.detail.sepcialEstimateProductInfo.supplyPrice')}
-
{convertNumberToPriceDecimalToFixed(estimateContextState?.supplyPrice, 2)}
+
{convertNumberToPriceDecimal(estimateContextState?.supplyPrice)}
{getMessage('estimate.detail.sepcialEstimateProductInfo.vatPrice')}
-
{convertNumberToPriceDecimalToFixed(estimateContextState?.vatPrice, 2)}
+
{convertNumberToPriceDecimal(estimateContextState?.vatPrice)}
{getMessage('estimate.detail.sepcialEstimateProductInfo.totPrice')}
-
{convertNumberToPriceDecimalToFixed(estimateContextState?.totPrice, 2)}
+
{convertNumberToPriceDecimal(estimateContextState?.totPrice)}
@@ -1189,7 +1196,7 @@ export default function Estimate({ params }) { {getMessage('estimate.detail.sepcialEstimateProductInfo.pkgWeight')} {convertNumberToPriceDecimalToFixed(estimateContextState?.totVolKw, 2)} {getMessage('estimate.detail.sepcialEstimateProductInfo.pkgPrice')} - {convertNumberToPriceDecimalToFixed(estimateContextState?.pkgTotPrice, 2)} + {convertNumberToPriceDecimal(estimateContextState?.pkgTotPrice)} @@ -1405,7 +1412,7 @@ export default function Estimate({ params }) { */} - {convertNumberToPriceDecimalToFixed(item?.saleTotPrice?.replaceAll(',', ''), 2)} + {convertNumberToPriceDecimal(item?.saleTotPrice?.replaceAll(',', ''))} {/* {item?.showSaleTotPrice === '0' ? ( ) : ( diff --git a/src/hooks/floorPlan/estimate/useEstimateController.js b/src/hooks/floorPlan/estimate/useEstimateController.js index c5b8537c..0bf4bad7 100644 --- a/src/hooks/floorPlan/estimate/useEstimateController.js +++ b/src/hooks/floorPlan/estimate/useEstimateController.js @@ -80,7 +80,7 @@ export const useEstimateController = (planNo) => { itemId: '', //제품번호 itemNo: '', itemName: '', //형명 - amount: '0', //수량 + amount: '', //수량 unitPrice: '0', unit: '', //단위 salePrice: '', //단가 @@ -88,6 +88,7 @@ export const useEstimateController = (planNo) => { itemChangeFlg: '1', //추가시 체인지플래그 1로 partAdd: '1', //NEW 체인지 플래그 delFlg: '0', //삭제 플래그 0 삭제하면 1 + // addFlg: '1', //제품추가해서 추가된건지 구분값 }, ], })