moduleSelectionData 수정
This commit is contained in:
parent
9976ff59d6
commit
468c7fda6f
@ -77,7 +77,7 @@ export default function BasicSetting({ id, pos = { x: 50, y: 230 } }) {
|
|||||||
const { trigger: orientationTrigger } = useCanvasPopupStatusController(1)
|
const { trigger: orientationTrigger } = useCanvasPopupStatusController(1)
|
||||||
const { trigger: trestleTrigger } = useCanvasPopupStatusController(2)
|
const { trigger: trestleTrigger } = useCanvasPopupStatusController(2)
|
||||||
const { trigger: placementTrigger } = useCanvasPopupStatusController(3)
|
const { trigger: placementTrigger } = useCanvasPopupStatusController(3)
|
||||||
const roofsStore = useRecoilValue(roofsState)
|
const [roofsStore, setRoofsStore] = useRecoilState(roofsState)
|
||||||
|
|
||||||
// const { initEvent } = useContext(EventContext)
|
// const { initEvent } = useContext(EventContext)
|
||||||
const { manualModuleSetup, autoModuleSetup, manualFlatroofModuleSetup, autoFlatroofModuleSetup, manualModuleLayoutSetup } =
|
const { manualModuleSetup, autoModuleSetup, manualFlatroofModuleSetup, autoFlatroofModuleSetup, manualModuleLayoutSetup } =
|
||||||
@ -95,6 +95,7 @@ export default function BasicSetting({ id, pos = { x: 50, y: 230 } }) {
|
|||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
console.log(roofsStore)
|
||||||
setModuleSelectionData({
|
setModuleSelectionData({
|
||||||
...moduleSelectionData,
|
...moduleSelectionData,
|
||||||
roofConstructions: roofsStore.map((roof) => {
|
roofConstructions: roofsStore.map((roof) => {
|
||||||
@ -255,6 +256,7 @@ export default function BasicSetting({ id, pos = { x: 50, y: 230 } }) {
|
|||||||
const trestleProps = {
|
const trestleProps = {
|
||||||
roofs,
|
roofs,
|
||||||
setRoofs,
|
setRoofs,
|
||||||
|
setRoofsStore,
|
||||||
tabNum,
|
tabNum,
|
||||||
setTabNum,
|
setTabNum,
|
||||||
moduleSelectionData,
|
moduleSelectionData,
|
||||||
|
|||||||
@ -352,8 +352,8 @@ const Placement = forwardRef((props, refs) => {
|
|||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<div className="color-wrap">
|
<div className="color-wrap">
|
||||||
<span className="color-box" style={{ backgroundColor: roofOutlineColor(item.addRoof.index) }}></span>
|
<span className="color-box" style={{ backgroundColor: roofOutlineColor(item.addRoof?.index) }}></span>
|
||||||
<span className="name">{item.addRoof.roofMatlNmJp}</span>
|
<span className="name">{item.addRoof?.roofMatlNmJp}</span>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
{moduleRowColArray[index]?.map((item) => (
|
{moduleRowColArray[index]?.map((item) => (
|
||||||
|
|||||||
@ -6,12 +6,11 @@ import { useMessage } from '@/hooks/useMessage'
|
|||||||
import { currentAngleTypeSelector, pitchTextSelector } from '@/store/canvasAtom'
|
import { currentAngleTypeSelector, pitchTextSelector } from '@/store/canvasAtom'
|
||||||
import { roofsState } from '@/store/roofAtom'
|
import { roofsState } from '@/store/roofAtom'
|
||||||
import { moduleSelectionDataState, selectedModuleState } from '@/store/selectedModuleOptions'
|
import { moduleSelectionDataState, selectedModuleState } from '@/store/selectedModuleOptions'
|
||||||
import { isObjectNotEmpty } from '@/util/common-utils'
|
|
||||||
import { forwardRef, useContext, useEffect, useImperativeHandle, useRef, useState } from 'react'
|
import { forwardRef, useContext, useEffect, useImperativeHandle, useRef, useState } from 'react'
|
||||||
import { useRecoilState, useRecoilValue } from 'recoil'
|
import { useRecoilState, useRecoilValue } from 'recoil'
|
||||||
|
|
||||||
const Trestle = forwardRef((props, ref) => {
|
const Trestle = forwardRef((props, ref) => {
|
||||||
const { tabNum, setTabNum, trestleTrigger, roofs, setRoofs, moduleSelectionData, setModuleSelectionData } = props
|
const { tabNum, setTabNum, trestleTrigger, roofs, setRoofs, moduleSelectionData, setModuleSelectionData, setRoofsStore } = props
|
||||||
const { getMessage } = useMessage()
|
const { getMessage } = useMessage()
|
||||||
// const [selectedTrestle, setSelectedTrestle] = useState()
|
// const [selectedTrestle, setSelectedTrestle] = useState()
|
||||||
const currentAngleType = useRecoilValue(currentAngleTypeSelector)
|
const currentAngleType = useRecoilValue(currentAngleTypeSelector)
|
||||||
@ -66,8 +65,6 @@ const Trestle = forwardRef((props, ref) => {
|
|||||||
restoreModuleInstArea()
|
restoreModuleInstArea()
|
||||||
}, [roofs])
|
}, [roofs])
|
||||||
|
|
||||||
useEffect(() => {}, [moduleSelectionData])
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (flag && moduleSelectionData) {
|
if (flag && moduleSelectionData) {
|
||||||
if (JSON.stringify(tempModuleSelectionData.current) === JSON.stringify(moduleSelectionData)) {
|
if (JSON.stringify(tempModuleSelectionData.current) === JSON.stringify(moduleSelectionData)) {
|
||||||
@ -82,7 +79,16 @@ const Trestle = forwardRef((props, ref) => {
|
|||||||
setEavesMargin(selectedRoof?.eavesMargin ?? 0)
|
setEavesMargin(selectedRoof?.eavesMargin ?? 0)
|
||||||
setRidgeMargin(selectedRoof?.ridgeMargin ?? 0)
|
setRidgeMargin(selectedRoof?.ridgeMargin ?? 0)
|
||||||
setKerabaMargin(selectedRoof?.kerabaMargin ?? 0)
|
setKerabaMargin(selectedRoof?.kerabaMargin ?? 0)
|
||||||
dispatch({ type: 'SET_INITIALIZE', roof: { ...selectedRoof, ...moduleSelectionData } })
|
setLengthBase(Math.round(selectedRoof?.lenBase ?? 0))
|
||||||
|
if (moduleSelectionData?.roofConstructions?.length >= selectedRoof.index + 1) {
|
||||||
|
const { construction, trestle, trestleDetail } = moduleSelectionData?.roofConstructions[selectedRoof.index]
|
||||||
|
dispatch({
|
||||||
|
type: 'SET_INITIALIZE',
|
||||||
|
roof: { common: moduleSelectionData.common, module: moduleSelectionData.module, construction, trestle, trestleDetail, ...selectedRoof },
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
dispatch({ type: 'SET_INITIALIZE', roof: { ...selectedRoof, ...moduleSelectionData } })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, [selectedRoof])
|
}, [selectedRoof])
|
||||||
|
|
||||||
@ -180,33 +186,6 @@ const Trestle = forwardRef((props, ref) => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
const handleChangeRoofMaterial = (index) => {
|
|
||||||
const newAddedRoofs = roofs.map((roof, i) => {
|
|
||||||
if (i === selectedRoof.index) {
|
|
||||||
return {
|
|
||||||
...selectedRoof,
|
|
||||||
eavesMargin,
|
|
||||||
ridgeMargin,
|
|
||||||
kerabaMargin,
|
|
||||||
roofIndex: roof.index,
|
|
||||||
trestle: {
|
|
||||||
lengthBase: lengthBase,
|
|
||||||
...selectedRaftBase,
|
|
||||||
...selectedTrestle,
|
|
||||||
...selectedConstMthd,
|
|
||||||
...selectedRoofBase,
|
|
||||||
},
|
|
||||||
construction: {
|
|
||||||
...constructionList.find((data) => data.constTp === trestleState.constTp),
|
|
||||||
},
|
|
||||||
trestleDetail: trestleDetail,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return roof
|
|
||||||
})
|
|
||||||
setRoofs(newAddedRoofs)
|
|
||||||
setSelectedRoof(newAddedRoofs[index])
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleConstruction = (index) => {
|
const handleConstruction = (index) => {
|
||||||
if (constructionList[index]?.constPossYn === 'Y') {
|
if (constructionList[index]?.constPossYn === 'Y') {
|
||||||
@ -227,7 +206,7 @@ const Trestle = forwardRef((props, ref) => {
|
|||||||
roofPitch: Math.round(selectedRoof?.roofPchBase ?? 0),
|
roofPitch: Math.round(selectedRoof?.roofPchBase ?? 0),
|
||||||
constTp: constructionList[index].constTp,
|
constTp: constructionList[index].constTp,
|
||||||
mixMatlNo: selectedModules.mixMatlNo,
|
mixMatlNo: selectedModules.mixMatlNo,
|
||||||
workingWidth: selectedRoof?.length.toString() ?? '',
|
workingWidth: selectedRoof?.length?.toString() ?? '',
|
||||||
// snowGdPossYn: constructionList[index].snowGdPossYn,
|
// snowGdPossYn: constructionList[index].snowGdPossYn,
|
||||||
// cvrYn: constructionList[index].cvrYn,
|
// cvrYn: constructionList[index].cvrYn,
|
||||||
},
|
},
|
||||||
@ -240,9 +219,38 @@ const Trestle = forwardRef((props, ref) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleChangeRoofMaterial = (index) => {
|
||||||
|
const newAddedRoofs = roofs.map((roof, i) => {
|
||||||
|
if (i === selectedRoof.index) {
|
||||||
|
return {
|
||||||
|
...selectedRoof,
|
||||||
|
eavesMargin,
|
||||||
|
ridgeMargin,
|
||||||
|
kerabaMargin,
|
||||||
|
roofIndex: selectedRoof.index,
|
||||||
|
trestle: {
|
||||||
|
lengthBase: lengthBase,
|
||||||
|
...selectedRaftBase,
|
||||||
|
...selectedTrestle,
|
||||||
|
...selectedConstMthd,
|
||||||
|
...selectedRoofBase,
|
||||||
|
},
|
||||||
|
construction: {
|
||||||
|
...constructionList.find((data) => data.constTp === trestleState.constTp),
|
||||||
|
},
|
||||||
|
trestleDetail: trestleDetail,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return roof
|
||||||
|
})
|
||||||
|
setRoofs(newAddedRoofs)
|
||||||
|
setSelectedRoof(newAddedRoofs[index])
|
||||||
|
console.log(newAddedRoofs)
|
||||||
|
}
|
||||||
|
|
||||||
const isComplete = async () => {
|
const isComplete = async () => {
|
||||||
const newAddedRoofs = roofs.map((roof, i) => {
|
const newAddedRoofs = roofs.map((roof, i) => {
|
||||||
if (i === selectedRoof?.roofIndex) {
|
if (i === selectedRoof?.index) {
|
||||||
return {
|
return {
|
||||||
...selectedRoof,
|
...selectedRoof,
|
||||||
eavesMargin,
|
eavesMargin,
|
||||||
@ -286,7 +294,7 @@ const Trestle = forwardRef((props, ref) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const newRoofs = newAddedRoofs.map((roof) => {
|
const newRoofs = newAddedRoofs.map((roof) => {
|
||||||
const { addRoof, trestle, construction, ...rest } = roof
|
const { addRoof, construction, trestle, trestleDetail, roofConstructions, ...rest } = roof
|
||||||
return rest
|
return rest
|
||||||
})
|
})
|
||||||
if (result) {
|
if (result) {
|
||||||
@ -321,23 +329,25 @@ const Trestle = forwardRef((props, ref) => {
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
new Promise((resolve) => {
|
new Promise((resolve) => {
|
||||||
trestleTrigger({
|
const roofConstruction = newAddedRoofs.map((roof, index) => ({
|
||||||
roofConstruction: newAddedRoofs.map((roof, index) => ({
|
roofIndex: roof.index,
|
||||||
|
addRoof: newRoofs[index],
|
||||||
|
trestle: {
|
||||||
|
...roof.trestle,
|
||||||
|
raftBaseCd: roof.raftBaseCd,
|
||||||
|
},
|
||||||
|
construction: {
|
||||||
|
...constructionList.find((construction) => newAddedRoofs[index].construction.constTp === construction.constTp),
|
||||||
roofIndex: roof.index,
|
roofIndex: roof.index,
|
||||||
addRoof: newRoofs[index],
|
setupCover: roof.cvrYn === 'Y',
|
||||||
trestle: {
|
setupSnowCover: roof.snowGdYn === 'Y',
|
||||||
...selectedTrestle,
|
selectedIndex: roof.index,
|
||||||
raftBaseCd: roof.raftBaseCd,
|
},
|
||||||
},
|
}))
|
||||||
construction: {
|
trestleTrigger({
|
||||||
...constructionList.find((construction) => trestleState.constTp === construction.constTp),
|
roofConstruction,
|
||||||
roofIndex: roof.index,
|
|
||||||
setupCover: roof.cvrYn === 'Y',
|
|
||||||
setupSnowCover: roof.snowGdYn === 'Y',
|
|
||||||
selectedIndex: roof.index,
|
|
||||||
},
|
|
||||||
})),
|
|
||||||
})
|
})
|
||||||
|
setRoofsStore(roofConstruction)
|
||||||
resolve()
|
resolve()
|
||||||
}),
|
}),
|
||||||
]
|
]
|
||||||
@ -383,7 +393,7 @@ const Trestle = forwardRef((props, ref) => {
|
|||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
className="input-origin block"
|
className="input-origin block"
|
||||||
value={trestleState?.lengthBase}
|
value={lengthBase}
|
||||||
onChange={(e) => setLengthBase(e.target.value)}
|
onChange={(e) => setLengthBase(e.target.value)}
|
||||||
disabled={selectedRoof.lenAuth === 'R'}
|
disabled={selectedRoof.lenAuth === 'R'}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -23,21 +23,21 @@ const trestleReducer = (state, action) => {
|
|||||||
moduleTpCd: action.roof.module?.itemTp ?? '',
|
moduleTpCd: action.roof.module?.itemTp ?? '',
|
||||||
roofMatlCd: action.roof?.roofMatlCd ?? '',
|
roofMatlCd: action.roof?.roofMatlCd ?? '',
|
||||||
raftBaseCd: action.roof?.raftBaseCd ?? null,
|
raftBaseCd: action.roof?.raftBaseCd ?? null,
|
||||||
trestleMkrCd: action.roof.roofConstructions[action.roof.index].trestle?.trestleMkrCd ?? null,
|
trestleMkrCd: action.roof.trestle?.trestleMkrCd ?? null,
|
||||||
constMthdCd: action.roof.roofConstructions[action.roof.index].trestle?.constMthdCd ?? null,
|
constMthdCd: action.roof.trestle?.constMthdCd ?? null,
|
||||||
constTp: action.roof.roofConstructions[action.roof.index].construction?.constTp ?? null,
|
constTp: action.roof.construction?.constTp ?? null,
|
||||||
roofBaseCd: action.roof.roofConstructions[action.roof.index].trestle?.roofBaseCd ?? null,
|
roofBaseCd: action.roof.trestle?.roofBaseCd ?? null,
|
||||||
workingWidth: action.roof.workingWidth ?? 0,
|
workingWidth: action.roof.workingWidth ?? 0,
|
||||||
lengthBase: action.roof.roofConstructions[action.roof.index].addRoof?.length ?? 0,
|
lengthBase: action.roof?.length ?? 0,
|
||||||
illuminationTp: action.roof.common.illuminationTp ?? null,
|
illuminationTp: action.roof.common.illuminationTp ?? null,
|
||||||
instHt: action.roof.common.instHt ?? null,
|
instHt: action.roof.common.instHt ?? null,
|
||||||
stdWindSpeed: action.roof.common.stdWindSpeed ?? null,
|
stdWindSpeed: action.roof.common.stdWindSpeed ?? null,
|
||||||
stdSnowLd: action.roof.common.stdSnowLd ?? null,
|
stdSnowLd: action.roof.common.stdSnowLd ?? null,
|
||||||
inclCd: action.roof.roofConstructions[action.roof.index].addRoof?.pitch ?? null,
|
inclCd: action.roof?.pitch ?? null,
|
||||||
roofPitch: action.roof.roofConstructions[action.roof.index].addRoof?.roofPchBase ?? 0,
|
roofPitch: action.roof?.roofPchBase ?? 0,
|
||||||
eavesMargin: action.roof.roofConstructions[action.roof.index].addRoof?.eavesMargin ?? null,
|
eavesMargin: action.roof?.eavesMargin ?? null,
|
||||||
ridgeMargin: action.roof.roofConstructions[action.roof.index].addRoof?.ridgeMargin ?? null,
|
ridgeMargin: action.roof?.ridgeMargin ?? null,
|
||||||
kerabaMargin: action.roof.roofConstructions[action.roof.index].addRoof?.kerabaMargin ?? null,
|
kerabaMargin: action.roof?.kerabaMargin ?? null,
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return state
|
return state
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user