1. 完成用户导出的功能

2. 完成前后端的导出的封装
This commit is contained in:
YunaiV
2021-01-14 01:18:56 +08:00
parent 02ff516f0f
commit f942b34d02
16 changed files with 246 additions and 131 deletions

View File

@ -101,6 +101,21 @@ export function download(fileName) {
window.location.href = baseURL + "/common/download?fileName=" + encodeURI(fileName) + "&delete=" + true;
}
// 下载 Excel 方法
export function downloadExcel(data, fileName) {
// 创建 blob
let blob = new Blob([data], {type: 'application/vnd.ms-excel'});
// 创建 href 超链接,点击进行下载
window.URL = window.URL || window.webkitURL;
let href = URL.createObjectURL(blob);
let downA = document.createElement("a");
downA.href = href;
downA.download = fileName;
downA.click();
// 销毁超连接
window.URL.revokeObjectURL(href);
}
// 字符串格式化(%s )
export function sprintf(str) {
var args = arguments, flag = true, i = 1;