-
{getMessage('modal.circuit.trestle.setting.power.conditional.select')}
-
-
- {getMessage('modal.circuit.trestle.setting.circuit.allocation')}({getMessage('modal.circuit.trestle.setting.step.up.allocation')})
+ <>
+ {showHiddenBasicSetting && (
+
+
+
+ )}
+
+ handleClose()}
+ isFold={isFold}
+ onFold={() => setIsFold(!isFold)}
+ />
+
+
+
+
+
{getMessage('modal.circuit.trestle.setting.power.conditional.select')}
+
+
+ {getMessage('modal.circuit.trestle.setting.circuit.allocation')}({getMessage('modal.circuit.trestle.setting.step.up.allocation')})
+
+ {tabNum === 1 && allocationType === ALLOCATION_TYPE.AUTO &&
}
+ {tabNum === 1 && allocationType === ALLOCATION_TYPE.PASSIVITY && (
+
+ )}
+ {tabNum === 2 &&
}
- {tabNum === 1 && allocationType === ALLOCATION_TYPE.AUTO && }
- {tabNum === 1 && allocationType === ALLOCATION_TYPE.PASSIVITY && (
-
- )}
- {tabNum === 2 && }
-
- {tabNum === 1 && allocationType === ALLOCATION_TYPE.AUTO && (
-
-
-
-
- )}
- {tabNum === 1 && allocationType === ALLOCATION_TYPE.PASSIVITY && (
-
-
-
-
- )}
- {tabNum === 2 && (
-
-
- {/*
- )}
-
-
+ {tabNum === 1 && allocationType === ALLOCATION_TYPE.AUTO && (
+
+ onAutoRecommend()}>
+ {getMessage('modal.circuit.trestle.setting.circuit.allocation.auto')}
+
+ onPassivityAllocation()}>
+ {getMessage('modal.circuit.trestle.setting.circuit.allocation.passivity')}
+
+
+ )}
+ {tabNum === 1 && allocationType === ALLOCATION_TYPE.PASSIVITY && (
+
+ onClickPrev()}>
+ {getMessage('modal.common.prev')}
+
+ handleStepUp()}>
+ {getMessage('modal.circuit.trestle.setting.circuit.allocation')}({getMessage('modal.circuit.trestle.setting.step.up.allocation')})
+
+
+ )}
+ {tabNum === 2 && (
+
+ onClickPrev()}>
+ {getMessage('modal.common.prev')}
+
+ {/* apply()}> */}
+
+ {getMessage('modal.common.save')}({getMessage('modal.circuit.trestle.setting.circuit.allocation')})
+
+
+ )}
+
+
+ >
)
}
diff --git a/src/components/floor-plan/modal/placementShape/PlacementShapeSetting.jsx b/src/components/floor-plan/modal/placementShape/PlacementShapeSetting.jsx
index 95442b8a..87ad753c 100644
--- a/src/components/floor-plan/modal/placementShape/PlacementShapeSetting.jsx
+++ b/src/components/floor-plan/modal/placementShape/PlacementShapeSetting.jsx
@@ -8,7 +8,7 @@ import MaterialGuide from '@/components/floor-plan/modal/placementShape/Material
import WithDraggable from '@/components/common/draggable/WithDraggable'
import { useCanvasSetting } from '@/hooks/option/useCanvasSetting'
-import { useRecoilState, useRecoilValue } from 'recoil'
+import { useRecoilState, useRecoilValue, useSetRecoilState } from 'recoil'
import { addedRoofsState, roofDisplaySelector, roofMaterialsAtom } from '@/store/settingAtom'
import { useCommonCode } from '@/hooks/common/useCommonCode'
import QSelectBox from '@/components/common/select/QSelectBox'
@@ -16,11 +16,12 @@ import { globalLocaleStore } from '@/store/localeAtom'
import { getChonByDegree, getDegreeByChon } from '@/util/canvas-util'
import { usePolygon } from '@/hooks/usePolygon'
-import { canvasState } from '@/store/canvasAtom'
+import { canvasState, canvasSettingState, currentCanvasPlanState, currentMenuState } from '@/store/canvasAtom'
+import { useCanvasMenu } from '@/hooks/common/useCanvasMenu'
+import { MENU, POLYGON_TYPE } from '@/common/common'
import { useRoofFn } from '@/hooks/common/useRoofFn'
import { usePlan } from '@/hooks/usePlan'
-import { normalizeDecimal, normalizeDigits } from '@/util/input-utils'
-import { logger } from '@/util/logger'
+import { normalizeDecimal } from '@/util/input-utils'
import { CalculatorInput } from '@/components/common/input/CalcInput'
/**
@@ -41,14 +42,23 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, pla
const { basicSetting, setBasicSettings, fetchBasicSettings, basicSettingSave } = useCanvasSetting()
const [addedRoofs, setAddedRoofs] = useRecoilState(addedRoofsState)
const { findCommonCode } = useCommonCode()
- const [raftCodes, setRaftCodes] = useState([]) /** 서까래 정보 */
- const [currentRoof, setCurrentRoof] = useState(null) /** 현재 선택된 지붕재 정보 */
- const { closePopup } = usePopup() /** usePopup에서 closePopup 함수 가져오기 */
+ const [raftCodes, setRaftCodes] = useState([])
+ /** 서까래 정보 */
+ const [currentRoof, setCurrentRoof] = useState(null)
+ /** 현재 선택된 지붕재 정보 */
+ const { closePopup } = usePopup()
+ /** usePopup에서 closePopup 함수 가져오기 */
const { drawDirectionArrow } = usePolygon()
const { setSurfaceShapePattern } = useRoofFn()
const canvas = useRecoilValue(canvasState)
+ const [canvasSetting, setCanvasSetting] = useRecoilState(canvasSettingState)
+ const currentCanvasPlan = useRecoilValue(currentCanvasPlanState)
const roofDisplay = useRecoilValue(roofDisplaySelector)
+ const { setPolygonLinesActualSize } = usePolygon()
+ const { setSelectedMenu } = useCanvasMenu()
+ const setCurrentMenu = useSetRecoilState(currentMenuState)
+
const roofRef = {
roofCd: useRef(null),
width: useRef(null),
@@ -114,6 +124,15 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, pla
if (openPoint && openPoint === 'canvasMenus') fetchBasicSettings(planNo, openPoint)
}, [])
+ /**
+ * 현재 활성 플랜이 변경될 때 currentRoof.planNo 업데이트
+ */
+ useEffect(() => {
+ if (currentCanvasPlan?.planNo && currentRoof) {
+ setCurrentRoof(prev => ({ ...prev, planNo: currentCanvasPlan.planNo }))
+ }
+ }, [currentCanvasPlan?.planNo])
+
/**
* 배치면초기설정 데이터 조회 후 화면 오픈
*/
@@ -121,7 +140,12 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, pla
if (addedRoofs.length > 0) {
const raftCodeList = findCommonCode('203800')
setRaftCodes(raftCodeList)
- setCurrentRoof({ ...addedRoofs[0], planNo: planNo, roofSizeSet: String(basicSetting.roofSizeSet), roofAngleSet: basicSetting.roofAngleSet })
+ setCurrentRoof({
+ ...addedRoofs[0],
+ planNo: currentCanvasPlan?.planNo || planNo,
+ roofSizeSet: String(basicSetting.roofSizeSet),
+ roofAngleSet: basicSetting.roofAngleSet,
+ })
} else {
/** 데이터 설정 확인 후 데이터가 없으면 기본 데이터 설정 */
setCurrentRoof({ ...DEFAULT_ROOF_SETTINGS })
@@ -154,10 +178,6 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, pla
})
}, [currentRoof])
- const handleRoofSizeSetChange = (value) => {
- setCurrentRoof({ ...currentRoof, roofSizeSet: value })
- }
-
const handleRoofAngleSetChange = (value) => {
setCurrentRoof({ ...currentRoof, roofAngleSet: value })
}
@@ -209,10 +229,9 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, pla
* 배치면초기설정 저장 버튼 클릭
*/
const handleSaveBtn = async () => {
-
const roofInfo = {
...currentRoof,
- planNo: basicSetting.planNo,
+ planNo: currentCanvasPlan?.planNo || basicSetting.planNo,
roofCd: roofRef.roofCd.current?.value,
width: roofRef.width.current?.value,
length: roofRef.length.current?.value,
@@ -227,25 +246,22 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, pla
newAddedRoofs[0] = { ...roofInfo }
setAddedRoofs(newAddedRoofs)
- logger.debug('save Info', {
- ...basicSetting,
- selectedRoofMaterial: {
- ...newAddedRoofs[0],
- },
- })
+ // currentRoof의 roofSizeSet을 canvasSetting에 반영
+ setCanvasSetting({ ...canvasSetting, roofSizeSet: currentRoof?.roofSizeSet })
/**
- * 배치면초기설정 저장
+ * 배치면초기설정 저장 (메뉴 변경/useEffect 트리거 없이)
*/
basicSettingSave({
...basicSetting,
+ planNo: currentCanvasPlan?.planNo || basicSetting.planNo,
/**
* 선택된 지붕재 정보
*/
selectedRoofMaterial: {
...newAddedRoofs[0],
},
- })
+ }, { skipSideEffects: true })
const roofs = canvas.getObjects().filter((obj) => obj.roofMaterial?.index === 0)
@@ -254,7 +270,27 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, pla
setSurfaceShapePattern(roof, roofDisplay.column, false, { ...roofInfo })
roof.roofMaterial = { ...roofInfo }
drawDirectionArrow(roof)
+ setPolygonLinesActualSize(roof, true)
})
+ canvas.renderAll()
+
+ /** 지붕면 존재 여부에 따라 메뉴 설정 */
+ const hasRoofs = canvas.getObjects().some((obj) => obj.name === POLYGON_TYPE.ROOF)
+
+ // roofSizeSet에 따라 메뉴 설정
+ if (currentRoof?.roofSizeSet === '2') {
+ setSelectedMenu('surface')
+ setCurrentMenu(MENU.BATCH_CANVAS.BATCH_DRAWING)
+ } else if (currentRoof?.roofSizeSet === '1') {
+ setSelectedMenu('outline')
+ setCurrentMenu(MENU.ROOF_COVERING.EXTERIOR_WALL_LINE)
+ } else if (hasRoofs) {
+ setSelectedMenu('surface')
+ setCurrentMenu(MENU.BATCH_CANVAS.BATCH_DRAWING)
+ } else {
+ setSelectedMenu('outline')
+ setCurrentMenu(MENU.ROOF_COVERING.EXTERIOR_WALL_LINE)
+ }
/* 저장 후 화면 닫기 */
closePopup(id)
@@ -353,26 +389,26 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, pla
value={index === 0 ? (currentRoof?.pitch ?? basicSetting?.inclBase ?? '0') : (currentRoof?.angle ?? '0')}
onChange={(value) => {
if (index === 0) {
- const pitch = value === '' ? '' : Number(value);
- const angle = pitch === '' ? '' : getDegreeByChon(pitch);
- setCurrentRoof(prev => ({
+ const pitch = value === '' ? '' : Number(value)
+ const angle = pitch === '' ? '' : getDegreeByChon(pitch)
+ setCurrentRoof((prev) => ({
...prev,
pitch,
- angle
- }));
+ angle,
+ }))
} else {
- const angle = value === '' ? '' : Number(value);
- const pitch = angle === '' ? '' : getChonByDegree(angle);
- setCurrentRoof(prev => ({
+ const angle = value === '' ? '' : Number(value)
+ const pitch = angle === '' ? '' : getChonByDegree(angle)
+ setCurrentRoof((prev) => ({
...prev,
pitch,
- angle
- }));
+ angle,
+ }))
}
}}
options={{
allowNegative: false,
- allowDecimal: true
+ allowDecimal: true,
}}
/>
@@ -432,7 +468,7 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, pla
label=""
className="input-origin block"
ref={roofRef.width}
- value={currentRoof?.width||0}
+ value={currentRoof?.width || 0}
onChange={(value) => {
setCurrentRoof({ ...currentRoof, value })
}}
@@ -440,7 +476,7 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, pla
disabled={currentRoof?.roofSizeSet === '3'}
options={{
allowNegative: false,
- allowDecimal: false //(index !== 0),
+ allowDecimal: false, //(index !== 0),
}}
/>