Merge pull request 'dev' (#88) from dev into dev-deploy
Reviewed-on: #88
This commit is contained in:
commit
bc607d4828
@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
@ -159,5 +159,6 @@ export const useLine = () => {
|
||||
addPitchText,
|
||||
removePitchText,
|
||||
addPitchTextsByOuterLines,
|
||||
getLengthByLine,
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user