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