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