커밋
This commit is contained in:
parent
50bd18c2f6
commit
5def9c77a1
@ -15,6 +15,7 @@ import { moduleSelectionDataState } from '@/store/selectedModuleOptions'
|
|||||||
import { addedRoofsState } from '@/store/settingAtom'
|
import { addedRoofsState } from '@/store/settingAtom'
|
||||||
import { isObjectNotEmpty } from '@/util/common-utils'
|
import { isObjectNotEmpty } from '@/util/common-utils'
|
||||||
import Swal from 'sweetalert2'
|
import Swal from 'sweetalert2'
|
||||||
|
import { useCanvasPopupStatusController } from '@/hooks/common/useCanvasPopupStatusController'
|
||||||
|
|
||||||
export default function BasicSetting({ id, pos = { x: 50, y: 230 } }) {
|
export default function BasicSetting({ id, pos = { x: 50, y: 230 } }) {
|
||||||
const { getMessage } = useMessage()
|
const { getMessage } = useMessage()
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { useEffect, useState, useReducer } from 'react'
|
import { useEffect, useState, useReducer, useRef } from 'react'
|
||||||
import { useRecoilValue, useRecoilState } from 'recoil'
|
import { useRecoilValue, useRecoilState } from 'recoil'
|
||||||
import { addedRoofsState } from '@/store/settingAtom'
|
import { addedRoofsState } from '@/store/settingAtom'
|
||||||
import { currentCanvasPlanState } from '@/store/canvasAtom'
|
import { currentCanvasPlanState } from '@/store/canvasAtom'
|
||||||
@ -41,6 +41,18 @@ export default function Module({ setTabNum }) {
|
|||||||
const [debouncedVerticalSnowCover] = useDebounceValue(inputVerticalSnowCover, 500)
|
const [debouncedVerticalSnowCover] = useDebounceValue(inputVerticalSnowCover, 500)
|
||||||
|
|
||||||
const [moduleSelectionData, setModuleSelectionData] = useRecoilState(moduleSelectionDataState) //다음으로 넘어가는 최종 데이터
|
const [moduleSelectionData, setModuleSelectionData] = useRecoilState(moduleSelectionDataState) //다음으로 넘어가는 최종 데이터
|
||||||
|
|
||||||
|
const dataRef = useRef({
|
||||||
|
selectedSurfaceType,
|
||||||
|
installHeight,
|
||||||
|
standardWindSpeed,
|
||||||
|
verticalSnowCover,
|
||||||
|
})
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
console.log('dataRef', dataRef)
|
||||||
|
}, [])
|
||||||
|
|
||||||
const [tempModuleSelectionData, setTempModuleSelectionData] = useReducer((prevState, nextState) => {
|
const [tempModuleSelectionData, setTempModuleSelectionData] = useReducer((prevState, nextState) => {
|
||||||
return { ...prevState, ...nextState }
|
return { ...prevState, ...nextState }
|
||||||
}, moduleSelectionData)
|
}, moduleSelectionData)
|
||||||
@ -55,15 +67,13 @@ export default function Module({ setTabNum }) {
|
|||||||
}, [installHeight, verticalSnowCover])
|
}, [installHeight, verticalSnowCover])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (tempModuleSelectionData) {
|
if (tempModuleSelectionData.roofConstructions.length > 0) {
|
||||||
setModuleSelectionData(tempModuleSelectionData)
|
if (tempModuleSelectionData.common.moduleItemId && isObjectNotEmpty(tempModuleSelectionData.module)) {
|
||||||
|
//저장된 temp데이터가 지붕재(addedRoofs) 개수와 같으면 모듈 선택 저장
|
||||||
if (
|
if (tempModuleSelectionData.roofConstructions.length === addedRoofs.length) {
|
||||||
tempModuleSelectionData.common.moduleItemId &&
|
setModuleSelectionData(tempModuleSelectionData)
|
||||||
isObjectNotEmpty(tempModuleSelectionData.module) &&
|
moduleSelectedDataTrigger(tempModuleSelectionData)
|
||||||
tempModuleSelectionData.roofConstructions.length > 0
|
}
|
||||||
) {
|
|
||||||
moduleSelectedDataTrigger(tempModuleSelectionData)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [tempModuleSelectionData])
|
}, [tempModuleSelectionData])
|
||||||
@ -134,7 +144,8 @@ export default function Module({ setTabNum }) {
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{selectedModules.itemList &&
|
{selectedModules &&
|
||||||
|
selectedModules.itemList &&
|
||||||
selectedModules.itemList.map((row, index) => (
|
selectedModules.itemList.map((row, index) => (
|
||||||
<tr key={index}>
|
<tr key={index}>
|
||||||
<td>
|
<td>
|
||||||
@ -250,10 +261,10 @@ export default function Module({ setTabNum }) {
|
|||||||
<div style={{ display: roofTab === index ? 'block' : 'none' }} key={index}>
|
<div style={{ display: roofTab === index ? 'block' : 'none' }} key={index}>
|
||||||
<ModuleTabContents
|
<ModuleTabContents
|
||||||
key={index}
|
key={index}
|
||||||
index={index}
|
tabIndex={index}
|
||||||
addRoof={roof}
|
addRoof={roof}
|
||||||
setAddedRoofs={setAddedRoofs}
|
setAddedRoofs={setAddedRoofs}
|
||||||
roofTab={index}
|
roofTab={roofTab}
|
||||||
tempModuleSelectionData={tempModuleSelectionData}
|
tempModuleSelectionData={tempModuleSelectionData}
|
||||||
setTempModuleSelectionData={setTempModuleSelectionData}
|
setTempModuleSelectionData={setTempModuleSelectionData}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -9,7 +9,15 @@ import { isObjectNotEmpty } from '@/util/common-utils'
|
|||||||
import QSelectBox from '@/components/common/select/QSelectBox'
|
import QSelectBox from '@/components/common/select/QSelectBox'
|
||||||
import { addedRoofsState } from '@/store/settingAtom'
|
import { addedRoofsState } from '@/store/settingAtom'
|
||||||
|
|
||||||
export default function ModuleTabContents({ addRoof, setAddedRoofs, roofTab, tempModuleSelectionData, setTempModuleSelectionData }) {
|
export default function ModuleTabContents({
|
||||||
|
tabIndex,
|
||||||
|
addRoof,
|
||||||
|
setAddedRoofs,
|
||||||
|
roofTab,
|
||||||
|
tempModuleSelectionData,
|
||||||
|
setTempModuleSelectionData,
|
||||||
|
moduleSelectionInitParams,
|
||||||
|
}) {
|
||||||
const { getMessage } = useMessage()
|
const { getMessage } = useMessage()
|
||||||
const [roofMaterial, setRoofMaterial] = useState(addRoof) //지붕재`
|
const [roofMaterial, setRoofMaterial] = useState(addRoof) //지붕재`
|
||||||
|
|
||||||
@ -37,7 +45,7 @@ export default function ModuleTabContents({ addRoof, setAddedRoofs, roofTab, tem
|
|||||||
const [constructionParams, setConstructionParams] = useState({}) //공법 관련 api호출 파라메터
|
const [constructionParams, setConstructionParams] = useState({}) //공법 관련 api호출 파라메터
|
||||||
const [roofBaseParams, setRoofBaseParams] = useState({}) //지붕밑바탕 관련 api호출 파라메터
|
const [roofBaseParams, setRoofBaseParams] = useState({}) //지붕밑바탕 관련 api호출 파라메터
|
||||||
|
|
||||||
const moduleSelectionInitParams = useRecoilValue(moduleSelectionInitParamsState) //모듈 기본 데이터 ex) 면조도, 높이등등
|
// const moduleSelectionInitParams = useRecoilValue(moduleSelectionInitParamsState) //모듈 기본 데이터 ex) 면조도, 높이등등
|
||||||
|
|
||||||
const { getTrestleList, getConstructionList } = useMasterController()
|
const { getTrestleList, getConstructionList } = useMasterController()
|
||||||
|
|
||||||
@ -61,15 +69,73 @@ export default function ModuleTabContents({ addRoof, setAddedRoofs, roofTab, tem
|
|||||||
const hajebichiRef = useRef()
|
const hajebichiRef = useRef()
|
||||||
const lengthRef = useRef()
|
const lengthRef = useRef()
|
||||||
|
|
||||||
|
const originalModuleSelectionData = useRef(moduleSelectionData)
|
||||||
|
|
||||||
|
//서까래간격 변경
|
||||||
|
const handleChangeRaftBase = (option) => {
|
||||||
|
setSelectedRaftBase(option)
|
||||||
|
setTrestleParams({ ...trestleParams, raftBaseCd: option.clCode }) //가대메이커
|
||||||
|
setConstMthdList([]) //공법 초기화
|
||||||
|
setRoofBaseList([]) //지붕밑바탕 초기화
|
||||||
|
setConstructionList([]) //공법 초기화
|
||||||
|
}
|
||||||
|
|
||||||
|
//지붕밑바탕변경
|
||||||
|
|
||||||
|
//처마력바 체크
|
||||||
|
const handleCvrChecked = () => {
|
||||||
|
setCvrChecked(!cvrChecked)
|
||||||
|
setSelectedConstruction({ ...selectedConstruction, setupCover: !cvrChecked })
|
||||||
|
}
|
||||||
|
|
||||||
|
//눈막이금구 체크
|
||||||
|
const handleSnowGdChecked = () => {
|
||||||
|
setSnowGdChecked(!snowGdChecked)
|
||||||
|
setSelectedConstruction({ ...selectedConstruction, setupSnowCover: !snowGdChecked })
|
||||||
|
}
|
||||||
|
|
||||||
|
const getConstructionListData = async (params) => {
|
||||||
|
if (params.trestleMkrCd && params.constMthdCd && params.roofBaseCd) {
|
||||||
|
const optionsList = await getConstructionList(params)
|
||||||
|
setConstructionList(optionsList.data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setHajebichi(addRoof.hajebichi)
|
setHajebichi(addRoof.hajebichi)
|
||||||
setLengthBase(addRoof.lenBase)
|
setLengthBase(addRoof.lenBase)
|
||||||
|
|
||||||
|
// 202600 경사도
|
||||||
|
const raftCodeList = findCommonCode('203800')
|
||||||
|
//서까래 코드
|
||||||
|
raftCodeList.forEach((obj) => {
|
||||||
|
obj.name = obj.clCodeNm
|
||||||
|
obj.id = obj.clCode
|
||||||
|
})
|
||||||
|
setRaftCodes(raftCodeList)
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
//리코일에 데이터가 담기는 시점에 시작
|
||||||
|
useEffect(() => {
|
||||||
|
if (
|
||||||
|
moduleSelectionData.roofConstructions.length > 0 &&
|
||||||
|
isObjectNotEmpty(moduleSelectionData.roofConstructions[tabIndex].trestle) &&
|
||||||
|
isObjectNotEmpty(moduleSelectionData.roofConstructions[tabIndex].construction)
|
||||||
|
) {
|
||||||
|
setModuleConstructionSelectionData(moduleSelectionData.roofConstructions[tabIndex])
|
||||||
|
}
|
||||||
|
}, [moduleSelectionData])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isObjectNotEmpty(moduleConstructionSelectionData)) {
|
||||||
|
setIsExistData(true)
|
||||||
|
}
|
||||||
|
}, [moduleConstructionSelectionData])
|
||||||
|
|
||||||
//높이를 변경하면 addRoofs에 적용
|
//높이를 변경하면 addRoofs에 적용
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
//가대 조회 api 파라메터
|
// //가대 조회 api 파라메터
|
||||||
setTrestleParams({ ...trestleParams, workingWidth: lengthBase })
|
// setTrestleParams({ ...trestleParams, workingWidth: lengthBase })
|
||||||
|
|
||||||
const copyAddRoof = { ...addRoof }
|
const copyAddRoof = { ...addRoof }
|
||||||
copyAddRoof.length = Number(lengthBase)
|
copyAddRoof.length = Number(lengthBase)
|
||||||
@ -90,29 +156,69 @@ export default function ModuleTabContents({ addRoof, setAddedRoofs, roofTab, tem
|
|||||||
}, [hajebichi])
|
}, [hajebichi])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (moduleSelectionData.roofConstructions.length > 0) {
|
if (isExistData) {
|
||||||
setModuleConstructionSelectionData(moduleSelectionData.roofConstructions[roofTab])
|
setConstructionListParams({
|
||||||
|
...moduleSelectionInitParams,
|
||||||
|
...roofBaseParams,
|
||||||
|
roofBaseCd: selectedRoofBase.roofBaseCd,
|
||||||
|
inclCd: addRoof.pitch,
|
||||||
|
roofPitch: hajebichiRef.current ? hajebichiRef.current.value : 0,
|
||||||
|
raftBaseCd: addRoof.raftBaseCd,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}, [moduleSelectionData])
|
}, [selectedRoofBase])
|
||||||
|
|
||||||
//서까래간격 변경
|
useEffect(() => {
|
||||||
const handleChangeRaftBase = (option) => {
|
if (
|
||||||
setSelectedRaftBase(option)
|
isExistData &&
|
||||||
setTrestleParams({ ...trestleParams, raftBaseCd: option.clCode }) //가대메이커
|
constructionList.length > 0 &&
|
||||||
setConstMthdList([]) //공법 초기화
|
isObjectNotEmpty(moduleConstructionSelectionData?.construction) &&
|
||||||
setRoofBaseList([]) //지붕밑바탕 초기화
|
moduleConstructionSelectionData?.construction.hasOwnProperty('constPossYn') ///키가 있으면
|
||||||
setConstructionList([]) //공법 초기화
|
) {
|
||||||
}
|
const selectedIndex = moduleConstructionSelectionData.construction.selectedIndex
|
||||||
|
const construction = constructionList[selectedIndex]
|
||||||
|
if (construction.constPossYn === 'Y') {
|
||||||
|
handleConstruction(selectedIndex)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [constructionList])
|
||||||
|
|
||||||
//가대메이커 변경
|
//모듈 변경
|
||||||
|
useEffect(() => {
|
||||||
|
//lengbase는 무조건 있다고 가정 하고 최초에 실행 방지
|
||||||
|
if (selectedModules) {
|
||||||
|
//가대메이커 파라메터 만들기
|
||||||
|
setTrestleParams({
|
||||||
|
moduleTpCd: selectedModules.itemTp,
|
||||||
|
roofMatlCd: addRoof.roofMatlCd,
|
||||||
|
raftBaseCd: addRoof.raftBaseCd,
|
||||||
|
workingWidth: lengthBase,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}, [selectedModules])
|
||||||
|
|
||||||
|
//가대메이커 api 호출
|
||||||
|
useEffect(() => {
|
||||||
|
if (isObjectNotEmpty(trestleParams)) {
|
||||||
|
getModuleOptionsListData(trestleParams, 'trestle')
|
||||||
|
}
|
||||||
|
}, [trestleParams])
|
||||||
|
|
||||||
|
//가대메이커 변경 함수
|
||||||
const handleChangeTrestle = (option) => {
|
const handleChangeTrestle = (option) => {
|
||||||
setSelectedTrestle(option) //선택값 저장
|
setSelectedTrestle(option) //선택값 저장
|
||||||
setConstructionParams({ ...trestleParams, trestleMkrCd: option.trestleMkrCd, constMthdCd: '', roofBaseCd: '' })
|
setConstructionParams({ ...trestleParams, trestleMkrCd: option.trestleMkrCd, constMthdCd: '', roofBaseCd: '' })
|
||||||
setConstMthdList([]) //공법 초기화
|
// setConstMthdList([]) //공법 초기화
|
||||||
setRoofBaseList([]) //지붕밑바탕 초기화
|
// setRoofBaseList([]) //지붕밑바탕 초기화
|
||||||
setConstructionList([]) //공법 초기화
|
// setConstructionList([]) //공법 초기화
|
||||||
}
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isObjectNotEmpty(constructionParams)) {
|
||||||
|
getModuleOptionsListData(constructionParams, 'construction')
|
||||||
|
}
|
||||||
|
}, [constructionParams])
|
||||||
|
|
||||||
//공법 변경
|
//공법 변경
|
||||||
const handleChangeConstMthd = (option) => {
|
const handleChangeConstMthd = (option) => {
|
||||||
setSelectedConstMthd(option) //선택된값 저장
|
setSelectedConstMthd(option) //선택된값 저장
|
||||||
@ -121,24 +227,37 @@ export default function ModuleTabContents({ addRoof, setAddedRoofs, roofTab, tem
|
|||||||
trestleMkrCd: selectedTrestle.trestleMkrCd,
|
trestleMkrCd: selectedTrestle.trestleMkrCd,
|
||||||
constMthdCd: option.constMthdCd,
|
constMthdCd: option.constMthdCd,
|
||||||
roofBaseCd: '',
|
roofBaseCd: '',
|
||||||
roofPitch: hajebichiRef.current ? hajebichiRef.current.value : '',
|
|
||||||
})
|
})
|
||||||
setRoofBaseList([]) //지붕밑바탕 초기화
|
|
||||||
setConstructionList([]) //공법 초기화
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//지붕밑바탕변경
|
useEffect(() => {
|
||||||
|
if (isObjectNotEmpty(roofBaseParams)) {
|
||||||
|
getModuleOptionsListData(roofBaseParams, 'roofBase')
|
||||||
|
}
|
||||||
|
}, [roofBaseParams])
|
||||||
|
|
||||||
const handleChangeRoofBase = (option) => {
|
const handleChangeRoofBase = (option) => {
|
||||||
// if (option) {
|
|
||||||
setConstructionListParams({
|
setConstructionListParams({
|
||||||
...moduleSelectionInitParams,
|
...moduleSelectionInitParams,
|
||||||
...roofBaseParams,
|
trestleMkrCd: selectedTrestle.trestleMkrCd,
|
||||||
|
constMthdCd: selectedConstMthd.constMthdCd,
|
||||||
roofBaseCd: option.roofBaseCd,
|
roofBaseCd: option.roofBaseCd,
|
||||||
inclCd: addRoof.pitch,
|
inclCd: addRoof.pitch,
|
||||||
|
roofPitch: hajebichiRef.current ? hajebichiRef.current.value : 0,
|
||||||
|
raftBaseCd: addRoof.raftBaseCd,
|
||||||
|
roofMatlCd: addRoof.roofMatlCd,
|
||||||
})
|
})
|
||||||
setSelectedRoofBase(option)
|
setSelectedRoofBase(option)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//공법 리스트 변경 함수
|
||||||
|
useEffect(() => {
|
||||||
|
if (isObjectNotEmpty(constructionListParams)) {
|
||||||
|
getConstructionListData(constructionListParams)
|
||||||
|
}
|
||||||
|
}, [constructionListParams])
|
||||||
|
|
||||||
|
//공법 선택 함수
|
||||||
const handleConstruction = (index) => {
|
const handleConstruction = (index) => {
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
const isPossibleIndex = constructionRef.current
|
const isPossibleIndex = constructionRef.current
|
||||||
@ -160,6 +279,9 @@ export default function ModuleTabContents({ addRoof, setAddedRoofs, roofTab, tem
|
|||||||
selectedConstruction.setupSnowCover = false //눈막이금구 설치 여부
|
selectedConstruction.setupSnowCover = false //눈막이금구 설치 여부
|
||||||
selectedConstruction.selectedIndex = index
|
selectedConstruction.selectedIndex = index
|
||||||
|
|
||||||
|
setCvrYn(selectedConstruction.cvrYn)
|
||||||
|
setSnowGdPossYn(selectedConstruction.snowGdPossYn)
|
||||||
|
|
||||||
//기존에 선택된 데이터가 있으면 체크한다
|
//기존에 선택된 데이터가 있으면 체크한다
|
||||||
if (moduleConstructionSelectionData && moduleConstructionSelectionData.construction) {
|
if (moduleConstructionSelectionData && moduleConstructionSelectionData.construction) {
|
||||||
selectedConstruction.setupCover = moduleConstructionSelectionData.construction.setupCover
|
selectedConstruction.setupCover = moduleConstructionSelectionData.construction.setupCover
|
||||||
@ -168,8 +290,6 @@ export default function ModuleTabContents({ addRoof, setAddedRoofs, roofTab, tem
|
|||||||
setSnowGdChecked(selectedConstruction.setupSnowCover)
|
setSnowGdChecked(selectedConstruction.setupSnowCover)
|
||||||
}
|
}
|
||||||
|
|
||||||
setCvrYn(selectedConstruction.cvrYn)
|
|
||||||
setSnowGdPossYn(selectedConstruction.snowGdPossYn)
|
|
||||||
setSelectedConstruction(selectedConstruction)
|
setSelectedConstruction(selectedConstruction)
|
||||||
} else {
|
} else {
|
||||||
constructionRef.current.forEach((ref) => {
|
constructionRef.current.forEach((ref) => {
|
||||||
@ -178,178 +298,128 @@ export default function ModuleTabContents({ addRoof, setAddedRoofs, roofTab, tem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleCvrChecked = () => {
|
//공법 선택시 이후 프로세스
|
||||||
setCvrChecked(!cvrChecked)
|
|
||||||
setSelectedConstruction({ ...selectedConstruction, setupCover: !cvrChecked })
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleSnowGdChecked = () => {
|
|
||||||
setSnowGdChecked(!snowGdChecked)
|
|
||||||
setSelectedConstruction({ ...selectedConstruction, setupSnowCover: !snowGdChecked })
|
|
||||||
}
|
|
||||||
|
|
||||||
const getModuleOptionsListData = async (params) => {
|
|
||||||
const optionsList = await getTrestleList(params)
|
|
||||||
|
|
||||||
if (optionsList.data.length > 0) {
|
|
||||||
if (optionsList.data[0].trestleMkrCd && optionsList.data[0].constMthdCd === null) {
|
|
||||||
setTrestleList(optionsList.data)
|
|
||||||
if (isExistData) {
|
|
||||||
setSelectedTrestle({ ...moduleConstructionSelectionData?.trestle })
|
|
||||||
} else {
|
|
||||||
setConstMthdList([])
|
|
||||||
setRoofBaseList([])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (optionsList.data[0].trestleMkrCd && optionsList.data[0].constMthdCd && optionsList.data[0].roofBaseCd === null) {
|
|
||||||
setConstMthdList(optionsList.data)
|
|
||||||
if (isExistData) {
|
|
||||||
setSelectedConstMthd({ ...moduleConstructionSelectionData?.trestle })
|
|
||||||
} else {
|
|
||||||
setRoofBaseList([])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (optionsList.data[0].trestleMkrCd && optionsList.data[0].constMthdCd && optionsList.data[0].roofBaseCd) {
|
|
||||||
setRoofBaseList(optionsList.data)
|
|
||||||
if (isExistData) {
|
|
||||||
setSelectedRoofBase({ ...moduleConstructionSelectionData?.trestle })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const getConstructionListData = async (params) => {
|
|
||||||
if (params.trestleMkrCd && params.constMthdCd && params.roofBaseCd) {
|
|
||||||
const optionsList = await getConstructionList(params)
|
|
||||||
setConstructionList(optionsList.data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isObjectNotEmpty(selectedRoofBase) && isObjectNotEmpty(selectedConstruction)) {
|
if (isObjectNotEmpty(selectedRoofBase) && isObjectNotEmpty(selectedConstruction)) {
|
||||||
const newRoofConstructions = {
|
if (tabIndex === roofTab) {
|
||||||
roofIndex: roofTab,
|
const common = { ...moduleSelectionInitParams }
|
||||||
addRoof: addRoof,
|
const module = { ...selectedModules }
|
||||||
trestle: selectedRoofBase,
|
const newRoofConstructions = {
|
||||||
construction: selectedConstruction,
|
roofIndex: tabIndex,
|
||||||
}
|
addRoof: addRoof,
|
||||||
|
trestle: selectedRoofBase,
|
||||||
|
construction: selectedConstruction,
|
||||||
|
}
|
||||||
|
|
||||||
const index = tempModuleSelectionData.roofConstructions.findIndex((obj) => obj.roofIndex === roofTab)
|
console.log('newRoofConstructions', newRoofConstructions)
|
||||||
|
console.log('roofTab', roofTab)
|
||||||
|
|
||||||
if (index > -1) {
|
const index = tempModuleSelectionData.roofConstructions.findIndex((obj) => obj.roofIndex === tabIndex)
|
||||||
const newArray = [
|
|
||||||
...tempModuleSelectionData.roofConstructions.slice(0, index),
|
if (index > -1) {
|
||||||
newRoofConstructions,
|
const newArray = [
|
||||||
...tempModuleSelectionData.roofConstructions.slice(index + 1),
|
...tempModuleSelectionData.roofConstructions.slice(0, index),
|
||||||
]
|
newRoofConstructions,
|
||||||
setTempModuleSelectionData({ roofConstructions: newArray })
|
...tempModuleSelectionData.roofConstructions.slice(index + 1),
|
||||||
} else {
|
]
|
||||||
setTempModuleSelectionData({ roofConstructions: [...tempModuleSelectionData.roofConstructions, { ...newRoofConstructions }] })
|
setTempModuleSelectionData({ common: common, module: module, roofConstructions: newArray })
|
||||||
|
} else {
|
||||||
|
setTempModuleSelectionData({
|
||||||
|
common: common,
|
||||||
|
module: module,
|
||||||
|
roofConstructions: [...tempModuleSelectionData.roofConstructions, { ...newRoofConstructions }],
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [selectedConstruction])
|
}, [selectedConstruction])
|
||||||
|
|
||||||
useEffect(() => {
|
const getModuleOptionsListData = async (params, type) => {
|
||||||
if (isExistData) {
|
const optionsList = await getTrestleList(params)
|
||||||
setConstructionListParams({
|
|
||||||
...moduleSelectionInitParams,
|
|
||||||
...roofBaseParams,
|
|
||||||
roofBaseCd: selectedRoofBase.roofBaseCd,
|
|
||||||
inclCd: addRoof.pitch,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}, [selectedRoofBase])
|
|
||||||
|
|
||||||
useEffect(() => {
|
if (optionsList.data.length > 0) {
|
||||||
console.log('moduleConstructionSelectionData', moduleConstructionSelectionData)
|
if (type === 'trestle') {
|
||||||
|
setTrestleList(optionsList.data)
|
||||||
if (
|
if (isExistData) {
|
||||||
isExistData &&
|
// setSelectedTrestle({ ...moduleConstructionSelectionData?.trestle })
|
||||||
constructionList.length > 0 &&
|
handleChangeTrestle(moduleConstructionSelectionData?.trestle)
|
||||||
isObjectNotEmpty(moduleConstructionSelectionData?.construction) &&
|
} else {
|
||||||
moduleConstructionSelectionData?.construction.hasOwnProperty('constPossYn') ///키가 있으면
|
setConstMthdList([])
|
||||||
) {
|
setRoofBaseList([])
|
||||||
const selectedIndex = moduleConstructionSelectionData.construction.selectedIndex
|
}
|
||||||
const construction = constructionList[selectedIndex]
|
} else if (type === 'construction') {
|
||||||
if (construction.constPossYn === 'Y') {
|
setConstMthdList(optionsList.data)
|
||||||
handleConstruction(selectedIndex)
|
if (isExistData) {
|
||||||
}
|
handleChangeConstMthd(moduleConstructionSelectionData?.trestle)
|
||||||
}
|
} else {
|
||||||
}, [constructionList])
|
setRoofBaseList([])
|
||||||
|
}
|
||||||
useEffect(() => {
|
} else if (type === 'roofBase') {
|
||||||
if (isObjectNotEmpty(moduleSelectionData) && isObjectNotEmpty(moduleSelectionData.module)) {
|
setRoofBaseList(optionsList.data)
|
||||||
setSelectedModules(moduleSelectionData.module)
|
if (isExistData) {
|
||||||
}
|
handleChangeRoofBase(moduleConstructionSelectionData?.trestle)
|
||||||
}, [moduleSelectionData])
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
// 202600 경사도
|
|
||||||
const raftCodeList = findCommonCode('203800')
|
|
||||||
//서까래 코드
|
|
||||||
raftCodeList.forEach((obj) => {
|
|
||||||
obj.name = obj.clCodeNm
|
|
||||||
obj.id = obj.clCode
|
|
||||||
})
|
|
||||||
setRaftCodes(raftCodeList)
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
//물건 상세의 데이터를 가지고 초기화 데이터를 만든다
|
|
||||||
if (
|
|
||||||
moduleSelectionInitParams.illuminationTp &&
|
|
||||||
moduleSelectionInitParams.instHt &&
|
|
||||||
moduleSelectionInitParams.stdSnowLd &&
|
|
||||||
moduleSelectionInitParams.stdWindSpeed
|
|
||||||
) {
|
|
||||||
const isModuleLoaded = moduleSelectionInitParams.hasOwnProperty('moduleTpCd') //모듈컬럼이 있으면 모듈을 변경했다는 내용
|
|
||||||
if (isModuleLoaded) {
|
|
||||||
setTrestleParams({
|
|
||||||
moduleTpCd: moduleSelectionInitParams.moduleTpCd,
|
|
||||||
roofMatlCd: addRoof.roofMatlCd,
|
|
||||||
raftBaseCd: addRoof.raftBaseCd,
|
|
||||||
workingWidth: lengthBase,
|
|
||||||
})
|
|
||||||
setConstructionList([])
|
|
||||||
|
|
||||||
if (isObjectNotEmpty(moduleConstructionSelectionData)) {
|
|
||||||
//기존에 데이터가 있으면 파라메터를 넣는다
|
|
||||||
setConstructionParams({ ...moduleConstructionSelectionData.trestle, constMthdCd: '', roofBaseCd: '' })
|
|
||||||
setRoofBaseParams({ ...moduleConstructionSelectionData.trestle, roofBaseCd: '' })
|
|
||||||
|
|
||||||
setIsExistData(true)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setTempModuleSelectionData({ common: moduleSelectionInitParams, module: selectedModules })
|
useEffect(() => {
|
||||||
|
console.log('originalModuleSelectionData', originalModuleSelectionData)
|
||||||
|
console.log('moduleSelectionInitParams', moduleSelectionInitParams)
|
||||||
|
|
||||||
|
// console.log('moduleSelectionInitParams', moduleSelectionInitParams)
|
||||||
|
// setSelectedTrestle({})
|
||||||
|
// setSelectedConstMthd({})
|
||||||
|
// setSelectedRoofBase({})
|
||||||
|
// setModuleSelectionData({
|
||||||
|
// ...moduleSelectionData,
|
||||||
|
// roofConstructions: [],
|
||||||
|
// })
|
||||||
}, [moduleSelectionInitParams])
|
}, [moduleSelectionInitParams])
|
||||||
|
|
||||||
useEffect(() => {
|
// useEffect(() => {
|
||||||
if (isObjectNotEmpty(trestleParams)) {
|
// useEffect(() => {
|
||||||
getModuleOptionsListData(trestleParams)
|
// console.log('moduleSelectionInitParams', moduleSelectionInitParams)
|
||||||
}
|
|
||||||
}, [trestleParams])
|
|
||||||
|
|
||||||
useEffect(() => {
|
// //물건 상세의 데이터를 가지고 초기화 데이터를 만든다
|
||||||
if (isObjectNotEmpty(constructionParams)) {
|
// if (
|
||||||
getModuleOptionsListData(constructionParams)
|
// moduleSelectionInitParams.illuminationTp &&
|
||||||
}
|
// moduleSelectionInitParams.instHt &&
|
||||||
}, [constructionParams])
|
// moduleSelectionInitParams.stdSnowLd &&
|
||||||
|
// moduleSelectionInitParams.stdWindSpeed
|
||||||
|
// ) {
|
||||||
|
// const isModuleLoaded = moduleSelectionInitParams.hasOwnProperty('moduleTpCd') //모듈컬럼이 있으면 모듈을 변경했다는 내용
|
||||||
|
|
||||||
useEffect(() => {
|
// //모듈 이름이 있고 모듈이 선택되어있다면
|
||||||
if (isObjectNotEmpty(roofBaseParams)) {
|
// if (isModuleLoaded && moduleSelectionInitParams.moduleTpCd) {
|
||||||
getModuleOptionsListData(roofBaseParams)
|
// setTrestleParams({
|
||||||
}
|
// moduleTpCd: moduleSelectionInitParams.moduleTpCd,
|
||||||
}, [roofBaseParams])
|
// roofMatlCd: addRoof.roofMatlCd,
|
||||||
|
// raftBaseCd: addRoof.raftBaseCd,
|
||||||
|
// workingWidth: lengthBase,
|
||||||
|
// })
|
||||||
|
// // setConstructionList([])
|
||||||
|
|
||||||
useEffect(() => {
|
// if (isObjectNotEmpty(moduleConstructionSelectionData)) {
|
||||||
if (isObjectNotEmpty(constructionListParams)) {
|
// //기존에 데이터가 있으면 파라메터를 넣는다
|
||||||
getConstructionListData(constructionListParams)
|
// setConstructionParams({ ...moduleConstructionSelectionData.trestle, constMthdCd: '', roofBaseCd: '' })
|
||||||
}
|
// setRoofBaseParams({ ...moduleConstructionSelectionData.trestle, roofBaseCd: '' })
|
||||||
}, [constructionListParams])
|
|
||||||
|
// setIsExistData(true)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// setTempModuleSelectionData({ common: moduleSelectionInitParams, module: selectedModules })
|
||||||
|
// }, [])
|
||||||
|
|
||||||
|
// useEffect(() => {
|
||||||
|
// console.log('roofBaseParams', roofBaseParams)
|
||||||
|
|
||||||
|
// if (isObjectNotEmpty(roofBaseParams)) {
|
||||||
|
// getModuleOptionsListData(roofBaseParams)
|
||||||
|
// }
|
||||||
|
// }, [roofBaseParams])
|
||||||
|
|
||||||
// useEffect(() => {
|
// useEffect(() => {
|
||||||
// if (isObjectNotEmpty(tempModuleSelectionData)) {
|
// if (isObjectNotEmpty(tempModuleSelectionData)) {
|
||||||
|
|||||||
@ -615,7 +615,7 @@ export function useModuleBasicSetting() {
|
|||||||
for (let i = 0; i <= totalWidth; i++) {
|
for (let i = 0; i <= totalWidth; i++) {
|
||||||
leftMargin = i === 0 ? 0 : intvHor * i
|
leftMargin = i === 0 ? 0 : intvHor * i
|
||||||
chidoriLength = 0
|
chidoriLength = 0
|
||||||
if (isChidori) {
|
if (isChidori && !isMaxSetup) {
|
||||||
chidoriLength = j % 2 === 0 ? 0 : width / 2 - intvHor
|
chidoriLength = j % 2 === 0 ? 0 : width / 2 - intvHor
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -716,7 +716,7 @@ export function useModuleBasicSetting() {
|
|||||||
for (let j = 0; j < totalHeight; j++) {
|
for (let j = 0; j < totalHeight; j++) {
|
||||||
leftMargin = j === 0 ? 0 : intvVer * j
|
leftMargin = j === 0 ? 0 : intvVer * j
|
||||||
chidoriLength = 0
|
chidoriLength = 0
|
||||||
if (isChidori) {
|
if (isChidori && !isMaxSetup) {
|
||||||
chidoriLength = i % 2 === 0 ? 0 : height / 2
|
chidoriLength = i % 2 === 0 ? 0 : height / 2
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -827,7 +827,7 @@ export function useModuleBasicSetting() {
|
|||||||
for (let i = 0; i < diffRightEndPoint; i++) {
|
for (let i = 0; i < diffRightEndPoint; i++) {
|
||||||
leftMargin = i === 0 ? 0 : intvHor * i
|
leftMargin = i === 0 ? 0 : intvHor * i
|
||||||
chidoriLength = 0
|
chidoriLength = 0
|
||||||
if (isChidori) {
|
if (isChidori && !isMaxSetup) {
|
||||||
chidoriLength = j % 2 === 0 ? 0 : width / 2 - intvHor
|
chidoriLength = j % 2 === 0 ? 0 : width / 2 - intvHor
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -927,7 +927,7 @@ export function useModuleBasicSetting() {
|
|||||||
leftMargin = j === 0 ? 0 : intvVer * j
|
leftMargin = j === 0 ? 0 : intvVer * j
|
||||||
|
|
||||||
chidoriLength = 0
|
chidoriLength = 0
|
||||||
if (isChidori) {
|
if (isChidori && !isMaxSetup) {
|
||||||
chidoriLength = i % 2 === 0 ? 0 : height / 2 - intvHor
|
chidoriLength = i % 2 === 0 ? 0 : height / 2 - intvHor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,8 +3,8 @@ import { useContext, useEffect, useState } from 'react'
|
|||||||
import { GlobalDataContext } from '@/app/GlobalDataProvider'
|
import { GlobalDataContext } from '@/app/GlobalDataProvider'
|
||||||
import { useMasterController } from '@/hooks/common/useMasterController'
|
import { useMasterController } from '@/hooks/common/useMasterController'
|
||||||
import { useCommonCode } from '@/hooks/common/useCommonCode'
|
import { useCommonCode } from '@/hooks/common/useCommonCode'
|
||||||
|
|
||||||
import { selectedModuleState, moduleSelectionInitParamsState, moduleSelectionDataState } from '@/store/selectedModuleOptions'
|
import { selectedModuleState, moduleSelectionInitParamsState, moduleSelectionDataState } from '@/store/selectedModuleOptions'
|
||||||
|
import { isObjectNotEmpty } from '@/util/common-utils'
|
||||||
|
|
||||||
export function useModuleSelection(props) {
|
export function useModuleSelection(props) {
|
||||||
const { managementState, setManagementState, managementStateLoaded } = useContext(GlobalDataContext)
|
const { managementState, setManagementState, managementStateLoaded } = useContext(GlobalDataContext)
|
||||||
@ -30,6 +30,8 @@ export function useModuleSelection(props) {
|
|||||||
setSelectedSurfaceType(managementState?.surfaceType)
|
setSelectedSurfaceType(managementState?.surfaceType)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const [moduleSelectionData, setModuleSelectionData] = useRecoilState(moduleSelectionDataState) //다음으로 넘어가는 최종 데이터
|
||||||
|
|
||||||
//탭별 파라메터 초기화
|
//탭별 파라메터 초기화
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
bindInitData()
|
bindInitData()
|
||||||
@ -94,6 +96,13 @@ export function useModuleSelection(props) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//데이터가 있으면 모듈 자동 선택
|
||||||
|
useEffect(() => {
|
||||||
|
if (moduleList.length > 0 && isObjectNotEmpty(moduleSelectionData.module)) {
|
||||||
|
handleChangeModule(moduleSelectionData.module)
|
||||||
|
}
|
||||||
|
}, [moduleList])
|
||||||
|
|
||||||
const handleChangeModule = (option) => {
|
const handleChangeModule = (option) => {
|
||||||
//선택된 모듈
|
//선택된 모듈
|
||||||
setSelectedModules(option) //선택값 저장
|
setSelectedModules(option) //선택값 저장
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user