1.html代码
<el-button icon="el-icon-download" size="small"
type="primary" plain @click="exportExcel()">导出</el-button>
2.js代码
//导出 exportExcel
exportExcel() {
const paralist = {
month: this.listQuery.month,
};
const _that = this;
// 导出所有数据
this.$confirm("是否确认导出数据?", "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
}).then(function () {
_that.fullscreenLoading = true;
//exportExcel 连接后台数据方法
exportExcel(paralist).then((response) => {
const blob = new Blob([response], { type: "application/xlsx" });
const filename = "绩效.xlsx";
const link = document.createElement("a");
console.log(link);
link.href = URL.createObjectURL(blob);
link.download = filename;
console.log(link);
document.body.appendChild(link);
link.click();
window.setTimeout(function () {
URL.revokeObjectURL(blob);
document.body.removeChild(link);
_that.fullscreenLoading = false;
}, 0);
});
});
},
|