모듈 공법 선택 유지 작업중

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} index={index}
addRoof={roof} addRoof={roof}
roofTab={roofTab} roofTab={roofTab}
moduleSelectionData={moduleSelectionData}
setModuleSelectionData={setModuleSelectionData} setModuleSelectionData={setModuleSelectionData}
tempModuleSelectionData={tempModuleSelectionData} tempModuleSelectionData={tempModuleSelectionData}
setTempModuleSelectionData={setTempModuleSelectionData} setTempModuleSelectionData={setTempModuleSelectionData}

View File

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