export function format_input_paramt(params) {
let option = []
Object.keys(params).forEach(function (name) {
option.push({
type: 'hidden',
name,
value: params[name]
})
});
return option;
}
// 下载文件
export function downloadExcel(download_url, params) {
//自定义form标签,初始化相关参数
var form = document.createElement("form");
// var access_token = sessionStorage.getItem("X-TOKEN");
form.setAttribute("style", "display:none");
form.setAttribute("method", "post");
// X-TOKEN
format_input_paramt(params).map(({ type, name, value }) => {
let input = document.createElement("input");
input.setAttribute("type", type);
input.setAttribute("name", name);
input.setAttribute("value", value);
form.append(input);
})
form.setAttribute(
"action",
download_url
);
form.setAttribute("target", "_self");
var body = document.createElement("body");
body.setAttribute("style", "display:none");
document.body.appendChild(form);
form.submit();
form.remove();
}
this.$downloadExcel(
`${this.baseUrl}/taiping-attendance-management/workDay/download`,
{}
);
js文件下载
最新推荐文章于 2024-09-30 09:26:43 发布