diff --git a/src/components/estimate/Estimate.jsx b/src/components/estimate/Estimate.jsx index 9a60fd0e..e59dd9ff 100644 --- a/src/components/estimate/Estimate.jsx +++ b/src/components/estimate/Estimate.jsx @@ -154,7 +154,7 @@ export default function Estimate({}) { useEffect(() => { // console.log('๐Ÿš€ ~ Estimate ~ selectedPlan:', selectedPlan) - if (selectedPlan) initEstimate(selectedPlan.planNo) + if (selectedPlan) initEstimate(selectedPlan?.planNo?? currentPid) }, [selectedPlan]) useEffect(() => { diff --git a/src/components/floor-plan/CanvasMenu.jsx b/src/components/floor-plan/CanvasMenu.jsx index 5d2d1030..b876d517 100644 --- a/src/components/floor-plan/CanvasMenu.jsx +++ b/src/components/floor-plan/CanvasMenu.jsx @@ -241,7 +241,7 @@ export default function CanvasMenu(props) { return } setIsGlobalLoading(true) - promiseGet({ url: `/api/estimate/${objectNo}/${selectedPlan.planNo}/detail` }).then((res) => { + promiseGet({ url: `/api/estimate/${objectNo}/${selectedPlan?.planNo??pid}/detail` }).then((res) => { if (res.status === 200) { const estimateDetail = res.data if (estimateDetail.estimateDate !== null) { @@ -249,7 +249,7 @@ export default function CanvasMenu(props) { setCurrentMenu(menu.title) setFloorPlanObjectNo({ floorPlanObjectNo: objectNo }) setIsGlobalLoading(false) - router.push(`/floor-plan/estimate/5?pid=${selectedPlan.planNo}&objectNo=${objectNo}`) + router.push(`/floor-plan/estimate/5?pid=${selectedPlan?.planNo??pid}&objectNo=${objectNo}`) if (pathname === '/floor-plan/estimate/5') { setIsGlobalLoading(false) } @@ -262,13 +262,13 @@ export default function CanvasMenu(props) { break case 'simulation': setIsGlobalLoading(true) - promiseGet({ url: `/api/estimate/${objectNo}/${selectedPlan.planNo}/detail` }).then((res) => { + promiseGet({ url: `/api/estimate/${objectNo}/${selectedPlan?.planNo??pid}/detail` }).then((res) => { if (res.status === 200) { const estimateDetail = res.data if (estimateDetail.estimateDate !== null && estimateDetail.docNo) { setSelectedMenu(menu.type) setCurrentMenu(menu.title) - router.push(`/floor-plan/simulator/6?pid=${selectedPlan.planNo}&objectNo=${objectNo}`) + router.push(`/floor-plan/simulator/6?pid=${selectedPlan?.planNo??pid}&objectNo=${objectNo}`) if (pathname === '/floor-plan/simulator/6') { setIsGlobalLoading(false) } diff --git a/src/components/floor-plan/modal/placementShape/PlacementShapeSetting.jsx b/src/components/floor-plan/modal/placementShape/PlacementShapeSetting.jsx index 0ac134ef..91332f43 100644 --- a/src/components/floor-plan/modal/placementShape/PlacementShapeSetting.jsx +++ b/src/components/floor-plan/modal/placementShape/PlacementShapeSetting.jsx @@ -227,7 +227,7 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, pla console.log('save Info', { ...basicSetting, selectedRoofMaterial: { - roofInfo, + ...newAddedRoofs[0], }, }) @@ -240,7 +240,7 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, pla * ์„ ํƒ๋œ ์ง€๋ถ•์žฌ ์ •๋ณด */ selectedRoofMaterial: { - roofInfo, + ...newAddedRoofs[0], }, }) diff --git a/src/components/simulator/Simulator.jsx b/src/components/simulator/Simulator.jsx index 6683ff9e..94307e8d 100644 --- a/src/components/simulator/Simulator.jsx +++ b/src/components/simulator/Simulator.jsx @@ -114,7 +114,7 @@ export default function Simulator() { setHatsudenryouPeakcutAllSnow([]) if (objectNo && pid && selectedPlan) { - fetchObjectDetail(objectNo, selectedPlan.planNo) + fetchObjectDetail(objectNo, selectedPlan?.planNo??pid) fetchSimulatorNotice() setPwrGnrSimType('D') setPwrRecoil({ ...pwrRecoil, type: 'D' }) diff --git a/src/hooks/module/useTrestle.js b/src/hooks/module/useTrestle.js index 8a41149d..0aea8bfc 100644 --- a/src/hooks/module/useTrestle.js +++ b/src/hooks/module/useTrestle.js @@ -1627,6 +1627,8 @@ export const useTrestle = () => { // ๋ž™ ์—†์Œ์˜ ์ง€์ง€๊ธˆ๊ตฌ๋ฅผ ๊ทธ๋ฆฐ๋‹ค. const drawBracketWithOutRack = (module, rackIntvlPct, count, l, direction, moduleIntvlHor, moduleIntvlVer) => { const { leftFindModuleList, rightFindModuleList, centerFindModuleList } = module + rackIntvlPct = rackIntvlPct === 0 ? 1 : rackIntvlPct // 0์ธ ๊ฒฝ์šฐ 1๋กœ ๋ณ€๊ฒฝ + rackIntvlPct = 100 / rackIntvlPct // ํผ์„ผํŠธ๋กœ ๋ณ€๊ฒฝ let { width, height, left, top } = module let startPointX @@ -1641,14 +1643,14 @@ export const useTrestle = () => { break } else if (direction === 'east') { startPointX = left + width - startPointY = top + height - height / rackIntvlPct + startPointY = top + height - height / rackIntvlPct - 10 break } else if (direction === 'west') { startPointX = left startPointY = top + height / rackIntvlPct break } else if (direction === 'north') { - startPointX = left + width - width / rackIntvlPct + startPointX = left + width - width / rackIntvlPct - 10 startPointY = top break } @@ -1657,7 +1659,7 @@ export const useTrestle = () => { case 'R': { // ์˜ค๋ฅธ์ชฝ๋ถ€๋ถ„ ์‹œ์ž‘ ์  if (direction === 'south') { - startPointX = left + width - width / rackIntvlPct + startPointX = left + width - width / rackIntvlPct - 10 startPointY = top + height / 2 + height / 2 break } else if (direction === 'east') { @@ -1666,7 +1668,7 @@ export const useTrestle = () => { break } else if (direction === 'west') { startPointX = left - startPointY = top + height - height / rackIntvlPct + startPointY = top + height - height / rackIntvlPct - 10 break } else if (direction === 'north') { startPointX = left + width / rackIntvlPct diff --git a/src/hooks/option/useCanvasSetting.js b/src/hooks/option/useCanvasSetting.js index 1c7c0e39..db374c7f 100644 --- a/src/hooks/option/useCanvasSetting.js +++ b/src/hooks/option/useCanvasSetting.js @@ -498,11 +498,26 @@ export function useCanvasSetting(executeEffect = true) { roofSeq: 0, roofMatlCd: params.roofsData.roofMatlCd === null || params.roofsData.roofMatlCd === undefined ? 'ROOF_ID_WA_53A' : params.roofsData.roofMatlCd, - roofWidth: params.roofsData.roofWidth === null || params.roofsData.roofWidth === undefined ? 0 : params.roofsData.roofWidth, - roofHeight: params.roofsData.roofHeight === null || params.roofsData.roofHeight === undefined ? 0 : params.roofsData.roofHeight, + roofWidth: + params.selectedRoofMaterial.width === null || params.selectedRoofMaterial.width === undefined + ? !params.selectedRoofMaterial.widBase + ? 0 + : Number(params.roofsData.widBase) + : Number(params.selectedRoofMaterial.width), + roofHeight: + params.selectedRoofMaterial.height === null || params.selectedRoofMaterial.height === undefined + ? !params.selectedRoofMaterial.lenBase + ? 0 + : Number(params.selectedRoofMaterial.lenBase) + : Number(params.roofsData.roofHeight), roofHajebichi: - params.roofsData.roofHajebichi === null || params.roofsData.roofHajebichi === undefined ? 0 : params.roofsData.roofHajebichi, - roofGap: params.roofsData.roofGap === null || params.roofsData.roofGap === undefined ? 'HEI_455' : params.roofsData.roofGap, + params.selectedRoofMaterial.hajebichi === null || params.selectedRoofMaterial.hajebichi === undefined + ? 0 + : Number(params.selectedRoofMaterial.hajebichi), + roofGap: + params.selectedRoofMaterial.raft === null || params.selectedRoofMaterial.raft === undefined + ? params.selectedRoofMaterial.raftBaseCd + : params.roofsData.raft, roofLayout: params.roofsData.roofLayout === null || params.roofsData.roofLayout === undefined ? 'P' : params.roofsData.roofLayout, roofPitch: params.roofsData.roofPitch === null || params.roofsData.roofPitch === undefined ? 0 : params.roofsData.roofPitch, roofAngle: params.roofsData.roofAngle === null || params.roofsData.roofAngle === undefined ? 0 : params.roofsData.roofAngle, diff --git a/src/hooks/useEvent.js b/src/hooks/useEvent.js index 9f9e4ea0..8b7b687d 100644 --- a/src/hooks/useEvent.js +++ b/src/hooks/useEvent.js @@ -1,4 +1,4 @@ -import { useRef } from 'react' +import { useEffect, useRef } from 'react' import { useRecoilValue, useSetRecoilState } from 'recoil' import { canvasState, canvasZoomState, currentMenuState, textModeState } from '@/store/canvasAtom' import { fabric } from 'fabric' @@ -15,7 +15,8 @@ import { useDotLineGrid } from '@/hooks/useDotLineGrid' import { useTempGrid } from '@/hooks/useTempGrid' import { gridColorState } from '@/store/gridAtom' import { gridDisplaySelector } from '@/store/settingAtom' -import { POLYGON_TYPE } from '@/common/common' +import { MENU, POLYGON_TYPE } from '@/common/common' +import useMenu from '@/hooks/common/useMenu' export function useEvent() { const canvas = useRecoilValue(canvasState) @@ -25,6 +26,7 @@ export function useEvent() { const setCanvasZoom = useSetRecoilState(canvasZoomState) const gridColor = useRecoilValue(gridColorState) const isGridDisplay = useRecoilValue(gridDisplaySelector) + const zoom = useRecoilValue(canvasZoomState) const { adsorptionPointAddMode, adsorptionPointMode, adsorptionRange, getAdsorptionPoints, adsorptionPointAddModeStateEvent } = useAdsorptionPoint() const { dotLineGridSetting, interval, getClosestLineGrid } = useDotLineGrid() @@ -59,6 +61,13 @@ export function useEvent() { addDefaultEvent() } + useEffect(() => { + const whiteMenus = [MENU.BATCH_CANVAS.SURFACE_SHAPE_BATCH, MENU.BATCH_CANVAS.OBJECT_BATCH, MENU.MODULE_CIRCUIT_SETTING.BASIC_SETTING] + if (canvas && !whiteMenus.includes(currentMenu)) { + addCanvasMouseEventListener('mouse:move', defaultMouseMoveEvent) + } + }, [zoom]) + const addDefaultEvent = () => { //default Event ์ถ”๊ฐ€ addCanvasMouseEventListener('mouse:move', defaultMouseMoveEvent) @@ -280,7 +289,7 @@ export function useEvent() { } const drawMouseLine = (pointer) => { - const horizontalLine = new fabric.Line([-4 * canvas.width, pointer.y, 4 * canvas.width, pointer.y], { + const horizontalLine = new fabric.Line([-2 * canvas.width, pointer.y, 2 * canvas.width, pointer.y], { stroke: 'red', strokeWidth: 1, selectable: false, @@ -288,7 +297,7 @@ export function useEvent() { }) // ์„ธ๋กœ์„  - const verticalLine = new fabric.Line([pointer.x, -4 * canvas.height, pointer.x, 4 * canvas.height], { + const verticalLine = new fabric.Line([pointer.x, -2 * canvas.height, pointer.x, 2 * canvas.height], { stroke: 'red', strokeWidth: 1, selectable: false, diff --git a/src/hooks/usePolygon.js b/src/hooks/usePolygon.js index 558bec36..b83d4ac4 100644 --- a/src/hooks/usePolygon.js +++ b/src/hooks/usePolygon.js @@ -1193,7 +1193,7 @@ export const usePolygon = () => { }) canvas.add(roof) - // addLengthText(roof) + addLengthText(roof) canvas.remove(polygon) canvas.renderAll() })