설치면 모듈 추가 수정
This commit is contained in:
parent
2b2a69aab2
commit
b0bcfbd701
@ -9,7 +9,7 @@ import ModuleTabContents from './ModuleTabContents'
|
|||||||
import { useDebounceCallback, useDebounceValue } from 'usehooks-ts'
|
import { useDebounceCallback, useDebounceValue } from 'usehooks-ts'
|
||||||
import { moduleSelectionDataState } from '@/store/selectedModuleOptions'
|
import { moduleSelectionDataState } from '@/store/selectedModuleOptions'
|
||||||
|
|
||||||
export default function Module({}) {
|
export default function Module() {
|
||||||
const { getMessage } = useMessage()
|
const { getMessage } = useMessage()
|
||||||
const addedRoofs = useRecoilValue(addedRoofsState) //지붕재 선택
|
const addedRoofs = useRecoilValue(addedRoofsState) //지붕재 선택
|
||||||
const [roofTab, setRoofTab] = useState(0) //지붕재 탭
|
const [roofTab, setRoofTab] = useState(0) //지붕재 탭
|
||||||
|
|||||||
@ -20,8 +20,6 @@ export default function ModuleTabContents({
|
|||||||
const { getMessage } = useMessage()
|
const { getMessage } = useMessage()
|
||||||
const canvasSetting = useRecoilValue(canvasSettingState) //캔버스 기본 셋팅
|
const canvasSetting = useRecoilValue(canvasSettingState) //캔버스 기본 셋팅
|
||||||
const [roofMaterial, setRoofMaterial] = useState(addRoof) //지붕재`
|
const [roofMaterial, setRoofMaterial] = useState(addRoof) //지붕재`
|
||||||
|
|
||||||
const globalPitch = useRecoilValue(pitchSelector) //피치
|
|
||||||
const globalPitchText = useRecoilValue(pitchTextSelector) //피치 텍스트
|
const globalPitchText = useRecoilValue(pitchTextSelector) //피치 텍스트
|
||||||
|
|
||||||
const { findCommonCode } = useCommonCode()
|
const { findCommonCode } = useCommonCode()
|
||||||
@ -55,10 +53,6 @@ export default function ModuleTabContents({
|
|||||||
|
|
||||||
const [isExistData, setIsExistData] = useState(false)
|
const [isExistData, setIsExistData] = useState(false)
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
console.log('addRoof', addRoof)
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
//서까래간격 변경
|
//서까래간격 변경
|
||||||
const handleChangeRaftBase = (option) => {
|
const handleChangeRaftBase = (option) => {
|
||||||
setSelectedRaftBase(option)
|
setSelectedRaftBase(option)
|
||||||
@ -88,6 +82,7 @@ export default function ModuleTabContents({
|
|||||||
...moduleSelectionInitParams,
|
...moduleSelectionInitParams,
|
||||||
...roofBaseParams,
|
...roofBaseParams,
|
||||||
roofBaseCd: option.roofBaseCd,
|
roofBaseCd: option.roofBaseCd,
|
||||||
|
inclCd: addRoof.pitch,
|
||||||
})
|
})
|
||||||
setSelectedRoofBase(option)
|
setSelectedRoofBase(option)
|
||||||
}
|
}
|
||||||
@ -158,7 +153,12 @@ export default function ModuleTabContents({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isObjectNotEmpty(selectedRoofBase) && isObjectNotEmpty(selectedConstruction)) {
|
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)
|
const index = tempModuleSelectionData.roofConstructions.findIndex((obj) => obj.roofIndex === roofTab)
|
||||||
|
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
@ -196,6 +196,7 @@ export default function ModuleTabContents({
|
|||||||
...moduleSelectionInitParams,
|
...moduleSelectionInitParams,
|
||||||
...roofBaseParams,
|
...roofBaseParams,
|
||||||
roofBaseCd: selectedRoofBase.roofBaseCd,
|
roofBaseCd: selectedRoofBase.roofBaseCd,
|
||||||
|
inclCd: addRoof.pitch,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}, [selectedRoofBase])
|
}, [selectedRoofBase])
|
||||||
@ -270,6 +271,7 @@ export default function ModuleTabContents({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isObjectNotEmpty(tempModuleSelectionData)) {
|
if (isObjectNotEmpty(tempModuleSelectionData)) {
|
||||||
|
console.log('tempModuleSelectionData', tempModuleSelectionData)
|
||||||
setModuleSelectionData(tempModuleSelectionData)
|
setModuleSelectionData(tempModuleSelectionData)
|
||||||
}
|
}
|
||||||
}, [tempModuleSelectionData])
|
}, [tempModuleSelectionData])
|
||||||
@ -280,7 +282,8 @@ export default function ModuleTabContents({
|
|||||||
<div className="module-table-flex-wrap tab2">
|
<div className="module-table-flex-wrap tab2">
|
||||||
<div className="module-flex-item">
|
<div className="module-flex-item">
|
||||||
<div className="module-flex-item-tit">
|
<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})
|
{globalPitchText})
|
||||||
</div>
|
</div>
|
||||||
<div className="eaves-keraba-table">
|
<div className="eaves-keraba-table">
|
||||||
|
|||||||
@ -129,6 +129,8 @@ export function useModuleBasicSetting() {
|
|||||||
|
|
||||||
//설치 범위 지정 클릭 이벤트
|
//설치 범위 지정 클릭 이벤트
|
||||||
const toggleSelection = (setupSurface) => {
|
const toggleSelection = (setupSurface) => {
|
||||||
|
console.log('setupSurface', setupSurface)
|
||||||
|
|
||||||
const isExist = selectedModuleInstSurfaceArray.some((obj) => obj.parentId === setupSurface.parentId)
|
const isExist = selectedModuleInstSurfaceArray.some((obj) => obj.parentId === setupSurface.parentId)
|
||||||
//최초 선택일때
|
//최초 선택일때
|
||||||
if (!isExist) {
|
if (!isExist) {
|
||||||
@ -1122,7 +1124,7 @@ export function useModuleBasicSetting() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// moduleSetupSurface.set({ modules: moduleSetupArray })
|
moduleSetupSurface.set({ modules: moduleSetupArray })
|
||||||
|
|
||||||
// const moduleArray = [...moduleIsSetup]
|
// const moduleArray = [...moduleIsSetup]
|
||||||
// moduleArray.push({
|
// moduleArray.push({
|
||||||
|
|||||||
@ -8,177 +8,5 @@ import { selectedModuleState, moduleSelectionInitParamsState } from '@/store/sel
|
|||||||
import { pitchSelector } from '@/store/canvasAtom'
|
import { pitchSelector } from '@/store/canvasAtom'
|
||||||
|
|
||||||
export function useModuleSelection(props) {
|
export function useModuleSelection(props) {
|
||||||
const { managementState, setManagementState, managementStateLoaded } = useContext(GlobalDataContext)
|
return {}
|
||||||
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,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,7 +38,6 @@ export function useModuleSelection(props) {
|
|||||||
instHt: managementState?.installHeight, //설치높이
|
instHt: managementState?.installHeight, //설치높이
|
||||||
stdWindSpeed: managementState?.standardWindSpeedId, //기준풍속
|
stdWindSpeed: managementState?.standardWindSpeedId, //기준풍속
|
||||||
stdSnowLd: managementState?.verticalSnowCover, //기준적설량
|
stdSnowLd: managementState?.verticalSnowCover, //기준적설량
|
||||||
inclCd: globalPitch,
|
|
||||||
}
|
}
|
||||||
setModuleSelectionInitParams(initParams)
|
setModuleSelectionInitParams(initParams)
|
||||||
}, [managementState])
|
}, [managementState])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user