|
|
@@ -28,13 +28,17 @@ const GoodsManage = () => { |
|
|
|
const [goodData, setGoodData] = useState([]); |
|
|
|
const [deviceId, setDeviceId] = useState(''); |
|
|
|
const [deviceName, setDeviceName] = useState(''); |
|
|
|
const [goodId, setGoodId] = useState(''); |
|
|
|
const [goodName, setGoodName] = useState(''); |
|
|
|
const [goodsId, setGoodsId] = useState([]); |
|
|
|
/** 国际化配置 */ |
|
|
|
useEffect(() => { |
|
|
|
gettree().then((r) => { |
|
|
|
setTreeData(r.data); |
|
|
|
}); |
|
|
|
initGetDeviceTechnology(); |
|
|
|
initGetgoodslist(); |
|
|
|
}, []); |
|
|
|
|
|
|
|
const initGetDeviceTechnology = () =>{ |
|
|
|
GetDeviceTechnology().then((r) => { |
|
|
|
var arr = r.data; |
|
|
|
if (r.succeeded) { |
|
|
@@ -48,6 +52,8 @@ const GoodsManage = () => { |
|
|
|
setDeviceData(list); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
const initGetgoodslist = () =>{ |
|
|
|
Getgoodslist().then((r)=>{ |
|
|
|
var arr = r.data; |
|
|
|
if (r.succeeded) { |
|
|
@@ -61,7 +67,7 @@ const GoodsManage = () => { |
|
|
|
setGoodData(list); |
|
|
|
} |
|
|
|
}); |
|
|
|
}, []); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 添加节点 |
|
|
@@ -383,8 +389,7 @@ const GoodsManage = () => { |
|
|
|
setDeviceName(option?.label); |
|
|
|
} |
|
|
|
const handleGoodChange = (value, option) => { |
|
|
|
setGoodId(option?.value); |
|
|
|
setGoodName(option?.label); |
|
|
|
setGoodsId(value); |
|
|
|
} |
|
|
|
const handleDownload = async () => { |
|
|
|
if(deviceName == '') |
|
|
@@ -407,7 +412,7 @@ const GoodsManage = () => { |
|
|
|
link1.click(); |
|
|
|
document.body.removeChild(link1); |
|
|
|
// 第二次下载操作 |
|
|
|
const base64String = await GoodsTechnologyExport({ goodId: goodId, deviceId: deviceId, fileName: fileName1 }); |
|
|
|
const base64String = await GoodsTechnologyExport({ goodsId: goodsId, deviceId: deviceId, fileName: fileName1 }); |
|
|
|
if (!base64String) { |
|
|
|
message.error('未能获取第二个文件Base64数据'); |
|
|
|
return; |
|
|
@@ -425,7 +430,7 @@ const GoodsManage = () => { |
|
|
|
const url = window.URL.createObjectURL(blob); |
|
|
|
// 创建第二个 <a> 元素,用于下载第二个文件 |
|
|
|
const link2 = document.createElement('a'); |
|
|
|
const fileName2 = goodName ? goodName : "所有商品" + ".xlsx"; |
|
|
|
const fileName2 = "商品.xlsx"; |
|
|
|
link2.href = url; |
|
|
|
link2.setAttribute('download', fileName2); |
|
|
|
// 将第二个 <a> 元素添加到页面中 |
|
|
@@ -434,8 +439,9 @@ const GoodsManage = () => { |
|
|
|
link2.click(); |
|
|
|
// 下载完成后,移除第二个 <a> 元素 |
|
|
|
document.body.removeChild(link2); |
|
|
|
setGoodName(''); |
|
|
|
setGoodId(''); |
|
|
|
setDeviceId(''); |
|
|
|
setDeviceName(''); |
|
|
|
setGoodsId([]); |
|
|
|
setIsModalOpen(false); |
|
|
|
} catch (error) { |
|
|
|
message.error('下载过程中发生错误:', error); |
|
|
@@ -490,6 +496,7 @@ const GoodsManage = () => { |
|
|
|
<Button |
|
|
|
key="primary" |
|
|
|
onClick={async () => { |
|
|
|
initGetgoodslist(); |
|
|
|
setIsModalOpen(true); |
|
|
|
}} |
|
|
|
> |
|
|
@@ -564,9 +571,7 @@ const GoodsManage = () => { |
|
|
|
maskClosable={false} |
|
|
|
destroyOnClose={true} |
|
|
|
onCancel={() => { |
|
|
|
setGoodId('') |
|
|
|
setDeviceId('') |
|
|
|
setGoodName('') |
|
|
|
setDeviceName('') |
|
|
|
setIsModalOpen(false) |
|
|
|
}}> |
|
|
@@ -593,6 +598,7 @@ const GoodsManage = () => { |
|
|
|
<div style={{ marginBottom: 10 }}> |
|
|
|
<span style={{ marginLeft: 9, marginRight: 10 }}>选择商品:</span> |
|
|
|
<Select |
|
|
|
mode='multiple' |
|
|
|
showSearch |
|
|
|
allowClear |
|
|
|
style={{ |
|
|
|