diff --git a/src/components/floor-plan/CanvasMenu.jsx b/src/components/floor-plan/CanvasMenu.jsx index 553b3613..1ed413cf 100644 --- a/src/components/floor-plan/CanvasMenu.jsx +++ b/src/components/floor-plan/CanvasMenu.jsx @@ -221,6 +221,7 @@ export default function CanvasMenu(props) { await reloadCanvasStatus(objectNo, pid) break case 5: + setIsGlobalLoading(true) promiseGet({ url: `/api/estimate/${objectNo}/${selectedPlan.planNo}/detail` }).then((res) => { if (res.status === 200) { const estimateDetail = res.data @@ -230,6 +231,9 @@ export default function CanvasMenu(props) { setFloorPlanObjectNo({ floorPlanObjectNo: objectNo }) setIsGlobalLoading(false) router.push(`/floor-plan/estimate/${menu.index}?pid=${selectedPlan.planNo}&objectNo=${objectNo}`) + if (pathname === '/floor-plan/estimate/5') { + setIsGlobalLoading(false) + } } else { setIsGlobalLoading(false) swalFire({ text: getMessage('estimate.menu.move.valid1') }) diff --git a/src/hooks/module/useTrestle.js b/src/hooks/module/useTrestle.js index 248568b5..17f58814 100644 --- a/src/hooks/module/useTrestle.js +++ b/src/hooks/module/useTrestle.js @@ -710,7 +710,7 @@ export const useTrestle = () => { slope, classType: currentAngleType === 'slope' ? '0' : '1', angle: getDegreeByChon(slope), - azimuth: surfaceCompass ?? moduleCompass ?? 0, + azimuth: getAzimuth(surface), moduleList, } }) @@ -726,6 +726,70 @@ export const useTrestle = () => { return { itemList, northArrangement, roofSurfaceList, circuitItemList } } + const getAzimuth = (surface) => { + const { moduleCompass, surfaceCompass, direction } = surface + + if (surfaceCompass) { + if (surfaceCompass > 180) { + return surfaceCompass - 360 + } + return surfaceCompass + } + + switch (direction) { + case 'south': { + if (moduleCompass < 0) { + return -1 * moduleCompass + } else if (moduleCompass === 0) { + return 0 + } else if (moduleCompass < 180) { + return -1 * moduleCompass + } else if (moduleCompass === 180) { + return 180 + } + } + case 'north': { + if (moduleCompass < 0) { + return -1 * (180 + moduleCompass) + } else if (moduleCompass === 0) { + return 180 + } else if (moduleCompass < 180) { + return 180 - moduleCompass + } else if (moduleCompass === 180) { + return 0 + } + } + case 'west': { + if (moduleCompass > -180 && moduleCompass < -90) { + return -180 - (90 + moduleCompass) + } else if (moduleCompass < 0) { + return 180 - (90 + moduleCompass) + } else if (moduleCompass === 0) { + return 90 + } else if (moduleCompass < 180) { + return 90 - moduleCompass + } else if (moduleCompass === 180) { + return -90 + } + } + case 'east': { + if (moduleCompass < 0) { + return -(90 + moduleCompass) + } else if (moduleCompass === 0) { + return -90 + } else if (moduleCompass < 90) { + return -180 + (90 - moduleCompass) + } else if (moduleCompass < 180) { + return 180 + (90 - moduleCompass) + } else if (moduleCompass === 180) { + return 90 + } + } + } + + return 0 + } + const getNorthArrangement = () => { const surfaces = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE) let northArrangement = '0'