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,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>

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

@@ -39,10 +39,11 @@ const DishList = (props) => {
39 39
       title: '菜肴单位',
40 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 48
       title: '操作',
48 49
       valueType: 'option',

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

@@ -7,6 +7,13 @@ import { request } from '@umijs/max';
7 7
  */
8 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 19
  * @param {*} id