Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
yoosangwook 2025-01-10 19:01:04 +09:00
commit 08bcf1c858

View File

@ -38,6 +38,8 @@ export default function ModuleTabContents({
const [constructionListParams, setConstructionListParams] = useState({})
const [trestleParams, setTrestleParams] = useState({}) //, ,, api
const [constructionParams, setConstructionParams] = useState({}) // api
const [roofBaseParams, setRoofBaseParams] = useState({}) // api
const moduleSelectionInitParams = useRecoilValue(moduleSelectionInitParamsState) // ex) ,
@ -50,6 +52,8 @@ export default function ModuleTabContents({
const [cvrChecked, setCvrChecked] = useState(false)
const [snowGdChecked, setSnowGdChecked] = useState(false)
const [isExistData, setIsExistData] = useState(false)
//
const handleChangeRaftBase = (option) => {
setSelectedRaftBase(option)
@ -62,49 +66,25 @@ export default function ModuleTabContents({
//
const handleChangeTrestle = (option) => {
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([]) //
setSelectedTrestle(option) //
setConstructionParams({ ...trestleParams, trestleMkrCd: option.trestleMkrCd, constMthdCd: '', roofBaseCd: '' })
}
//
const handleChangeConstMthd = (option) => {
if (option) {
setSelectedConstMthd(option) //
setTrestleParams({ ...trestleParams, constMthdCd: option.constMthdCd, roofBaseCd: '' })
} else {
const existTrestle = moduleSelectionData.roofConstructions[roofTab].trestle
setSelectedConstMthd(existTrestle)
setTrestleParams({ ...existTrestle, constMthdCd: '', roofBaseCd: '' })
}
setRoofBaseList([])
setSelectedConstMthd(option) //
setRoofBaseParams({ ...trestleParams, trestleMkrCd: selectedTrestle.trestleMkrCd, constMthdCd: option.constMthdCd, roofBaseCd: '' })
}
//
const handleChangeRoofBase = (option) => {
if (option) {
setConstructionListParams({
...moduleSelectionInitParams,
...trestleParams,
roofBaseCd: option.roofBaseCd,
})
setSelectedRoofBase(option)
} else {
const existTrestle = moduleSelectionData.roofConstructions[roofTab].trestle
setConstructionListParams({
...existTrestle,
})
setSelectedRoofBase(existTrestle)
}
// if (option) {
setConstructionListParams({
...moduleSelectionInitParams,
...roofBaseParams,
roofBaseCd: option.roofBaseCd,
})
setSelectedRoofBase(option)
}
const getModuleOptionsListData = async (params) => {
@ -112,17 +92,28 @@ export default function ModuleTabContents({
if (optionsList.data.length > 0) {
if (optionsList.data[0].trestleMkrCd && optionsList.data[0].constMthdCd === null) {
setTrestleList(optionsList.data)
setConstMthdList([])
setRoofBaseList([])
if (isExistData) {
setSelectedTrestle({ ...moduleSelectionData.roofConstructions[roofTab].trestle })
} else {
setConstMthdList([])
setRoofBaseList([])
}
}
if (optionsList.data[0].trestleMkrCd && optionsList.data[0].constMthdCd && optionsList.data[0].roofBaseCd === null) {
setConstMthdList(optionsList.data)
setRoofBaseList([])
if (isExistData) {
setSelectedConstMthd({ ...moduleSelectionData.roofConstructions[roofTab].trestle })
} else {
setRoofBaseList([])
}
}
if (optionsList.data[0].trestleMkrCd && optionsList.data[0].constMthdCd && optionsList.data[0].roofBaseCd) {
setRoofBaseList(optionsList.data)
if (isExistData) {
setSelectedRoofBase({ ...moduleSelectionData.roofConstructions[roofTab].trestle })
}
}
}
}
@ -148,10 +139,13 @@ export default function ModuleTabContents({
constructionRef.current[index].classList.remove('white')
constructionRef.current[index].classList.add('blue')
debugger
const selectedConstruction = constructionList[index]
selectedConstruction.roofIndex = roofTab
selectedConstruction.setupCover = false //
selectedConstruction.setupSnowCover = false //
selectedConstruction.selectedIndex = index
setCvrYn(selectedConstruction.cvrYn)
setSnowGdPossYn(selectedConstruction.snowGdPossYn)
@ -192,6 +186,23 @@ export default function ModuleTabContents({
setSelectedConstruction({ ...selectedConstruction, setupSnowCover: snowGdChecked })
}, [snowGdChecked])
useEffect(() => {
if (isExistData) {
setConstructionListParams({
...moduleSelectionInitParams,
...roofBaseParams,
roofBaseCd: selectedRoofBase.roofBaseCd,
})
}
}, [selectedRoofBase])
useEffect(() => {
if (isExistData) {
const selectedIndex = moduleSelectionData.roofConstructions[roofTab].construction.selectedIndex
handleConstruction(selectedIndex)
}
}, [constructionList])
useEffect(() => {
// 202600
const raftCodeList = findCommonCode('203800')
@ -215,6 +226,12 @@ export default function ModuleTabContents({
if (isModuleLoaded) {
setTrestleParams({ moduleTpCd: moduleSelectionInitParams.moduleTpCd, roofMatlCd: addRoof.roofMatlCd, raftBaseCd: addRoof.raftBaseCd })
setConstructionList([])
if (isObjectNotEmpty(moduleSelectionData.roofConstructions[roofTab])) {
setConstructionParams({ ...moduleSelectionData.roofConstructions[roofTab].trestle, constMthdCd: '', roofBaseCd: '' })
setRoofBaseParams({ ...moduleSelectionData.roofConstructions[roofTab].trestle, roofBaseCd: '' })
setIsExistData(true)
}
}
}
@ -227,6 +244,18 @@ export default function ModuleTabContents({
}
}, [trestleParams])
useEffect(() => {
if (isObjectNotEmpty(constructionParams)) {
getModuleOptionsListData(constructionParams)
}
}, [constructionParams])
useEffect(() => {
if (isObjectNotEmpty(roofBaseParams)) {
getModuleOptionsListData(roofBaseParams)
}
}, [roofBaseParams])
useEffect(() => {
if (isObjectNotEmpty(constructionListParams)) {
getConstructionListData(constructionListParams)
@ -239,13 +268,6 @@ export default function ModuleTabContents({
}
}, [tempModuleSelectionData])
useEffect(() => {
if (isObjectNotEmpty(moduleSelectionData.roofConstructions[roofTab])) {
handleChangeTrestle()
handleChangeConstMthd()
}
}, [])
return (
<>
<div className="module-table-inner">