Yansen 2 년 전
부모
커밋
da6542932e
6개의 변경된 파일83개의 추가작업 그리고 48개의 파일을 삭제
  1. 30
    17
      src/pages/dish/edit/Detail.jsx
  2. 3
    9
      src/pages/dish/edit/index.jsx
  3. 13
    1
      src/pages/dish/list/index.jsx
  4. 3
    2
      src/pages/guaranteeTask/Edit/DishList.jsx
  5. 24
    19
      src/pages/package/List.jsx
  6. 10
    0
      src/routes/routes.jsx

+ 30
- 17
src/pages/dish/edit/Detail.jsx 파일 보기

@@ -1,27 +1,40 @@
1 1
 import React from 'react';
2
-import { Row, Col, Divider, Typography, Image } from 'antd';
2
+import { Button, Row, Col, Card, Typography, Image } from 'antd';
3
+import { useNavigate, useSearchParams } from 'react-router-dom';
4
+import { getDishById } from '@/services/dish';
3 5
 
4 6
 const { Title, Paragraph } = Typography;
5 7
 
6 8
 export default (props) => {
9
+  const [searchParams] = useSearchParams();
10
+  const id = searchParams.get('id');
11
+  const [dish, setDish] = React.useState({});
7 12
 
8
-  const { dish = {} } = props;
13
+  const navigate = useNavigate();
14
+
15
+  React.useEffect(() => {
16
+    if (id) {
17
+      getDishById(id).then((res) => {
18
+        setDish(res);
19
+        console.log(res)
20
+      });
21
+    }
22
+  }, [id]);
9 23
 
10 24
   return (
11
-    <Row gutter={24}>
12
-      <Col span={12}>
13
-        <Typography>
14
-          {/* <Title level={3}>
15
-            五花肉
16
-          </Title> */}
17
-          <Paragraph>
18
-            <div dangerouslySetInnerHTML={{ __html: dish.content }}  style={{ fontSize: '16px', lineHeight: '2em' }} />
19
-          </Paragraph>
20
-        </Typography>
21
-      </Col>
22
-      <Col span={12}>
23
-        <Image src={dish.thumb} />
24
-      </Col>
25
-    </Row>
25
+    <Card title={dish.name} extra={<Button onClick={() => navigate(-1)}>返回</Button>}>
26
+      <Row gutter={24}>
27
+        <Col span={12}>
28
+          <Typography>
29
+            <Paragraph>
30
+              <div dangerouslySetInnerHTML={{ __html: dish.content }}  style={{ fontSize: '16px', lineHeight: '2em' }} />
31
+            </Paragraph>
32
+          </Typography>
33
+        </Col>
34
+        <Col span={12}>
35
+          <Image style={{ minWidth: '240px' }} src={dish.thumb} />
36
+        </Col>
37
+      </Row>
38
+    </Card>
26 39
   )
27 40
 }

+ 3
- 9
src/pages/dish/edit/index.jsx 파일 보기

@@ -3,14 +3,12 @@ import { PageContainer } from '@ant-design/pro-components';
3 3
 import { useNavigate, useSearchParams } from 'react-router-dom';
4 4
 import { Alert, Card, Row, Col, message, Space, Button } from 'antd';
5 5
 import { useEffect, useRef, useState, useMemo } from 'react';
6
-import Detail from './Detail';
7 6
 import Edit from './Edit';
8 7
 
9 8
 export default (props) => {
10 9
   const [searchParams] = useSearchParams();
11 10
   const id = searchParams.get('id');
12 11
   const [dish, setDish] = useState();
13
-  const [isPreivw, setIsPreview] = useState(!!id);
14 12
   const navigate = useNavigate();
15 13
   
16 14
   useEffect(() => {
@@ -23,17 +21,13 @@ export default (props) => {
23 21
 
24 22
   const onFinish = (values) => {
25 23
     setDish(values);
26
-    // navigate(-1);
24
+    navigate(-1);
27 25
   };
28 26
 
29 27
   return (
30 28
     <PageContainer>
31
-      <Card
32
-        title={(dish || {}).name}
33
-        extra={<Button type='link' disabled={!id} onClick={() => setIsPreview(!isPreivw)}>{ isPreivw ? '编辑' : '图文' }</Button>}>
34
-        {
35
-          isPreivw ? <Detail dish={dish} /> : <Edit dish={dish} onFinish={onFinish} />
36
-        }
29
+      <Card style={{ paddingTop: '24px' }}>
30
+        <Edit dish={dish} onFinish={onFinish} />
37 31
       </Card>
38 32
     </PageContainer>
39 33
   );

+ 13
- 1
src/pages/dish/list/index.jsx 파일 보기

@@ -1,7 +1,7 @@
1 1
 import { getDishList, addDish, updataDish, deleteDish } from '@/services/dish';
2 2
 import { queryTable } from '@/utils/request';
3 3
 import { PageContainer, ProTable } from '@ant-design/pro-components';
4
-import { useNavigate } from 'react-router-dom';
4
+import { useNavigate, Link } from 'react-router-dom';
5 5
 import { Button, message, Popconfirm } from 'antd';
6 6
 import { useRef, useState } from 'react';
7 7
 
@@ -34,6 +34,7 @@ const DishList = (props) => {
34 34
     {
35 35
       title: '菜肴名称',
36 36
       dataIndex: 'name',
37
+      render: (t, row) => <Link to={`/stock/dish/detail?id=${row.id}`}>{t}</Link>
37 38
     },
38 39
 
39 40
     {
@@ -52,6 +53,17 @@ const DishList = (props) => {
52 53
       width: 200,
53 54
       render: (_, record) => [
54 55
 
56
+        <Button
57
+          key={1}
58
+          style={{ padding: 0 }}
59
+          type="link"
60
+          onClick={() => {
61
+            navigate(`/stock/dish/detail?id=${record.id}`);
62
+          }}
63
+        >
64
+          详情
65
+        </Button>,
66
+
55 67
         <Button
56 68
           key={2}
57 69
           style={{ padding: 0 }}

+ 3
- 2
src/pages/guaranteeTask/Edit/DishList.jsx 파일 보기

@@ -35,16 +35,17 @@ export default (props) => {
35 35
       const { records = [] } = res;
36 36
       if (records.length > 0) {
37 37
         for (let it of records) {
38
+          const dishAmount = (it.amount || 1) * amount;
38 39
           const found = list.filter(x => x.dishId === it.id)[0]
39 40
           if (found) {
40
-            found.dishAmount = amount;
41
+            found.dishAmount = dishAmount;
41 42
           } else {
42 43
             list.push({
43 44
               guaranteeId: dataSource.id,
44 45
               dishId: it.id,
45 46
               dishName: it.name,
46 47
               dishUnit: it.unit,
47
-              dishAmount: amount,
48
+              dishAmount: dishAmount,
48 49
             })
49 50
           }
50 51
         }

+ 24
- 19
src/pages/package/List.jsx 파일 보기

@@ -4,13 +4,14 @@ import classNames from 'classnames';
4 4
 import BasicForm from './BasicForm';
5 5
 import { getPackageList, deletePackage } from '@/services/package';
6 6
 import useBool from '@/utils/hooks/useBool';
7
+import { floatDivide } from '@/utils/float';
7 8
 
8 9
 export default forwardRef((props, ref) => {
9 10
   const { current, setCurrent } = props;
10 11
   const [loading, startLoading, stopLoading] = useBool();
11 12
   const [open, setVisible, hide] = useBool();
12 13
   const [hasMore, setHasMore] = useState(false);
13
-  const [filter, setFilter] = useState({ pageNum: 1, pageSize: 10, total: 0 });
14
+  const [filter, setFilter] = useState({ pageNum: 1, pageSize: 20, total: 0 });
14 15
   const [list, setList] = useState([]);
15 16
   const listRef = useRef();
16 17
   listRef.current = list;
@@ -121,24 +122,28 @@ export default forwardRef((props, ref) => {
121 122
       dataSource={list}
122 123
       loading={loading}
123 124
       loadMore={loadMore}
124
-      renderItem={item => (
125
-        <List.Item
126
-          className={classNames({ active: current.id === item.id })}
127
-          onClick={() => setCurrent(item)}
128
-          actions={[
129
-            <Button key="edit" type='link' onClick={() => onEdit(item)}>编辑</Button>,
130
-            <Popconfirm
131
-              key="delete"
132
-              title="确认删除?"
133
-              onConfirm={() => onDelete(item)}
134
-              >
135
-              <a href="#">删除</a>
136
-            </Popconfirm>
137
-          ]}
138
-        >
139
-          {item.name}
140
-        </List.Item>
141
-      )}
125
+      renderItem={item => {
126
+        const price = item.price ? floatDivide(item.price, 100) : 0;
127
+
128
+        return (
129
+          <List.Item
130
+            className={classNames({ active: current.id === item.id })}
131
+            onClick={() => setCurrent(item)}
132
+            actions={[
133
+              <Button key="edit" type='link' onClick={() => onEdit(item)}>编辑</Button>,
134
+              <Popconfirm
135
+                key="delete"
136
+                title="确认删除?"
137
+                onConfirm={() => onDelete(item)}
138
+                >
139
+                <a href="#">删除</a>
140
+              </Popconfirm>
141
+            ]}
142
+          >
143
+            {`${item.name} ¥${price}元`}
144
+          </List.Item>
145
+        )
146
+      }}
142 147
     />
143 148
     <Modal open={open} title="套餐维护" footer={null} onCancel={hide} maskClosable={false} >
144 149
       <BasicForm current={current} onChange={handleForm}></BasicForm>

+ 10
- 0
src/routes/routes.jsx 파일 보기

@@ -24,6 +24,7 @@ import GuaranteePersonnelList from "@/pages/guarantee/personnel/list";
24 24
 import GuaranteePersonnelEdit from "@/pages/guarantee/personnel/edit";
25 25
 import DishList from "@/pages/dish/list";
26 26
 import DishEdit from "@/pages/dish/edit";
27
+import DishDetail from "@/pages/dish/edit/detail";
27 28
 import PackageList from "@/pages/package";
28 29
 import StockList from "@/pages/stock/list";
29 30
 import StockEdit from "@/pages/stock/edit";
@@ -208,6 +209,15 @@ export const authRoutes = [
208 209
           permission: 'dish.edit',
209 210
         },
210 211
       },
212
+      {
213
+        path: "dish/detail",
214
+        element: <DishDetail />,
215
+        meta: {
216
+          hideInMenu: true,
217
+          title: "菜肴详情",
218
+          // permission: 'dish.detail',
219
+        },
220
+      },
211 221
       {
212 222
         path: "package/list",
213 223
         element: <PackageList />,