Yansen 2 years ago
parent
commit
a337ef76ad
1 changed files with 7 additions and 4 deletions
  1. 7
    4
      src/pages/package/DishList.jsx

+ 7
- 4
src/pages/package/DishList.jsx View File

@@ -1,5 +1,5 @@
1 1
 import React, { useEffect, useState, useRef, forwardRef, useImperativeHandle } from 'react';
2
-import { Button, Modal, List, Popconfirm, Form, Select, message } from 'antd';
2
+import { Button, Modal, List, Popconfirm, Form, Select, InputNumber } from 'antd';
3 3
 import classNames from 'classnames';
4 4
 import useBool from '@/utils/hooks/useBool';
5 5
 import { getPackageDetailList, addPackageDetail, deletePackageDetail } from '@/services/package';
@@ -15,8 +15,7 @@ const AddDish = props => {
15 15
 
16 16
   const onFinish = (values) => {
17 17
     const it = data.filter(x => x.id === values.dishId)[0] || {};
18
-    const dishKind = values.dishKind || defaultKind;
19
-    onChange({...it, dishKind});
18
+    onChange({...it, ...values });
20 19
   };
21 20
 
22 21
   const handleSearch = (newValue) => {
@@ -39,6 +38,7 @@ const AddDish = props => {
39 38
 
40 39
   useEffect(() => {
41 40
     initList();
41
+    form.setFieldsValue({ dishKind: 2, amount: 1 });
42 42
   }, [])
43 43
 
44 44
   return (
@@ -65,6 +65,9 @@ const AddDish = props => {
65 65
           <Select.Option value={2}>菜肴</Select.Option>
66 66
         </Select>
67 67
       </Form.Item>
68
+      <Form.Item name="amount" label="菜肴数量" rules={[{ required: true, message: '请设置数量' }]}>
69
+        <InputNumber style={{ width: '100%' }} min={1} />
70
+      </Form.Item>
68 71
       <Form.Item>
69 72
         <Button type='primary' htmlType='sumbit'>确定</Button>
70 73
       </Form.Item>
@@ -150,7 +153,7 @@ export default forwardRef((props, ref) => {
150 153
               </Popconfirm>
151 154
             ]}
152 155
           >
153
-            {`【${kindDict[`${item.dishKind}`]}】${item.name}`}
156
+            {`【${kindDict[`${item.dishKind}`]}】${item.name} x ${item.amount}`}
154 157
           </List.Item>
155 158
         )}
156 159
       />