dev #88
@ -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자)
|
* 전각20자 (반각40자)
|
||||||
*/
|
*/
|
||||||
@ -509,5 +522,6 @@ export const useEstimateController = (planNo, flag) => {
|
|||||||
fetchSetting,
|
fetchSetting,
|
||||||
handleEstimateFileDownload,
|
handleEstimateFileDownload,
|
||||||
handleEstimateCopy,
|
handleEstimateCopy,
|
||||||
|
handleDeleteEstimate,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -159,5 +159,6 @@ export const useLine = () => {
|
|||||||
addPitchText,
|
addPitchText,
|
||||||
removePitchText,
|
removePitchText,
|
||||||
addPitchTextsByOuterLines,
|
addPitchTextsByOuterLines,
|
||||||
|
getLengthByLine,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,6 +30,7 @@ import { useCanvasPopupStatusController } from './common/useCanvasPopupStatusCon
|
|||||||
import { useCanvasMenu } from './common/useCanvasMenu'
|
import { useCanvasMenu } from './common/useCanvasMenu'
|
||||||
import { QcastContext } from '@/app/QcastProvider'
|
import { QcastContext } from '@/app/QcastProvider'
|
||||||
import { unescapeString } from '@/util/common-utils'
|
import { unescapeString } from '@/util/common-utils'
|
||||||
|
import { useTrestle } from '@/hooks/module/useTrestle'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 플랜 처리 훅
|
* 플랜 처리 훅
|
||||||
@ -54,7 +55,7 @@ export function usePlan(params = {}) {
|
|||||||
const { getMessage } = useMessage()
|
const { getMessage } = useMessage()
|
||||||
const { get, post, promisePost, promisePut, promiseDel, promiseGet } = useAxios()
|
const { get, post, promisePost, promisePut, promiseDel, promiseGet } = useAxios()
|
||||||
|
|
||||||
const { setEstimateContextState } = useEstimateController()
|
const { setEstimateContextState, handleDeleteEstimate } = useEstimateController()
|
||||||
|
|
||||||
const resetOuterLinePoints = useResetRecoilState(outerLinePointsState)
|
const resetOuterLinePoints = useResetRecoilState(outerLinePointsState)
|
||||||
const resetPlacementShapeDrawingPoints = useResetRecoilState(placementShapeDrawingPointsState)
|
const resetPlacementShapeDrawingPoints = useResetRecoilState(placementShapeDrawingPointsState)
|
||||||
@ -79,6 +80,8 @@ export function usePlan(params = {}) {
|
|||||||
//선택된 모듈 배치면 초기화
|
//선택된 모듈 배치면 초기화
|
||||||
const resetModuleSetupSurface = useResetRecoilState(moduleSetupSurfaceState)
|
const resetModuleSetupSurface = useResetRecoilState(moduleSetupSurfaceState)
|
||||||
|
|
||||||
|
const { isAllComplete } = useTrestle()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 마우스 포인터의 가이드라인 제거
|
* 마우스 포인터의 가이드라인 제거
|
||||||
*/
|
*/
|
||||||
@ -172,7 +175,11 @@ export function usePlan(params = {}) {
|
|||||||
*/
|
*/
|
||||||
const saveCanvas = async (saveAlert = true) => {
|
const saveCanvas = async (saveAlert = true) => {
|
||||||
const canvasStatus = currentCanvasData('save')
|
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 - 저장 완료 알림 표시 여부
|
* @param {boolean} saveAlert - 저장 완료 알림 표시 여부
|
||||||
*/
|
*/
|
||||||
const putCanvasStatus = async (canvasStatus, saveAlert = true) => {
|
const putCanvasStatus = async (canvasStatus, saveAlert = true) => {
|
||||||
|
let rtn = false
|
||||||
const planData = {
|
const planData = {
|
||||||
id: currentCanvasPlan.id,
|
id: currentCanvasPlan.id,
|
||||||
bgImageName: currentCanvasPlan?.bgImageName ?? null,
|
bgImageName: currentCanvasPlan?.bgImageName ?? null,
|
||||||
mapPositionAddress: currentCanvasPlan?.mapPositionAddress ?? null,
|
mapPositionAddress: currentCanvasPlan?.mapPositionAddress ?? null,
|
||||||
canvasStatus: canvasToDbFormat(canvasStatus),
|
canvasStatus: canvasToDbFormat(canvasStatus),
|
||||||
}
|
}
|
||||||
|
|
||||||
await promisePut({ url: '/api/canvas-management/canvas-statuses', data: planData })
|
await promisePut({ url: '/api/canvas-management/canvas-statuses', data: planData })
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
setPlans((plans) => plans.map((plan) => (plan.id === currentCanvasPlan.id ? { ...plan, canvasStatus: canvasStatus } : plan)))
|
setPlans((plans) => plans.map((plan) => (plan.id === currentCanvasPlan.id ? { ...plan, canvasStatus: canvasStatus } : plan)))
|
||||||
if (saveAlert) swalFire({ text: getMessage('plan.message.save') })
|
if (saveAlert) swalFire({ text: getMessage('plan.message.save') })
|
||||||
|
rtn = true
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
swalFire({ text: error.message, icon: 'error' })
|
swalFire({ text: error.message, icon: 'error' })
|
||||||
})
|
})
|
||||||
|
return rtn
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -15,6 +15,7 @@ import { flowDisplaySelector } from '@/store/settingAtom'
|
|||||||
import { fontSelector } from '@/store/fontAtom'
|
import { fontSelector } from '@/store/fontAtom'
|
||||||
import { QLine } from '@/components/fabric/QLine'
|
import { QLine } from '@/components/fabric/QLine'
|
||||||
import { LINE_TYPE, POLYGON_TYPE } from '@/common/common'
|
import { LINE_TYPE, POLYGON_TYPE } from '@/common/common'
|
||||||
|
import { useLine } from '@/hooks/useLine'
|
||||||
|
|
||||||
export const usePolygon = () => {
|
export const usePolygon = () => {
|
||||||
const canvas = useRecoilValue(canvasState)
|
const canvas = useRecoilValue(canvasState)
|
||||||
@ -24,6 +25,8 @@ export const usePolygon = () => {
|
|||||||
const currentAngleType = useRecoilValue(currentAngleTypeSelector)
|
const currentAngleType = useRecoilValue(currentAngleTypeSelector)
|
||||||
const pitchText = useRecoilValue(pitchTextSelector)
|
const pitchText = useRecoilValue(pitchTextSelector)
|
||||||
|
|
||||||
|
const { getLengthByLine } = useLine()
|
||||||
|
|
||||||
const addPolygon = (points, options, isAddCanvas = true) => {
|
const addPolygon = (points, options, isAddCanvas = true) => {
|
||||||
const polygon = new QPolygon(points, {
|
const polygon = new QPolygon(points, {
|
||||||
...options,
|
...options,
|
||||||
@ -1104,7 +1107,7 @@ export const usePolygon = () => {
|
|||||||
if (!representLine) {
|
if (!representLine) {
|
||||||
representLine = line
|
representLine = line
|
||||||
} else {
|
} else {
|
||||||
if (representLine.length < line.length) {
|
if (getLengthByLine(representLine) < getLengthByLine(line)) {
|
||||||
representLine = line
|
representLine = line
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user