Commit 77e2e162 authored by 前端-钟卫鹏's avatar 前端-钟卫鹏

fix: 商品导出二维码仅限上架商品

parent 60302a68
......@@ -523,6 +523,10 @@ const Products: React.FC<{}> = () => {
} else if (e.key === '3' || e.key === '4') {
handleBatch(e.key)
} else if(e.key === '5') {
console.log(currentRefRow.current)
if(!currentRefRow.current.every(item => item.status === 5)) {
return message.error('请选择上架的商品操作')
}
currentRef.current.length ? setExportQrcodeModal(true) : message.error('请选择需要操作的商品')
}
}
......@@ -533,23 +537,14 @@ const Products: React.FC<{}> = () => {
a.style = "display: none"
setExportLoading(true)
postProductCommodityExportCommodityQrCode({idList: currentRef.current}, { responseType: 'blob', getResponse: true }).then((res:any) => {
const { code, data, response } = res
if(code !== 1000) {
throw new Error(res.message)
} else {
const filename = response.headers.get('content-disposition').split('=')[1]
let blob = new Blob([data], {type: "application/x-zip-compressed"})
// let objectUrl = URL.createObjectURL(blob)
// window.location.href = objectUrl
const url = window.URL.createObjectURL(blob);
a.href = url;
a.download = filename;
a.click();
window.URL.revokeObjectURL(url);
}
}).catch(error => {
console.log(error, 'error')
message.error(error)
const { data, response } = res
const filename = response.headers.get('content-disposition').split('=')[1]
let blob = new Blob([data], {type: "application/x-zip-compressed"})
const url = window.URL.createObjectURL(blob);
a.href = url;
a.download = filename;
a.click();
window.URL.revokeObjectURL(url);
}).finally(() => {
setExportLoading(false)
message.success('导出成功')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment