[1068] : [견적서 생성된 플랜복사 --> 복사된 플랜에서 모듈삭제 --> 견적서 진입이 됨.. ]
[작업내용] : 가대까지 완성 -> 삭제 안함, 그 전상태면 무조건 삭제 로직으로 구현
This commit is contained in:
parent
48dc3d6328
commit
8b81998f8c
@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user