From 94985feed8eb993ecdf61f2c70179f40fdd5dc5f Mon Sep 17 00:00:00 2001 From: "hyojun.choi" Date: Fri, 30 May 2025 17:29:37 +0900 Subject: [PATCH 1/2] =?UTF-8?q?length=EA=B0=80=20=EC=97=86=EB=8A=94?= =?UTF-8?q?=EA=B2=BD=EC=9A=B0=20=EB=94=B0=EB=A1=9C=20=EA=B3=84=EC=82=B0=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/useLine.js | 1 + src/hooks/usePolygon.js | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/hooks/useLine.js b/src/hooks/useLine.js index fcf14312..9d1a48eb 100644 --- a/src/hooks/useLine.js +++ b/src/hooks/useLine.js @@ -159,5 +159,6 @@ export const useLine = () => { addPitchText, removePitchText, addPitchTextsByOuterLines, + getLengthByLine, } } diff --git a/src/hooks/usePolygon.js b/src/hooks/usePolygon.js index 39e82210..558bec36 100644 --- a/src/hooks/usePolygon.js +++ b/src/hooks/usePolygon.js @@ -15,6 +15,7 @@ import { flowDisplaySelector } from '@/store/settingAtom' import { fontSelector } from '@/store/fontAtom' import { QLine } from '@/components/fabric/QLine' import { LINE_TYPE, POLYGON_TYPE } from '@/common/common' +import { useLine } from '@/hooks/useLine' export const usePolygon = () => { const canvas = useRecoilValue(canvasState) @@ -24,6 +25,8 @@ export const usePolygon = () => { const currentAngleType = useRecoilValue(currentAngleTypeSelector) const pitchText = useRecoilValue(pitchTextSelector) + const { getLengthByLine } = useLine() + const addPolygon = (points, options, isAddCanvas = true) => { const polygon = new QPolygon(points, { ...options, @@ -1104,7 +1107,7 @@ export const usePolygon = () => { if (!representLine) { representLine = line } else { - if (representLine.length < line.length) { + if (getLengthByLine(representLine) < getLengthByLine(line)) { representLine = line } } From 8b81998f8ccf398292f92e8b5279dc16e3d1df70 Mon Sep 17 00:00:00 2001 From: yjnoh Date: Fri, 30 May 2025 17:56:39 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[1068]=20:=20[=EA=B2=AC=EC=A0=81=EC=84=9C?= =?UTF-8?q?=20=EC=83=9D=EC=84=B1=EB=90=9C=20=ED=94=8C=EB=9E=9C=EB=B3=B5?= =?UTF-8?q?=EC=82=AC=20-->=20=EB=B3=B5=EC=82=AC=EB=90=9C=20=ED=94=8C?= =?UTF-8?q?=EB=9E=9C=EC=97=90=EC=84=9C=20=EB=AA=A8=EB=93=88=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=20-->=20=EA=B2=AC=EC=A0=81=EC=84=9C=20=EC=A7=84?= =?UTF-8?q?=EC=9E=85=EC=9D=B4=20=EB=90=A8..=20]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [작업내용] : 가대까지 완성 -> 삭제 안함, 그 전상태면 무조건 삭제 로직으로 구현 --- .../floorPlan/estimate/useEstimateController.js | 14 ++++++++++++++ src/hooks/usePlan.js | 15 +++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/hooks/floorPlan/estimate/useEstimateController.js b/src/hooks/floorPlan/estimate/useEstimateController.js index 4a752a9f..ae37c8db 100644 --- a/src/hooks/floorPlan/estimate/useEstimateController.js +++ b/src/hooks/floorPlan/estimate/useEstimateController.js @@ -489,6 +489,19 @@ export const useEstimateController = (planNo, flag) => { }) } + const handleDeleteEstimate = async (canvasStatus) => { + try { + setIsGlobalLoading(true) + await promisePost({ url: `${ESTIMATE_API_ENDPOINT}/delete-estimate`, data: canvasStatus }).then((res) => { + if (res.status === 201) { + } + }) + } catch (e) { + console.error('error::::::::::::', e.response.data.message) + } + setIsGlobalLoading(false) + } + /** * 전각20자 (반각40자) */ @@ -509,5 +522,6 @@ export const useEstimateController = (planNo, flag) => { fetchSetting, handleEstimateFileDownload, handleEstimateCopy, + handleDeleteEstimate, } } diff --git a/src/hooks/usePlan.js b/src/hooks/usePlan.js index afae51c8..81d66455 100644 --- a/src/hooks/usePlan.js +++ b/src/hooks/usePlan.js @@ -30,6 +30,7 @@ import { useCanvasPopupStatusController } from './common/useCanvasPopupStatusCon import { useCanvasMenu } from './common/useCanvasMenu' import { QcastContext } from '@/app/QcastProvider' import { unescapeString } from '@/util/common-utils' +import { useTrestle } from '@/hooks/module/useTrestle' /** * 플랜 처리 훅 @@ -54,7 +55,7 @@ export function usePlan(params = {}) { const { getMessage } = useMessage() const { get, post, promisePost, promisePut, promiseDel, promiseGet } = useAxios() - const { setEstimateContextState } = useEstimateController() + const { setEstimateContextState, handleDeleteEstimate } = useEstimateController() const resetOuterLinePoints = useResetRecoilState(outerLinePointsState) const resetPlacementShapeDrawingPoints = useResetRecoilState(placementShapeDrawingPointsState) @@ -79,6 +80,8 @@ export function usePlan(params = {}) { //선택된 모듈 배치면 초기화 const resetModuleSetupSurface = useResetRecoilState(moduleSetupSurfaceState) + const { isAllComplete } = useTrestle() + /** * 마우스 포인터의 가이드라인 제거 */ @@ -172,7 +175,11 @@ export function usePlan(params = {}) { */ const saveCanvas = async (saveAlert = true) => { const canvasStatus = currentCanvasData('save') - await putCanvasStatus(canvasStatus, saveAlert) + const result = await putCanvasStatus(canvasStatus, saveAlert) + //캔버스 저장 완료 후 + if (result && !isAllComplete()) { + handleDeleteEstimate(currentCanvasPlan) + } } /** @@ -318,20 +325,24 @@ export function usePlan(params = {}) { * @param {boolean} saveAlert - 저장 완료 알림 표시 여부 */ const putCanvasStatus = async (canvasStatus, saveAlert = true) => { + let rtn = false const planData = { id: currentCanvasPlan.id, bgImageName: currentCanvasPlan?.bgImageName ?? null, mapPositionAddress: currentCanvasPlan?.mapPositionAddress ?? null, canvasStatus: canvasToDbFormat(canvasStatus), } + await promisePut({ url: '/api/canvas-management/canvas-statuses', data: planData }) .then((res) => { setPlans((plans) => plans.map((plan) => (plan.id === currentCanvasPlan.id ? { ...plan, canvasStatus: canvasStatus } : plan))) if (saveAlert) swalFire({ text: getMessage('plan.message.save') }) + rtn = true }) .catch((error) => { swalFire({ text: error.message, icon: 'error' }) }) + return rtn } /**