물건상세, 견적서 상세 문서다운로드 기능

This commit is contained in:
basssy 2024-11-14 18:03:04 +09:00
parent 9752925cd1
commit 160874c6c7
4 changed files with 51 additions and 7 deletions

View File

@ -6,9 +6,8 @@ import { useRecoilValue } from 'recoil'
import { floorPlanObjectState } from '@/store/floorPlanObjectAtom' import { floorPlanObjectState } from '@/store/floorPlanObjectAtom'
export default function DocDownOptionPop({ planNo, setEstimatePopupOpen }) { export default function DocDownOptionPop({ planNo, setEstimatePopupOpen }) {
// console.log('::::::::::::', planNo)
const { getMessage } = useMessage() const { getMessage } = useMessage()
const { promiseGet } = useAxios() const { promisePost } = useAxios()
// EXCEL // EXCEL
const [schUnitPriceFlg, setSchUnitPriceFlg] = useState('0') const [schUnitPriceFlg, setSchUnitPriceFlg] = useState('0')
@ -33,9 +32,40 @@ export default function DocDownOptionPop({ planNo, setEstimatePopupOpen }) {
// console.log(schDisplayFlg) // console.log(schDisplayFlg)
// console.log(schWeightFlg) // console.log(schWeightFlg)
// console.log(schDrawingFlg) // console.log(schDrawingFlg)
//post
const url = '/api/estimate/excel-download' 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' } 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 ( return (

View File

@ -19,10 +19,15 @@ import { useCommonCode } from '@/hooks/common/useCommonCode'
import StuffPlanQGrid from './StuffPlanQGrid' import StuffPlanQGrid from './StuffPlanQGrid'
import { floorPlanObjectState } from '@/store/floorPlanObjectAtom' import { floorPlanObjectState } from '@/store/floorPlanObjectAtom'
import { ManagementContext } from '@/app/management/ManagementProvider' import { ManagementContext } from '@/app/management/ManagementProvider'
import DocDownOptionPop from '../estimate/popup/DocDownOptionPop'
export default function StuffDetail() { export default function StuffDetail() {
const setFloorPlanObjectNo = useSetRecoilState(floorPlanObjectState) // const setFloorPlanObjectNo = useSetRecoilState(floorPlanObjectState) //
const [estimatePopupOpen, setEstimatePopupOpen] = useState(false)
const [popPlanNo, setPopPlanNo] = useState('1') //default 1
// //
const { commonCode, findCommonCode } = useCommonCode() const { commonCode, findCommonCode } = useCommonCode()
const [selOptions, setSelOptions] = useState('') // 1 const [selOptions, setSelOptions] = useState('') // 1
@ -266,11 +271,12 @@ export default function StuffDetail() {
type="button" type="button"
className="grid-btn" className="grid-btn"
onClick={() => { onClick={() => {
console.log('엑셀버튼클릭') setFloorPlanObjectNo({ floorPlanObjectNo: params.data.objectNo })
handleEstimatePopup(params.data.planNo)
}} }}
> >
<span className="excel"></span> <span className="excel"></span>
{getMessage('stuff.detail.planGrid.btn2')} {getMessage('stuff.detail.planGrid.docDownload')}
</button> </button>
</div> </div>
</> </>
@ -280,6 +286,12 @@ export default function StuffDetail() {
], ],
}) })
//
const handleEstimatePopup = (planNo) => {
setPopPlanNo(planNo)
setEstimatePopupOpen(true)
}
useEffect(() => { useEffect(() => {
if (objectNo) { if (objectNo) {
setEditMode('EDIT') setEditMode('EDIT')
@ -2433,6 +2445,8 @@ export default function StuffDetail() {
{showWindSpeedButtonValid && ( {showWindSpeedButtonValid && (
<WindSelectPop setShowWindSpeedButtonValid={setShowWindSpeedButtonValid} prefName={form.watch('prefName')} windSpeedInfo={setWindSppedInfo} /> <WindSelectPop setShowWindSpeedButtonValid={setShowWindSpeedButtonValid} prefName={form.watch('prefName')} windSpeedInfo={setWindSppedInfo} />
)} )}
{estimatePopupOpen && <DocDownOptionPop planNo={popPlanNo} setEstimatePopupOpen={setEstimatePopupOpen} />}
</> </>
) )
} }

View File

@ -733,7 +733,7 @@
"stuff.detail.planGridHeader.pcTypeNo": "パワーコンディショナー", "stuff.detail.planGridHeader.pcTypeNo": "パワーコンディショナー",
"stuff.detail.planGridHeader.management": "管理", "stuff.detail.planGridHeader.management": "管理",
"stuff.detail.planGrid.btn1": "見積書の照会", "stuff.detail.planGrid.btn1": "見積書の照会",
"stuff.detail.planGrid.btn2": "Excel", "stuff.detail.planGrid.docDownload": "文書のダウンロード",
"stuff.grid.noData": "照会されたデータがありません", "stuff.grid.noData": "照会されたデータがありません",
"length": "長さ", "length": "長さ",
"height": "高さ", "height": "高さ",

View File

@ -743,7 +743,7 @@
"stuff.detail.planGridHeader.pcTypeNo": "파워컨디셔너", "stuff.detail.planGridHeader.pcTypeNo": "파워컨디셔너",
"stuff.detail.planGridHeader.management": "관리", "stuff.detail.planGridHeader.management": "관리",
"stuff.detail.planGrid.btn1": "견적서 조회", "stuff.detail.planGrid.btn1": "견적서 조회",
"stuff.detail.planGrid.btn2": "Excel", "stuff.detail.planGrid.docDownload": "문서 다운로드",
"stuff.grid.noData": "조회된 데이터가 없습니다", "stuff.grid.noData": "조회된 데이터가 없습니다",
"length": "길이", "length": "길이",
"height": "높이", "height": "높이",