前端代码:
/**批量下载操作 */
handleDownload() {
if(this.chooseSelections.length ==0){
this.$message.warning("请选择要下载打包的数据!")
return false;
}
var that = this;
this.$confirm("确认下载打包选中数据吗?", "提示信息", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
var chooseList = this.chooseSelections;
var ids = "";
chooseList.forEach(item => {
ids = ids + item.id + ",";
})
const loading = this.$loading({
lock: true,
text: "批量下载打包中",
spinner: "el-icon-loading",
background: "rgba(0, 0, 0, 0.7)",
});
packageDownload(ids).then(res => {
loading.close();
this.fileHandle(res,`批量装箱照片_${new Date().getTime()}.zip`)
})
})
.catch(() => {});
},
===============================================================================
//装箱照片批量下载打包
export function packageDownload(ids) {
return request({
url: '/packingRecord/packageDownload/'+ids,
method: 'get',
responseType: 'blob',
headers:{ 'Content-Type': 'application/json; application/octet-stream'},
})
}
后端代码:
package com.ruoyi.web.utils;
import com.ruoyi.business.domain.entity.BusPackingRecord;
import org.apache.commons.io.FileU