모듈 설치면 초기화 기능

This commit is contained in:
yjnoh 2025-04-03 17:09:17 +09:00
parent 02a0e4a67f
commit e872df680d
2 changed files with 19 additions and 21 deletions

View File

@ -1,5 +1,6 @@
import { GlobalDataContext } from '@/app/GlobalDataProvider'
import QSelectBox from '@/components/common/select/QSelectBox'
import { useModuleBasicSetting } from '@/hooks/module/useModuleBasicSetting'
import { useModuleTrestle } from '@/hooks/module/useModuleTrestle'
import { useMessage } from '@/hooks/useMessage'
import { currentAngleTypeSelector, pitchTextSelector } from '@/store/canvasAtom'
@ -45,18 +46,22 @@ const Trestle = forwardRef((props, ref) => {
const selectedModules = useRecoilValue(selectedModuleState) //
// const [moduleSelectionData, setModuleSelectionData] = useRecoilState(moduleSelectionDataState)
const [lengthBase, setLengthBase] = useState(0)
const [hajebichi, setHajebichi] = useState(trestleState?.roofPitch ?? 0)
const [hajebichi, setHajebichi] = useState(0)
const [selectedRaftBase, setSelectedRaftBase] = useState(null)
const [selectedTrestle, setSelectedTrestle] = useState(null)
const [selectedConstMthd, setSelectedConstMthd] = useState(null)
const [selectedConstruction, setSelectedConstruction] = useState(null)
const [selectedRoofBase, setSelectedRoofBase] = useState(null)
const { managementState } = useContext(GlobalDataContext)
const { restoreModuleInstArea } = useModuleBasicSetting()
useEffect(() => {
if (roofs && !selectedRoof) {
setSelectedRoof(roofs[0])
}
//
restoreModuleInstArea()
}, [roofs])
useEffect(() => {
@ -196,12 +201,10 @@ const Trestle = forwardRef((props, ref) => {
stdWindSpeed: managementState?.standardWindSpeedId ?? '',
stdSnowLd: +managementState?.verticalSnowCover ?? '',
inclCd: selectedRoof?.pitch.toString() ?? 0,
// roofPitch: Math.round(selectedRoof?.roofPchBase ?? 0),
roofPitch: hajebichi ?? 0,
roofPitch: Math.round(selectedRoof?.roofPchBase ?? 0),
constTp: constructionList[index].constTp,
mixMatlNo: selectedModules.mixMatlNo,
// workingWidth: selectedRoof?.length.toString() ?? '',
workingWidth: lengthBase ?? '',
workingWidth: selectedRoof?.length.toString() ?? '',
// snowGdPossYn: constructionList[index].snowGdPossYn,
// cvrYn: constructionList[index].cvrYn,
},
@ -256,13 +259,14 @@ const Trestle = forwardRef((props, ref) => {
}
})
console.log('newAddedRoofs', newAddedRoofs)
if (result) {
setRoofs(newAddedRoofs)
setModuleSelectionData({
...moduleSelectionData,
roofConstructions: newAddedRoofs.map((roof, index) => {
return {
roofIndex: index,
addRoof: {
...moduleSelectionData.roofConstructions[index]?.addRoof,
...roof.addRoof,
@ -272,8 +276,8 @@ const Trestle = forwardRef((props, ref) => {
...moduleSelectionData.roofConstructions[index]?.trestle,
},
construction: {
...moduleSelectionData.roofConstructions[index]?.construction,
...roof.construction,
...moduleSelectionData.roofConstructions[index]?.construction,
},
trestleDetail: {
...roof.trestleDetail,
@ -339,7 +343,7 @@ const Trestle = forwardRef((props, ref) => {
<input
type="text"
className="input-origin block"
value={lengthBase}
value={trestleState?.lengthBase}
onChange={(e) => setLengthBase(e.target.value)}
disabled={selectedRoof.lenAuth === 'R'}
/>
@ -380,7 +384,7 @@ const Trestle = forwardRef((props, ref) => {
type="text"
className="input-origin block"
disabled={selectedRoof.roofPchAuth === 'R'}
onChange={(e) => setHajebichi(e.target.value)}
onChange={(e) => handleHajebichiAndLength(e, 'hajebichi')}
value={hajebichi}
/>
</div>

View File

@ -94,17 +94,9 @@ export function useModuleBasicSetting(tabNum) {
const listParams = roofConstructions.map((item) => {
return {
...common,
roofMatlCd: item.addRoof.roofMatlCd,
trestleMkrCd: item.addRoof.trestleMkrCd,
constMthdCd: item.addRoof.constMthdCd,
roofBaseCd: item.addRoof.roofBaseCd,
constTp: item.addRoof.constTp,
mixMatlNo: selectedModules.mixMatlNo,
...item.addRoof,
roofPitch: item.addRoof.hajebichi ? item.addRoof.hajebichi : 0,
inclCd: String(item.addRoof.pitch),
roofIndex: item.addRoof.index,
workingWidth: item.addRoof.lenBase,
raftBaseCd: item.trestle.raftBaseCd,
}
})
setTrestleDetailParams(listParams)
@ -177,9 +169,11 @@ export function useModuleBasicSetting(tabNum) {
trestleDetailList.forEach((detail) => {
const moduleRowArray = []
detail.data.module.forEach((module) => {
moduleRowArray.push({ moduleMaxRows: module.moduleMaxRows, mixModuleMaxRows: module.mixModuleMaxRows })
})
if (detail.data !== null && detail.data.module.length > 0) {
detail.data.module.forEach((module) => {
moduleRowArray.push({ moduleMaxRows: module.moduleMaxRows, mixModuleMaxRows: module.mixModuleMaxRows })
})
}
rowColArray.push(moduleRowArray)
})
setModuleRowColArray(rowColArray)