모듈 관련 데이터 수정시 roofs 데이터 초기화 버그 수정

This commit is contained in:
김민식 2025-04-03 16:31:12 +09:00
parent f32e772141
commit d524b33f56
4 changed files with 23 additions and 29 deletions

View File

@ -91,14 +91,14 @@ export default function BasicSetting({ id, pos = { x: 50, y: 230 } }) {
useEffect(() => { useEffect(() => {
if (roofsStore && addedRoofs) { if (roofsStore && addedRoofs) {
console.log('🚀 ~ useEffect ~ roofsStore, addedRoofs:', roofsStore, addedRoofs) console.log('🚀 ~ useEffect ~ roofsStore, addedRoofs:', roofsStore, addedRoofs)
setRoofs( // setRoofs(
addedRoofs.map((roof, index) => { // addedRoofs.map((roof, index) => {
return { // return {
...roof, // ...roof,
...roofsStore[index]?.addRoof, // ...roofsStore[index]?.addRoof,
} // }
}), // }),
) // )
setModuleSelectionData({ setModuleSelectionData({
...moduleSelectionData, ...moduleSelectionData,

View File

@ -1,6 +1,5 @@
import { GlobalDataContext } from '@/app/GlobalDataProvider' import { GlobalDataContext } from '@/app/GlobalDataProvider'
import QSelectBox from '@/components/common/select/QSelectBox' import QSelectBox from '@/components/common/select/QSelectBox'
import { useModuleBasicSetting } from '@/hooks/module/useModuleBasicSetting'
import { useModuleTrestle } from '@/hooks/module/useModuleTrestle' import { useModuleTrestle } from '@/hooks/module/useModuleTrestle'
import { useMessage } from '@/hooks/useMessage' import { useMessage } from '@/hooks/useMessage'
import { currentAngleTypeSelector, pitchTextSelector } from '@/store/canvasAtom' import { currentAngleTypeSelector, pitchTextSelector } from '@/store/canvasAtom'
@ -46,22 +45,18 @@ const Trestle = forwardRef((props, ref) => {
const selectedModules = useRecoilValue(selectedModuleState) // const selectedModules = useRecoilValue(selectedModuleState) //
// const [moduleSelectionData, setModuleSelectionData] = useRecoilState(moduleSelectionDataState) // const [moduleSelectionData, setModuleSelectionData] = useRecoilState(moduleSelectionDataState)
const [lengthBase, setLengthBase] = useState(0) const [lengthBase, setLengthBase] = useState(0)
const [hajebichi, setHajebichi] = useState(0) const [hajebichi, setHajebichi] = useState(trestleState?.roofPitch ?? 0)
const [selectedRaftBase, setSelectedRaftBase] = useState(null) const [selectedRaftBase, setSelectedRaftBase] = useState(null)
const [selectedTrestle, setSelectedTrestle] = useState(null) const [selectedTrestle, setSelectedTrestle] = useState(null)
const [selectedConstMthd, setSelectedConstMthd] = useState(null) const [selectedConstMthd, setSelectedConstMthd] = useState(null)
const [selectedConstruction, setSelectedConstruction] = useState(null) const [selectedConstruction, setSelectedConstruction] = useState(null)
const [selectedRoofBase, setSelectedRoofBase] = useState(null) const [selectedRoofBase, setSelectedRoofBase] = useState(null)
const { managementState } = useContext(GlobalDataContext) const { managementState } = useContext(GlobalDataContext)
const { restoreModuleInstArea } = useModuleBasicSetting()
useEffect(() => { useEffect(() => {
if (roofs && !selectedRoof) { if (roofs && !selectedRoof) {
setSelectedRoof(roofs[0]) setSelectedRoof(roofs[0])
} }
//
restoreModuleInstArea()
}, [roofs]) }, [roofs])
useEffect(() => { useEffect(() => {
@ -201,10 +196,12 @@ const Trestle = forwardRef((props, ref) => {
stdWindSpeed: managementState?.standardWindSpeedId ?? '', stdWindSpeed: managementState?.standardWindSpeedId ?? '',
stdSnowLd: +managementState?.verticalSnowCover ?? '', stdSnowLd: +managementState?.verticalSnowCover ?? '',
inclCd: selectedRoof?.pitch.toString() ?? 0, inclCd: selectedRoof?.pitch.toString() ?? 0,
roofPitch: Math.round(selectedRoof?.roofPchBase ?? 0), // roofPitch: Math.round(selectedRoof?.roofPchBase ?? 0),
roofPitch: hajebichi ?? 0,
constTp: constructionList[index].constTp, constTp: constructionList[index].constTp,
mixMatlNo: selectedModules.mixMatlNo, mixMatlNo: selectedModules.mixMatlNo,
workingWidth: selectedRoof?.length.toString() ?? '', // workingWidth: selectedRoof?.length.toString() ?? '',
workingWidth: lengthBase ?? '',
// snowGdPossYn: constructionList[index].snowGdPossYn, // snowGdPossYn: constructionList[index].snowGdPossYn,
// cvrYn: constructionList[index].cvrYn, // cvrYn: constructionList[index].cvrYn,
}, },
@ -259,14 +256,13 @@ const Trestle = forwardRef((props, ref) => {
} }
}) })
console.log('newAddedRoofs', newAddedRoofs)
if (result) { if (result) {
setRoofs(newAddedRoofs) setRoofs(newAddedRoofs)
setModuleSelectionData({ setModuleSelectionData({
...moduleSelectionData, ...moduleSelectionData,
roofConstructions: newAddedRoofs.map((roof, index) => { roofConstructions: newAddedRoofs.map((roof, index) => {
return { return {
roofIndex: index,
addRoof: { addRoof: {
...moduleSelectionData.roofConstructions[index]?.addRoof, ...moduleSelectionData.roofConstructions[index]?.addRoof,
...roof.addRoof, ...roof.addRoof,
@ -276,8 +272,8 @@ const Trestle = forwardRef((props, ref) => {
...moduleSelectionData.roofConstructions[index]?.trestle, ...moduleSelectionData.roofConstructions[index]?.trestle,
}, },
construction: { construction: {
...roof.construction,
...moduleSelectionData.roofConstructions[index]?.construction, ...moduleSelectionData.roofConstructions[index]?.construction,
...roof.construction,
}, },
trestleDetail: { trestleDetail: {
...roof.trestleDetail, ...roof.trestleDetail,
@ -343,7 +339,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'}
/> />
@ -384,7 +380,7 @@ const Trestle = forwardRef((props, ref) => {
type="text" type="text"
className="input-origin block" className="input-origin block"
disabled={selectedRoof.roofPchAuth === 'R'} disabled={selectedRoof.roofPchAuth === 'R'}
onChange={(e) => handleHajebichiAndLength(e, 'hajebichi')} onChange={(e) => setHajebichi(e.target.value)}
value={hajebichi} value={hajebichi}
/> />
</div> </div>

View File

@ -8,8 +8,6 @@ import { GlobalDataContext } from '@/app/GlobalDataProvider'
const RAFT_BASE_CODE = '203800' const RAFT_BASE_CODE = '203800'
const trestleReducer = (state, action) => { const trestleReducer = (state, action) => {
console.log('🚀 ~ trestleReducer ~ state:', state)
console.log('🚀 ~ trestleReducer ~ action:', action)
switch (action.type) { switch (action.type) {
case 'SET_RAFT_BASE': case 'SET_RAFT_BASE':
case 'SET_TRESTLE_MAKER': case 'SET_TRESTLE_MAKER':
@ -21,7 +19,6 @@ const trestleReducer = (state, action) => {
...action.roof, ...action.roof,
} }
case 'SET_INITIALIZE': case 'SET_INITIALIZE':
console.log('SET_INITIALIZE')
return { return {
moduleTpCd: action.roof.moduleTpCd ?? '', moduleTpCd: action.roof.moduleTpCd ?? '',
roofMatlCd: action.roof.roofMatlCd ?? '', roofMatlCd: action.roof.roofMatlCd ?? '',
@ -85,7 +82,6 @@ export function useModuleTrestle(props) {
useEffect(() => { useEffect(() => {
if (trestleState) { if (trestleState) {
console.log('🚀 ~ useEffect ~ trestleState:', trestleState)
handleSetTrestleList() handleSetTrestleList()
if (!trestleState.trestleMkrCd) { if (!trestleState.trestleMkrCd) {
setConstMthdList([]) setConstMthdList([])
@ -168,7 +164,7 @@ export function useModuleTrestle(props) {
stdSnowLd: trestleState.stdSnowLd ?? '', stdSnowLd: trestleState.stdSnowLd ?? '',
inclCd: trestleState.inclCd ?? '', inclCd: trestleState.inclCd ?? '',
raftBaseCd: trestleState.raftBaseCd ?? '', raftBaseCd: trestleState.raftBaseCd ?? '',
roofPitch: trestleState.roofPitch ?? '', roofPitch: Math.round(trestleState.roofPitch) ?? '',
}).then((res) => { }).then((res) => {
if (res?.data) setConstructionList(res.data) if (res?.data) setConstructionList(res.data)
}) })

View File

@ -296,7 +296,7 @@ export function useRoofAllocationSetting(id) {
}) })
} }
return { ...roof, index: idx, raft: roof.raft ? roof.raft : roof.raftBaseCd } return { ...roof, index: idx, raft: roof.raft ? roof.raft : roof.raftBaseCd, raftBaseCd: roof.raft ? roof.raft : roof.raftBaseCd }
}) })
setBasicSetting((prev) => { setBasicSetting((prev) => {
@ -308,7 +308,8 @@ export function useRoofAllocationSetting(id) {
const selectedRoofMaterial = newRoofList.find((roof) => roof.selected) const selectedRoofMaterial = newRoofList.find((roof) => roof.selected)
setSurfaceShapePattern(currentObject, roofDisplay.column, false, selectedRoofMaterial, true) setSurfaceShapePattern(currentObject, roofDisplay.column, false, selectedRoofMaterial, true)
drawDirectionArrow(currentObject) drawDirectionArrow(currentObject)
modifyModuleSelectionData() setModuleSelectionData({ ...moduleSelectionData, roofConstructions: newRoofList })
// modifyModuleSelectionData()
closeAll() closeAll()
basicSettingSave() basicSettingSave()
} }
@ -430,7 +431,8 @@ export function useRoofAllocationSetting(id) {
setSelectedMenu('surface') setSelectedMenu('surface')
/** 모듈 선택 데이터 초기화 */ /** 모듈 선택 데이터 초기화 */
modifyModuleSelectionData() // modifyModuleSelectionData()
setModuleSelectionData({ ...moduleSelectionData, roofConstructions: newRoofList })
} }
/** /**