From d73daf10246c84df2c439c668c8faf5af785911b Mon Sep 17 00:00:00 2001 From: changkyu choi Date: Thu, 16 Jan 2025 18:14:52 +0900 Subject: [PATCH] =?UTF-8?q?=EB=B0=B0=EC=B9=98=EB=A9=B4=EC=B4=88=EA=B8=B0?= =?UTF-8?q?=EC=84=A4=EC=A0=95=20=EC=84=9C=EA=B9=8C=EB=9E=98=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../placementShape/PlacementShapeSetting.jsx | 59 ++++++++++--------- src/hooks/option/useCanvasSetting.js | 15 +++-- 2 files changed, 41 insertions(+), 33 deletions(-) diff --git a/src/components/floor-plan/modal/placementShape/PlacementShapeSetting.jsx b/src/components/floor-plan/modal/placementShape/PlacementShapeSetting.jsx index a9619c2f..66fa021e 100644 --- a/src/components/floor-plan/modal/placementShape/PlacementShapeSetting.jsx +++ b/src/components/floor-plan/modal/placementShape/PlacementShapeSetting.jsx @@ -56,20 +56,25 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set ] // 데이터를 최초 한 번만 조회 - useEffect(() => { - if (!basicSetting || !currentRoof || Object.keys(currentRoof).length === 0 || Object.keys(basicSetting).length === 0) return - const raftCodeList = findCommonCode('203800') - setRaftCodes(raftCodeList) - - if (addedRoofs[0].roofAngleSet && addedRoofs[0].roofAngleSet?.length > 0) { - setCurrentRoof({ ...currentRoof, roofSizeSet: String(addedRoofs[0].roofSizeSet), roofAngleSet: addedRoofs[0].roofAngleSet }) - } else if (basicSetting.roofAngleSet && basicSetting.roofAngleSet?.length > 0) { - setCurrentRoof({ ...currentRoof, roofSizeSet: String(basicSetting.roofSizeSet), roofAngleSet: basicSetting.roofAngleSet }) - } - }, []) + // useEffect(() => { + // if (!basicSetting || !currentRoof || Object.keys(currentRoof).length === 0 || Object.keys(basicSetting).length === 0) return + // const raftCodeList = findCommonCode('203800') + // setRaftCodes(raftCodeList) + // console.log('🚀 ~ useEffect ~ >>>>>>>>>>>>> raftCodeList 11 :', raftCodeList) + + + // if (addedRoofs[0].roofAngleSet && addedRoofs[0].roofAngleSet?.length > 0) { + // setCurrentRoof({ ...currentRoof, roofSizeSet: String(addedRoofs[0].roofSizeSet), roofAngleSet: addedRoofs[0].roofAngleSet }) + // } else if (basicSetting.roofAngleSet && basicSetting.roofAngleSet?.length > 0) { + // setCurrentRoof({ ...currentRoof, roofSizeSet: String(basicSetting.roofSizeSet), roofAngleSet: basicSetting.roofAngleSet }) + // } + // }, []) useEffect(() => { if (addedRoofs.length > 0) { + const raftCodeList = findCommonCode('203800') + setRaftCodes(raftCodeList) + setCurrentRoof({ ...addedRoofs[0] }) } }, [addedRoofs]) @@ -155,20 +160,20 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set ...roofInfo, }, //roofs: addedRoofs, - roofsData: { - roofApply: true, - roofSeq: 0, - roofMatlCd: currentRoof.roofMatlCd, - roofWidth: currentRoof.width, - roofHeight: currentRoof.length, - roofHajebichi: currentRoof.hajebichi, - roofGap: currentRoof.raft, - roofLayout: currentRoof.layout, - roofSizeSet: currentRoof.roofSizeSet, - roofAngleSet: currentRoof.roofAngleSet, - roofPitch: currentRoof.pitch, - roofAngle: currentRoof.angle, - }, + // roofsData: { + // roofApply: true, + // roofSeq: 0, + // roofMatlCd: currentRoof.roofMatlCd, + // roofWidth: currentRoof.width, + // roofHeight: currentRoof.length, + // roofHajebichi: currentRoof.hajebichi, + // roofGap: currentRoof.raft, + // roofLayout: currentRoof.layout, + // roofSizeSet: currentRoof.roofSizeSet, + // roofAngleSet: currentRoof.roofAngleSet, + // roofPitch: currentRoof.pitch, + // roofAngle: currentRoof.angle, + // }, }) basicSettingSave() @@ -338,13 +343,13 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set {currentRoof && ['C', 'R'].includes(currentRoof.raftAuth) && (
{getMessage('modal.placement.initial.setting.rafter')} - {raftCodes.length > 0 && ( + {raftCodes?.length > 0 && (
r.clCode === (currentRoof?.raft === undefined ? currentRoof?.raftBaseCd : currentRoof?.raft)).clCodeNm + raftCodes?.find((r) => r.clCode === (currentRoof?.raft === undefined ? currentRoof?.raftBaseCd : currentRoof?.raft)).clCodeNm } value={currentRoof?.raft === undefined ? currentRoof?.raftBaseCd : currentRoof?.raft} onChange={(e) => handleRafterChange(e.clCode)} diff --git a/src/hooks/option/useCanvasSetting.js b/src/hooks/option/useCanvasSetting.js index 951d9801..ed9dec8c 100644 --- a/src/hooks/option/useCanvasSetting.js +++ b/src/hooks/option/useCanvasSetting.js @@ -48,7 +48,7 @@ const defaultDotLineGridSetting = { LINE: false, } -let previousRoofMaterialsYn = 'N' // 지붕재 select 정보 비교 후 변경된 것이 없으면 1회만 실행 +//let previousRoofMaterialsYn = 'N' // 지붕재 select 정보 비교 후 변경된 것이 없으면 1회만 실행 export function useCanvasSetting() { const canvas = useRecoilValue(canvasState) @@ -159,21 +159,23 @@ export function useCanvasSetting() { setBasicSettings({ ...basicSetting, selectedRoofMaterial: selectedRoofMaterial }) } + const previousObjectNoRef = useRef(null) const previousRoofMaterialsRef = useRef(null) useEffect(() => { // 지붕재 select 정보가 존재해야 배치면초기설정 DB 정보 비교 후 지붕재 정보를 가져올 수 있음 - if (roofMaterials.length !== 0 && JSON.stringify(previousRoofMaterialsRef.current) !== JSON.stringify(roofMaterials)) { - // 지붕재 select 정보 비교 후 변경된 것이 없으면 1회만 실행 - if (roofMaterials && previousRoofMaterialsYn === 'N') { + if (!previousObjectNoRef.current && !correntObjectNo && previousObjectNoRef.current !== correntObjectNo + || roofMaterials.length !== 0 && JSON.stringify(previousRoofMaterialsRef.current) !== JSON.stringify(roofMaterials)) { + + if (roofMaterials) { fetchBasicSettings() - previousRoofMaterialsYn = 'Y' } // 이전 값을 업데이트 + previousObjectNoRef.current = correntObjectNo previousRoofMaterialsRef.current = roofMaterials } - }, [roofMaterials]) + }, [roofMaterials, correntObjectNo]) useEffect(() => { if (!canvas) { @@ -328,6 +330,7 @@ export function useCanvasSetting() { roofGap: 'HEI_455', roofLayout: 'P', roofPitch: 4, + roofAngle: 21.8, }, ] }