-
- setHasAnglePassivity(!hasAnglePassivity)} />
-
-
-
-
-
checkDegree(e.target.value)
- // setCompasDeg(
-
- // e.target.value === '-' || (e.target.value !== '' && parseInt(e.target.value) <= 180 && parseInt(e.target.value) >= -180)
- // ? e.target.value
- // : 0,
- // )
- }
- />
+
+
+
+
{getMessage('modal.module.basic.setting.module.setting')}
+
+ {moduleList && (
+ handleChangeModule(e)}
+ />
+ )}
+
+
+
+
+
+
+ {moduleData.header.map((header) => {
+ return (
+ |
+ {header.name}
+ |
+ )
+ })}
+
+
+
+ {Array.from({ length: 2 }).map((_, index) => {
+ return selectedModules && selectedModules?.itemList && selectedModules?.itemList?.length >= index + 1 ? (
+
+ |
+
+
+ {selectedModules.itemList[index].itemNm}
+
+ |
+ {Number(selectedModules.itemList[index].shortAxis).toFixed(0)} |
+ {Number(selectedModules.itemList[index].longAxis).toFixed(0)} |
+ {Number(selectedModules.itemList[index].wpOut).toFixed(0)} |
+
+ ) : (
+
+ |
+
+ |
+ |
+ |
+ |
+
+ )
+ })}
+
+
+
+ {basicSetting && basicSetting.roofSizeSet === '3' && (
+
+
{getMessage('modal.module.basic.setting.module.placement.area')}
+
+ setInputInstallHeight(e.target.value)}
+ />
+
+
m
+
+ )}
-
°
+
+ {basicSetting && basicSetting.roofSizeSet !== '3' && (
+
+
+
+
{getMessage('modal.module.basic.setting.module.surface.type')}
+
+ {roughnessCodes.length > 0 && managementState && (
+ {
+ console.log('🚀 ~ handleChangeModule ~ inputRoughness:', e)
+ setInputRoughness(e)
+ }}
+ />
+ )}
+
+
+
+
{getMessage('modal.module.basic.setting.module.fitting.height')}
+
+ setInputInstallHeight(e.target.value)}
+ />
+
+
m
+
+
+
{getMessage('modal.module.basic.setting.module.standard.wind.speed')}
+
+ {windSpeedCodes.length > 0 && managementState && (
+ {
+ console.log('🚀 ~ handleChangeModule ~ inputStandardWindSpeed:', e)
+ setInputStandardWindSpeed(e)
+ }}
+ />
+ )}
+
+
+
+
{getMessage('modal.module.basic.setting.module.standard.snowfall.amount')}
+
+ setInputVerticalSnowCover(e.target.value)}
+ />
+
+
cm
+
+
+
+ )}
diff --git a/src/components/floor-plan/modal/basic/step/Trestle.jsx b/src/components/floor-plan/modal/basic/step/Trestle.jsx
new file mode 100644
index 00000000..a6c62750
--- /dev/null
+++ b/src/components/floor-plan/modal/basic/step/Trestle.jsx
@@ -0,0 +1,532 @@
+import { GlobalDataContext } from '@/app/GlobalDataProvider'
+import QSelectBox from '@/components/common/select/QSelectBox'
+import { useModuleTrestle } from '@/hooks/module/useModuleTrestle'
+import { useMessage } from '@/hooks/useMessage'
+import { currentAngleTypeSelector, pitchTextSelector } from '@/store/canvasAtom'
+import { roofsState } from '@/store/roofAtom'
+import { moduleSelectionDataState, selectedModuleState } from '@/store/selectedModuleOptions'
+import { isObjectNotEmpty } from '@/util/common-utils'
+import { forwardRef, useContext, useEffect, useImperativeHandle, useState } from 'react'
+import { useRecoilState, useRecoilValue } from 'recoil'
+
+const Trestle = forwardRef((props, ref) => {
+ const { setTabNum, trestleTrigger, roofs, setRoofs, moduleSelectionData, setModuleSelectionData } = props
+ const { getMessage } = useMessage()
+ // const [selectedTrestle, setSelectedTrestle] = useState()
+ const currentAngleType = useRecoilValue(currentAngleTypeSelector)
+ const pitchText = useRecoilValue(pitchTextSelector)
+ const [selectedRoof, setSelectedRoof] = useState()
+ const {
+ trestleState,
+ dispatch,
+ raftBaseList,
+ trestleList,
+ constMthdList,
+ roofBaseList,
+ constructionList,
+ eavesMargin,
+ ridgeMargin,
+ kerabaMargin,
+ setEavesMargin,
+ setRidgeMargin,
+ setKerabaMargin,
+ cvrYn,
+ cvrChecked,
+ snowGdPossYn,
+ snowGdChecked,
+ setCvrYn,
+ setCvrChecked,
+ setSnowGdPossYn,
+ setSnowGdChecked,
+ } = useModuleTrestle({
+ selectedRoof,
+ })
+ const selectedModules = useRecoilValue(selectedModuleState) //선택된 모듈
+ // const [moduleSelectionData, setModuleSelectionData] = useRecoilState(moduleSelectionDataState)
+ const [lengthBase, setLengthBase] = useState(0)
+ const [hajebichi, setHajebichi] = useState(0)
+ const [selectedRaftBase, setSelectedRaftBase] = useState(null)
+ const [selectedTrestle, setSelectedTrestle] = useState(null)
+ const [selectedConstMthd, setSelectedConstMthd] = useState(null)
+ const [selectedConstruction, setSelectedConstruction] = useState(null)
+ const [selectedRoofBase, setSelectedRoofBase] = useState(null)
+ const { managementState } = useContext(GlobalDataContext)
+
+ useEffect(() => {
+ if (roofs && !selectedRoof) {
+ setSelectedRoof(roofs[0])
+ }
+ }, [roofs])
+
+ useEffect(() => {
+ if (selectedRoof) {
+ dispatch({ type: 'SET_INITIALIZE', roof: { ...selectedRoof, moduleTpCd: selectedModules.itemTp } })
+ }
+ }, [selectedRoof])
+
+ useEffect(() => {
+ if (raftBaseList.length > 0) setSelectedRaftBase(raftBaseList.find((raft) => raft.clCode === trestleState?.raftBaseCd) ?? null)
+ }, [raftBaseList])
+
+ useEffect(() => {
+ if (trestleList.length > 0) setSelectedTrestle(trestleList.find((trestle) => trestle.trestleMkrCd === trestleState?.trestleMkrCd) ?? null)
+ }, [trestleList])
+
+ useEffect(() => {
+ if (roofBaseList.length > 0) setSelectedRoofBase(roofBaseList.find((roofBase) => roofBase.roofBaseCd === trestleState?.roofBaseCd) ?? null)
+ }, [roofBaseList])
+
+ useEffect(() => {
+ if (constMthdList.length > 0) setSelectedConstMthd(constMthdList.find((constMthd) => constMthd.constMthdCd === trestleState?.constMthdCd) ?? null)
+ }, [constMthdList])
+
+ useEffect(() => {
+ if (constructionList.length > 0) {
+ setSelectedConstruction(constructionList.find((construction) => construction.constTp === trestleState?.constTp) ?? null)
+ }
+ }, [constructionList])
+
+ const getConstructionState = (index) => {
+ if (constructionList && constructionList.length > 0) {
+ if (constructionList[index].constPossYn === 'Y') {
+ if (trestleState && trestleState.constTp === constructionList[index].constTp) {
+ return 'blue'
+ }
+ return 'white'
+ }
+ return 'no-click'
+ }
+ return 'no-click'
+ }
+
+ const onChangeRaftBase = (e) => {
+ setSelectedRaftBase(e)
+ dispatch({
+ type: 'SET_RAFT_BASE',
+ roof: {
+ moduleTpCd: selectedModules.itemTp ?? '',
+ roofMatlCd: selectedRoof?.roofMatlCd ?? '',
+ raftBaseCd: e.clCode,
+ },
+ })
+ }
+
+ const onChangeTrestleMaker = (e) => {
+ setSelectedTrestle(e)
+ dispatch({
+ type: 'SET_TRESTLE_MAKER',
+ roof: {
+ moduleTpCd: selectedModules.itemTp ?? '',
+ roofMatlCd: selectedRoof?.roofMatlCd ?? '',
+ raftBaseCd: trestleState.raftBaseCd ?? '',
+ trestleMkrCd: e.trestleMkrCd,
+ },
+ })
+ }
+
+ const onChangeConstMthd = (e) => {
+ setSelectedConstMthd(e)
+ dispatch({
+ type: 'SET_CONST_MTHD',
+ roof: {
+ moduleTpCd: selectedModules.itemTp ?? '',
+ roofMatlCd: selectedRoof?.roofMatlCd ?? '',
+ raftBaseCd: trestleState.raftBaseCd ?? '',
+ trestleMkrCd: trestleState.trestleMkrCd,
+ constMthdCd: e.constMthdCd,
+ },
+ })
+ }
+
+ const onChangeRoofBase = (e) => {
+ setSelectedRoofBase(e)
+ dispatch({
+ type: 'SET_ROOF_BASE',
+ roof: {
+ moduleTpCd: selectedModules.itemTp ?? '',
+ roofMatlCd: selectedRoof?.roofMatlCd ?? '',
+ raftBaseCd: trestleState.raftBaseCd ?? '',
+ trestleMkrCd: trestleState.trestleMkrCd,
+ constMthdCd: trestleState.constMthdCd,
+ roofBaseCd: e.roofBaseCd,
+ illuminationTp: managementState?.surfaceTypeValue ?? '',
+ instHt: managementState?.installHeight ?? '',
+ stdWindSpeed: managementState?.standardWindSpeedId ?? '',
+ stdSnowLd: managementState?.verticalSnowCover ?? '',
+ inclCd: selectedRoof?.pitch ?? 0,
+ roofPitch: Math.round(selectedRoof?.roofPchBase ?? 0),
+ },
+ })
+ }
+ const handleChangeRoofMaterial = (index) => {
+ const newAddedRoofs = roofs.map((roof, i) => {
+ if (i === selectedRoof.index) {
+ return {
+ ...selectedRoof,
+ ...trestleState,
+ eavesMargin,
+ ridgeMargin,
+ kerabaMargin,
+ cvrYn,
+ snowGdPossYn,
+ cvrChecked,
+ snowGdChecked,
+ }
+ }
+ return { ...roof }
+ })
+ setRoofs(newAddedRoofs)
+ setSelectedRoof(newAddedRoofs[index])
+ }
+
+ const handleConstruction = (index) => {
+ if (constructionList[index]?.constPossYn === 'Y') {
+ dispatch({
+ type: 'SET_CONSTRUCTION',
+ roof: {
+ moduleTpCd: selectedModules.itemTp ?? '',
+ roofMatlCd: selectedRoof?.roofMatlCd ?? '',
+ raftBaseCd: trestleState.raftBaseCd ?? '',
+ trestleMkrCd: trestleState.trestleMkrCd,
+ constMthdCd: trestleState.constMthdCd,
+ roofBaseCd: trestleState.roofBaseCd,
+ illuminationTp: managementState?.surfaceTypeValue ?? '',
+ instHt: managementState?.installHeight ?? '',
+ stdWindSpeed: managementState?.standardWindSpeedId ?? '',
+ stdSnowLd: +managementState?.verticalSnowCover ?? '',
+ inclCd: selectedRoof?.pitch.toString() ?? 0,
+ roofPitch: Math.round(selectedRoof?.roofPchBase ?? 0),
+ constTp: constructionList[index].constTp,
+ mixMatlNo: selectedModules.mixMatlNo,
+ workingWidth: selectedRoof?.length.toString() ?? '',
+ // snowGdPossYn: constructionList[index].snowGdPossYn,
+ // cvrYn: constructionList[index].cvrYn,
+ },
+ })
+
+ setCvrYn(constructionList[index].cvrYn)
+ setSnowGdPossYn(constructionList[index].snowGdPossYn)
+ setCvrChecked(false)
+ setSnowGdChecked(false)
+ }
+ }
+
+ const isComplete = () => {
+ const newAddedRoofs = roofs.map((roof, i) => {
+ if (i === selectedRoof?.index) {
+ return {
+ ...selectedRoof,
+ ...trestleState,
+ eavesMargin,
+ ridgeMargin,
+ kerabaMargin,
+ cvrYn,
+ snowGdPossYn,
+ cvrChecked,
+ snowGdChecked,
+ }
+ }
+ return { ...roof }
+ })
+
+ let result = true
+ newAddedRoofs.forEach((roof) => {
+ if (roof.eavesMargin && roof.ridgeMargin && roof.kerabaMargin) {
+ return true
+ }
+
+ if (!roof.trestleMkrCd) result = false
+ if (!roof.constMthdCd) result = false
+ if (!roof.roofBaseCd) result = false
+ if (!roof.constTp) result = false
+
+ if (selectedRoof.lenAuth === 'C') {
+ if (!trestleState?.lengthBase) result = false
+ }
+ if (['C', 'R'].includes(selectedRoof.raftAuth)) {
+ if (!roof.raftBaseCd) result = false
+ }
+
+ if (['C', 'R'].includes(selectedRoof.roofPchAuth)) {
+ if (!roof.roofPchBase) result = false
+ }
+ })
+
+ console.log('newAddedRoofs', newAddedRoofs)
+
+ if (result) {
+ setRoofs(newAddedRoofs)
+ setModuleSelectionData({
+ ...moduleSelectionData,
+ roofConstruction: {
+ ...newAddedRoofs,
+ },
+ })
+ trestleTrigger({
+ roofConstruction: newAddedRoofs.map((roof) => {
+ return {
+ roofIndex: roof.index,
+ addRoof: {
+ ...roof,
+ },
+ trestle: {
+ ...selectedTrestle,
+ raftBaseCd: roof.raftBaseCd,
+ },
+ construction: {
+ ...constructionList.find((construction) => trestleState.constTp === construction.constTp),
+ roofIndex: roof.index,
+ setupCover: roof.cvrYn === 'Y',
+ setupSnowCover: roof.snowGdYn === 'Y',
+ selectedIndex: roof.index,
+ },
+ }
+ }),
+ })
+ }
+
+ return result
+ }
+
+ useImperativeHandle(ref, () => ({
+ isComplete,
+ }))
+
+ return (
+
+
+
+ {roofs &&
+ roofs.map((roof, index) => (
+
+ ))}
+
+
+
+
+
+ {selectedRoof && selectedRoof.lenAuth === 'C' && (
+ <>
+
+
L
+
+
+ setLengthBase(e.target.value)}
+ disabled={selectedRoof.lenAuth === 'R'}
+ />
+
+
+
+ >
+ )}
+ {selectedRoof && ['C', 'R'].includes(selectedRoof.raftAuth) && (
+ <>
+
+
{getMessage('modal.module.basic.setting.module.rafter.margin')}
+
+
+ {raftBaseList.length > 0 && (
+ onChangeRaftBase(e)}
+ />
+ )}
+
+
+
+ >
+ )}
+ {selectedRoof && ['C', 'R'].includes(selectedRoof.roofPchAuth) && (
+ <>
+
+
{getMessage('modal.module.basic.setting.module.hajebichi')}
+
+
+ handleHajebichiAndLength(e, 'hajebichi')}
+ value={hajebichi}
+ />
+
+
+
+ >
+ )}
+
+
{getMessage('modal.module.basic.setting.module.trestle.maker')}
+
+
+ {trestleList && (
+ onChangeTrestleMaker(e)}
+ />
+ )}
+
+
+
+
+
{getMessage('modal.module.basic.setting.module.construction.method')}
+
+
+ {constMthdList && (
+ onChangeConstMthd(e)}
+ />
+ )}
+
+
+
+
+
{getMessage('modal.module.basic.setting.module.under.roof')}
+
+
+ {roofBaseList && (
+ onChangeRoofBase(e)}
+ />
+ )}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
{getMessage('modal.module.basic.setting.module.placement.area')}
+
+
{getMessage('modal.module.basic.setting.module.placement.area.eaves')}
+
+ dispatch({ type: 'SET_TRESTLE_DETAIL', roof: { ...trestleState, eavesMargin: e.target.value } })}
+ onChange={(e) => setEavesMargin(e.target.value)}
+ />
+
+
mm
+
+
+
{getMessage('modal.module.basic.setting.module.placement.area.ridge')}
+
+ dispatch({ type: 'SET_TRESTLE_DETAIL', roof: { ...trestleState, ridgeMargin: e.target.value } })}
+ onChange={(e) => setRidgeMargin(e.target.value)}
+ />
+
+
mm
+
+
+
{getMessage('modal.module.basic.setting.module.placement.area.keraba')}
+
+ dispatch({ type: 'SET_TRESTLE_DETAIL', roof: { ...trestleState, kerabaMargin: e.target.value } })}
+ onChange={(e) => setKerabaMargin(e.target.value)}
+ />
+
+
mm
+
+
+
+
+
+
+
+
+ {getMessage('modal.module.basic.setting.module.setting.info1')}
+
+ {getMessage('modal.module.basic.setting.module.setting.info2')}
+
+
+
+
+
+ )
+})
+
+export default Trestle
diff --git a/src/hooks/common/useCanvasPopupStatusController.js b/src/hooks/common/useCanvasPopupStatusController.js
index a31bd0ed..4a6ed6dd 100644
--- a/src/hooks/common/useCanvasPopupStatusController.js
+++ b/src/hooks/common/useCanvasPopupStatusController.js
@@ -1,6 +1,6 @@
'use client'
-import { useRecoilState, useRecoilValue } from 'recoil'
+import { useRecoilState, useRecoilValue, useSetRecoilState } from 'recoil'
import useSWRMutation from 'swr/mutation'
import { useAxios } from '../useAxios'
import { unescapeString } from '@/util/common-utils'
@@ -10,6 +10,8 @@ import { canvasState, currentCanvasPlanState } from '@/store/canvasAtom'
import { POLYGON_TYPE } from '@/common/common'
import { useCircuitTrestle } from '../useCirCuitTrestle'
import { useEffect } from 'react'
+import { addedRoofsState } from '@/store/settingAtom'
+import { roofsState } from '@/store/roofAtom'
/**
* 캔버스 팝업 상태 관리
@@ -19,13 +21,14 @@ import { useEffect } from 'react'
export function useCanvasPopupStatusController(param = 1) {
const popupType = parseInt(param)
- const [compasDeg, setCompasDeg] = useRecoilState(compasDegAtom)
- const [moduleSelectionDataStore, setModuleSelectionDataStore] = useRecoilState(moduleSelectionDataState)
- const [selectedModules, setSelectedModules] = useRecoilState(selectedModuleState)
+ const setCompasDeg = useSetRecoilState(compasDegAtom)
+ const setModuleSelectionDataStore = useSetRecoilState(moduleSelectionDataState)
+ const setSelectedModules = useSetRecoilState(selectedModuleState)
const { get, promiseGet, getFetcher, postFetcher } = useAxios()
const canvas = useRecoilValue(canvasState)
const currentCanvasPlan = useRecoilValue(currentCanvasPlanState)
-
+ const [addedRoofs, setAddedRoofs] = useRecoilState(addedRoofsState)
+ const [roofs, setRoofs] = useRecoilState(roofsState)
/**
* 팝업 상태 조회
* @param {number} popupTypeParam
@@ -53,19 +56,27 @@ export function useCanvasPopupStatusController(param = 1) {
const handleModuleSelectionTotal = async () => {
for (let i = 1; i < 3; i++) {
const result = await getModuleSelection(i)
- console.log('🚀 ~ handleModuleSelectionTotal ~ result:', result)
if (!result.objectNo) return
if (i === 1) {
- setCompasDeg(result.popupStatus)
+ if (result.popupStatus && unescapeString(result.popupStatus)) {
+ const data = JSON.parse(unescapeString(result.popupStatus))
+
+ if (data?.compasDeg) setCompasDeg(data.compasDeg)
+ if (data?.module) setSelectedModules(data.module)
+ setModuleSelectionDataStore(data)
+ }
} else if (i === 2) {
const data = JSON.parse(unescapeString(result.popupStatus))
- setModuleSelectionDataStore(data)
const roofSurfaceList = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE)
const modules = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE)
roofSurfaceList.forEach((surface) => {
surface.modules = modules.filter((module) => module.surfaceId === surface.id)
})
- if (data.module) setSelectedModules(data.module)
+ if (data.roofConstruction) {
+ setRoofs(data.roofConstruction)
+ // setManagementState({ ...managementState, roofs: data.roofConstruction.map((roof) => roof.construction.managementState) })
+ }
+ // if (data?.module) setManagementState(data.common.managementState)
}
}
}
@@ -80,7 +91,8 @@ export function useCanvasPopupStatusController(param = 1) {
objectNo: currentCanvasPlan.objectNo,
planNo: parseInt(currentCanvasPlan.planNo),
popupType: popupType.toString(),
- popupStatus: popupType === 1 ? arg : JSON.stringify(arg).replace(/"/g, '\"'),
+ // popupStatus: popupType === 1 ? arg : JSON.stringify(arg).replace(/"/g, '\"'),
+ popupStatus: JSON.stringify(arg).replace(/"/g, '\"'),
}
postFetcher(`/api/v1/canvas-popup-status`, params)
},
diff --git a/src/hooks/module/useModuleSelection.js b/src/hooks/module/useModuleSelection.js
index 8fa274a4..1373ea05 100644
--- a/src/hooks/module/useModuleSelection.js
+++ b/src/hooks/module/useModuleSelection.js
@@ -19,9 +19,9 @@ export function useModuleSelection(props) {
const [moduleList, setModuleList] = useState([{}]) //모듈 목록
const [selectedSurfaceType, setSelectedSurfaceType] = useState({}) //선택된 면조도
- const [installHeight, setInstallHeight] = useState() //설치 높이
- const [standardWindSpeed, setStandardWindSpeed] = useState({}) //기준풍속
- const [verticalSnowCover, setVerticalSnowCover] = useState() //수직적설량
+ const [installHeight, setInstallHeight] = useState(managementState?.installHeight) //설치 높이
+ const [standardWindSpeed, setStandardWindSpeed] = useState() //기준풍속
+ const [verticalSnowCover, setVerticalSnowCover] = useState(managementState?.verticalSnowCover) //수직적설량
const [selectedModules, setSelectedModules] = useRecoilState(selectedModuleState) //선택된 모듈
const [moduleSelectionInitParams, setModuleSelectionInitParams] = useRecoilState(moduleSelectionInitParamsState) //모듈 기본 데이터 ex) 면조도, 높이등등
@@ -32,6 +32,7 @@ export function useModuleSelection(props) {
const { restoreModuleInstArea } = useModuleBasicSetting()
const bindInitData = () => {
+ console.log('bindInitData', managementState)
setInstallHeight(managementState?.installHeight)
setStandardWindSpeed(managementState?.standardWindSpeedId)
setVerticalSnowCover(managementState?.verticalSnowCover)
@@ -184,14 +185,6 @@ export function useModuleSelection(props) {
})
}
- useEffect(() => {
- // console.log('installHeight', installHeight)
- }, [installHeight])
-
- useEffect(() => {
- // console.log('verticalSnowCover', verticalSnowCover)
- }, [verticalSnowCover])
-
//TODO: 설치높이, 기준적설량 debounce 적용해서 추가해야됨
// useEffect(() => {
@@ -226,11 +219,17 @@ export function useModuleSelection(props) {
roughnessCodes,
windSpeedCodes,
managementState,
+ setManagementState,
moduleList,
+ setSelectedModules,
selectedSurfaceType,
+ setSelectedSurfaceType,
installHeight,
+ setInstallHeight,
standardWindSpeed,
+ setStandardWindSpeed,
verticalSnowCover,
+ setVerticalSnowCover,
handleChangeModule,
handleChangeSurfaceType,
handleChangeWindSpeed,