diff --git a/src/components/estimate/Estimate.jsx b/src/components/estimate/Estimate.jsx index 8b8b38bc..38ff2289 100644 --- a/src/components/estimate/Estimate.jsx +++ b/src/components/estimate/Estimate.jsx @@ -99,7 +99,6 @@ export default function Estimate({}) { const initEstimate = (currPid = currentPid) => { console.log('🚀 ~ initEstimate ~ currPid:', currPid) - setCableItem('') closeAll() setObjectNo(objectRecoil.floorPlanObjectNo) @@ -1031,8 +1030,9 @@ export default function Estimate({}) { item.showSaleTotPrice = '0' } }) - + let dispCableFlgCnt = 0 estimateContextState.itemList.forEach((item) => { + // console.log('YJSS::::::::', item) if (item.delFlg === '0') { let amount = Number(item.amount?.replace(/[^0-9]/g, '').replaceAll(',', '')) || 0 let salePrice @@ -1066,8 +1066,19 @@ export default function Estimate({}) { item.showSalePrice = '0' item.showSaleTotPrice = '0' } + + if (item.dispCableFlg === '1') { + // console.log('YJSS22222::::::::', item) + dispCableFlgCnt++ + setCableItem(item.itemId) + } } }) + + if (dispCableFlgCnt === 0) { + setCableItem('100038') + } + let pkgAsp = estimateContextState.pkgAsp ? Number(estimateContextState.pkgAsp.replaceAll(',', '')) : 0 totals.pkgTotPrice = pkgAsp * totals.totVolKw * 1000 @@ -1095,6 +1106,7 @@ export default function Estimate({}) { } }) + let dispCableFlgCnt = 0 estimateContextState.itemList.forEach((item) => { delete item.showSalePrice delete item.showSaleTotPrice @@ -1122,9 +1134,21 @@ export default function Estimate({}) { item.showSalePrice = '0' item.showSaleTotPrice = '0' } + + if (item.dispCableFlg === '1') { + dispCableFlgCnt++ + } + + if (item.dispCableFlg === '1') { + setCableItem(item.itemId) + } } }) + if (dispCableFlgCnt === 0) { + setCableItem('100038') + } + totals.vatPrice = totals.supplyPrice * 0.1 totals.totPrice = totals.supplyPrice + totals.vatPrice @@ -1167,6 +1191,26 @@ export default function Estimate({}) { } }, [estimateContextState]) + useEffect(() => { + if (cableItemList.lenght > 0 || estimateContextState?.itemList.length > 0) { + let dispCableFlgCnt = 0 + estimateContextState.itemList.map((item) => { + if (item.dispCableFlg === '1') { + dispCableFlgCnt++ + cableItemList.map((cable) => { + if (item.itemId === cable.clRefChr1) { + cable.clRefChr3 = item.itemName + } + }) + } + }) + + if (dispCableFlgCnt === 0) { + setCableItem('100038') + } + } + }, [estimateContextState?.itemList, cableItemList]) + return (