물건상세, 견적서 상세 문서다운로드 기능
This commit is contained in:
parent
9752925cd1
commit
160874c6c7
@ -6,9 +6,8 @@ import { useRecoilValue } from 'recoil'
|
||||
import { floorPlanObjectState } from '@/store/floorPlanObjectAtom'
|
||||
|
||||
export default function DocDownOptionPop({ planNo, setEstimatePopupOpen }) {
|
||||
// console.log('플랜번호::::::::::::', planNo)
|
||||
const { getMessage } = useMessage()
|
||||
const { promiseGet } = useAxios()
|
||||
const { promisePost } = useAxios()
|
||||
|
||||
//다운로드 파일 EXCEL
|
||||
const [schUnitPriceFlg, setSchUnitPriceFlg] = useState('0')
|
||||
@ -33,9 +32,40 @@ export default function DocDownOptionPop({ planNo, setEstimatePopupOpen }) {
|
||||
// console.log(schDisplayFlg)
|
||||
// console.log(schWeightFlg)
|
||||
// console.log(schDrawingFlg)
|
||||
//post방식
|
||||
const url = '/api/estimate/excel-download'
|
||||
const params = {}
|
||||
const params = {
|
||||
objectNo: objectRecoil.floorPlanObjectNo,
|
||||
planNo: planNo,
|
||||
schUnitPriceFlg: schUnitPriceFlg,
|
||||
schDisplayFlg: schDisplayFlg,
|
||||
schWeightFlg: schWeightFlg,
|
||||
schDrawingFlg: schDrawingFlg,
|
||||
}
|
||||
const options = { responseType: 'blob' }
|
||||
|
||||
console.log('다운로드 PARAM:::', params)
|
||||
return
|
||||
await promisePost({ url: url, data: params, option: options })
|
||||
.then((resultData) => {
|
||||
console.log('결과::::::', resultData)
|
||||
if (resultData) {
|
||||
const blob = new Blob([resultData.data], { type: resultData.headers['content-type'] || 'application/octet-stream' })
|
||||
const fileUrl = window.URL.createObjectURL(blob)
|
||||
const link = document.createElement('a')
|
||||
|
||||
link.href = fileUrl
|
||||
// link.download = originFile.faileName //resultData에내려주는 파일명으로 변경??
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
link.remove()
|
||||
window.URL.revokeObjectURL(fileUrl)
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log('::FileDownLoad Error::', error)
|
||||
alert('File does not exist.')
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@ -19,10 +19,15 @@ import { useCommonCode } from '@/hooks/common/useCommonCode'
|
||||
import StuffPlanQGrid from './StuffPlanQGrid'
|
||||
import { floorPlanObjectState } from '@/store/floorPlanObjectAtom'
|
||||
import { ManagementContext } from '@/app/management/ManagementProvider'
|
||||
import DocDownOptionPop from '../estimate/popup/DocDownOptionPop'
|
||||
|
||||
export default function StuffDetail() {
|
||||
const setFloorPlanObjectNo = useSetRecoilState(floorPlanObjectState) //견적서 화면용 물건번호리코일
|
||||
|
||||
const [estimatePopupOpen, setEstimatePopupOpen] = useState(false)
|
||||
|
||||
const [popPlanNo, setPopPlanNo] = useState('1') //default 1
|
||||
|
||||
//공통코드
|
||||
const { commonCode, findCommonCode } = useCommonCode()
|
||||
const [selOptions, setSelOptions] = useState('') //선택한 1차점
|
||||
@ -266,11 +271,12 @@ export default function StuffDetail() {
|
||||
type="button"
|
||||
className="grid-btn"
|
||||
onClick={() => {
|
||||
console.log('엑셀버튼클릭')
|
||||
setFloorPlanObjectNo({ floorPlanObjectNo: params.data.objectNo })
|
||||
handleEstimatePopup(params.data.planNo)
|
||||
}}
|
||||
>
|
||||
<span className="excel"></span>
|
||||
{getMessage('stuff.detail.planGrid.btn2')}
|
||||
{getMessage('stuff.detail.planGrid.docDownload')}
|
||||
</button>
|
||||
</div>
|
||||
</>
|
||||
@ -280,6 +286,12 @@ export default function StuffDetail() {
|
||||
],
|
||||
})
|
||||
|
||||
// 문서다운로드 팝업 오픈 셋팅
|
||||
const handleEstimatePopup = (planNo) => {
|
||||
setPopPlanNo(planNo)
|
||||
setEstimatePopupOpen(true)
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (objectNo) {
|
||||
setEditMode('EDIT')
|
||||
@ -2433,6 +2445,8 @@ export default function StuffDetail() {
|
||||
{showWindSpeedButtonValid && (
|
||||
<WindSelectPop setShowWindSpeedButtonValid={setShowWindSpeedButtonValid} prefName={form.watch('prefName')} windSpeedInfo={setWindSppedInfo} />
|
||||
)}
|
||||
|
||||
{estimatePopupOpen && <DocDownOptionPop planNo={popPlanNo} setEstimatePopupOpen={setEstimatePopupOpen} />}
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
@ -733,7 +733,7 @@
|
||||
"stuff.detail.planGridHeader.pcTypeNo": "パワーコンディショナー",
|
||||
"stuff.detail.planGridHeader.management": "管理",
|
||||
"stuff.detail.planGrid.btn1": "見積書の照会",
|
||||
"stuff.detail.planGrid.btn2": "Excel",
|
||||
"stuff.detail.planGrid.docDownload": "文書のダウンロード",
|
||||
"stuff.grid.noData": "照会されたデータがありません",
|
||||
"length": "長さ",
|
||||
"height": "高さ",
|
||||
|
||||
@ -743,7 +743,7 @@
|
||||
"stuff.detail.planGridHeader.pcTypeNo": "파워컨디셔너",
|
||||
"stuff.detail.planGridHeader.management": "관리",
|
||||
"stuff.detail.planGrid.btn1": "견적서 조회",
|
||||
"stuff.detail.planGrid.btn2": "Excel",
|
||||
"stuff.detail.planGrid.docDownload": "문서 다운로드",
|
||||
"stuff.grid.noData": "조회된 데이터가 없습니다",
|
||||
"length": "길이",
|
||||
"height": "높이",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user