메뉴 이동 관련 ...

This commit is contained in:
basssy 2025-01-15 16:25:48 +09:00
parent 65620a28fa
commit 4618b7a4fa
4 changed files with 57 additions and 18 deletions

View File

@ -74,7 +74,6 @@ export default function Estimate({}) {
const { estimateContextState, setEstimateContextState, addItem, handleEstimateFileDownload } = useEstimateController(currentPid) const { estimateContextState, setEstimateContextState, addItem, handleEstimateFileDownload } = useEstimateController(currentPid)
const { selectedPlan } = usePlan() const { selectedPlan } = usePlan()
const router = useRouter()
// List // List
const [specialNoteList, setSpecialNoteList] = useState([]) const [specialNoteList, setSpecialNoteList] = useState([])
@ -299,6 +298,9 @@ export default function Estimate({}) {
} else { } else {
if (originFiles.length > 0) { if (originFiles.length > 0) {
if (isEmptyArray(files)) { if (isEmptyArray(files)) {
if (originFiles[0].planNo !== estimateContextState.planNo) {
setOriginFiles([])
} else {
let file let file
file = originFiles.filter((item) => item.delFlg === '0') file = originFiles.filter((item) => item.delFlg === '0')
setEstimateContextState({ setEstimateContextState({
@ -309,6 +311,7 @@ export default function Estimate({}) {
} }
} }
} }
}
}, [estimateContextState?.fileList]) }, [estimateContextState?.fileList])
const originReset = () => { const originReset = () => {
@ -1002,6 +1005,7 @@ export default function Estimate({}) {
<div className="estimate-box"> <div className="estimate-box">
<div className="estimate-tit">{getMessage('estimate.detail.objectNo')}</div> <div className="estimate-tit">{getMessage('estimate.detail.objectNo')}</div>
<div className="estimate-name"> <div className="estimate-name">
{/* {objectNo} (Plan No: {estimateContextState.planNo}) */}
{objectNo} (Plan No: {planNo}) {objectNo} (Plan No: {planNo})
</div> </div>
</div> </div>

View File

@ -2,7 +2,7 @@
import { useContext, useEffect, useState } from 'react' import { useContext, useEffect, useState } from 'react'
import { usePathname, useRouter } from 'next/navigation' import { usePathname, useRouter, useSearchParams } from 'next/navigation'
import { useRecoilState, useRecoilValue, useSetRecoilState } from 'recoil' import { useRecoilState, useRecoilValue, useSetRecoilState } from 'recoil'
@ -63,7 +63,7 @@ export default function CanvasMenu(props) {
const canvas = useRecoilValue(canvasState) const canvas = useRecoilValue(canvasState)
const { handleZoomClear, handleZoom } = useCanvasEvent() const { handleZoomClear, handleZoom } = useCanvasEvent()
const { handleMenu } = useMenu() const { handleMenu } = useMenu()
// const urlParams = useSearchParams()
const { handleEstimateSubmit, fetchSetting } = useEstimateController() const { handleEstimateSubmit, fetchSetting } = useEstimateController()
const estimateRecoilState = useRecoilValue(estimateState) const estimateRecoilState = useRecoilValue(estimateState)
const [estimatePopupOpen, setEstimatePopupOpen] = useState(false) const [estimatePopupOpen, setEstimatePopupOpen] = useState(false)
@ -85,7 +85,6 @@ export default function CanvasMenu(props) {
const selectedRoofMaterial = useRecoilValue(selectedRoofMaterialSelector) const selectedRoofMaterial = useRecoilValue(selectedRoofMaterialSelector)
// //
const [buttonStyle, setButtonStyle] = useState('') //
const [buttonStyle1, setButtonStyle1] = useState('') // const [buttonStyle1, setButtonStyle1] = useState('') //
const [buttonStyle2, setButtonStyle2] = useState('') // const [buttonStyle2, setButtonStyle2] = useState('') //
const [buttonStyle3, setButtonStyle3] = useState('') // const [buttonStyle3, setButtonStyle3] = useState('') //
@ -173,6 +172,7 @@ export default function CanvasMenu(props) {
setType('module') setType('module')
break break
case 5: case 5:
// let pid = urlParams.get('pid')
promiseGet({ url: `/api/estimate/${objectNo}/${pid}/detail` }).then((res) => { promiseGet({ url: `/api/estimate/${objectNo}/${pid}/detail` }).then((res) => {
if (res.status === 200) { if (res.status === 200) {
const estimateDetail = res.data const estimateDetail = res.data

View File

@ -88,6 +88,8 @@ export const useEstimateController = (planNo) => {
setIsGlobalLoading(false) setIsGlobalLoading(false)
} catch (error) { } catch (error) {
console.error('견적서 상세조회 Error: ', error) console.error('견적서 상세조회 Error: ', error)
swalFire({ text: getMessage('estimate.menu.move.valid1') })
setIsLoading(true) setIsLoading(true)
setIsGlobalLoading(false) setIsGlobalLoading(false)
} }

View File

@ -14,7 +14,7 @@ import { useCanvas } from '@/hooks/useCanvas'
import { SAVE_KEY } from '@/common/common' import { SAVE_KEY } from '@/common/common'
import { readImage, removeImage } from '@/lib/fileAction' import { readImage, removeImage } from '@/lib/fileAction'
import { FloorPlanContext } from '@/app/floor-plan/FloorPlanProvider' import { FloorPlanContext } from '@/app/floor-plan/FloorPlanProvider'
import { useEstimateController } from '@/hooks/floorPlan/estimate/useEstimateController'
export function usePlan(params = {}) { export function usePlan(params = {}) {
const { floorPlanState } = useContext(FloorPlanContext) const { floorPlanState } = useContext(FloorPlanContext)
@ -31,8 +31,9 @@ export function usePlan(params = {}) {
const { swalFire } = useSwal() const { swalFire } = useSwal()
const { getMessage } = useMessage() const { getMessage } = useMessage()
const { get, promisePost, promisePut, promiseDel } = useAxios() const { get, promisePost, promisePut, promiseDel, promiseGet } = useAxios()
const { setEstimateContextState } = useEstimateController()
/** /**
* 마우스 포인터의 가이드라인을 제거합니다. * 마우스 포인터의 가이드라인을 제거합니다.
*/ */
@ -203,12 +204,44 @@ export function usePlan(params = {}) {
* 현재 plan의 작업상태를 저장 이동 * 현재 plan의 작업상태를 저장 이동
*/ */
const handleCurrentPlan = async (newCurrentId) => { 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'
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 (pathname === '/floor-plan') {
if (!currentCanvasPlan || currentCanvasPlan.id !== newCurrentId) { if (!currentCanvasPlan || currentCanvasPlan.id !== newCurrentId) {
await saveCanvas() saveCanvas()
} }
} }
updateCurrentPlan(newCurrentId) updateCurrentPlan(newCurrentId)
} else {
swalFire({ text: getMessage('estimate.menu.move.valid1') })
}
}
})
.catch((error) => {
swalFire({ text: getMessage('estimate.menu.move.valid1') })
})
} }
const updateCurrentPlan = (newCurrentId) => { const updateCurrentPlan = (newCurrentId) => {