Your Name 2 år sedan
förälder
incheckning
55b0a2fc07
2 ändrade filer med 21 tillägg och 3 borttagningar
  1. 14
    2
      src/pages/package/index.jsx
  2. 7
    1
      src/services/package.js

+ 14
- 2
src/pages/package/index.jsx Visa fil

@@ -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>

+ 7
- 1
src/services/package.js Visa fil

@@ -52,4 +52,10 @@ export const getPackageDetailList = params => request('/packageDetail', { params
52 52
  * @param {*} params 
53 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 });