import { getparams } from "@/utils/exportparams";
exportExcelTwo() {
try {
const a = document.createElement("a");
a.download = Date.now();
let obj = {}; //obj的字段根据动态添加如搜索等
obj.tenantId = localStorage.getItem("tenantId");
obj.typeName = this.page.typeName;
obj.name = this.page.name;
window.location.href =
`${this.$load}/export/exportExcel?` + this.getTable(obj);
a.click();
// this.getTable(obj)
this.$message({
type: "success",
message: "物资信息导出成功",
});
} catch (e) {
this.$message({
type: "error",
message: "物资信息导出失败",
});
}
},
getTable(data) {
let paramsList = "";
paramsList = getparams(data);
console.log(paramsList,'看结果')
return paramsList;
},
//exportparams.js
export function getparams(params) {
let parameter = ''
for (var i in params) {
if(params[i]!=='') {
parameter+=i+'='+params[i]+'&'
}
}
return encodeURI(parameter)
}
vue导出excel文件
最新推荐文章于 2024-09-02 17:34:07 发布