|
@@ -1,16 +1,28 @@
|
1
|
|
-import { addDish, updataDish, getDishById, getDishList } from '@/services/api/dish';
|
|
1
|
+import { addDish, updataDish, getDishById, getDishList, getFoodIngredientsList } from '@/services/api/dish';
|
2
|
2
|
import { queryTable } from '@/utils/request';
|
3
|
|
-import { PageContainer, ProForm, ProFormDigit, ProFormText, ModalForm, Select, Option } from '@ant-design/pro-components';
|
|
3
|
+import { PageContainer, ProForm, ProFormDigit, ProFormText, ModalForm, ProFormSelect } from '@ant-design/pro-components';
|
4
|
4
|
import { history, useSearchParams } from '@umijs/max';
|
5
|
|
-import { Card, Col, message, Row, Space, Image } from 'antd';
|
|
5
|
+import { Card, Col, message, Row, Space, Image, Select, Option } from 'antd';
|
6
|
6
|
import { values } from 'lodash';
|
7
|
7
|
import { useEffect, useRef, useState } from 'react';
|
8
|
8
|
|
9
|
9
|
export default (props) => {
|
10
|
10
|
const [searchParams, setSearchParams] = useSearchParams();
|
11
|
11
|
const id = searchParams.get('id');
|
|
12
|
+ const [datas, setDatas] = useState([]);
|
12
|
13
|
const [data, setData] = useState({});
|
13
|
14
|
const formRef = useRef();
|
|
15
|
+ useEffect(() => {
|
|
16
|
+
|
|
17
|
+ getFoodIngredientsList().then((res) => {
|
|
18
|
+ setDatas(res?.records?.map((x) => ({
|
|
19
|
+ label: x.name,
|
|
20
|
+ value: x.dishId
|
|
21
|
+ })))
|
|
22
|
+
|
|
23
|
+ });
|
|
24
|
+ }, [id]);
|
|
25
|
+
|
14
|
26
|
useEffect(() => {
|
15
|
27
|
if (id) {
|
16
|
28
|
getDishById(id).then((res) => {
|
|
@@ -22,7 +34,7 @@ export default (props) => {
|
22
|
34
|
}, [id]);
|
23
|
35
|
|
24
|
36
|
const onFinish = async (values) => {
|
25
|
|
- console.log(values)
|
|
37
|
+
|
26
|
38
|
|
27
|
39
|
if (id) {
|
28
|
40
|
// 修改
|
|
@@ -40,7 +52,7 @@ export default (props) => {
|
40
|
52
|
|
41
|
53
|
return false;
|
42
|
54
|
};
|
43
|
|
-
|
|
55
|
+ console.log("datas", datas)
|
44
|
56
|
return (
|
45
|
57
|
<PageContainer>
|
46
|
58
|
<Card>
|
|
@@ -70,11 +82,9 @@ export default (props) => {
|
70
|
82
|
>
|
71
|
83
|
<ProFormText name="name" label="菜肴名称" placeholder="请输入菜肴名称" width={460} />
|
72
|
84
|
<ProFormText name="unit" label="菜肴单位" placeholder="请输入菜肴单位" width={460} />
|
73
|
|
- {/* <Select label="包含食材" mode="multiple" >
|
74
|
|
- <Option></Option>
|
75
|
|
- <Option></Option>
|
76
|
|
- </Select> */}
|
77
|
|
-
|
|
85
|
+ <ProFormSelect mode="multiple" label="包含食材" placeholder="多选下拉" width={460}
|
|
86
|
+ options={datas}
|
|
87
|
+ />
|
78
|
88
|
</ProForm>
|
79
|
89
|
</Card>
|
80
|
90
|
</PageContainer>
|