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

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

parent 60302a68
...@@ -523,6 +523,10 @@ const Products: React.FC<{}> = () => { ...@@ -523,6 +523,10 @@ const Products: React.FC<{}> = () => {
} else if (e.key === '3' || e.key === '4') { } else if (e.key === '3' || e.key === '4') {
handleBatch(e.key) handleBatch(e.key)
} else if(e.key === '5') { } 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('请选择需要操作的商品') currentRef.current.length ? setExportQrcodeModal(true) : message.error('请选择需要操作的商品')
} }
} }
...@@ -533,23 +537,14 @@ const Products: React.FC<{}> = () => { ...@@ -533,23 +537,14 @@ const Products: React.FC<{}> = () => {
a.style = "display: none" a.style = "display: none"
setExportLoading(true) setExportLoading(true)
postProductCommodityExportCommodityQrCode({idList: currentRef.current}, { responseType: 'blob', getResponse: true }).then((res:any) => { postProductCommodityExportCommodityQrCode({idList: currentRef.current}, { responseType: 'blob', getResponse: true }).then((res:any) => {
const { code, data, response } = res const { data, response } = res
if(code !== 1000) { const filename = response.headers.get('content-disposition').split('=')[1]
throw new Error(res.message) let blob = new Blob([data], {type: "application/x-zip-compressed"})
} else { const url = window.URL.createObjectURL(blob);
const filename = response.headers.get('content-disposition').split('=')[1] a.href = url;
let blob = new Blob([data], {type: "application/x-zip-compressed"}) a.download = filename;
// let objectUrl = URL.createObjectURL(blob) a.click();
// window.location.href = objectUrl window.URL.revokeObjectURL(url);
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)
}).finally(() => { }).finally(() => {
setExportLoading(false) setExportLoading(false)
message.success('导出成功') 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