update download url
This commit is contained in:
@ -78,15 +78,19 @@ function Index() {
|
||||
function setingReport(e){
|
||||
setReport(e.target.value);
|
||||
setStartDate(null);
|
||||
setDownloadUrl('');
|
||||
}
|
||||
|
||||
function setingSelectedCons(e) {
|
||||
setSelectedCons(e.target.value);
|
||||
setStartDate(null);
|
||||
setDownloadUrl('');
|
||||
}
|
||||
|
||||
function setingGraph(e){
|
||||
console.log("setting report" + downloadUrl);
|
||||
setGraph(e.target.checked);
|
||||
setDownloadUrl('');
|
||||
}
|
||||
|
||||
function doGetReport(){
|
||||
@ -102,36 +106,36 @@ function Index() {
|
||||
else{
|
||||
url = baseUrl + "/generate" + report + "?construction_id=" +selectedcons+ "&construction_date="+getDateWithFormat(startDate);
|
||||
}
|
||||
setDownloadUrl(url)
|
||||
setDownloadUrl(url);
|
||||
//downloadReport(url);
|
||||
}
|
||||
else {
|
||||
if(graph){
|
||||
url = baseUrl + "/generate" + report + "?construction_id=" +selectedcons+"&graph=true";
|
||||
}
|
||||
else{
|
||||
url = baseUrl + "/generate" + report + "?construction_id=" +selectedcons;
|
||||
}
|
||||
setDownloadUrl(url)
|
||||
// if(graph){
|
||||
// url = baseUrl + "/generate" + report + "?construction_id=" +selectedcons+"&graph=true";
|
||||
// }
|
||||
// else{
|
||||
// url = baseUrl + "/generate" + report + "?construction_id=" +selectedcons;
|
||||
// }
|
||||
setDownloadUrl('');
|
||||
//downloadReport(url);
|
||||
}
|
||||
}
|
||||
|
||||
function downloadReport(url) {
|
||||
console.log(url);
|
||||
fetch(url)
|
||||
.then(response => {
|
||||
console.log(response)
|
||||
const filename = response.headers.get('Content-Disposition').split('filename=')[1];
|
||||
response.blob().then(blob => {
|
||||
let url = window.URL.createObjectURL(blob);
|
||||
let a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = filename;
|
||||
a.click();
|
||||
});
|
||||
});
|
||||
}
|
||||
// function downloadReport(url) {
|
||||
// console.log(url);
|
||||
// fetch(url)
|
||||
// .then(response => {
|
||||
// console.log(response)
|
||||
// const filename = response.headers.get('Content-Disposition').split('filename=')[1];
|
||||
// response.blob().then(blob => {
|
||||
// let url = window.URL.createObjectURL(blob);
|
||||
// let a = document.createElement('a');
|
||||
// a.href = url;
|
||||
// a.download = filename;
|
||||
// a.click();
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
|
||||
// function downloadReport(url) {
|
||||
// axios({
|
||||
|
||||
Reference in New Issue
Block a user