fangmingyue 2 years ago
parent
commit
0b5f121477

+ 20
- 0
config/routes.js View File

@@ -49,6 +49,26 @@
49 49
     icon: 'VideoCameraOutlined',
50 50
     component: './monitor/index',
51 51
   },
52
+  {
53
+    path: '/dish/list',
54
+    name: '菜肴管理',
55
+    icon: 'VideoCameraOutlined',
56
+    component: './dish/list',
57
+  },
58
+  {
59
+    path: '/dish/add',
60
+    name: '菜肴详情',
61
+    icon: 'smile',
62
+    hideInMenu: true,
63
+    component: './dish/edit',
64
+  },
65
+  {
66
+    path: '/package/list',
67
+    name: '套餐管理',
68
+    icon: 'VideoCameraOutlined',
69
+    component: './package/list',
70
+
71
+  },
52 72
   {
53 73
     component: './404',
54 74
   },

+ 73
- 0
src/pages/dish/edit/index.jsx View File

@@ -0,0 +1,73 @@
1
+import { addDish, updataDish } from '@/services/api/dish';
2
+import { PageContainer, ProForm, ProFormDigit, ProFormText, ModalForm, Select, Option } from '@ant-design/pro-components';
3
+import { history, useSearchParams } from '@umijs/max';
4
+import { Card, Col, message, Row, Space, Image } from 'antd';
5
+import { useEffect, useRef, useState } from 'react';
6
+
7
+export default (props) => {
8
+  const [searchParams, setSearchParams] = useSearchParams();
9
+  const id = searchParams.get('id');
10
+  const [data, setData] = useState({});
11
+  const formRef = useRef();
12
+  useEffect(() => {
13
+    if (id) {
14
+      getBannerdById(id).then((res) => {
15
+        setData(res);
16
+
17
+        formRef.current.setFieldsValue(res);
18
+      });
19
+    }
20
+  }, [id]);
21
+
22
+  const onFinish = async (values) => {
23
+    if (id) {
24
+      // 修改
25
+      updataDish(id, { ...values }).then((res) => {
26
+        message.success('修改成功');
27
+        history.back();
28
+      });
29
+    } else {
30
+      // 新增
31
+      addDish({ ...values }).then((res) => {
32
+        message.success('添加成功');
33
+        history.back();
34
+      });
35
+    }
36
+
37
+    return false;
38
+  };
39
+
40
+  return (
41
+    <PageContainer>
42
+      <Card>
43
+        <ProForm
44
+          formRef={formRef}
45
+          layout={'horizontal'}
46
+          labelCol={{ span: 8 }}
47
+          wrapperCol={{ span: 16 }}
48
+          onFinish={onFinish}
49
+          initialValues={{ type: '1', state: '1' }}
50
+          submitter={{
51
+            searchConfig: {
52
+              resetText: '返回',
53
+            },
54
+            onReset: () => history.back(),
55
+            render: (props, doms) => {
56
+              return (
57
+                <Row>
58
+                  <Col span={8} offset={8}>
59
+                    <Space>{doms}</Space>
60
+                  </Col>
61
+                </Row>
62
+              );
63
+            },
64
+          }}
65
+        >
66
+          <ProFormText name="name" label="菜肴名称" placeholder="请输入菜肴名称" width={460} />
67
+          <ProFormText name="unit" label="菜肴单位" placeholder="请输入菜肴单位" width={460} />
68
+          {/* <Select label="包含食材" mode="multiple"></Select> */}
69
+        </ProForm>
70
+      </Card>
71
+    </PageContainer>
72
+  );
73
+};

+ 114
- 0
src/pages/dish/list/index.jsx View File

