diff --git a/src/components/floor-plan/CanvasMenu.jsx b/src/components/floor-plan/CanvasMenu.jsx index 3b3e0003..6d33d474 100644 --- a/src/components/floor-plan/CanvasMenu.jsx +++ b/src/components/floor-plan/CanvasMenu.jsx @@ -203,9 +203,7 @@ export default function CanvasMenu(props) { setCurrentMenu(menu.title) } - if (pathname !== '/floor-plan' && pathname !== '/floor-plan/estimate/5' && pathname !== '/floor-plan/simulator/6') { - router.push(`/floor-plan?pid=${pid}&objectNo=${objectNo}`) - } + if (pathname !== '/floor-plan') router.push(`/floor-plan?pid=${pid}&objectNo=${objectNo}`) } const changeSelectedRoofMaterial = (e) => { @@ -368,7 +366,9 @@ export default function CanvasMenu(props) { */ const handleEstimateLockController = (estimateRecoilState) => { swalFire({ - text: estimateRecoilState.lockFlg === '0' ? getMessage('estimate.detail.lock.alertMsg') : getMessage('estimate.detail.unlock.alertMsg'), + // text: estimateRecoilState.lockFlg === '0' ? getMessage('estimate.detail.lock.alertMsg') : getMessage('estimate.detail.unlock.alertMsg'), + html: estimateRecoilState.lockFlg === '0' ? getMessage('estimate.detail.lock.alertMsg') : getMessage('estimate.detail.unlock.alertMsg'), + confirmButtonText: estimateRecoilState.lockFlg === '1' ? getMessage('estimate.detail.unlock.confirmBtnName') : '', type: 'confirm', confirmFn: async () => { setIsGlobalLoading(true) diff --git a/src/hooks/usePlan.js b/src/hooks/usePlan.js index db170dc7..86b6aee3 100644 --- a/src/hooks/usePlan.js +++ b/src/hooks/usePlan.js @@ -206,42 +206,52 @@ export function usePlan(params = {}) { const handleCurrentPlan = async (newCurrentId) => { const orderingNo = plans?.find((obj) => obj.id === newCurrentId).ordering const objectNo = floorPlanState.objectNo - await promiseGet({ url: `/api/estimate/${objectNo}/${orderingNo}/detail` }) - .then((res) => { - if (res.status === 200) { - const estimateDetail = res.data - if (estimateDetail.docNo) { - res.data.resetFlag = 'N' + //견적서 or 발전시뮬 + if (pathname !== '/floor-plan') { + await promiseGet({ url: `/api/estimate/${objectNo}/${orderingNo}/detail` }) + .then((res) => { + if (res.status === 200) { + const estimateDetail = res.data + if (estimateDetail.docNo) { + res.data.resetFlag = 'N' - if (res.data.itemList.length > 0) { - res.data.itemList.map((item) => { - item.delFlg = '0' - }) - } - if (res.data.pkgAsp === null || res.data.pkgAsp == undefined) { - res.data.pkgAsp = '0.00' - } else { - const number = parseFloat(res.data.pkgAsp) - const roundedNumber = isNaN(number) ? '0.00' : number.toFixed(2) - - res.data.pkgAsp = roundedNumber.toString() - } - setEstimateContextState(res.data) - - if (pathname === '/floor-plan') { - if (!currentCanvasPlan || currentCanvasPlan.id !== newCurrentId) { - saveCanvas() + if (res.data.itemList.length > 0) { + res.data.itemList.map((item) => { + item.delFlg = '0' + }) } + if (res.data.pkgAsp === null || res.data.pkgAsp == undefined) { + res.data.pkgAsp = '0.00' + } else { + const number = parseFloat(res.data.pkgAsp) + const roundedNumber = isNaN(number) ? '0.00' : number.toFixed(2) + + res.data.pkgAsp = roundedNumber.toString() + } + setEstimateContextState(res.data) + + if (pathname === '/floor-plan') { + if (!currentCanvasPlan || currentCanvasPlan.id !== newCurrentId) { + saveCanvas() + } + } + updateCurrentPlan(newCurrentId) + } else { + swalFire({ text: getMessage('estimate.menu.move.valid1') }) } - updateCurrentPlan(newCurrentId) - } else { - swalFire({ text: getMessage('estimate.menu.move.valid1') }) } - } - }) - .catch((error) => { - swalFire({ text: getMessage('estimate.menu.move.valid1') }) - }) + }) + .catch((error) => { + swalFire({ text: getMessage('estimate.menu.move.valid1') }) + }) + } else { + // if (pathname === '/floor-plan') { + if (!currentCanvasPlan || currentCanvasPlan.id !== newCurrentId) { + saveCanvas() + } + // } + updateCurrentPlan(newCurrentId) + } } const updateCurrentPlan = (newCurrentId) => { diff --git a/src/hooks/useSwal.js b/src/hooks/useSwal.js index 018d8f32..f904091d 100644 --- a/src/hooks/useSwal.js +++ b/src/hooks/useSwal.js @@ -1,5 +1,6 @@ import Swal from 'sweetalert2' import withReactContent from 'sweetalert2-react-content' +import { useMessage } from '@/hooks/useMessage' /** * title: 제목 @@ -13,14 +14,25 @@ import withReactContent from 'sweetalert2-react-content' */ export const useSwal = () => { const MySwal = withReactContent(Swal) + const { getMessage } = useMessage() - const swalFire = ({ title = '', text = '', html = '', type = 'alert', icon = '', confirmFn = () => {}, denyFn = () => {} }) => { + const swalFire = ({ + title = '', + text = '', + html = '', + type = 'alert', + icon = '', + confirmButtonText = '', + cancelButtonText = '', + confirmFn = () => {}, + denyFn = () => {}, + }) => { if (type === 'alert') { MySwal.fire({ title, text, icon: icon === '' ? 'success' : icon, - confirmButtonText: '확인', + confirmButtonText: getMessage('common.ok'), }).then(() => { confirmFn() }) @@ -32,8 +44,8 @@ export const useSwal = () => { icon: icon === '' ? 'question' : icon, showCloseButton: true, showCancelButton: true, - confirmButtonText: '확인', - cancelButtonText: '취소', + confirmButtonText: confirmButtonText === '' ? getMessage('common.ok') : confirmButtonText, + cancelButtonText: cancelButtonText === '' ? getMessage('common.cancel') : cancelButtonText, }).then((result) => { if (result.isConfirmed) { confirmFn() diff --git a/src/locales/ja.json b/src/locales/ja.json index a96ff061..900165c5 100644 --- a/src/locales/ja.json +++ b/src/locales/ja.json @@ -498,6 +498,7 @@ "common.require": "必須", "common.finish": "完了", "common.ok": "確認", + "common.cancel": "キャンセル", "commons.west": "立つ", "commons.east": "ドン", "commons.south": "南", @@ -935,7 +936,8 @@ "estimate.detail.reset.alertMsg": "初期化されました.", "estimate.detail.reset.confirmMsg": "保存した見積書情報が初期化され、図面情報が反映されます。本当に初期化しますか?", "estimate.detail.lock.alertMsg": "見積書を[ロック]すると、変更できません。見積もりを編集するには、ロックを解除してください.", - "estimate.detail.unlock.alertMsg": "見積書を修正して保存", + "estimate.detail.unlock.alertMsg": "[ロック解除]すると、見積書を編集できます.\n 解除しますか?", + "estimate.detail.unlock.confirmBtnName": "解放", "estimate.detail.alert.delFile": "添付ファイルを完全に削除するには[保存]ボタンをクリックしてください", "estimate.detail.alert.selectDelItem": "削除する商品を選択してください.", "estimate.menu.move.valid1": "回路を分割していないため、見積もりを呼び出すことはできません.", diff --git a/src/locales/ko.json b/src/locales/ko.json index 2d049d61..c5ba4658 100644 --- a/src/locales/ko.json +++ b/src/locales/ko.json @@ -507,6 +507,7 @@ "common.require": "필수", "common.finish": "완료", "common.ok": "확인", + "common.cancel": "취소", "commons.west": "서", "commons.east": "동", "commons.south": "남", @@ -943,8 +944,9 @@ "estimate.detail.save.requiredSalePrice": "단가는 0보다 큰값을 입력해주세요.", "estimate.detail.reset.alertMsg": "초기화 되었습니다.", "estimate.detail.reset.confirmMsg": "수기 변경(저장)한 견적 정보가 초기화되고, 최근 저장된 도면정보가 반영됩니다. 정말로 초기화하시겠습니까?", - "estimate.detail.lock.alertMsg": "견적서를 [잠금]하면, 수정할 수 없습니다. 견적서를 수정하려면 잠금해제를 하십시오", - "estimate.detail.unlock.alertMsg": "견적서를 수정하고, 저장하십시오", + "estimate.detail.lock.alertMsg": "견적서를 [잠금]하면, 수정할 수 없습니다.
견적서를 수정하려면 잠금해제를 하십시오.", + "estimate.detail.unlock.alertMsg": "[잠금해제]하면 견적서를 수정할 수 있습니다.
해제하시겠습니까?", + "estimate.detail.unlock.confirmBtnName": "해제", "estimate.detail.alert.delFile": "첨부파일을 완전히 삭제하려면 [저장]버튼을 클릭하십시오.", "estimate.detail.alert.selectDelItem": "삭제할 제품을 선택하세요.", "estimate.menu.move.valid1": "회로를 나누지 않았기 때문에 견적서를 호출할 수 없습니다.",