diff --git a/src/components/estimate/Estimate.jsx b/src/components/estimate/Estimate.jsx index 7eb23fa5..e506b6a2 100644 --- a/src/components/estimate/Estimate.jsx +++ b/src/components/estimate/Estimate.jsx @@ -58,7 +58,7 @@ export default function Estimate({ params }) { const objectRecoil = useRecoilValue(floorPlanObjectState) //견적서 상세데이터 - const { state, setState, addItem, handleEstimateFileDownload } = useEstimateController(params.pid) + const { estimateContextState, setEstimateContextState, addItem, handleEstimateFileDownload } = useEstimateController(params.pid) //견적특이사항 List const [specialNoteList, setSpecialNoteList] = useState([]) @@ -105,9 +105,9 @@ export default function Estimate({ params }) { let url = `/api/estimate/special-note-list` get({ url: url }).then((res) => { if (isNotEmptyArray(res)) { - if (state?.estimateOption) { + if (estimateContextState?.estimateOption) { res.map((row) => { - let estimateOption = state?.estimateOption?.split('、') + let estimateOption = estimateContextState?.estimateOption?.split('、') row.text = false estimateOption.map((row2) => { if (row2 === row.code) { @@ -119,16 +119,16 @@ export default function Estimate({ params }) { } } }) - }, [state?.estimateOption]) + }, [estimateContextState?.estimateOption]) //견적일 set useEffect(() => { let estimateDate = dayjs(startDate).format('YYYY-MM-DD') - setState({ estimateDate: estimateDate }) + setEstimateContextState({ estimateDate: estimateDate }) }, [startDate]) useEffect(() => { - //선택된 견적특이사항 setState + //선택된 견적특이사항 setEstimateContextState if (isNotEmptyArray(specialNoteList)) { const liveCheckedData = specialNoteList.filter((row) => row.text === true) @@ -138,7 +138,7 @@ export default function Estimate({ params }) { } const newData = data.join('、') - setState({ estimateOption: newData }) + setEstimateContextState({ estimateOption: newData }) } }, [specialNoteList]) @@ -148,23 +148,23 @@ export default function Estimate({ params }) { event.stopPropagation() } - // 추가한 첨부파일 state에 넣기 + // 추가한 첨부파일 estimateContextState에 넣기 useEffect(() => { if (isNotEmptyArray(files)) { files.map((row) => { - setState({ fileList: row.data }) + setEstimateContextState({ fileList: row.data }) }) } else { - setState({ fileList: [] }) + setEstimateContextState({ fileList: [] }) } }, [files]) //상세에서 내려온 첨부파일 set 만들기 useEffect(() => { - if (isNotEmptyArray(state.fileList)) { - setOriginFiles(state.fileList) + if (isNotEmptyArray(estimateContextState.fileList)) { + setOriginFiles(estimateContextState.fileList) } - }, [state?.fileList]) + }, [estimateContextState?.fileList]) // 기존첨부파일 삭제 const deleteOriginFile = async (objectNo, no) => { @@ -176,7 +176,7 @@ export default function Estimate({ params }) { await promisePost({ url: 'api/file/fileDelete', data: delParams }).then((res) => { if (res.status === 204) { setOriginFiles(originFiles.filter((file) => file.objectNo === objectNo && file.no !== no)) - setState({ + setEstimateContextState({ fileList: originFiles.filter((file) => file.objectNo === objectNo && file.no !== no), }) } @@ -185,11 +185,11 @@ export default function Estimate({ params }) { //가격표시 option 목록 최초세팅 && 주문분류 변경시 useEffect(() => { - if (state.estimateType !== '') { + if (estimateContextState.estimateType !== '') { const param = { saleStoreId: session.storeId, sapSalesStoreCd: session.custCd, - docTpCd: state?.estimateType, + docTpCd: estimateContextState?.estimateType, } const apiUrl = `/api/estimate/price/store-price-list?${queryStringFormatter(param)}` @@ -201,13 +201,13 @@ export default function Estimate({ params }) { setItemChangeYn(true) } - }, [state?.estimateType]) + }, [estimateContextState?.estimateType]) useEffect(() => { - if (state?.priceCd) { - setShowPriceCd(state.priceCd) + if (estimateContextState?.priceCd) { + setShowPriceCd(estimateContextState.priceCd) } - }, [state?.priceCd]) + }, [estimateContextState?.priceCd]) //가격 표시 option 변경 이벤트 const onChangeStorePriceList = (priceCd) => { @@ -217,7 +217,7 @@ export default function Estimate({ params }) { docTpCd: priceCd, } - //프라이싱 했을때 priceCd setState + //프라이싱 했을때 priceCd setEstimateContextState //화면에 보여지는 값은 showPriceCd로 관리 setShowPriceCd(priceCd) @@ -234,10 +234,10 @@ export default function Estimate({ params }) { const param = { saleStoreId: session.storeId, sapSalesStoreCd: session.custCd, - docTpCd: state.estimateType, + docTpCd: estimateContextState.estimateType, priceCd: showPriceCd, - //itemIdList: state.itemList, //아이템 최초정보로 호출 delFlg 0인거만.. - itemIdList: state.itemList.filter((item) => item.delFlg === '0'), + //itemIdList: estimateContextState.itemList, //아이템 최초정보로 호출 delFlg 0인거만.. + itemIdList: estimateContextState.itemList.filter((item) => item.delFlg === '0'), } if (param.itemIdList.length > 0) { @@ -264,7 +264,7 @@ export default function Estimate({ params }) { //itemId로 비교해서 단가정보만 업데이트 if (data.result.code === 200) { if (isNotEmptyArray(data.data2)) { - state.itemList.map((item) => { + estimateContextState.itemList.map((item) => { let checkYn = false data.data2.map((item2) => { if (item2.itemId === item.itemId) { @@ -278,7 +278,7 @@ export default function Estimate({ params }) { } }) - setState({ + setEstimateContextState({ priceCd: showPriceCd, itemList: updateList, }) @@ -305,7 +305,7 @@ export default function Estimate({ params }) { //주택PKG input 변경 const onChangePkgAsp = (value) => { - if (state.estimateType === 'YJSS') { + if (estimateContextState.estimateType === 'YJSS') { let pkgAsp = Number(value.replace(/[^0-9]/g, '').replaceAll(',', '')) if (isNaN(pkgAsp)) { pkgAsp = 0 @@ -314,10 +314,10 @@ export default function Estimate({ params }) { } //현재 PKG용량값 가져오기 - let totVolKw = state.totVolKw * 1000 + let totVolKw = estimateContextState.totVolKw * 1000 let pkgTotPrice = pkgAsp * totVolKw - setState({ + setEstimateContextState({ pkgAsp: pkgAsp, pkgTotPrice: pkgTotPrice.toFixed(3), }) @@ -339,9 +339,9 @@ export default function Estimate({ params }) { updates.amount = amount updates.itemChangeFlg = '1' updates.partAdd = '0' - updates.saleTotPrice = (Number(amount.replaceAll(',', '')) * state.itemList[index].salePrice.replaceAll(',', '')).toLocaleString() + updates.saleTotPrice = (Number(amount.replaceAll(',', '')) * estimateContextState.itemList[index].salePrice.replaceAll(',', '')).toLocaleString() - updateList = state.itemList.map((item) => { + updateList = estimateContextState.itemList.map((item) => { if (item.dispOrder === dispOrder) { return { ...item, ...updates } } else { @@ -349,7 +349,7 @@ export default function Estimate({ params }) { } }) - setState({ + setEstimateContextState({ itemList: updateList, }) @@ -368,9 +368,9 @@ export default function Estimate({ params }) { let updateList = [] let updates = {} updates.salePrice = salePrice - updates.saleTotPrice = (Number(salePrice.replaceAll(',', '')) * state.itemList[index].amount.replaceAll(',', '')).toLocaleString() + updates.saleTotPrice = (Number(salePrice.replaceAll(',', '')) * estimateContextState.itemList[index].amount.replaceAll(',', '')).toLocaleString() - updateList = state.itemList.map((item) => { + updateList = estimateContextState.itemList.map((item) => { if (item.dispOrder === dispOrder) { return { ...item, ...updates } } else { @@ -378,7 +378,7 @@ export default function Estimate({ params }) { } }) - setState({ + setEstimateContextState({ itemList: updateList, }) @@ -414,12 +414,12 @@ export default function Estimate({ params }) { updates.specialNoteCd = res.spnAttrCds updates.itemGroup = res.itemGroup updates.delFlg = '0' // 삭제플래그 0 - // updates.saleTotPrice = res.salePrice * state.itemList[index].amount + // updates.saleTotPrice = res.salePrice * estimateContextState.itemList[index].amount updates.saleTotPrice = '0' //추가때는 수량을 안받아서 합계를 무조건 0으로 //104671 let bomList = res.itemBomList - updateList = state.itemList.map((item) => { + updateList = estimateContextState.itemList.map((item) => { if (item.dispOrder === dispOrder) { return { ...item, ...updates } } else if (item.paDispOrder === dispOrder) { @@ -431,18 +431,18 @@ export default function Estimate({ params }) { //paDispOrder if (bomList) { bomList.map((bomItem, index) => { - let newItemDispOrder = Math.max(...state.itemList.map((item) => item.dispOrder)) + let newItemDispOrder = Math.max(...estimateContextState.itemList.map((item) => item.dispOrder)) bomItem.dispOrder = index + 1 + newItemDispOrder bomItem.delFlg = '0' bomItem.objectNo = objectNo bomItem.planNo = planNo }) - setState({ + setEstimateContextState({ itemList: [...updateList, ...bomList], }) } else { - setState({ + setEstimateContextState({ itemList: updateList, }) } @@ -455,7 +455,7 @@ export default function Estimate({ params }) { const removeItem = () => { const array = [...selection] let delList = [] - state.itemList.filter((row) => { + estimateContextState.itemList.filter((row) => { array.map((row2) => { if (row2 === row.dispOrder) { delList.push({ ...row }) @@ -466,7 +466,7 @@ export default function Estimate({ params }) { }) }) - const updateList = state.itemList.map((item) => { + const updateList = estimateContextState.itemList.map((item) => { const isDeleted = delList.some((row) => item.delFlg === '1' || item.dispOrder === row.dispOrder) return { ...item, @@ -485,7 +485,7 @@ export default function Estimate({ params }) { return alert(getMessage('estimate.detail.save.requiredItem')) } - setState({ + setEstimateContextState({ itemList: updateList, }) @@ -501,8 +501,8 @@ export default function Estimate({ params }) { let vatPrice = 0 let totPrice = 0 let addPkgPrice = 0 - if (state.estimateType === 'YJOD') { - state.itemList.map((item) => { + if (estimateContextState.estimateType === 'YJOD') { + estimateContextState.itemList.map((item) => { if (item.delFlg === '0') { const amount = Number(item.amount.replace(/[^0-9]/g, '').replaceAll(',', '')) const price = Number(item.saleTotPrice.replaceAll(',', '')) @@ -521,7 +521,7 @@ export default function Estimate({ params }) { vatPrice = supplyPrice * 0.1 totPrice = supplyPrice + vatPrice - setState({ + setEstimateContextState({ totAmount: totAmount, totVolKw: totVolKw.toFixed(3), supplyPrice: supplyPrice.toFixed(3), @@ -530,7 +530,7 @@ export default function Estimate({ params }) { }) } else { //YJSS - state.itemList.map((item) => { + estimateContextState.itemList.map((item) => { if (item.delFlg === '0') { const amount = Number(item.amount.replace(/[^0-9]/g, '').replaceAll(',', '')) const price = Number(item.saleTotPrice.replaceAll(',', '')) @@ -556,7 +556,7 @@ export default function Estimate({ params }) { vatPrice = supplyPrice * 0.1 totPrice = supplyPrice + vatPrice - setState({ + setEstimateContextState({ totAmount: totAmount, totVolKw: totVolKw.toFixed(3), supplyPrice: supplyPrice.toFixed(3), @@ -567,21 +567,22 @@ export default function Estimate({ params }) { setItemChangeYn(false) } - }, [itemChangeYn, state.itemList]) + }, [itemChangeYn, estimateContextState.itemList]) //안건명 인풋 변경 const handleBlurObjectName = (e) => { - setState({ objectName: e.target.value }) + setEstimateContextState({ objectName: e.target.value }) } //담당자 인풋 변경 const handleBlurCharger = (e) => { - setState({ charger: e.target.value }) + setEstimateContextState({ charger: e.target.value }) } - useEffect(() => { - console.log('수정날짜시간???????????', state.lastEditDatetime) - }, [state]) + //비고 인풋 변경 + const handleBlurRemarks = (e) => { + setEstimateContextState({ remarks: e.target.value }) + } return (
| {getMessage('estimate.detail.sepcialEstimateProductInfo.pkgWeight')} | -{convertNumberToPriceDecimal(state?.totVolKw)} | +{convertNumberToPriceDecimal(estimateContextState?.totVolKw)} | {getMessage('estimate.detail.sepcialEstimateProductInfo.pkgPrice')} | -{convertNumberToPriceDecimal(state?.pkgTotPrice)} | +{convertNumberToPriceDecimal(estimateContextState?.pkgTotPrice)} |
|---|