diff --git a/src/components/estimate/Estimate.jsx b/src/components/estimate/Estimate.jsx index 442c597b..4d816f4b 100644 --- a/src/components/estimate/Estimate.jsx +++ b/src/components/estimate/Estimate.jsx @@ -15,7 +15,7 @@ import { useCommonCode } from '@/hooks/common/useCommonCode' import { useEstimateController } from '@/hooks/floorPlan/estimate/useEstimateController' import { SessionContext } from '@/app/SessionProvider' import Select, { components } from 'react-select' -// import EstimateItemTable from './EstimateItemTable' +import { convertNumberToPriceDecimal } from '@/util/common-utils' export default function Estimate({ params }) { const { session } = useContext(SessionContext) @@ -36,6 +36,8 @@ export default function Estimate({ params }) { const [storePriceList, setStorePriceList] = useState([]) //가격표시 option + const [tempPriceCd, setTempPriceCd] = useState('') + const [startDate, setStartDate] = useState(new Date()) const singleDatePickerProps = { startDate, @@ -47,7 +49,7 @@ export default function Estimate({ params }) { //견적서 상세데이터 const { state, setState } = useEstimateController(params.pid) - const [itemList, setItemList] = useState([]) + const [itemList, setItemList] = useState([]) //기존 아이템 리스트 //견적특이사항 List const [specialNoteList, setSpecialNoteList] = useState([]) @@ -151,9 +153,13 @@ export default function Estimate({ params }) { objectNo: objectNo, no: no, } + 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({ + fileList: originFiles.filter((file) => file.objectNo === objectNo && file.no !== no), + }) } }) } @@ -165,13 +171,14 @@ export default function Estimate({ params }) { } }, [state?.itemList]) - //가격표시 option 세팅 + //가격표시 option 최초세팅 useEffect(() => { const param = { saleStoreId: session.storeId, sapSalesStoreCd: session.custCd, docTpCd: state?.estimateType, } + const apiUrl = `/api/estimate/price/store-price-list?${queryStringFormatter(param)}` get({ url: apiUrl }).then((res) => { if (isNotEmptyArray(res?.data)) { @@ -180,21 +187,58 @@ export default function Estimate({ params }) { }) }, [state?.estimateType]) + useEffect(() => { + if (state.priceCd) { + setTempPriceCd(state.priceCd) + } + }, [state?.priceCd]) + + //가격표시 option 변경시 + useEffect(() => { + if (tempPriceCd !== '') { + const param = { + saleStoreId: session.storeId, + sapSalesStoreCd: session.custCd, + docTpCd: tempPriceCd, + } + + const apiUrl = `/api/estimate/price/store-price-list?${queryStringFormatter(param)}` + get({ url: apiUrl }).then((res) => { + if (isNotEmptyArray(res?.data)) { + setStorePriceList(res.data) + } + }) + } + }, [tempPriceCd]) + //Pricing 버튼 const handlePricing = async (priceCd) => { const param = { saleStoreId: session.storeId, sapSalesStoreCd: session.custCd, docTpCd: state.estimateType, - priceCd: priceCd, - itemIdList: [], //아이템 + priceCd: session.storeLvl === '1' ? tempPriceCd : priceCd, + itemIdList: state.itemList, //아이템 최초정보로 호출 } - console.log('param::', param) - return + // console.log('프라이싱파람::', param) await promisePost({ url: '/api/estimate/price/item-price-list', data: param }).then((res) => { - console.log('프라이싱결과::::::', res) - //아이템쪽 다 새로고침............SUCK!!! + if (res) { + if (res.status === 200) { + const data = res.data + if (data.result.code === 200) { + if (isNotEmptyArray(data.data2)) { + //아이템쪽 다 새로고침............ + //성공후.. + //기존itemList랑 프라이싱결과랑 비교해서 단가만 업뎃 서로 갯수가 안맞을 수 있음 없는 itemId면 unitPrice 0으로 + //itemId로 비교해서 단가정보만 업데이트 + setState({ + priceCd: session.storeLvl === '1' ? tempPriceCd : priceCd, + }) + } + } + } + } }) } @@ -249,7 +293,7 @@ export default function Estimate({ params }) { {/* 1차 판매점명 */} {getMessage('estimate.detail.saleStoreId')} - + {state?.firstSaleStoreName} {/* 견적일 */} {getMessage('estimate.detail.estimateDate')} * @@ -263,7 +307,7 @@ export default function Estimate({ params }) { {/* 2차 판매점명 */} {getMessage('estimate.detail.otherSaleStoreId')} - + {state?.agencySaleStoreName} {/* 담당자 */} {getMessage('estimate.detail.receiveUser')} * @@ -622,7 +666,7 @@ export default function Estimate({ params }) { + + + + {item?.dispOrder * 100} + +
+
+ +
+ + {item.unit} + +
+
+ +
+ {/*
+ OPEN아이콘 처리 +
*/} +
+ + {convertNumberToPriceDecimal(item?.saleTotPrice)} + + ) + })} + {/*
@@ -716,7 +819,7 @@ export default function Estimate({ params }) { 100
-
{/*