|
|
@@ -1,5 +1,5 @@ |
|
|
|
import { PlusOutlined, UploadOutlined } from '@ant-design/icons'; |
|
|
|
import { Button, message, Input, Drawer, Popconfirm, Upload } from 'antd'; |
|
|
|
import { Button, message, Input, Drawer, Popconfirm, Upload, Spin } from 'antd'; |
|
|
|
import React, { useState, useRef, useEffect } from 'react'; |
|
|
|
import { PageContainer, FooterToolbar } from '@ant-design/pro-layout'; |
|
|
|
import ProTable from '@ant-design/pro-table'; |
|
|
@@ -124,8 +124,9 @@ const GoodsManage = () => { |
|
|
|
const [getGoodsBoms, setGoodsBoms] = useState(); |
|
|
|
/** 商品配方调整新建/更新窗口的弹窗 */ |
|
|
|
const [setGoodsBomModalVisible, handleGoodsBomModalVisible] = useState(); |
|
|
|
/** 国际化配置 */ |
|
|
|
|
|
|
|
const [loading, setLoading] = useState(false); |
|
|
|
/** 国际化配置 */ |
|
|
|
useEffect(() => { |
|
|
|
function initBom() { |
|
|
|
|
|
|
@@ -337,6 +338,7 @@ const GoodsManage = () => { |
|
|
|
]; |
|
|
|
const props = { |
|
|
|
beforeUpload: (file) => { |
|
|
|
setLoading(true); |
|
|
|
if ( |
|
|
|
file.type !== 'application/vnd.ms-excel' && |
|
|
|
file.type !== 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' |
|
|
@@ -352,15 +354,17 @@ const GoodsManage = () => { |
|
|
|
action: '/kitchen/api/goodes/ExportGood', |
|
|
|
headers: { |
|
|
|
// authorization: 'authorization-text', |
|
|
|
Authorization:'Bearer ' + localStorage.getItem('token') |
|
|
|
Authorization: 'Bearer ' + localStorage.getItem('token') |
|
|
|
}, |
|
|
|
onChange(info) { |
|
|
|
if (info.file.status !== 'uploading') { |
|
|
|
console.log(info.file, info.fileList); |
|
|
|
} |
|
|
|
if (info.file.status === 'done') { |
|
|
|
setLoading(false); |
|
|
|
message.success(`${info.file.name} file uploaded successfully`); |
|
|
|
} else if (info.file.status === 'error') { |
|
|
|
setLoading(false); |
|
|
|
message.error(`${info.file.name}:${info.file.response} `); |
|
|
|
} |
|
|
|
} |
|
|
@@ -368,33 +372,34 @@ const GoodsManage = () => { |
|
|
|
|
|
|
|
return ( |
|
|
|
<PageContainer> |
|
|
|
<ProTable |
|
|
|
headerTitle="" |
|
|
|
actionRef={actionRef} |
|
|
|
rowKey="id" |
|
|
|
search={{ |
|
|
|
labelWidth: 120, |
|
|
|
}} |
|
|
|
toolBarRender={() => [ |
|
|
|
<Button |
|
|
|
type="primary" |
|
|
|
key="primary" |
|
|
|
onClick={() => { |
|
|
|
history.push({ |
|
|
|
pathname: '/goods/goodsInfo', |
|
|
|
query: { |
|
|
|
isAdd: true, |
|
|
|
values: null, |
|
|
|
tabStatus: 'basis' |
|
|
|
}, |
|
|
|
}); |
|
|
|
}} |
|
|
|
> |
|
|
|
<PlusOutlined /> 新建 |
|
|
|
</Button>, |
|
|
|
<Button |
|
|
|
key="primary" |
|
|
|
onClick={async () => { |
|
|
|
<Spin spinning={loading} tip="上传中..."> |
|
|
|
<ProTable |
|
|
|
headerTitle="" |
|
|
|
actionRef={actionRef} |
|
|
|
rowKey="id" |
|
|
|
search={{ |
|
|
|
labelWidth: 120, |
|
|
|
}} |
|
|
|
toolBarRender={() => [ |
|
|
|
<Button |
|
|
|
type="primary" |
|
|
|
key="primary" |
|
|
|
onClick={() => { |
|
|
|
history.push({ |
|
|
|
pathname: '/goods/goodsInfo', |
|
|
|
query: { |
|
|
|
isAdd: true, |
|
|
|
values: null, |
|
|
|
tabStatus: 'basis' |
|
|
|
}, |
|
|
|
}); |
|
|
|
}} |
|
|
|
> |
|
|
|
<PlusOutlined /> 新建 |
|
|
|
</Button>, |
|
|
|
<Button |
|
|
|
key="primary" |
|
|
|
onClick={async () => { |
|
|
|
// const response = await GoodsTemplateExport(); |
|
|
|
// const blob = new Blob([response]); |
|
|
|
// const url = URL.createObjectURL(blob); |
|
|
@@ -404,94 +409,94 @@ const GoodsManage = () => { |
|
|
|
// link.href = url; |
|
|
|
// link.click(); |
|
|
|
const link = document.createElement('a'); |
|
|
|
link.href = "https://hbl-test-1305371387.cos.ap-chengdu.myqcloud.com//Franchisee/goods/133461572557666278.xlsx"; |
|
|
|
link.click(); |
|
|
|
}} |
|
|
|
> |
|
|
|
<UploadOutlined /> 下载商品导入模板 |
|
|
|
</Button>, |
|
|
|
// <Popconfirm |
|
|
|
// type="primary" |
|
|
|
// key="primary" |
|
|
|
// title="导入后重复数据将被替换" |
|
|
|
// okText="是" |
|
|
|
// cancelText="否" |
|
|
|
// onConfirm={() => { |
|
|
|
// handleRemove([record.id]); |
|
|
|
// actionRef.current?.reloadAndRest(); |
|
|
|
// }} |
|
|
|
// onCancel={() => {}} |
|
|
|
// > |
|
|
|
|
|
|
|
// </Popconfirm> |
|
|
|
<Upload {...props}> |
|
|
|
<Button icon={<UploadOutlined />}>导入商品</Button> |
|
|
|
</Upload> |
|
|
|
|
|
|
|
|
|
|
|
]} |
|
|
|
request={async (params) => { |
|
|
|
var goodsData = []; |
|
|
|
if (params.goodsTypeId != undefined) { |
|
|
|
params.goodsTypeId = goodsTypes[params.goodsTypeId].goodsTypeId; |
|
|
|
} |
|
|
|
var total = 0; |
|
|
|
await goods(params).then((r) => { |
|
|
|
goodsData = r.data.data; |
|
|
|
console.log(goodsData) |
|
|
|
goodsData.forEach((x) => { |
|
|
|
if (x.defaultMate != null) { |
|
|
|
x.defaultMate = x.defaultMate.split(","); |
|
|
|
} |
|
|
|
link.href = "https://hbl-test-1305371387.cos.ap-chengdu.myqcloud.com//Franchisee/goods/133463060115739076.xlsx"; |
|
|
|
link.click(); |
|
|
|
}} |
|
|
|
> |
|
|
|
<UploadOutlined /> 下载商品导入模板 |
|
|
|
</Button>, |
|
|
|
// <Popconfirm |
|
|
|
// type="primary" |
|
|
|
// key="primary" |
|
|
|
// title="导入后重复数据将被替换" |
|
|
|
// okText="是" |
|
|
|
// cancelText="否" |
|
|
|
// onConfirm={() => { |
|
|
|
// handleRemove([record.id]); |
|
|
|
// actionRef.current?.reloadAndRest(); |
|
|
|
// }} |
|
|
|
// onCancel={() => {}} |
|
|
|
// > |
|
|
|
|
|
|
|
// </Popconfirm> |
|
|
|
<Upload {...props} showUploadList={false} > |
|
|
|
<Button icon={<UploadOutlined />} >导入商品</Button> |
|
|
|
</Upload> |
|
|
|
|
|
|
|
|
|
|
|
]} |
|
|
|
request={async (params) => { |
|
|
|
var goodsData = []; |
|
|
|
if (params.goodsTypeId != undefined) { |
|
|
|
params.goodsTypeId = goodsTypes[params.goodsTypeId].goodsTypeId; |
|
|
|
} |
|
|
|
var total = 0; |
|
|
|
await goods(params).then((r) => { |
|
|
|
goodsData = r.data.data; |
|
|
|
console.log(goodsData) |
|
|
|
goodsData.forEach((x) => { |
|
|
|
if (x.defaultMate != null) { |
|
|
|
x.defaultMate = x.defaultMate.split(","); |
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
console.log(goodsData) |
|
|
|
total = r.data.total; |
|
|
|
}); |
|
|
|
console.log(goodsData) |
|
|
|
total = r.data.total; |
|
|
|
}); |
|
|
|
return { |
|
|
|
data: goodsData, |
|
|
|
success: true, |
|
|
|
total: total, |
|
|
|
}; |
|
|
|
}} |
|
|
|
columns={columns} |
|
|
|
rowSelection={{ |
|
|
|
onChange: (_, selectedRows) => { |
|
|
|
setSelectedRows(selectedRows); |
|
|
|
}, |
|
|
|
}} |
|
|
|
/> |
|
|
|
{selectedRowsState?.length > 0 && ( |
|
|
|
<FooterToolbar |
|
|
|
extra={ |
|
|
|
<div> |
|
|
|
已选择{' '} |
|
|
|
<a |
|
|
|
style={{ |
|
|
|
fontWeight: 600, |
|
|
|
}} |
|
|
|
> |
|
|
|
{selectedRowsState.length} |
|
|
|
</a>{' '} |
|
|
|
项 |
|
|
|
{/* <span> |
|
|
|
return { |
|
|
|
data: goodsData, |
|
|
|
success: true, |
|
|
|
total: total, |
|
|
|
}; |
|
|
|
}} |
|
|
|
columns={columns} |
|
|
|
rowSelection={{ |
|
|
|
onChange: (_, selectedRows) => { |
|
|
|
setSelectedRows(selectedRows); |
|
|
|
}, |
|
|
|
}} |
|
|
|
/> |
|
|
|
{selectedRowsState?.length > 0 && ( |
|
|
|
<FooterToolbar |
|
|
|
extra={ |
|
|
|
<div> |
|
|
|
已选择{' '} |
|
|
|
<a |
|
|
|
style={{ |
|
|
|
fontWeight: 600, |
|
|
|
}} |
|
|
|
> |
|
|
|
{selectedRowsState.length} |
|
|
|
</a>{' '} |
|
|
|
项 |
|
|
|
{/* <span> |
|
|
|
服务调用次数总计 {selectedRowsState.reduce((pre, item) => pre + item.id, 0)} 万 |
|
|
|
</span> */} |
|
|
|
</div> |
|
|
|
} |
|
|
|
> |
|
|
|
<Button |
|
|
|
onClick={async () => { |
|
|
|
await handleRemove(selectedRowsState); |
|
|
|
setSelectedRows([]); |
|
|
|
actionRef.current?.reloadAndRest?.(); |
|
|
|
}} |
|
|
|
</div> |
|
|
|
} |
|
|
|
> |
|
|
|
删除 |
|
|
|
</Button> |
|
|
|
</FooterToolbar> |
|
|
|
)} |
|
|
|
{/* <CreateForm |
|
|
|
<Button |
|
|
|
onClick={async () => { |
|
|
|
await handleRemove(selectedRowsState); |
|
|
|
setSelectedRows([]); |
|
|
|
actionRef.current?.reloadAndRest?.(); |
|
|
|
}} |
|
|
|
> |
|
|
|
删除 |
|
|
|
</Button> |
|
|
|
</FooterToolbar> |
|
|
|
)} |
|
|
|
{/* <CreateForm |
|
|
|
goodsTypaData={goodsTypes} |
|
|
|
onFinish={async (value) => { |
|
|
|
var success = false; |
|
|
@@ -518,29 +523,30 @@ const GoodsManage = () => { |
|
|
|
values={currentRow || {}} |
|
|
|
/> */} |
|
|
|
|
|
|
|
<Drawer |
|
|
|
width={600} |
|
|
|
visible={showDetail} |
|
|
|
onClose={() => { |
|
|
|
setCurrentRow(undefined); |
|
|
|
setShowDetail(false); |
|
|
|
}} |
|
|
|
closable={false} |
|
|
|
> |
|
|
|
{currentRow?.name && ( |
|
|
|
<ProDescriptions |
|
|
|
column={2} |
|
|
|
title={currentRow?.name} |
|
|
|
request={async () => ({ |
|
|
|
data: currentRow || {}, |
|
|
|
})} |
|
|
|
params={{ |
|
|
|
id: currentRow?.name, |
|
|
|
}} |
|
|
|
columns={columns} |
|
|
|
/> |
|
|
|
)} |
|
|
|
</Drawer> |
|
|
|
<Drawer |
|
|
|
width={600} |
|
|
|
visible={showDetail} |
|
|
|
onClose={() => { |
|
|
|
setCurrentRow(undefined); |
|
|
|
setShowDetail(false); |
|
|
|
}} |
|
|
|
closable={false} |
|
|
|
> |
|
|
|
{currentRow?.name && ( |
|
|
|
<ProDescriptions |
|
|
|
column={2} |
|
|
|
title={currentRow?.name} |
|
|
|
request={async () => ({ |
|
|
|
data: currentRow || {}, |
|
|
|
})} |
|
|
|
params={{ |
|
|
|
id: currentRow?.name, |
|
|
|
}} |
|
|
|
columns={columns} |
|
|
|
/> |
|
|
|
)} |
|
|
|
</Drawer> |
|
|
|
</Spin> |
|
|
|
</PageContainer> |
|
|
|
); |
|
|
|
}; |
|
|
|