简历批量下载更改
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
231a993f8b
commit
849142bd23
|
|
@ -712,11 +712,12 @@ export default {
|
|||
this.model_cfg.visible = false
|
||||
this.model_cfg.showClose = true
|
||||
console.log(res.Result)
|
||||
for (let i = 0; res.Result.length > i; i++) {
|
||||
let item = res.Result[i]
|
||||
console.log(item)
|
||||
await this.handleBatchDown(item)
|
||||
}
|
||||
this.downloadAllInOneZip(res.Result)
|
||||
// for (let i = 0; res.Result.length > i; i++) {
|
||||
// let item = res.Result[i]
|
||||
// console.log(item)
|
||||
// await this.handleBatchDown(item)
|
||||
// }
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
|
|
@ -736,6 +737,54 @@ export default {
|
|||
// this.model_cfg.showClose = true
|
||||
// })
|
||||
},
|
||||
async downloadAllInOneZip(arr) {
|
||||
if (!arr.length) {
|
||||
return
|
||||
}
|
||||
const zip = new JSZip()
|
||||
const allTasks = []
|
||||
arr.forEach((reviewer) => {
|
||||
if (!reviewer?.FileList?.length) return
|
||||
|
||||
reviewer.FileList.forEach((fileItem) => {
|
||||
const fileUrl = this.OSSclientConfig.basePath + fileItem.Path
|
||||
const zipPath = `${reviewer.Name}_${fileItem.FileName}`
|
||||
|
||||
const task = this.getFileData(fileUrl)
|
||||
.then((response) => {
|
||||
zip.file(zipPath, response.data, { binary: true })
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(`文件下载失败 [${zipPath}]:`, err)
|
||||
});
|
||||
allTasks.push(task)
|
||||
})
|
||||
})
|
||||
|
||||
if (allTasks.length === 0) {
|
||||
console.log('无可下载的文件')
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await Promise.all(allTasks)
|
||||
|
||||
// 生成 ZIP
|
||||
const zipBlob = await zip.generateAsync({
|
||||
type: 'blob',
|
||||
compression: 'DEFLATE',
|
||||
compressionOptions: { level: 9 },
|
||||
})
|
||||
|
||||
// 下载
|
||||
saveAs(zipBlob, `CV_${new Date().getTime()}.zip`)
|
||||
|
||||
console.error('ZIP 生成成功')
|
||||
} catch (err) {
|
||||
console.error('ZIP 生成失败:', err)
|
||||
} finally {
|
||||
}
|
||||
},
|
||||
// 查询
|
||||
handleSelectSearch() {
|
||||
this.searchData.PageIndex = 1
|
||||
|
|
|
|||
Loading…
Reference in New Issue