fangmingyue 2 vuotta sitten
vanhempi
commit
c176b39069
3 muutettua tiedostoa jossa 32 lisäystä ja 14 poistoa
  1. 20
    10
      src/pages/dish/edit/index.jsx
  2. 5
    4
      src/pages/dish/list/index.jsx
  3. 7
    0
      src/services/api/dish.js

+ 20
- 10
src/pages/dish/edit/index.jsx Näytä tiedosto

1
-import { addDish, updataDish, getDishById, getDishList } from '@/services/api/dish';
1
+import { addDish, updataDish, getDishById, getDishList, getFoodIngredientsList } from '@/services/api/dish';
2
 import { queryTable } from '@/utils/request';
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
 import { history, useSearchParams } from '@umijs/max';
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
 import { values } from 'lodash';
6
 import { values } from 'lodash';
7
 import { useEffect, useRef, useState } from 'react';
7
 import { useEffect, useRef, useState } from 'react';
8
 
8
 
9
 export default (props) => {
9
 export default (props) => {
10
   const [searchParams, setSearchParams] = useSearchParams();
10
   const [searchParams, setSearchParams] = useSearchParams();
11
   const id = searchParams.get('id');
11
   const id = searchParams.get('id');
12
+  const [datas, setDatas] = useState([]);
12
   const [data, setData] = useState({});
13
   const [data, setData] = useState({});
13
   const formRef = useRef();
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
   useEffect(() => {
26
   useEffect(() => {
15
     if (id) {
27
     if (id) {
16
       getDishById(id).then((res) => {
28
       getDishById(id).then((res) => {
22
   }, [id]);
34
   }, [id]);
23
 
35
 
24
   const onFinish = async (values) => {
36
   const onFinish = async (values) => {
25
-    console.log(values)
37
+
26
 
38
 
27
     if (id) {
39
     if (id) {
28
       // 修改
40
       // 修改
40
 
52
 
41
     return false;
53
     return false;
42
   };
54
   };
43
-
55
+  console.log("datas", datas)
44
   return (
56
   return (
45
     <PageContainer>
57
     <PageContainer>
46
       <Card>
58
       <Card>
70
         >
82
         >
71
           <ProFormText name="name" label="菜肴名称" placeholder="请输入菜肴名称" width={460} />
83
           <ProFormText name="name" label="菜肴名称" placeholder="请输入菜肴名称" width={460} />
72
           <ProFormText name="unit" label="菜肴单位" placeholder="请输入菜肴单位" width={460} />
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
         </ProForm>
88
         </ProForm>
79
       </Card>
89
       </Card>
80
     </PageContainer>
90
     </PageContainer>

+ 5
- 4
src/pages/dish/list/index.jsx Näytä tiedosto

39
       title: '菜肴单位',
39
       title: '菜肴单位',
40
       dataIndex: 'unit',
40
       dataIndex: 'unit',
41
     },
41
     },
42
-    // {
43
-    //   title: '包含食材(种)',
44
-    //   dataIndex: 'status',
45
-    // },
42
+    {
43
+      title: '包含食材(种)',
44
+      dataIndex: 'status',
45
+      search: false,
46
+    },
46
     {
47
     {
47
       title: '操作',
48
       title: '操作',
48
       valueType: 'option',
49
       valueType: 'option',

+ 7
- 0
src/services/api/dish.js Näytä tiedosto

7
  */
7
  */
8
 export const getDishList = (params) => request('/dishes', { params });
8
 export const getDishList = (params) => request('/dishes', { params });
9
 
9
 
10
+/**
11
+ * 查询食材列表
12
+ * @param {*} params
13
+ * @returns
14
+ */
15
+export const getFoodIngredientsList = (params) => request('/foodIngredients', { params });
16
+
10
 /**
17
 /**
11
  * 详情
18
  * 详情
12
  * @param {*} id
19
  * @param {*} id