@@ -0,0 +1,114 @@
1
+import { getDishList, addDish, updataDish } from '@/services/api/dish';
2
+import { queryTable } from '@/utils/request';
3
+import { PageContainer, ProTable } from '@ant-design/pro-components';
4
+import { history } from '@umijs/max';
5
+import { Button, message, Popconfirm, EditForm } from 'antd';
6
+import { useRef, useState } from 'react';
7
+
8
+const DishList = (props) => {
9
+  console.log(props, '===');
10
+  const [showDetail, setShowDetail] = useState(false);
11
+  const [activeKey, setActiveKey] = useState('');
12
+  const actionRef = useRef();
13
+
14
+  const updata = (row) => {
15
+    if (row.id) {
16
+      updataDish(row.id, { state: row.state === '1' ? '2' : '1' }).then((res) => {
17
+        message.success('修改成功');
18
+        actionRef.current.reload();
19
+      });
20
+    }
21
+  };
22
+
23
+  const handleDelete = (id) => {
24
+    if (id) {
25
+      deleteBanner(id).then((res) => {
26
+        message.success('删除成功');
27
+        actionRef.current.reload();
28
+      });
29
+    }
30
+  };
31
+
32
+  const columns = [
33
+    {
34
+      title: '菜肴名称',
35
+      dataIndex: 'name',
36
+    },
37
+
38
+    {
39
+      title: '菜肴单位',
40
+      dataIndex: 'unit',
41
+    },
42
+    {
43
+      title: '包含食材(种)',
44
+      dataIndex: 'itemId.amount',
45
+    },
46
+    {
47
+      title: '操作',
48
+      valueType: 'option',
49
+      width: 200,
50
+      render: (_, record) => [
51
+        <Button
52
+          key={1}
53
+          style={{ padding: 0 }}
54
+          type="link"
55
+          onClick={() => {
56
+            updata(record);
57
+          }}
58
+        >
59
+          {record.state === '1' ? '下架' : '上架'}
60
+        </Button>,
61
+        <Button
62
+          key={2}
63
+          style={{ padding: 0 }}
64
+          type="link"
65
+          onClick={() => {
66
+            console.log(record, ']]');
67
+            history.push(`/rotationChart/add?id=${record.id}`);
68
+          }}
69
+        >
70
+          编辑
71
+        </Button>,
72
+
73
+        <Popconfirm
74
+          key={3}
75
+          title="您是否确认删除 ?"
76
+          onConfirm={() => handleDelete(record.id)}
77
+          okText="确定"
78
+          cancelText="取消"
79
+        >
80
+          {/* manualPush */}
81
+          <Button style={{ padding: 0 }} type="link">
82
+            删除
83
+          </Button>
84
+        </Popconfirm>,
85
+      ],
86
+    },
87
+  ];
88
+
89
+  return (
90
+    <PageContainer>
91
+      <ProTable
92
+        search={false}
93
+        actionRef={actionRef}
94
+        rowKey="id"
95
+        toolBarRender={() => [
96
+          <Button
97
+            key="2"
98
+            type="primary"
99
+            // onClick={() => { setCurrent({}); setVisible(true); }}
100
+            onClick={() => {
101
+              history.push('/dish/add');
102
+            }}
103
+          >
104
+            新增
105
+          </Button>,
106
+        ]}
107
+        // request={queryTable(getDishList)}
108
+        columns={columns}
109
+      />
110
+    </PageContainer>
111
+  );
112
+};
113
+
114
+export default DishList;

+ 0
- 0
src/pages/package/a.js View File


+ 115
- 0
src/pages/package/list/index.jsx View File

