From 173f26a1fc29db391193e731e67ef7b271819a7a Mon Sep 17 00:00:00 2001 From: basssy Date: Wed, 13 Nov 2024 08:29:48 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B2=AC=EC=A0=81=EC=84=9C=20=EC=83=81?= =?UTF-8?q?=EC=84=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/estimate/Estimate.jsx | 88 +++++++++++++------ .../estimate/useEstimateController.js | 8 +- 2 files changed, 65 insertions(+), 31 deletions(-) diff --git a/src/components/estimate/Estimate.jsx b/src/components/estimate/Estimate.jsx index 8c6af884..697a0fd0 100644 --- a/src/components/estimate/Estimate.jsx +++ b/src/components/estimate/Estimate.jsx @@ -17,7 +17,6 @@ import { SessionContext } from '@/app/SessionProvider' import Select, { components } from 'react-select' import { convertNumberToPriceDecimal } from '@/util/common-utils' import ProductFeaturesPop from './popup/ProductFeaturesPop' - export default function Estimate({ params }) { const { session } = useContext(SessionContext) const [objectNo, setObjectNo] = useState('') //물건번호 @@ -31,6 +30,7 @@ export default function Estimate({ params }) { const [productFeaturesPopupOpen, setProductFeaturesPopupOpen] = useState(false) //견적특이사항 팝업 const [showProductFeatureData, setShowProductFeatureData] = useState([]) //팝업에 보여줄 견적특이사항 데이터 + const [selection, setSelection] = useState(new Set()) //견적특이사항 접고 펼치기 const [hidden, setHidden] = useState(false) @@ -54,7 +54,7 @@ export default function Estimate({ params }) { const objectRecoil = useRecoilValue(floorPlanObjectState) //견적서 상세데이터 - const { state, setState } = useEstimateController(params.pid) + const { state, setState, addItem } = useEstimateController(params.pid) const [itemList, setItemList] = useState([]) //기존 아이템 리스트 @@ -191,25 +191,27 @@ export default function Estimate({ params }) { //가격표시 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)) { - setStorePriceList(res.data) + if (state.estimateType !== '') { + 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)) { + setStorePriceList(res.data) + } + }) + } }, [state?.estimateType]) - useEffect(() => { - if (state.priceCd) { - setTempPriceCd(state.priceCd) - } - }, [state?.priceCd]) + // useEffect(() => { + // if (state.priceCd) { + // setTempPriceCd(state.priceCd) + // } + // }, [state?.priceCd]) //가격표시 option 변경시 useEffect(() => { @@ -260,10 +262,37 @@ export default function Estimate({ params }) { }) } - // 제품 추가 테스트 - const addItemTest = () => { - const newItemDispOrder = (Math.max(...state.itemList.map((item) => item.dispOrder)) + 1) * 100 - console.log('newItemDispOrder::', newItemDispOrder) + //row 체크박스 컨트롤 + const onChangeSelect = (dispOrder) => { + const newSelection = new Set(selection) + if (newSelection.has(dispOrder)) { + newSelection.delete(dispOrder) + } else { + newSelection.add(dispOrder) + } + + setSelection(newSelection) + } + + // 아이템 자동완성 검색시 + const onChangeDisplayItem = (itemId, dispOrder) => { + console.log('아이템 자동완성:::::::', dispOrder) + const param = { + itemId: itemId, + } + const apiUrl = `/api/display-item/item-detail?${queryStringFormatter(param)}` + get({ url: apiUrl }).then((res) => { + console.log('제품상세 결과::::::::', res) + }) + // setState({ + // itemList: [{ itemNo: '123123123123' }], + // }) + } + + //제품 삭제 + const removeItem = () => { + const array = [...selection] + console.log(array) } return ( @@ -731,11 +760,11 @@ export default function Estimate({ params }) {
- - @@ -774,14 +803,14 @@ export default function Estimate({ params }) { - {itemList.length > 0 && - itemList.map((item, index) => { + {state?.itemList.length > 0 && + state.itemList.map((item, index) => { return (
- - + onChangeSelect(item.dispOrder)} /> +
{item?.dispOrder * 100} @@ -795,11 +824,14 @@ export default function Estimate({ params }) { classNamePrefix="custom" placeholder="Select" options={displayItemList} + onChange={(e) => onChangeDisplayItem(e.itemId, item.dispOrder)} getOptionLabel={(x) => x.itemName} getOptionValue={(x) => x.itemId} isClearable={true} isDisabled={false} value={displayItemList.filter(function (option) { + // console.log('옵션값???', option.itemId) + // console.log('골랐을때 여기오지???', item.itemId) return option.itemId === item.itemId })} /> diff --git a/src/hooks/floorPlan/estimate/useEstimateController.js b/src/hooks/floorPlan/estimate/useEstimateController.js index 05d10554..d2e067ba 100644 --- a/src/hooks/floorPlan/estimate/useEstimateController.js +++ b/src/hooks/floorPlan/estimate/useEstimateController.js @@ -19,7 +19,7 @@ const defaultEstimateData = { charger: '', //담당자 objectName: '', //안건명 objectNameOmit: '', //경칭코드 - estimateType: 'YJOD', //주문분류 + estimateType: '', //주문분류 remarks: '', //비고 estimateOption: '', //견적특이사항 itemList: [], @@ -76,12 +76,14 @@ export const useEstimateController = (planNo) => { } const addItem = () => { - const newItemDispOrder = (Math.max(...state.itemList.map((item) => item.dispOrder)) + 1) * 100 + const newItemDispOrder = Math.max(...state.itemList.map((item) => item.dispOrder)) + 1 setState({ itemList: [ ...state.itemList, { - dispOrder: newItemDispOrder, + objectNo: objectRecoil.floorPlanObjectNo, + planNo: planNo, + dispOrder: newItemDispOrder.toString(), itemId: '', //제품번호 itemNo: '', //형명 itemName: '',