update for downloaded file
This commit is contained in:
@ -27,8 +27,12 @@ import {
|
||||
CSwitch
|
||||
} from '@coreui/react'
|
||||
import CIcon from '@coreui/icons-react'
|
||||
import Downloader from '../downloader';
|
||||
|
||||
|
||||
const FileDownload = require('js-file-download');
|
||||
|
||||
|
||||
function Index() {
|
||||
|
||||
const baseUrl = "https://natnats.mobilous.com/";
|
||||
@ -64,7 +68,7 @@ function Index() {
|
||||
|
||||
function doGetReport(){
|
||||
if(report == "" || selectedcons == ""){
|
||||
alert("Please select both Construction and Report");
|
||||
alert("建設とレポートの両方を選択してください");
|
||||
return;
|
||||
}
|
||||
var url = baseUrl + "/" + report + "?construction_id=" +selectedcons+ "&construction_date="+sdate;
|
||||
@ -75,10 +79,25 @@ function Index() {
|
||||
}
|
||||
|
||||
function downloadReport(url) {
|
||||
const response = axios(url).then((res) => {
|
||||
FileDownload(res.data, 'report.xls');
|
||||
})
|
||||
console.log(response);
|
||||
axios({
|
||||
url: url, //your url
|
||||
method: 'GET',
|
||||
responseType: 'blob', // important
|
||||
}).then((response) => {
|
||||
const url = window.URL.createObjectURL(new Blob([response.data]));
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.setAttribute('download', 'file.xlsx'); //or any other extension
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
});
|
||||
|
||||
|
||||
//return <Downloader iframeSrc={url} />
|
||||
// const response = axios(url).then((res) => {
|
||||
// FileDownload(res.data, 'report.xls');
|
||||
// })
|
||||
//console.log(response);
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user