From b0bcfbd70167ffee8041d50af37eb143c05878f9 Mon Sep 17 00:00:00 2001 From: lelalela Date: Mon, 13 Jan 2025 17:46:55 +0900 Subject: [PATCH] =?UTF-8?q?=EC=84=A4=EC=B9=98=EB=A9=B4=20=EB=AA=A8?= =?UTF-8?q?=EB=93=88=20=EC=B6=94=EA=B0=80=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../floor-plan/modal/basic/step/Module.jsx | 2 +- .../modal/basic/step/ModuleTabContents.jsx | 19 +- src/hooks/module/useModuleBasicSetting.js | 4 +- src/hooks/module/useModulePlace.js | 174 +----------------- src/hooks/module/useModuleSelection.js | 1 - 5 files changed, 16 insertions(+), 184 deletions(-) diff --git a/src/components/floor-plan/modal/basic/step/Module.jsx b/src/components/floor-plan/modal/basic/step/Module.jsx index 32b85e56..14ad4f69 100644 --- a/src/components/floor-plan/modal/basic/step/Module.jsx +++ b/src/components/floor-plan/modal/basic/step/Module.jsx @@ -9,7 +9,7 @@ import ModuleTabContents from './ModuleTabContents' import { useDebounceCallback, useDebounceValue } from 'usehooks-ts' import { moduleSelectionDataState } from '@/store/selectedModuleOptions' -export default function Module({}) { +export default function Module() { const { getMessage } = useMessage() const addedRoofs = useRecoilValue(addedRoofsState) //지붕재 선택 const [roofTab, setRoofTab] = useState(0) //지붕재 탭 diff --git a/src/components/floor-plan/modal/basic/step/ModuleTabContents.jsx b/src/components/floor-plan/modal/basic/step/ModuleTabContents.jsx index 24f76a35..b753cbc5 100644 --- a/src/components/floor-plan/modal/basic/step/ModuleTabContents.jsx +++ b/src/components/floor-plan/modal/basic/step/ModuleTabContents.jsx @@ -20,8 +20,6 @@ export default function ModuleTabContents({ const { getMessage } = useMessage() const canvasSetting = useRecoilValue(canvasSettingState) //캔버스 기본 셋팅 const [roofMaterial, setRoofMaterial] = useState(addRoof) //지붕재` - - const globalPitch = useRecoilValue(pitchSelector) //피치 const globalPitchText = useRecoilValue(pitchTextSelector) //피치 텍스트 const { findCommonCode } = useCommonCode() @@ -55,10 +53,6 @@ export default function ModuleTabContents({ const [isExistData, setIsExistData] = useState(false) - useEffect(() => { - console.log('addRoof', addRoof) - }, []) - //서까래간격 변경 const handleChangeRaftBase = (option) => { setSelectedRaftBase(option) @@ -88,6 +82,7 @@ export default function ModuleTabContents({ ...moduleSelectionInitParams, ...roofBaseParams, roofBaseCd: option.roofBaseCd, + inclCd: addRoof.pitch, }) setSelectedRoofBase(option) } @@ -158,7 +153,12 @@ export default function ModuleTabContents({ useEffect(() => { if (isObjectNotEmpty(selectedRoofBase) && isObjectNotEmpty(selectedConstruction)) { - const newRoofConstructions = { roofIndex: roofTab, trestle: selectedRoofBase, construction: selectedConstruction } + const newRoofConstructions = { + roofIndex: roofTab, + addRoof: addRoof, + trestle: selectedRoofBase, + construction: selectedConstruction, + } const index = tempModuleSelectionData.roofConstructions.findIndex((obj) => obj.roofIndex === roofTab) if (index > -1) { @@ -196,6 +196,7 @@ export default function ModuleTabContents({ ...moduleSelectionInitParams, ...roofBaseParams, roofBaseCd: selectedRoofBase.roofBaseCd, + inclCd: addRoof.pitch, }) } }, [selectedRoofBase]) @@ -270,6 +271,7 @@ export default function ModuleTabContents({ useEffect(() => { if (isObjectNotEmpty(tempModuleSelectionData)) { + console.log('tempModuleSelectionData', tempModuleSelectionData) setModuleSelectionData(tempModuleSelectionData) } }, [tempModuleSelectionData]) @@ -280,7 +282,8 @@ export default function ModuleTabContents({
- {getMessage('modal.module.basic.setting.module.roof.material')}:{roofMaterial.nameJp}({globalPitch} + {getMessage('modal.module.basic.setting.module.roof.material')}:{roofMaterial.nameJp}( + {addRoof.roofAngleSet === 'slope' ? roofMaterial.pitch : roofMaterial.angle} {globalPitchText})
diff --git a/src/hooks/module/useModuleBasicSetting.js b/src/hooks/module/useModuleBasicSetting.js index 8f6772c9..03035cda 100644 --- a/src/hooks/module/useModuleBasicSetting.js +++ b/src/hooks/module/useModuleBasicSetting.js @@ -129,6 +129,8 @@ export function useModuleBasicSetting() { //설치 범위 지정 클릭 이벤트 const toggleSelection = (setupSurface) => { + console.log('setupSurface', setupSurface) + const isExist = selectedModuleInstSurfaceArray.some((obj) => obj.parentId === setupSurface.parentId) //최초 선택일때 if (!isExist) { @@ -1122,7 +1124,7 @@ export function useModuleBasicSetting() { } }) - // moduleSetupSurface.set({ modules: moduleSetupArray }) + moduleSetupSurface.set({ modules: moduleSetupArray }) // const moduleArray = [...moduleIsSetup] // moduleArray.push({ diff --git a/src/hooks/module/useModulePlace.js b/src/hooks/module/useModulePlace.js index 73343547..02bf71be 100644 --- a/src/hooks/module/useModulePlace.js +++ b/src/hooks/module/useModulePlace.js @@ -8,177 +8,5 @@ import { selectedModuleState, moduleSelectionInitParamsState } from '@/store/sel import { pitchSelector } from '@/store/canvasAtom' export function useModuleSelection(props) { - const { managementState, setManagementState, managementStateLoaded } = useContext(GlobalDataContext) - const globalPitch = useRecoilValue(pitchSelector) //피치 - - const [roughnessCodes, setRoughnessCodes] = useState([]) //면조도 목록 - const [windSpeedCodes, setWindSpeedCodes] = useState([]) //기준풍속 목록 - const [moduleList, setModuleList] = useState([{}]) //모듈 목록 - - const [selectedModules, setSelectedModules] = useRecoilState(selectedModuleState) //선택된 모듈 - const [selectedSurfaceType, setSelectedSurfaceType] = useState({}) //선택된 면조도 - const [installHeight, setInstallHeight] = useState('0') //설치 높이 - const [standardWindSpeed, setStandardWindSpeed] = useState({}) //기준풍속 - const [verticalSnowCover, setVerticalSnowCover] = useState('0') //수직적설량 - const [moduleSelectionInitParams, setModuleSelectionInitParams] = useRecoilState(moduleSelectionInitParamsState) //모듈 기본 데이터 ex) 면조도, 높이등등 - - const { getModuleTypeItemList } = useMasterController() - - const { findCommonCode } = useCommonCode() - - //탭별 파라메터 초기화 - useEffect(() => { - setInstallHeight(managementState?.installHeight) - setStandardWindSpeed(managementState?.standardWindSpeedId) - setVerticalSnowCover(managementState?.verticalSnowCover) - setSelectedSurfaceType(managementState?.surfaceType) - - const initParams = { - illuminationTp: managementState?.surfaceTypeValue, //면조도 - instHt: managementState?.installHeight, //설치높이 - stdWindSpeed: managementState?.standardWindSpeedId, //기준풍속 - stdSnowLd: managementState?.verticalSnowCover, //기준적설량 - inclCd: globalPitch, - } - setModuleSelectionInitParams(initParams) - }, [managementState]) - - useEffect(() => { - // 113700 면조도 - const roughnessCodeList = findCommonCode('113700') - roughnessCodeList.forEach((obj) => { - obj.name = obj.clCodeNm - obj.id = obj.clCode - }) - setRoughnessCodes(roughnessCodeList) - - // 202000 풍속 - const windCodeList = findCommonCode('202000') - windCodeList.forEach((obj) => { - obj.name = obj.clCodeNm - obj.id = obj.clCode - }) - setWindSpeedCodes(windCodeList) - - //지붕재 선택 - const roofsIds = props.addedRoofs.filter((obj) => obj.roofMatlCd).map((obj) => obj.roofMatlCd) - - if (roofsIds.length === 0) { - return - } - - //새로고침시 데이터 날아가는거 방지 - if (!managementState) { - setManagementState(managementStateLoaded) - } - - getModuleData(roofsIds) - }, []) - - const getModuleData = async (roofsIds) => { - const list = await getModuleTypeItemList(roofsIds) - //selectbox에 이름을 넣는다 - list.data.forEach((item) => { - item.name = item.itemNm - }) - //셀렉트박스 데이터 초기화 - setModuleList(list.data) - } - - const handleChangeModule = (option) => { - //선택된 모듈 - setSelectedModules(option) //선택값 저장 - - //init 데이터에 선택된 모듈 추가 - setModuleSelectionInitParams({ - ...moduleSelectionInitParams, - moduleTpCd: option.itemTp, - }) - } - - const handleChangeSurfaceType = (option) => { - setModuleSelectionInitParams({ - ...moduleSelectionInitParams, - illuminationTp: option.clCode, - }) - } - - const handleChangeWindSpeed = (option) => { - setModuleSelectionInitParams({ - ...moduleSelectionInitParams, - surfaceType: option.clCode, - }) - } - - const handleChangeInstallHeight = (option) => { - setInstallHeight(option) - - setModuleSelectionInitParams({ - ...moduleSelectionInitParams, - instHt: option, - }) - } - - const handleChangeVerticalSnowCover = (option) => { - setVerticalSnowCover(option) - - setModuleSelectionInitParams({ - ...moduleSelectionInitParams, - stdSnowLd: option, - }) - } - - useEffect(() => { - console.log('installHeight', installHeight) - }, [installHeight]) - - useEffect(() => { - console.log('verticalSnowCover', verticalSnowCover) - }, [verticalSnowCover]) - - //TODO: 설치높이, 기준적설량 debounce 적용해서 추가해야됨 - - // useEffect(() => { - // getConstructionListData(constructionListParams) - // }, [constructionListParams]) - - // const getConstructionListData = async (params) => { - // if (params.trestleMkrCd && params.constMthdCd && params.roofBaseCd) { - // const optionsList = await getConstructionList(params) - // console.log('optionsList', optionsList) - // setConstructionList(optionsList.data) - // } - // } - - //state 배열에 데이터 추가 함수 - // const addRoofTabParams = (key, value, excludeArray = []) => { - // const index = roofTabParams.findIndex((obj) => obj.roofTab === roofTab) - // if (index !== -1) { - // roofTabParams[index][key] = value - // if (excludeArray.length > 0) { - // excludeArray.forEach((exclude) => { - // roofTabParams[index][exclude] = '' - // }) - // } - // setRoofTabParams((prev) => [...prev.slice(0, index), roofTabParams[index], ...prev.slice(index + 1)]) - // } - // } - - return { - moduleSelectionInitParams, - selectedModules, - roughnessCodes, - windSpeedCodes, - managementState, - moduleList, - selectedSurfaceType, - installHeight, - standardWindSpeed, - verticalSnowCover, - handleChangeModule, - handleChangeSurfaceType, - handleChangeWindSpeed, - handleChangeInstallHeight, - handleChangeVerticalSnowCover, - } + return {} } diff --git a/src/hooks/module/useModuleSelection.js b/src/hooks/module/useModuleSelection.js index 73343547..11cc289f 100644 --- a/src/hooks/module/useModuleSelection.js +++ b/src/hooks/module/useModuleSelection.js @@ -38,7 +38,6 @@ export function useModuleSelection(props) { instHt: managementState?.installHeight, //설치높이 stdWindSpeed: managementState?.standardWindSpeedId, //기준풍속 stdSnowLd: managementState?.verticalSnowCover, //기준적설량 - inclCd: globalPitch, } setModuleSelectionInitParams(initParams) }, [managementState])