견적서 문서다운로드

This commit is contained in:
basssy 2024-11-15 08:58:51 +09:00
parent 160874c6c7
commit eb5bb77f1f
3 changed files with 42 additions and 29 deletions

View File

@ -9,6 +9,8 @@ export default function DocDownOptionPop({ planNo, setEstimatePopupOpen }) {
const { getMessage } = useMessage() const { getMessage } = useMessage()
const { promisePost } = useAxios() const { promisePost } = useAxios()
//EXCEL, PDF
const [schDownload, setSchDownload] = useState('EXCEL')
// EXCEL // EXCEL
const [schUnitPriceFlg, setSchUnitPriceFlg] = useState('0') const [schUnitPriceFlg, setSchUnitPriceFlg] = useState('0')
@ -24,38 +26,45 @@ export default function DocDownOptionPop({ planNo, setEstimatePopupOpen }) {
// //
const handleFileDown = async () => { const handleFileDown = async () => {
// console.log(':::', objectRecoil.floorPlanObjectNo)
// console.log('planNo::', planNo)
//
//0 : Excel 1 : Excel 2: PDF 3 :PDF
// console.log(schUnitPriceFlg)
// console.log(schDisplayFlg)
// console.log(schWeightFlg)
// console.log(schDrawingFlg)
//post
const url = '/api/estimate/excel-download' const url = '/api/estimate/excel-download'
let sendUnitPriceFlg
if (schUnitPriceFlg === '0') {
sendUnitPriceFlg = '0'
} else if (schUnitPriceFlg === '1') {
sendUnitPriceFlg = '1'
} else if (schUnitPriceFlg === '2') {
sendUnitPriceFlg = '0'
} else {
sendUnitPriceFlg = '1'
}
const params = { const params = {
objectNo: objectRecoil.floorPlanObjectNo, objectNo: objectRecoil.floorPlanObjectNo,
planNo: planNo, planNo: planNo,
schUnitPriceFlg: schUnitPriceFlg, schDownload: schDownload,
schUnitPriceFlg: sendUnitPriceFlg,
schDisplayFlg: schDisplayFlg, schDisplayFlg: schDisplayFlg,
schWeightFlg: schWeightFlg, schWeightFlg: schWeightFlg,
schDrawingFlg: schDrawingFlg, schDrawingFlg: schDrawingFlg,
} }
const options = { responseType: 'blob' } const options = { responseType: 'blob' }
let fileName
console.log('다운로드 PARAM:::', params) console.log('다운로드 PARAM:::', params)
return
await promisePost({ url: url, data: params, option: options }) await promisePost({ url: url, data: params, option: options })
.then((resultData) => { .then((resultData) => {
console.log('결과::::::', resultData)
if (resultData) { if (resultData) {
console.log('결과::::::', resultData)
const blob = new Blob([resultData.data], { type: resultData.headers['content-type'] || 'application/octet-stream' }) const blob = new Blob([resultData.data], { type: resultData.headers['content-type'] || 'application/octet-stream' })
const fileUrl = window.URL.createObjectURL(blob) const fileUrl = window.URL.createObjectURL(blob)
const link = document.createElement('a') const link = document.createElement('a')
link.href = fileUrl link.href = fileUrl
// link.download = originFile.faileName //resultData ??
if (schDownload === 'EXCEL') {
fileName = 'EXCEL_DOWN.xlsx'
} else {
fileName = 'PDF_DOWN.pdf'
}
link.download = fileName
document.body.appendChild(link) document.body.appendChild(link)
link.click() link.click()
link.remove() link.remove()
@ -104,28 +113,30 @@ export default function DocDownOptionPop({ planNo, setEstimatePopupOpen }) {
<div className="d-check-radio light mr10"> <div className="d-check-radio light mr10">
<input <input
type="radio" type="radio"
id="schUnitPriceFlg0" id="schUnitPriceExcelFlg0"
name="schUnitPriceFlg" name="schUnitPriceFlg"
value={'0'} value={'0'}
checked={schUnitPriceFlg === '0'} checked={schUnitPriceFlg === '0'}
onChange={(e) => { onChange={(e) => {
setSchDownload('EXCEL')
setSchUnitPriceFlg(e.target.value) setSchUnitPriceFlg(e.target.value)
}} }}
/> />
<label htmlFor="schUnitPriceFlg0">{getMessage('estimate.detail.docPopup.schUnitPriceFlg.schUnitPriceFlg0')}</label> <label htmlFor="schUnitPriceExcelFlg0">{getMessage('estimate.detail.docPopup.schUnitPriceFlg.excelFlg0')}</label>
</div> </div>
<div className="d-check-radio light mr10"> <div className="d-check-radio light mr10">
<input <input
type="radio" type="radio"
id="schUnitPriceFlg1" id="schUnitPriceExcelFlg1"
name="schUnitPriceFlg" name="schUnitPriceFlg"
value={'1'} value={'1'}
checked={schUnitPriceFlg === '1'} checked={schUnitPriceFlg === '1'}
onChange={(e) => { onChange={(e) => {
setSchDownload('EXCEL')
setSchUnitPriceFlg(e.target.value) setSchUnitPriceFlg(e.target.value)
}} }}
/> />
<label htmlFor="schUnitPriceFlg1">{getMessage('estimate.detail.docPopup.schUnitPriceFlg.schUnitPriceFlg1')}</label> <label htmlFor="schUnitPriceExcelFlg1">{getMessage('estimate.detail.docPopup.schUnitPriceFlg.excelFlg1')}</label>
</div> </div>
<div className="d-check-radio light mr10"> <div className="d-check-radio light mr10">
<input <input
@ -135,10 +146,11 @@ export default function DocDownOptionPop({ planNo, setEstimatePopupOpen }) {
value={'2'} value={'2'}
checked={schUnitPriceFlg === '2'} checked={schUnitPriceFlg === '2'}
onChange={(e) => { onChange={(e) => {
setSchDownload('PDF')
setSchUnitPriceFlg(e.target.value) setSchUnitPriceFlg(e.target.value)
}} }}
/> />
<label htmlFor="schUnitPricePdfFlg0">{getMessage('estimate.detail.docPopup.schUnitPriceFlg.schUnitPriceFlg2')}</label> <label htmlFor="schUnitPricePdfFlg0">{getMessage('estimate.detail.docPopup.schUnitPriceFlg.pdfFlg0')}</label>
</div> </div>
<div className="d-check-radio light "> <div className="d-check-radio light ">
<input <input
@ -148,10 +160,11 @@ export default function DocDownOptionPop({ planNo, setEstimatePopupOpen }) {
value={'3'} value={'3'}
checked={schUnitPriceFlg === '3'} checked={schUnitPriceFlg === '3'}
onChange={(e) => { onChange={(e) => {
setSchDownload('PDF')
setSchUnitPriceFlg(e.target.value) setSchUnitPriceFlg(e.target.value)
}} }}
/> />
<label htmlFor="schUnitPricePdfFlg1">{getMessage('estimate.detail.docPopup.schUnitPriceFlg.schUnitPriceFlg3')}</label> <label htmlFor="schUnitPricePdfFlg1">{getMessage('estimate.detail.docPopup.schUnitPriceFlg.pdfFlg1')}</label>
</div> </div>
</div> </div>
</td> </td>

View File

@ -860,10 +860,10 @@
"estimate.detail.docPopup.title": "ドキュメントダウンロードオプションの設定", "estimate.detail.docPopup.title": "ドキュメントダウンロードオプションの設定",
"estimate.detail.docPopup.explane": "ダウンロードする文書のオプションを選択したら、 [文書のダウンロード]ボタンをクリックします.", "estimate.detail.docPopup.explane": "ダウンロードする文書のオプションを選択したら、 [文書のダウンロード]ボタンをクリックします.",
"estimate.detail.docPopup.schUnitPriceFlg": "ダウンロードファイル", "estimate.detail.docPopup.schUnitPriceFlg": "ダウンロードファイル",
"estimate.detail.docPopup.schUnitPriceFlg.schUnitPriceFlg0": "見積もり Excel", "estimate.detail.docPopup.schUnitPriceFlg.excelFlg0": "見積もり Excel",
"estimate.detail.docPopup.schUnitPriceFlg.schUnitPriceFlg1": "定価用 Excel", "estimate.detail.docPopup.schUnitPriceFlg.excelFlg1": "定価用 Excel",
"estimate.detail.docPopup.schUnitPriceFlg.schUnitPriceFlg2": "見積もり PDF", "estimate.detail.docPopup.schUnitPriceFlg.pdfFlg0": "見積もり PDF",
"estimate.detail.docPopup.schUnitPriceFlg.schUnitPriceFlg3": "定価用 PDF", "estimate.detail.docPopup.schUnitPriceFlg.pdfFlg1": "定価用 PDF",
"estimate.detail.docPopup.schDisplayFlg": "見積提出先表示名", "estimate.detail.docPopup.schDisplayFlg": "見積提出先表示名",
"estimate.detail.docPopup.schDisplayFlg.schDisplayFlg0": "販売店名", "estimate.detail.docPopup.schDisplayFlg.schDisplayFlg0": "販売店名",
"estimate.detail.docPopup.schDisplayFlg.schDisplayFlg1": "案件名", "estimate.detail.docPopup.schDisplayFlg.schDisplayFlg1": "案件名",

View File

@ -870,10 +870,10 @@
"estimate.detail.docPopup.title": "문서다운로드 옵션설정", "estimate.detail.docPopup.title": "문서다운로드 옵션설정",
"estimate.detail.docPopup.explane": "다운로드할 문서 옵션을 선택한 후 문서 다운로드 버튼을 클릭합니다.", "estimate.detail.docPopup.explane": "다운로드할 문서 옵션을 선택한 후 문서 다운로드 버튼을 클릭합니다.",
"estimate.detail.docPopup.schUnitPriceFlg": "다운로드 파일", "estimate.detail.docPopup.schUnitPriceFlg": "다운로드 파일",
"estimate.detail.docPopup.schUnitPriceFlg.schUnitPriceFlg0": "견적가 Excel", "estimate.detail.docPopup.schUnitPriceFlg.excelFlg0": "견적가 Excel",
"estimate.detail.docPopup.schUnitPriceFlg.schUnitPriceFlg1": "정가용 Excel", "estimate.detail.docPopup.schUnitPriceFlg.excelFlg1": "정가용 Excel",
"estimate.detail.docPopup.schUnitPriceFlg.schUnitPriceFlg2": "견적가 PDF", "estimate.detail.docPopup.schUnitPriceFlg.pdfFlg0": "견적가 PDF",
"estimate.detail.docPopup.schUnitPriceFlg.schUnitPriceFlg3": "정가용 PDF", "estimate.detail.docPopup.schUnitPriceFlg.pdfFlg1": "정가용 PDF",
"estimate.detail.docPopup.schDisplayFlg": "견적제출서 표시명", "estimate.detail.docPopup.schDisplayFlg": "견적제출서 표시명",
"estimate.detail.docPopup.schDisplayFlg.schDisplayFlg0": "판매점명", "estimate.detail.docPopup.schDisplayFlg.schDisplayFlg0": "판매점명",
"estimate.detail.docPopup.schDisplayFlg.schDisplayFlg1": "안건명", "estimate.detail.docPopup.schDisplayFlg.schDisplayFlg1": "안건명",