@@ -0,0 +1,115 @@
1
+import { getPackageList, addPackage, updataPackage } from '@/services/api/package';
2
+import { queryTable } from '@/utils/request';
3
+import { PageContainer, ProTable } from '@ant-design/pro-components';
4
+import { history } from '@umijs/max';
5
+import { Button, message, Popconfirm, EditForm } from 'antd';
6
+import { useRef, useState } from 'react';
7
+
8
+const PackageList = (props) => {
9
+  console.log(props, '===');
10
+  const [showDetail, setShowDetail] = useState(false);
11
+  const [activeKey, setActiveKey] = useState('');
12
+  const actionRef = useRef();
13
+
14
+  const updata = (row) => {
15
+    if (row.id) {
16
+      updataPackage(row.id, { state: row.state === '1' ? '2' : '1' }).then((res) => {
17
+        message.success('修改成功');
18
+        actionRef.current.reload();
19
+      });
20
+    }
21
+  };
22
+
23
+  const handleDelete = (id) => {
24
+    if (id) {
25
+      deleteBanner(id).then((res) => {
26
+        message.success('删除成功');
27
+        actionRef.current.reload();
28
+      });
29
+    }
30
+  };
31
+
32
+  const columns = [
33
+    {
34
+      title: '套餐名称',
35
+      dataIndex: 'name',
36
+    },
37
+
38
+    {
39
+      title: '套餐单位',
40
+      dataIndex: 'unit',
41
+    },
42
+    {
43
+      title: '包含菜肴(份)',
44
+      dataIndex: 'itemId.amount',
45
+    },
46
+    {
47
+      title: '包含食材(种)',
48
+      dataIndex: 'itemId.amount',
49
+    },
50
+    {
51
+      title: '操作',
52
+      valueType: 'option',
53
+      width: 200,
54
+      render: (_, record) => [
55
+        <Button
56
+          key={1}
57
+          style={{ padding: 0 }}
58
+          type="link"
59
+          onClick={() => {
60
+            updata(record);
61
+          }}
62
+        >
63
+          {record.state === '1' ? '下架' : '上架'}
64
+        </Button>,
65
+        <Button
66
+          key={2}
67
+          style={{ padding: 0 }}
68
+          type="link"
69
+          onClick={() => {
70
+            console.log(record, ']]');
71
+            history.push(`/rotationChart/add?id=${record.id}`);
72
+          }}
73
+        >
74
+          编辑
75
+        </Button>,
76
+
77
+        <Popconfirm
78
+          key={3}
79
+          title="您是否确认删除 ?"
80
+          onConfirm={() => handleDelete(record.id)}
81
+          okText="确定"
82
+          cancelText="取消"
83
+        >
84
+          {/* manualPush */}
85
+          <Button style={{ padding: 0 }} type="link">
86
+            删除
87
+          </Button>
88
+        </Popconfirm>,
89
+      ],
90
+    },
91
+  ];
92
+
93
+  return (
94
+    <PageContainer>
95
+      <ProTable
96
+        search={false}
97
+        actionRef={actionRef}
98
+        rowKey="id"
99
+        toolBarRender={() => [
100
+          <Button
101
+            key="2"
102
+            type="primary"
103
+            onClick={() => { setCurrent({}); setVisible(true); }}
104
+          >
105
+            新增
106
+          </Button>,
107
+        ]}
108
+        // request={queryTable(getDishList)}
109
+        columns={columns}
110
+      />
111
+    </PageContainer>
112
+  );
113
+};
114
+
115
+export default PackageList;

+ 1
- 1
src/pages/rotationChart/list/index.jsx View File

@@ -46,7 +46,7 @@ const RotationChartList = (props) => {
46 46
     {
47 47
       title: '封面图',
48 48
       dataIndex: 'image',
49
-      render: t => !t || '-' === t ? t : <img src={t}  style={{ width: '96px', borderRadius: '6px' }} />
49
+      render: t => !t || '-' === t ? t : <img src={t} style={{ width: '96px', borderRadius: '6px' }} />
50 50
     },
51 51
 
52 52
     {

+ 24
- 0
src/services/api/dish.js View File

@@ -0,0 +1,24 @@
1
+import { request } from '@umijs/max';
2
+
3
+/**
4
+ * 查询列表
5
+ * @param {*} params
6
+ * @returns
7
+ */
8
+export const getDishList = (params) => request('/dish', { params });
9
+
10
+
11
+/**
12
+ * 新增
13
+ * @param {*} data
14
+ * @returns
15
+ */
16
+export const addDish = (data) => request('/dish', { method: 'post', data });
17
+
18
+/**
19
+ * 新增
20
+ *  @param {*} id
21
+ * @param {*} data
22
+ * @returns
23
+ */
24
+export const updataDish = (id, data) => request(`/dish/${id}`, { method: 'put', data });

+ 24
- 0
src/services/api/package.js View File

@@ -0,0 +1,24 @@
1
+import { request } from '@umijs/max';
2
+
3
+/**
4
+ * 查询列表
5
+ * @param {*} params
6
+ * @returns
7
+ */
8
+export const getPackageList = (params) => request('/package', { params });
9
+
10
+
11
+/**
12
+ * 新增
13
+ * @param {*} data
14
+ * @returns
15
+ */
16
+export const addPackage = (data) => request('/package', { method: 'post', data });
17
+
18
+/**
19
+ * 新增
20
+ *  @param {*} id
21
+ * @param {*} data
22
+ * @returns
23
+ */
24
+export const updataPackage = (id, data) => request(`/package/${id}`, { method: 'put', data });