Your Name 2 anos atrás
pai
commit
55b0a2fc07
2 arquivos alterados com 21 adições e 3 exclusões
  1. 14
    2
      src/pages/package/index.jsx
  2. 7
    1
      src/services/package.js

+ 14
- 2
src/pages/package/index.jsx Ver arquivo

1
 import React from 'react';
1
 import React from 'react';
2
 import { PageContainer } from '@ant-design/pro-components';
2
 import { PageContainer } from '@ant-design/pro-components';
3
 import { Button, Row, Col, Card } from 'antd';
3
 import { Button, Row, Col, Card } from 'antd';
4
+import useBool from '@/utils/hooks/useBool';
5
+import { downloadPackage } from '@/services/package';
4
 import List from './List';
6
 import List from './List';
5
-import BasicForm from './BasicForm';
6
 import DishList from './DishList';
7
 import DishList from './DishList';
7
 
8
 
8
 import './style.less';
9
 import './style.less';
11
   const [current, setCurrent] = React.useState({});
12
   const [current, setCurrent] = React.useState({});
12
   const pkgRef = React.useRef();
13
   const pkgRef = React.useRef();
13
   const dishRef = React.useRef();
14
   const dishRef = React.useRef();
15
+  const [exporting, startExport, stopExport] = useBool();
14
 
16
 
15
   const onAdd = () => pkgRef.current.new();
17
   const onAdd = () => pkgRef.current.new();
16
   const onDishAdd = () => dishRef.current.new();
18
   const onDishAdd = () => dishRef.current.new();
17
 
19
 
20
+  const onExport = () => {
21
+    startExport();
22
+    downloadPackage().then(stopExport).catch(stopExport);
23
+  }
24
+
18
   return (
25
   return (
19
     <Row gutter={24}>
26
     <Row gutter={24}>
20
       <Col span={12}>
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
           <List ref={pkgRef} current={current} setCurrent={setCurrent}/>
34
           <List ref={pkgRef} current={current} setCurrent={setCurrent}/>
23
         </Card>
35
         </Card>
24
       </Col>
36
       </Col>

+ 7
- 1
src/services/package.js Ver arquivo

52
  * @param {*} params 
52
  * @param {*} params 
53
  * @returns 
53
  * @returns 
54
  */
54
  */
55
- export const deletePackageDetail = params => request('/packageDetail', { method: 'delete', params });
55
+ export const deletePackageDetail = params => request('/packageDetail', { method: 'delete', params });
56
+
57
+ /**
58
+  * 下载套餐
59
+  * @returns 
60
+  */
61
+ export const downloadPackage = () => request('/package/export', { download: true });