代码提交_6_3
This commit is contained in:
parent
8f7aaf109b
commit
c511d67954
|
@ -185,6 +185,7 @@
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary" @click="onSubmit">查询</el-button>
|
<el-button type="primary" @click="onSubmit">查询</el-button>
|
||||||
|
<el-button type="success" @click="onExport" style="background: #57c7d4;border:#57c7d4">导出</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</div>
|
</div>
|
||||||
|
@ -290,6 +291,36 @@
|
||||||
}
|
}
|
||||||
this.getTabel(timeData)
|
this.getTabel(timeData)
|
||||||
},
|
},
|
||||||
|
//导出列表
|
||||||
|
onExport() {
|
||||||
|
let timeData = {
|
||||||
|
start_date: moment(this.addForm.date_range_start).format("YYYY-MM-DD"),
|
||||||
|
end_date: moment(this.addForm.date_range_end).format("YYYY-MM-DD")
|
||||||
|
}
|
||||||
|
this.downloadFile('http://172.16.1.253:8087/Vue/ExportEnergy.ashx?start_date=' + timeData.start_date + '&end_date=' + timeData.end_date)
|
||||||
|
},
|
||||||
|
downloadFile(url) {
|
||||||
|
fetch(url)
|
||||||
|
.then(response => {
|
||||||
|
var disposition = response.headers.get('Content-Disposition');
|
||||||
|
var filenameRegex = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/;
|
||||||
|
var matches = filenameRegex.exec(disposition);
|
||||||
|
var filename = matches != null && matches[1] ? matches[1].replace(/['"]/g, '') : 'download';
|
||||||
|
|
||||||
|
return response.blob().then(blob => {
|
||||||
|
var a = document.createElement('a');
|
||||||
|
var url = window.URL.createObjectURL(blob);
|
||||||
|
a.href = url;
|
||||||
|
a.download = decodeURIComponent(filename);
|
||||||
|
document.body.appendChild(a);
|
||||||
|
a.click();
|
||||||
|
window.URL.revokeObjectURL(url);
|
||||||
|
document.body.removeChild(a);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(error => console.error('下载文件时出错:', error));
|
||||||
|
},
|
||||||
|
|
||||||
//时间戳转化方法
|
//时间戳转化方法
|
||||||
formatStringDate(jsondate) {
|
formatStringDate(jsondate) {
|
||||||
jsondate = jsondate.replace("/Date(", "").replace(")/", "");
|
jsondate = jsondate.replace("/Date(", "").replace(")/", "");
|
||||||
|
|
Loading…
Reference in New Issue