|
@@ -1,8 +1,9 @@
|
1
|
1
|
import React from 'react';
|
2
|
2
|
import { PageContainer } from '@ant-design/pro-components';
|
3
|
3
|
import { Button, Row, Col, Card } from 'antd';
|
|
4
|
+import useBool from '@/utils/hooks/useBool';
|
|
5
|
+import { downloadPackage } from '@/services/package';
|
4
|
6
|
import List from './List';
|
5
|
|
-import BasicForm from './BasicForm';
|
6
|
7
|
import DishList from './DishList';
|
7
|
8
|
|
8
|
9
|
import './style.less';
|
|
@@ -11,14 +12,25 @@ export default (props) => {
|
11
|
12
|
const [current, setCurrent] = React.useState({});
|
12
|
13
|
const pkgRef = React.useRef();
|
13
|
14
|
const dishRef = React.useRef();
|
|
15
|
+ const [exporting, startExport, stopExport] = useBool();
|
14
|
16
|
|
15
|
17
|
const onAdd = () => pkgRef.current.new();
|
16
|
18
|
const onDishAdd = () => dishRef.current.new();
|
17
|
19
|
|
|
20
|
+ const onExport = () => {
|
|
21
|
+ startExport();
|
|
22
|
+ downloadPackage().then(stopExport).catch(stopExport);
|
|
23
|
+ }
|
|
24
|
+
|
18
|
25
|
return (
|
19
|
26
|
<Row gutter={24}>
|
20
|
27
|
<Col span={12}>
|
21
|
|
- <Card title="套餐列表" extra={<Button type='primary' onClick={onAdd}>新增</Button>}>
|
|
28
|
+ <Card title="套餐列表" extra={(
|
|
29
|
+ <>
|
|
30
|
+ <Button type='primary' onClick={onAdd}>新增</Button>
|
|
31
|
+ <Button onClick={onExport} loading={exporting}>导出</Button>
|
|
32
|
+ </>
|
|
33
|
+ )}>
|
22
|
34
|
<List ref={pkgRef} current={current} setCurrent={setCurrent}/>
|
23
|
35
|
</Card>
|
24
|
36
|
</Col>
|