diff --git a/src/components/Main.jsx b/src/components/Main.jsx index a6c00444..cbdea01d 100644 --- a/src/components/Main.jsx +++ b/src/components/Main.jsx @@ -28,11 +28,12 @@ export default function MainPage() { const [searchForm, setSearchForm] = useRecoilState(searchState) - const { qcastState } = useContext(QcastContext) + const { qcastState, setIsGlobalLoading } = useContext(QcastContext) // 엔터 이벤트 const handleByOnKeyUp = (e) => { if (e.key === 'Enter') { + setIsGlobalLoading(true) //물건번호 일떄 if (searchRadioType === 'object') { setStuffSearch({ @@ -55,6 +56,7 @@ export default function MainPage() { // 돋보기 클릭 const handleOnSubmit = () => { + setIsGlobalLoading(true) if (searchRadioType === 'object') { setStuffSearch({ ...stuffSearch, diff --git a/src/components/community/Faq.jsx b/src/components/community/Faq.jsx index 17254f5c..d1304106 100644 --- a/src/components/community/Faq.jsx +++ b/src/components/community/Faq.jsx @@ -7,12 +7,16 @@ import Search from '@/components/community/Search' import Pagination from '@/components/community/Pagination' import Table from '@/components/community/Table' +import { useContext } from 'react' + import { useEffect, useState } from 'react' import { useResetRecoilState, useRecoilValue, useRecoilState } from 'recoil' import { useMessage } from '@/hooks/useMessage' import { searchState } from '@/store/boardAtom' +import { QcastContext } from '@/app/QcastProvider' + export default function Faq() { const { getMessage } = useMessage() const resetSearch = useResetRecoilState(searchState) @@ -21,10 +25,14 @@ export default function Faq() { const search = useRecoilValue(searchState) const [searchForm, setSearchForm] = useRecoilState(searchState) + const { setIsGlobalLoading } = useContext(QcastContext) + useEffect(() => { if (search.mainFlag === 'N') { resetSearch() } else { + //메인에서 FAQ 조회 왔을때 로딩바 해제 + setIsGlobalLoading(false) setSearchForm({ ...searchForm, mainFlag: 'N' }) } setIsInitialized(true) diff --git a/src/components/estimate/Estimate.jsx b/src/components/estimate/Estimate.jsx index 71affac4..44e706ec 100644 --- a/src/components/estimate/Estimate.jsx +++ b/src/components/estimate/Estimate.jsx @@ -294,6 +294,7 @@ export default function Estimate({}) { const originReset = () => { setOriginFiles([]) + estimateContextState.resetFlag = 'N' } // 삭제누른 첨부파일 복원 const returnOriginFile = (no) => { @@ -894,6 +895,7 @@ export default function Estimate({}) { } } }) + // console.log('itemList::', itemList) let pkgAsp = estimateContextState.pkgAsp ? Number(estimateContextState.pkgAsp.replaceAll(',', '')) : 0 totals.pkgTotPrice = pkgAsp * totals.totVolKw * 1000 diff --git a/src/components/estimate/popup/DocDownOptionPop.jsx b/src/components/estimate/popup/DocDownOptionPop.jsx index 6fe73c53..01a979cf 100644 --- a/src/components/estimate/popup/DocDownOptionPop.jsx +++ b/src/components/estimate/popup/DocDownOptionPop.jsx @@ -3,9 +3,9 @@ import { useState } from 'react' import { useMessage } from '@/hooks/useMessage' import { useAxios } from '@/hooks/useAxios' import { useRecoilValue } from 'recoil' -import { floorPlanObjectState } from '@/store/floorPlanObjectAtom' +import { floorPlanObjectState, estimateState } from '@/store/floorPlanObjectAtom' -export default function DocDownOptionPop({ planNo, setEstimatePopupOpen }) { +export default function DocDownOptionPop({ planNo, setEstimatePopupOpen, docDownPopLockFlg }) { const { getMessage } = useMessage() const { promisePost } = useAxios() @@ -22,6 +22,7 @@ export default function DocDownOptionPop({ planNo, setEstimatePopupOpen }) { // recoil 물건번호 const objectRecoil = useRecoilValue(floorPlanObjectState) + const estimateRecoilState = useRecoilValue(estimateState) //문서 다운로드 const handleFileDown = async () => { @@ -82,6 +83,9 @@ export default function DocDownOptionPop({ planNo, setEstimatePopupOpen }) { link.click() link.remove() window.URL.revokeObjectURL(fileUrl) + //문서 다운받으면 lockFlg = 1 잠금상태로! + estimateRecoilState.lockFlg = '1' + docDownPopLockFlg() } }) .catch((error) => { diff --git a/src/components/floor-plan/CanvasMenu.jsx b/src/components/floor-plan/CanvasMenu.jsx index b06f5e6e..8a244650 100644 --- a/src/components/floor-plan/CanvasMenu.jsx +++ b/src/components/floor-plan/CanvasMenu.jsx @@ -85,7 +85,11 @@ export default function CanvasMenu(props) { const selectedRoofMaterial = useRecoilValue(selectedRoofMaterialSelector) //견적서버튼 노출용 - const [buttonStyle, setButtonStyle] = useState('') + const [buttonStyle1, setButtonStyle1] = useState('') //문서 다운로드 버튼 + const [buttonStyle2, setButtonStyle2] = useState('') //저장 버튼 + const [buttonStyle3, setButtonStyle3] = useState('') //초기화 버튼 + const [buttonStyle4, setButtonStyle4] = useState('') //견적서 복사 버튼 + const [buttonStyle5, setButtonStyle5] = useState('') //잠금 버튼 // 발전시뮬레이션 메뉴 이동 const { objectNo, pid } = floorPlanState @@ -256,22 +260,19 @@ export default function CanvasMenu(props) { // 견적서 초기화 버튼 const handleEstimateReset = () => { swalFire({ - //저장된 견적서 정보가 초기화되고, 도면정보가 반영됩니다. 정말로 초기화 하시겠습니까? - //물건정보 text: getMessage('estimate.detail.reset.confirmMsg'), type: 'confirm', confirmFn: async () => { + setIsGlobalLoading(true) const params = { objectNo: objectNo, planNo: pid, userId: sessionState.userId, } - //디테일 호출 try { await promisePost({ url: '/api/estimate/reset-estimate', data: params }).then((res) => { - setIsGlobalLoading(true) if (res.status === 201) { - swalFire({ text: getMessage('estimate.detail.copy.alertMsg'), type: 'alert' }) + swalFire({ text: getMessage('estimate.detail.reset.alertMsg'), type: 'alert' }) fetchSetting(objectNo, pid, 'R') } }) @@ -281,7 +282,7 @@ export default function CanvasMenu(props) { } }, denyFn: () => { - console.log('초기화하지 않음. 변경일시 갱신안함') + setIsGlobalLoading(false) }, }) } @@ -314,12 +315,112 @@ export default function CanvasMenu(props) { if (isObjectNotEmpty(estimateRecoilState)) { if (estimateRecoilState?.createUser === 'T01') { if (sessionState.userId !== 'T01') { - setButtonStyle('none') + setButtonStyle1('none') + setButtonStyle2('none') + setButtonStyle3('none') + setButtonStyle4('none') + setButtonStyle5('none') + } + } else { + if (estimateRecoilState?.tempFlg === '1') { + setButtonStyle1('none') + setButtonStyle2('') + setButtonStyle3('none') + setButtonStyle4('none') + setButtonStyle5('none') + } else { + if (estimateRecoilState?.tempFlg === '0' && estimateRecoilState?.lockFlg === '0') { + setButtonStyle1('') + setButtonStyle2('') + setButtonStyle3('') + setButtonStyle4('') + setButtonStyle5('') + } else { + setButtonStyle1('') + setButtonStyle2('none') + setButtonStyle3('none') + setButtonStyle4('') + setButtonStyle5('') + } } } } }, [estimateRecoilState]) + /** + * 견적서 잠금 / 해제 + * lockFlg : 0 잠금해제상태 / 1 잠금상태 + * --보낼때-- + * 0잠금해제는 1잠금으로 + * 1잠금 문서는 0 잠금해제로 + */ + const handleEstimateLockController = (estimateRecoilState) => { + swalFire({ + text: estimateRecoilState.lockFlg === '0' ? getMessage('estimate.detail.lock.alertMsg') : getMessage('estimate.detail.unlock.alertMsg'), + type: 'confirm', + confirmFn: async () => { + setIsGlobalLoading(true) + const params = { + objectNo: estimateRecoilState.objectNo, + planNo: estimateRecoilState.planNo, + lockFlg: estimateRecoilState.lockFlg === '0' ? '1' : '0', + userId: sessionState.userId, + } + try { + await promisePost({ url: '/api/estimate/save-estimate-lock', data: params }).then((res) => { + if (res.status === 201) { + estimateRecoilState.lockFlg = estimateRecoilState.lockFlg === '0' ? '1' : '0' + if (estimateRecoilState?.createUser === 'T01') { + if (sessionState.userId !== 'T01') { + setButtonStyle1('none') + setButtonStyle2('none') + setButtonStyle3('none') + setButtonStyle4('none') + setButtonStyle5('none') + } + } else { + if (estimateRecoilState?.tempFlg === '1') { + setButtonStyle1('none') + setButtonStyle2('') + setButtonStyle3('none') + setButtonStyle4('none') + setButtonStyle5('none') + } else { + if (estimateRecoilState?.tempFlg === '0' && estimateRecoilState?.lockFlg === '0') { + setButtonStyle1('') + setButtonStyle2('') + setButtonStyle3('') + setButtonStyle4('') + setButtonStyle5('') + } else { + setButtonStyle1('') + setButtonStyle2('none') + setButtonStyle3('none') + setButtonStyle4('') + setButtonStyle5('') + } + } + } + } + setIsGlobalLoading(false) + }) + } catch (error) { + setIsGlobalLoading(false) + console.log('error::::::::::::', e.response.data.message) + } + }, + }) + } + + // 문서다운로드 팝업에서 다운로드 하면 문서 잠금 + const docDownPopLockFlg = () => { + setButtonStyle1('') + setButtonStyle2('none') + setButtonStyle3('none') + setButtonStyle4('') + setButtonStyle5('') + } + return (