李志伟 3 лет назад
Родитель
Сommit
725a40d82c
3 измененных файлов: 262 добавлений и 0 удалений
  1. 19
    0
      config/routes.js
  2. 154
    0
      src/pages/Machinery/Cooperative/edit.jsx
  3. 89
    0
      src/pages/Machinery/Cooperative/index.jsx

+ 19
- 0
config/routes.js Просмотреть файл

@@ -63,6 +63,25 @@ export default [
63 63
     ],
64 64
   },
65 65
 
66
+  {
67
+    path: '/Machinery',
68
+    name: '农机管理',
69
+    icon: 'InsertRowLeftOutlined',
70
+    component: '../layouts/BasicLayout',
71
+    routes: [
72
+      {
73
+        path: '/Machinery/Cooperative',
74
+        name: '合作社列表',
75
+        component: './Machinery/Cooperative',
76
+      },
77
+      {
78
+        path: '/Machinery/Cooperative/edit.jsx',
79
+        name: '合作社编辑',
80
+        component: './Machinery/Cooperative/edit.jsx',
81
+        hideInMenu: true,
82
+      },
83
+    ],
84
+  },
66 85
   {
67 86
     path: '/MonitoringScreen',
68 87
     name: '农机监控大屏',

+ 154
- 0
src/pages/Machinery/Cooperative/edit.jsx Просмотреть файл

@@ -0,0 +1,154 @@
1
+import { Form, Input, Card, InputNumber, Select, message, Button } from 'antd';
2
+import { history } from 'umi';
3
+import ProCard from '@ant-design/pro-card';
4
+import { useState, useEffect } from 'react';
5
+// import { getTagList } from '@/services/tag';
6
+// import { addAttaList, gettaTouristForm, EditaddAttaList } from '@/services/AttaList'
7
+
8
+const { TextArea } = Input;
9
+const { Option } = Select;
10
+const formItemLayout = { labelCol: { span: 6 }, wrapperCol: { span: 14 } };
11
+
12
+const goBack = () => {
13
+  history.goBack();
14
+};
15
+const FormItem = Form.Item;
16
+export default (props) => {
17
+  const { location } = props;
18
+  const { id } = location.query;
19
+  const [form] = Form.useForm();
20
+  const [listForm, setListForm] = useState({});
21
+  const [loading, setLoading] = useState(false);
22
+  const [imageList, setImageList] = useState([]);
23
+
24
+  const Submit = (data) => {
25
+    const typeList = (data.typeList || []).map((x) => {
26
+      return { ...x, targetId: id, targetType: 'tourist' };
27
+    });
28
+    setLoading(true);
29
+
30
+    // if (id) {
31
+    //   EditaddAttaList(id, { ...listForm, ...data, imageList, typeList }).then(() => {
32
+    //     setLoading(false);
33
+    //     message.success('数据更新成功');
34
+    //     goBack();
35
+    //   })
36
+    //     .catch(err => {
37
+    //       setLoading(false);
38
+    //       message.error(err.message || err);
39
+    //     });
40
+    // } else {
41
+    //   addAttaList({ ...data, imageList, typeList }).then((res) => {
42
+    //     setLoading(false);
43
+    //     message.success('数据保存成功');
44
+    //     history.replace(`/Attractions/Edit?id=${res.touristId}`)
45
+    //   })
46
+    //     .catch(err => {
47
+    //       setLoading(false);
48
+    //       message.error(err.message || err);
49
+    //     });
50
+    // }
51
+  };
52
+
53
+  //地址--占位
54
+  const [newLocName, setLocName] = useState('');
55
+  const [newAddress, setAddress] = useState('');
56
+
57
+  const selectTagList = (params) => {
58
+    // return getTagList({
59
+    // }).then((res) => {
60
+    // }).catch((err) => {
61
+    //   return {
62
+    //     success: false,
63
+    //   }
64
+    // })
65
+  };
66
+
67
+  const imageInput = (image) => {
68
+    return {
69
+      uid: image.imageId,
70
+      url: image.url,
71
+    };
72
+  };
73
+
74
+  const imageOutput = (image) => {
75
+    return {
76
+      imageId: image?.raw?.imageId,
77
+      shopId: id,
78
+      url: image.url,
79
+    };
80
+  };
81
+  useEffect(() => {
82
+    selectTagList();
83
+    // if (id) {
84
+    //   gettaTouristForm(id).then((res) => {
85
+    //     setListForm(res)
86
+    //     form.setFieldsValue(res)
87
+    //     setImageList(res?.imageList || [])
88
+    //   })
89
+    // }
90
+  }, [id]);
91
+
92
+  return (
93
+    <Card>
94
+      <ProCard tabs={{ type: 'card' }}>
95
+        <ProCard.TabPane key={1} tab="合作社编辑">
96
+          <Form {...formItemLayout} onFinish={Submit} form={form}>
97
+            <FormItem
98
+              label="合作社名称"
99
+              name="title"
100
+              rules={[{ required: true, message: '请输入合作社名称16个字符以内' }]}
101
+            >
102
+              <Input
103
+                placeholder="请输入合作社名称16个字符以内"
104
+                maxLength="16"
105
+                style={{ width: '350px' }}
106
+              />
107
+            </FormItem>
108
+            <FormItem
109
+              label="信用代码"
110
+              name="creditCode"
111
+              rules={[{ required: true, message: '请输入' }]}
112
+            >
113
+              <Input placeholder="请输入信用代码" style={{ width: '350px' }} />
114
+            </FormItem>
115
+            <FormItem
116
+              label="联系人"
117
+              name="name"
118
+              rules={[{ required: true, message: '请输入联系人' }]}
119
+            >
120
+              <Input placeholder="请输入联系人" rows={4} style={{ width: '350px' }} />
121
+            </FormItem>
122
+            <FormItem
123
+              label="联系方式"
124
+              name="phone"
125
+              rules={[{ required: true, message: '请输入联系方式' }]}
126
+            >
127
+              <Input placeholder="请输入联系方式" rows={4} style={{ width: '350px' }} />
128
+            </FormItem>
129
+            <FormItem
130
+              label="地址"
131
+              name="address"
132
+              rules={[{ required: true, message: '请输入地址' }]}
133
+            >
134
+              <TextArea placeholder="请输入地址" style={{ width: '350px' }} />
135
+            </FormItem>
136
+            <FormItem label=" " colon={false}>
137
+              <Button type="default" onClick={() => goBack()}>
138
+                返回
139
+              </Button>
140
+              <Button
141
+                type="primary"
142
+                loading={loading}
143
+                htmlType="submit"
144
+                style={{ marginLeft: '4em' }}
145
+              >
146
+                保存
147
+              </Button>
148
+            </FormItem>
149
+          </Form>
150
+        </ProCard.TabPane>
151
+      </ProCard>
152
+    </Card>
153
+  );
154
+};

+ 89
- 0
src/pages/Machinery/Cooperative/index.jsx Просмотреть файл

@@ -0,0 +1,89 @@
1
+import React from 'react';
2
+import { history, Link } from 'umi';
3
+import { Button, Popconfirm, message, Tooltip } from 'antd';
4
+// import { getPersonList, exportPersonList } from '@/services/person';
5
+import { PageHeaderWrapper } from '@ant-design/pro-layout';
6
+import moment from 'moment';
7
+import PageTable from '@/components/PageTable';
8
+
9
+const formatterTime = (val) => {
10
+  return val ? moment(val).format('YYYY-MM-DD HH:mm:ss') : '';
11
+};
12
+
13
+export default (props) => {
14
+  const columns = [
15
+    {
16
+      title: '合作社名',
17
+      dataIndex: 'title',
18
+      key: 'title',
19
+    },
20
+    {
21
+      title: '地址',
22
+      dataIndex: 'address',
23
+      key: 'address',
24
+    },
25
+    {
26
+      title: '联系人',
27
+      dataIndex: 'name',
28
+      key: 'name',
29
+    },
30
+    {
31
+      title: '手机号',
32
+      dataIndex: 'phone',
33
+      key: 'phone',
34
+    },
35
+    {
36
+      title: '农机数',
37
+      dataIndex: 'machineryNum',
38
+      key: 'machineryNum',
39
+    },
40
+    {
41
+      title: '员工数',
42
+      dataIndex: 'employeesNum',
43
+      key: 'employeesNum',
44
+    },
45
+    {
46
+      title: '完成订单数',
47
+      dataIndex: 'orderNum',
48
+      key: 'orderNum',
49
+      search: false,
50
+    },
51
+    {
52
+      title: '评分',
53
+      dataIndex: 'score',
54
+      key: 'score',
55
+    },
56
+    {
57
+      title: '操作',
58
+      valueType: 'option',
59
+      render: (_, record) => [
60
+        <Link key={1} to={`./edit.jsx`}>
61
+          编辑
62
+        </Link>,
63
+        <Popconfirm
64
+          key={2}
65
+          title="您是否确认删除 ?"
66
+          onConfirm={() => handleDelete(record.cooperativeId)}
67
+          okText="确定"
68
+          cancelText="取消"
69
+        >
70
+          <a href="#">删除</a>
71
+        </Popconfirm>,
72
+      ],
73
+    },
74
+    // 农机列表点击进入详情页 下面是轨迹上面是时间
75
+  ];
76
+  const handleDelete = () => {};
77
+  return (
78
+    <PageHeaderWrapper>
79
+      <PageTable
80
+        // request={getPersonList}
81
+        // expfunc={exportPersonList}
82
+        columns={columns}
83
+        rowKey="cooperativeId"
84
+        options={false}
85
+        scroll={{ x: 1000 }}
86
+      />
87
+    </PageHeaderWrapper>
88
+  );
89
+};