설치면 모듈 추가 수정

This commit is contained in:
lelalela 2025-01-13 17:46:55 +09:00
parent 2b2a69aab2
commit b0bcfbd701
5 changed files with 16 additions and 184 deletions

View File

@ -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) //

View File

@ -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({
<div className="module-table-flex-wrap tab2">
<div className="module-flex-item">
<div className="module-flex-item-tit">
{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}
</div>
<div className="eaves-keraba-table">

View File

@ -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({

View File

@ -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 {}
}

View File

@ -38,7 +38,6 @@ export function useModuleSelection(props) {
instHt: managementState?.installHeight, //설치높이
stdWindSpeed: managementState?.standardWindSpeedId, //기준풍속
stdSnowLd: managementState?.verticalSnowCover, //기준적설량
inclCd: globalPitch,
}
setModuleSelectionInitParams(initParams)
}, [managementState])