모듈 공법 선택 유지 작업중

This commit is contained in:
lelalela 2025-01-10 16:25:57 +09:00
parent 2aa39acca5
commit 3b431f593b
2 changed files with 51 additions and 23 deletions

View File

@ -227,6 +227,7 @@ export default function Module({}) {
index={index}
addRoof={roof}
roofTab={roofTab}
moduleSelectionData={moduleSelectionData}
setModuleSelectionData={setModuleSelectionData}
tempModuleSelectionData={tempModuleSelectionData}
setTempModuleSelectionData={setTempModuleSelectionData}

View File

@ -8,7 +8,14 @@ import { moduleSelectionInitParamsState, selectedModuleState } from '@/store/sel
import { isNotEmptyArray, isObjectNotEmpty } from '@/util/common-utils'
import QSelectBox from '@/components/common/select/QSelectBox'
export default function ModuleTabContents({ addRoof, roofTab, setModuleSelectionData, tempModuleSelectionData, setTempModuleSelectionData }) {
export default function ModuleTabContents({
addRoof,
roofTab,
moduleSelectionData,
setModuleSelectionData,
tempModuleSelectionData,
setTempModuleSelectionData,
}) {
const { getMessage } = useMessage()
const canvasSetting = useRecoilValue(canvasSettingState) //
const [roofMaterial, setRoofMaterial] = useState(addRoof) //
@ -33,7 +40,6 @@ export default function ModuleTabContents({ addRoof, roofTab, setModuleSelection
const [trestleParams, setTrestleParams] = useState({}) //, ,, api
const moduleSelectionInitParams = useRecoilValue(moduleSelectionInitParamsState) // ex) ,
const selectedModules = useRecoilValue(selectedModuleState) //
const { getTrestleList, getConstructionList } = useMasterController()
@ -48,12 +54,22 @@ export default function ModuleTabContents({ addRoof, roofTab, setModuleSelection
const handleChangeRaftBase = (option) => {
setSelectedRaftBase(option)
setTrestleParams({ ...trestleParams, raftBaseCd: option.clCode })
setTrestleList([]) //
setConstMthdList([]) //
setRoofBaseList([]) //
}
//
const handleChangeTrestle = (option) => {
setSelectedTrestle(option) //
setTrestleParams({ ...trestleParams, trestleMkrCd: option.trestleMkrCd, constMthdCd: '' })
if (option) {
setSelectedTrestle(option) //
setTrestleParams({ ...trestleParams, trestleMkrCd: option.trestleMkrCd, constMthdCd: '', roofBaseCd: '' })
} else {
const existTrestle = moduleSelectionData.roofConstructions[roofTab].trestle
setSelectedTrestle(existTrestle)
setTrestleParams({ ...existTrestle, constMthdCd: '', roofBaseCd: '' })
}
setConstMthdList([]) //
setRoofBaseList([]) //
@ -61,20 +77,34 @@ export default function ModuleTabContents({ addRoof, roofTab, setModuleSelection
//
const handleChangeConstMthd = (option) => {
setSelectedConstMthd(option) //
setTrestleParams({ ...trestleParams, constMthdCd: option.constMthdCd, roofBaseCd: '' })
if (option) {
setSelectedConstMthd(option) //
setTrestleParams({ ...trestleParams, constMthdCd: option.constMthdCd, roofBaseCd: '' })
} else {
const existTrestle = moduleSelectionData.roofConstructions[roofTab].trestle
setSelectedConstMthd(existTrestle)
setTrestleParams({ ...existTrestle, constMthdCd: '', roofBaseCd: '' })
}
setRoofBaseList([])
}
//
const handleChangeRoofBase = (option) => {
setConstructionListParams({
...moduleSelectionInitParams,
...trestleParams,
roofBaseCd: option.roofBaseCd,
})
setSelectedRoofBase(option)
if (option) {
setConstructionListParams({
...moduleSelectionInitParams,
...trestleParams,
roofBaseCd: option.roofBaseCd,
})
setSelectedRoofBase(option)
} else {
const existTrestle = moduleSelectionData.roofConstructions[roofTab].trestle
setConstructionListParams({
...existTrestle,
})
setSelectedRoofBase(existTrestle)
}
}
const getModuleOptionsListData = async (params) => {
@ -165,10 +195,6 @@ export default function ModuleTabContents({ addRoof, roofTab, setModuleSelection
useEffect(() => {
// 202600
const raftCodeList = findCommonCode('203800')
console.log('addRoof', addRoof)
console.log('raftCodeList', raftCodeList)
//
raftCodeList.forEach((obj) => {
obj.name = obj.clCodeNm
@ -208,15 +234,16 @@ export default function ModuleTabContents({ addRoof, roofTab, setModuleSelection
}, [constructionListParams])
useEffect(() => {
console.log('🚀 ~ useEffect ~ tempModuleSelectionData:', tempModuleSelectionData)
if (isObjectNotEmpty(tempModuleSelectionData)) {
setModuleSelectionData(tempModuleSelectionData)
}
}, [tempModuleSelectionData])
useEffect(() => {
console.log('addRoof', addRoof)
if (isObjectNotEmpty(moduleSelectionData.roofConstructions[roofTab])) {
handleChangeTrestle()
handleChangeConstMthd()
}
}, [])
return (
@ -300,7 +327,7 @@ export default function ModuleTabContents({ addRoof, roofTab, setModuleSelection
<QSelectBox
title={getMessage('selectbox.title')}
options={trestleList}
// value={roofTabParams[roofTab]}
value={selectedTrestle}
sourceKey={'trestleMkrCd'}
targetKey={'trestleMkrCd'}
showKey={'trestleMkrCdNm'}
@ -318,7 +345,7 @@ export default function ModuleTabContents({ addRoof, roofTab, setModuleSelection
<QSelectBox
title={getMessage('selectbox.title')}
options={constMthdList}
// value={roofTabParams[roofTab]}
value={selectedConstMthd}
sourceKey={'constMthdCd'}
targetKey={'constMthdCd'}
showKey={'constMthdCdNm'}
@ -336,7 +363,7 @@ export default function ModuleTabContents({ addRoof, roofTab, setModuleSelection
<QSelectBox
title={getMessage('selectbox.title')}
options={roofBaseList}
// value={roofTabParams[roofTab]}
value={selectedRoofBase}
sourceKey={'roofBaseCd'}
targetKey={'roofBaseCd'}
showKey={'roofBaseCdNm'}