md
This commit is contained in:
parent
f830060feb
commit
70e3f10d89
@ -494,7 +494,7 @@ export default {
|
||||
const promises = []
|
||||
for(let i=0;i<this.selectionList.length;i++){
|
||||
let url=`emis/emisSettleBill/exportBill?settleBillNo=${item.settleBillNo}`;
|
||||
const promise = getFile(url).then(data => {
|
||||
const promise = this.getRemoteFile(url).then(data => {
|
||||
const fileName = `账单${item.settleBillName}.xlsx`
|
||||
zip.file(fileName, data, { binary: true }) // 逐个添加文件
|
||||
cache[fileName] = data
|
||||
@ -516,26 +516,6 @@ export default {
|
||||
}
|
||||
|
||||
},
|
||||
batchDownload() {
|
||||
const data = ['下载路径1', '下载路径2'] // 需要下载打包的路径, 可以是本地相对路径, 也可以是跨域的全路径
|
||||
const zip = new JSZip()
|
||||
const cache = {}
|
||||
const promises = []
|
||||
data.forEach(item => {
|
||||
const promise = getFile(item).then(data => {
|
||||
const arr_name = item.split("/")
|
||||
const file_name = arr_name[arr_name.length - 1] // 获取文件名
|
||||
zip.file(file_name, data, { binary: true }) // 逐个添加文件
|
||||
cache[file_name] = data
|
||||
})
|
||||
promises.push(promise)
|
||||
})
|
||||
Promise.all(promises).then(() => {
|
||||
zip.generateAsync({type:"blob"}).then(content => { // 生成二进制流
|
||||
FileSaver.saveAs(content, "批量下载.zip") // 利用file-saver保存文件
|
||||
})
|
||||
})
|
||||
},
|
||||
getRemoteFile(url){
|
||||
return new Promise((resolve, reject) => {
|
||||
axios({
|
||||
|
||||
Loading…
Reference in New Issue
Block a user