Merge pull request '[2321] 모듈배치 千鳥配置(지그재그 배치) 가부 판정 — 선택 배치면(지붕재)별 재계산' (#955) from dev into prd-deploy
Reviewed-on: #955
This commit is contained in:
commit
71be879154
@ -7,6 +7,7 @@ import {
|
||||
isManualModuleSetupState,
|
||||
moduleRowColArrayState,
|
||||
moduleSetupOptionState,
|
||||
moduleSetupSurfaceState,
|
||||
toggleManualSetupModeState,
|
||||
} from '@/store/canvasAtom'
|
||||
import { useRecoilState, useRecoilValue, useResetRecoilState, useSetRecoilState } from 'recoil'
|
||||
@ -42,14 +43,39 @@ const Placement = forwardRef((props, refs) => {
|
||||
const [colspan, setColspan] = useState(1)
|
||||
const moduleRowColArray = useRecoilValue(moduleRowColArrayState)
|
||||
|
||||
const moduleSetupSurface = useRecoilValue(moduleSetupSurfaceState) //선택된 배치면
|
||||
|
||||
// 千鳥可否 는 지붕재별로 다르므로 선택된 배치면 기준으로 재판정한다.
|
||||
// 일부 지붕재만 선택하면 그 지붕재 기준, 미선택이거나 모든 지붕재가 선택되면 전체 기준으로
|
||||
// 하나라도 不可(plvrYn==='N')면 千鳥 불가.
|
||||
useEffect(() => {
|
||||
const roofConstructions = moduleSelectionData?.roofConstructions
|
||||
if (!roofConstructions?.length) return
|
||||
|
||||
const plvrOf = (roofIndex) => roofConstructions.find((c) => Number(c.roofIndex) === Number(roofIndex))?.construction?.plvrYn
|
||||
const allRoofIndexes = roofConstructions.map((c) => Number(c.roofIndex))
|
||||
const selectedRoofIndexes = [...new Set((moduleSetupSurface ?? []).filter((s) => s.roofMaterial?.index != null).map((s) => Number(s.roofMaterial.index)))]
|
||||
|
||||
// 미선택 또는 모든 지붕재가 선택된 경우 = 전체 기준
|
||||
const useAll = selectedRoofIndexes.length === 0 || allRoofIndexes.every((roofIndex) => selectedRoofIndexes.includes(roofIndex))
|
||||
const targetRoofIndexes = useAll ? allRoofIndexes : selectedRoofIndexes
|
||||
|
||||
const notAble = targetRoofIndexes.some((roofIndex) => plvrOf(roofIndex) === 'N')
|
||||
setIsChidoriNotAble(notAble)
|
||||
|
||||
// 不可 지붕재가 선택되면 켜져 있던 千鳥 를 자동 해제하고, 진행 중이던 수동배치도 초기화한다.
|
||||
// (千鳥 오프셋이 바뀌면 기존/신규 모듈 배치가 섞이므로, 千鳥 수동 변경과 동일하게 수동 모드를 끈다)
|
||||
if (notAble) {
|
||||
setModuleSetupOption((prev) => (prev.isChidori ? { ...prev, isChidori: false } : prev))
|
||||
setIsManualModuleSetup(false)
|
||||
setIsManualModuleLayoutSetup(false)
|
||||
setManualSetupMode('off')
|
||||
}
|
||||
}, [moduleSetupSurface, moduleSelectionData])
|
||||
|
||||
//모듈 배치면 생성
|
||||
useEffect(() => {
|
||||
if (moduleSelectionData) {
|
||||
//1개라도 치도리 불가가 있으면 치도리 불가
|
||||
const isChidroriValue = moduleSelectionData.roofConstructions.some((item) => item.construction.plvrYn === 'N')
|
||||
if (isChidroriValue) {
|
||||
setIsChidoriNotAble(true)
|
||||
}
|
||||
makeModuleInitArea(moduleSelectionData)
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user