浏览代码

Merge branch 'master' of http://git.ycjcjy.com/nanyang/machinery-admin

张延森 3 年前
父节点
当前提交
4343b67e69

+ 1
- 1
config/defaultSettings.js 查看文件

@@ -7,7 +7,7 @@ const Settings = {
7 7
   fixedHeader: false,
8 8
   fixSiderbar: true,
9 9
   colorWeak: false,
10
-  title: 'Ant Design Pro',
10
+  title: '南阳智慧农机系统',
11 11
   pwa: false,
12 12
   menu: {
13 13
     locale: false,

+ 18
- 2
config/routes.js 查看文件

@@ -71,6 +71,22 @@ export default [
71 71
       },
72 72
     ],
73 73
   },
74
+  {
75
+    path: '/customer',
76
+    name: '客户管理',
77
+    icon: 'IdcardOutlined',
78
+    access: 'customer',
79
+    component: '../layouts/BasicLayout',
80
+    routes: [
81
+      {
82
+        path: '/customer/index.jsx',
83
+        name: '客户列表',
84
+        access: 'customerList',
85
+        icon: 'smile',
86
+        component: './customer',
87
+      },
88
+    ],
89
+  },
74 90
   {
75 91
     path: '/Machinery',
76 92
     name: '农机管理',
@@ -103,9 +119,9 @@ export default [
103 119
         component: './Machinery/Machinery',
104 120
       },
105 121
       {
106
-        path: '/Machinery/Machinery/edit.jsx',
122
+        path: '/Machinery/Machinery/Edit',
107 123
         name: '农机编辑',
108
-        component: './Machinery/Machinery/edit.jsx',
124
+        component: './Machinery/Machinery/Edit',
109 125
         hideInMenu: true,
110 126
       },
111 127
       {

二进制
src/assets/selectedImg.png 查看文件


+ 1
- 0
src/pages/ContentManagementSystem/InformationClassification/index.jsx 查看文件

@@ -29,6 +29,7 @@ export default (props) => {
29 29
         actionRef.current.reload();
30 30
       }).catch((err) => {
31 31
         console.log(err.message)
32
+        setLoading(false);
32 33
       });
33 34
     } else {
34 35
       addNewsType(values)

+ 1
- 0
src/pages/Finance/Withdrawal/audit.jsx 查看文件

@@ -28,6 +28,7 @@ export default (props) => {
28 28
       updateWithdrawal(withdrawal.withdrawalId, { ...withdrawal, auditStatus: val, auditRemark: remarks }).then(() => {
29 29
         message.success('操作成功');
30 30
         goBack()
31
+        setLoading(false)
31 32
       }).catch(err => {
32 33
         console.log(err.message)
33 34
         setLoading(false)

+ 388
- 0
src/pages/Machinery/Machinery/Edit/index.jsx 查看文件

@@ -0,0 +1,388 @@
1
+import { useState, useEffect } from 'react';
2
+import { history } from 'umi';
3
+import { Form, Input, Drawer, DatePicker, Select, InputNumber, message, Button, List, Card, Descriptions } from 'antd';
4
+import ProCard from '@ant-design/pro-card';
5
+import { PageHeaderWrapper } from '@ant-design/pro-layout';
6
+import moment from 'moment';
7
+import ExtendContent from '@/components/ExtendContent';
8
+import { UploadImage, UploadImageList } from '@/components/Upload';
9
+import Money from '@/components/Money';
10
+import { addMachinery, updateMachinery, getMachineryDetail } from '@/services/machinery';
11
+import { getMachineryTypeList } from '@/services/machineryType';
12
+import { getRegionList } from '@/services/region';
13
+import { getDeviceList, getdeviceDetail, getTerminalDeviceList, addDevice } from '@/services/device';
14
+import { getCooperativeList } from '@/services/cooperative';
15
+import selectedImg from '@/assets/selectedImg.png'
16
+import './style.less'
17
+
18
+const { Option } = Select;
19
+const { Search } = Input;
20
+const formItemLayout = { labelCol: { span: 6 }, wrapperCol: { span: 14 } };
21
+
22
+const goBack = () => {
23
+  history.goBack();
24
+};
25
+const FormItem = Form.Item;
26
+export default (props) => {
27
+  const { location } = props;
28
+  const { id } = location.query;
29
+  const [form] = Form.useForm();
30
+  const [loading, setLoading] = useState(false);
31
+  const [imageList, setImageList] = useState([]);
32
+  //农机类型列表
33
+  const [machineryTypeList, setMachineryTypeList] = useState([]);
34
+  //区域列表
35
+  const [regionList, setRegionList] = useState([]);
36
+  //合作社列表
37
+  const [cooperativeList, setCooperativeList] = useState([]);
38
+
39
+  const Submit = (data) => {
40
+    var newData = { ...data }
41
+    if (data.buyDate) {
42
+      newData = { ...data, buyDate: data.buyDate.format('YYYY-MM-DD HH:mm:ss') };
43
+    }
44
+    setLoading(true);
45
+    if (id) {
46
+      updateMachinery(id, newData)
47
+        .then(() => {
48
+          setLoading(false);
49
+          message.success('数据更新成功');
50
+          goBack();
51
+        })
52
+        .catch((err) => {
53
+          setLoading(false);
54
+          message.error(err.message || err);
55
+        });
56
+    } else {
57
+      addMachinery(newData)
58
+        .then((res) => {
59
+          setLoading(false);
60
+          message.success('数据保存成功');
61
+          history.replace(`./Edit?id=${res.machineryId}`)
62
+        })
63
+        .catch((err) => {
64
+          setLoading(false);
65
+          message.error(err.message || err);
66
+        });
67
+    }
68
+  };
69
+
70
+  const imageInput = (image) => {
71
+    return {
72
+      uid: image.imageId,
73
+      url: image.url,
74
+    };
75
+  };
76
+
77
+  const imageOutput = (image) => {
78
+    return {
79
+      imageId: image?.raw?.imageId,
80
+      targetId: id,
81
+      url: image.url,
82
+    };
83
+  };
84
+
85
+
86
+  //设备信息
87
+  const [deviceForm] = Form.useForm();
88
+  const [visible, setVisible] = useState(false);
89
+  const [terminalId, setTerminalId] = useState();
90
+  //设备列表
91
+  const [deviceList, setDeviceList] = useState([]);
92
+  const [device, setDevice] = useState();
93
+  const [bind, setBind] = useState(false);
94
+  const [deviceLoading, setDeviceLoading] = useState(false);
95
+  const [deviceDetail, setDeviceDetail] = useState();
96
+
97
+  //弹出设备列表抽屉
98
+  const changeCamera = () => {
99
+    if (device != null) {
100
+      getTerminalDeviceList(device.deviceId).then((res) => {
101
+        setDeviceList([res]);
102
+        setVisible(true);
103
+      })
104
+    } else {
105
+      setVisible(true);
106
+    }
107
+
108
+  }
109
+  const handleClose = () => {
110
+    setVisible(false);
111
+  }
112
+  const onSearch = (val) => {
113
+    if (val == '') {
114
+      getDeviceList({ pageSize: 500 }).then((res) => {
115
+        setDeviceList(res.records);
116
+      })
117
+    } else {
118
+      setTerminalId(val)
119
+    }
120
+  }
121
+  //选中设备
122
+  const handleSelect = (item) => {
123
+    setDevice(item);
124
+  }
125
+  const handleOk = () => {
126
+    if (device != null) {
127
+      setBind(true)
128
+    }
129
+    handleClose();
130
+  }
131
+  const submitDevice = (data) => {
132
+    if (!bind) {
133
+      message.info('请绑定摄像头');
134
+      return;
135
+    }
136
+    let obj = {
137
+      deviceId: device.deviceId,
138
+      channel: data.channel,
139
+      netType: data.netType
140
+    }
141
+    let config = JSON.stringify(obj);
142
+    setDeviceLoading(true);
143
+    addDevice({ ...deviceDetail, machineryId: id, apiConfig: config }).then((res) => {
144
+      message.success('保存成功!');
145
+      setDeviceLoading(false);
146
+      goBack();
147
+    }).catch((err) => {
148
+      setDeviceLoading(false);
149
+      console.log(err.message);
150
+    })
151
+  }
152
+  useEffect(() => {
153
+    getDeviceList({ terminalId: terminalId, pageSize: 500 }).then((res) => {
154
+      setDeviceList(res.records);
155
+    })
156
+  }, [terminalId])
157
+
158
+  useEffect(() => {
159
+    getMachineryTypeList({ pageSize: 500 }).then((res) => {
160
+      setMachineryTypeList(res.records);
161
+    }).catch((err) => {
162
+      console.log(err.message)
163
+    });
164
+    getRegionList({ pageSize: 500 }).then((res) => {
165
+      setRegionList(res.records);
166
+    }).catch((err) => {
167
+      console.log(err.message)
168
+    });
169
+    getCooperativeList({ pageSize: 500 }).then((res) => {
170
+      setCooperativeList(res.records);
171
+    }).catch((err) => {
172
+      console.log(err.message)
173
+    });
174
+  }, [])
175
+
176
+
177
+  useEffect(() => {
178
+    if (id) {
179
+      //编辑时获取基本信息内容
180
+      getMachineryDetail(id).then((res) => {
181
+        form.setFieldsValue({ ...res, buyDate: res.buyDate ? moment(res.buyDate, 'YYYY-MM-DD') : null });
182
+      }).catch((err) => {
183
+        console.log(err.message)
184
+      });
185
+      //获取设备信息内容
186
+      getdeviceDetail(id).then((res) => {
187
+        setDeviceDetail(res);
188
+        if (res) {
189
+          //json字符串转普通对象
190
+          let confit = JSON.parse(res.apiConfig)
191
+          deviceForm.setFieldsValue(confit);
192
+          if (res && res.deviceId != null) {
193
+            //获取绑定设备详情
194
+            getTerminalDeviceList(confit.deviceId).then((res) => {
195
+              setDevice(res);
196
+              setBind(true)
197
+            })
198
+          }
199
+        }
200
+      })
201
+    }
202
+  }, [id]);
203
+
204
+  return (
205
+    <PageHeaderWrapper>
206
+      <ProCard tabs={{ type: 'card' }} style={{ minHeight: '700px' }}>
207
+        <ProCard.TabPane key={1} tab="基本信息">
208
+          <Form {...formItemLayout} onFinish={Submit} form={form}>
209
+            <FormItem
210
+              label="农机名"
211
+              name="name"
212
+              rules={[{ required: true, message: '请输入农机名' }]}
213
+            >
214
+              <Input placeholder="请输入农机名" style={{ width: '350px' }} />
215
+            </FormItem>
216
+            <FormItem
217
+              label="农机类型"
218
+              name="typeId"
219
+              rules={[{ required: true, message: '请选择农机类型' }]}
220
+            >
221
+              <Select style={{ width: '350px' }}>
222
+                {machineryTypeList.map((item) => (
223
+                  <Option value={item.typeId} key={item.typeId}>
224
+                    {item.name}
225
+                  </Option>
226
+                ))}
227
+              </Select>
228
+            </FormItem>
229
+            <FormItem label="主图" name="thumb" rules={[{ required: true, message: '请选择主图' }]}>
230
+              <UploadImage />
231
+            </FormItem>
232
+            <FormItem label="农机banner图集" name="images">
233
+              <UploadImageList
234
+                value={imageList}
235
+                onChange={setImageList}
236
+                input={imageInput}
237
+                output={imageOutput}
238
+              />
239
+            </FormItem>
240
+            <FormItem
241
+              label="区域"
242
+              name="regionId"
243
+              rules={[{ required: true, message: '请选择区域' }]}
244
+            >
245
+              <Select style={{ width: '350px' }}>
246
+                {regionList.map((item) => (
247
+                  <Option value={item.regionId} key={item.regionId}>
248
+                    {item.name}
249
+                  </Option>
250
+                ))}
251
+              </Select>
252
+            </FormItem>
253
+            <FormItem
254
+              label="归属合作社"
255
+              name="orgId"
256
+              rules={[{ required: true, message: '请选择归属合作社' }]}
257
+            >
258
+              <Select style={{ width: '350px' }}>
259
+                {cooperativeList.map((item) => (
260
+                  <Option value={item.orgId} key={item.orgId}>
261
+                    {item.name}
262
+                  </Option>
263
+                ))}
264
+              </Select>
265
+            </FormItem>
266
+            <FormItem label="单价" name="price" rules={[{ required: true, message: '请输入价格' }]}>
267
+              <Money style={{ width: '350px' }} />
268
+            </FormItem>
269
+            <FormItem label="购买时间" name="buyDate">
270
+              <DatePicker format="YYYY-MM-DD" style={{ width: '350px' }} />
271
+            </FormItem>
272
+            <FormItem label="状态" name="status" rules={[{ required: true, message: '请选择' }]}>
273
+              <Select placeholder="请选择农机状态" style={{ width: '350px' }}>
274
+                <Option value={1}>正常</Option>
275
+                <Option value={0}>维修</Option>
276
+              </Select>
277
+            </FormItem>
278
+            {id && (
279
+              <FormItem label="详细信息" colon={false}>
280
+                <ExtendContent targetType="machinery" targetId={id} onCancel={goBack} />
281
+              </FormItem>
282
+            )}
283
+            <FormItem label=" " colon={false}>
284
+              <Button type="default" onClick={goBack}>
285
+                返回
286
+              </Button>
287
+              <Button
288
+                type="primary"
289
+                loading={loading}
290
+                htmlType="submit"
291
+                style={{ marginLeft: '4em' }}
292
+              >
293
+                保存
294
+              </Button>
295
+            </FormItem>
296
+          </Form>
297
+        </ProCard.TabPane>
298
+        <ProCard.TabPane key={2} disabled={!id} tab="设备信息">
299
+          <Form {...formItemLayout} onFinish={submitDevice} form={deviceForm}>
300
+            <FormItem label='摄像头'  >
301
+              <Button type='link' onClick={changeCamera}>{bind ? '已绑定' : '未绑定'}</Button>
302
+            </FormItem>
303
+            <FormItem
304
+              label="通道号"
305
+              name='channel'
306
+              rules={[{ required: true, message: '请输入通道号' }]}
307
+            >
308
+              <InputNumber min={1} placeholder="请输入通道号" style={{ width: '350px' }} />
309
+            </FormItem>
310
+            <FormItem
311
+              label="网络类型"
312
+              name='netType'
313
+              rules={[{ required: true, message: '请选择网络类型' }]}
314
+            >
315
+              <Select placeholder="请选择网络类型" style={{ width: '350px' }}>
316
+                <Option value={0}>内网</Option>
317
+                <Option value={1}>电信</Option>
318
+                <Option value={2}>移动</Option>
319
+                <Option value={3}>联通</Option>
320
+              </Select>
321
+            </FormItem>
322
+            <FormItem label=" " colon={false}>
323
+              <Button type="default" onClick={goBack}>
324
+                返回
325
+              </Button>
326
+              <Button
327
+                type="primary"
328
+                loading={deviceLoading}
329
+                htmlType="submit"
330
+                style={{ marginLeft: '4em' }}
331
+              >
332
+                保存
333
+              </Button>
334
+            </FormItem>
335
+          </Form>
336
+          <Drawer
337
+            title="摄像头列表"
338
+            width={500}
339
+            closable={false}
340
+            onClose={handleClose}
341
+            visible={visible}
342
+          >
343
+            <div style={{ display: 'flex', height: '100%', flexDirection: 'column' }}>
344
+              <Search
345
+                placeholder="请输入终端ID"
346
+                allowClear
347
+                enterButton="搜索"
348
+                size="middle"
349
+                onSearch={onSearch}
350
+                style={{ padding: '24px' }}
351
+              />
352
+              <List split={false} style={{ padding: '12px 0', flex: 1, overflowY: 'auto', background: 'rgb(240,242,245)' }}>
353
+                {
354
+                  deviceList.map(item =>
355
+                    <List.Item key={item.deviceId} onClick={() => handleSelect(item)}>
356
+                      <Card className='listCard' hoverable>
357
+                        <Descriptions labelStyle={{ width: '72px', display: 'inline-block', textAlign: 'end' }} >
358
+                          <Descriptions.Item span={3} label='型号名称'>{item.modelName}</Descriptions.Item>
359
+                          <Descriptions.Item span={3} label='协议'>{item.protocol}</Descriptions.Item>
360
+                          <Descriptions.Item span={3} label='终端ID'>{item.terminalId}</Descriptions.Item>
361
+                          <Descriptions.Item span={3} label='通道列表'>{item.deviceChannelList}</Descriptions.Item>
362
+                        </Descriptions>
363
+                        {
364
+                          device && item.deviceId == device.deviceId && <img src={selectedImg} />
365
+                        }
366
+                      </Card>
367
+                    </List.Item>
368
+                  )
369
+                }
370
+
371
+              </List>
372
+              <div style={{ padding: '24px' }}>
373
+                <Button
374
+                  type="primary"
375
+                  style={{ float: 'right' }}
376
+                  loading={loading}
377
+                  onClick={handleOk}
378
+                >
379
+                  确定
380
+                </Button>
381
+              </div>
382
+            </div>
383
+          </Drawer>
384
+        </ProCard.TabPane>
385
+      </ProCard>
386
+    </PageHeaderWrapper>
387
+  );
388
+};

+ 11
- 0
src/pages/Machinery/Machinery/Edit/style.less 查看文件

@@ -0,0 +1,11 @@
1
+.listCard{
2
+  margin:0 24px;
3
+  img{
4
+    position: absolute;
5
+    right: -11px;
6
+    top: 16px;
7
+  }
8
+}
9
+.ant-drawer-body{
10
+  padding: 0;
11
+}

+ 0
- 203
src/pages/Machinery/Machinery/edit.jsx 查看文件

@@ -1,203 +0,0 @@
1
-import { useState, useEffect } from 'react';
2
-import { Form, Input, Card, DatePicker, Select, InputNumber, message, Button } from 'antd';
3
-import { history } from 'umi';
4
-import ProCard from '@ant-design/pro-card';
5
-import ExtendContent from '@/components/ExtendContent';
6
-import { UploadImage, UploadImageList } from '@/components/Upload';
7
-import Money from '@/components/Money';
8
-import { addMachinery, updateMachinery, getMachineryDetail } from '@/services/machinery';
9
-import { getMachineryTypeList } from '@/services/machineryType';
10
-import { getRegionList } from '@/services/region';
11
-import { getCooperativeList } from '@/services/cooperative';
12
-import moment from 'moment';
13
-
14
-const { Option } = Select;
15
-const formItemLayout = { labelCol: { span: 6 }, wrapperCol: { span: 14 } };
16
-
17
-const goBack = () => {
18
-  history.goBack();
19
-};
20
-const FormItem = Form.Item;
21
-export default (props) => {
22
-  const { location } = props;
23
-  const { id } = location.query;
24
-  const [form] = Form.useForm();
25
-  const [loading, setLoading] = useState(false);
26
-  const [imageList, setImageList] = useState([]);
27
-  //农机类型列表
28
-  const [machineryTypeList, setMachineryTypeList] = useState([]);
29
-  //区域列表
30
-  const [regionList, setRegionList] = useState([]);
31
-  //合作社列表
32
-  const [cooperativeList, setCooperativeList] = useState([]);
33
-
34
-  const Submit = (data) => {
35
-    var newData = { ...data }
36
-    if (data.buyDate) {
37
-      newData = { ...data, buyDate: data.buyDate.format('YYYY-MM-DD HH:mm:ss') };
38
-    }
39
-    setLoading(true);
40
-
41
-    if (id) {
42
-      updateMachinery(id, newData)
43
-        .then(() => {
44
-          setLoading(false);
45
-          message.success('数据更新成功');
46
-          goBack();
47
-        })
48
-        .catch((err) => {
49
-          setLoading(false);
50
-          message.error(err.message || err);
51
-        });
52
-    } else {
53
-      addMachinery(newData)
54
-        .then((res) => {
55
-          setLoading(false);
56
-          message.success('数据保存成功');
57
-          goBack();
58
-        })
59
-        .catch((err) => {
60
-          setLoading(false);
61
-          message.error(err.message || err);
62
-        });
63
-    }
64
-  };
65
-
66
-  const onDateChange = () => { };
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
-      targetId: id,
78
-      url: image.url,
79
-    };
80
-  };
81
-  useEffect(() => {
82
-    getMachineryTypeList({ pageSize: 999 }).then((res) => {
83
-      setMachineryTypeList(res.records);
84
-    }).catch((err) => {
85
-      console.log(err.message)
86
-    });
87
-    getRegionList({ pageSize: 999 }).then((res) => {
88
-      setRegionList(res.records);
89
-    }).catch((err) => {
90
-      console.log(err.message)
91
-    });
92
-    getCooperativeList({ pageSize: 999 }).then((res) => {
93
-      setCooperativeList(res.records);
94
-    }).catch((err) => {
95
-      console.log(err.message)
96
-    });
97
-    if (id) {
98
-      getMachineryDetail(id).then((res) => {
99
-        form.setFieldsValue({ ...res, buyDate: res.buyDate ? moment(res.buyDate, 'YYYY-MM-DD') : null });
100
-      }).catch((err) => {
101
-        console.log(err.message)
102
-      });
103
-    }
104
-  }, [id]);
105
-
106
-  return (
107
-    <Card>
108
-      <ProCard tabs={{ type: 'card' }}>
109
-        <ProCard.TabPane key={1} tab="农机编辑">
110
-          <Form {...formItemLayout} onFinish={Submit} form={form}>
111
-            <FormItem
112
-              label="农机名"
113
-              name="name"
114
-              rules={[{ required: true, message: '请输入农机名' }]}
115
-            >
116
-              <Input placeholder="请输入农机名" style={{ width: '350px' }} />
117
-            </FormItem>
118
-            <FormItem
119
-              label="农机类型"
120
-              name="typeId"
121
-              rules={[{ required: true, message: '请选择农机类型' }]}
122
-            >
123
-              <Select style={{ width: '350px' }}>
124
-                {machineryTypeList.map((item) => (
125
-                  <Option value={item.typeId} key={item.typeId}>
126
-                    {item.name}
127
-                  </Option>
128
-                ))}
129
-              </Select>
130
-            </FormItem>
131
-            <FormItem label="主图" name="thumb" rules={[{ required: true, message: '请选择主图' }]}>
132
-              <UploadImage />
133
-            </FormItem>
134
-            <FormItem label="农机banner图集" name="images">
135
-              <UploadImageList
136
-                value={imageList}
137
-                onChange={setImageList}
138
-                input={imageInput}
139
-                output={imageOutput}
140
-              />
141
-            </FormItem>
142
-            <FormItem
143
-              label="区域"
144
-              name="regionId"
145
-              rules={[{ required: true, message: '请选择区域' }]}
146
-            >
147
-              <Select style={{ width: '350px' }}>
148
-                {regionList.map((item) => (
149
-                  <Option value={item.regionId} key={item.regionId}>
150
-                    {item.name}
151
-                  </Option>
152
-                ))}
153
-              </Select>
154
-            </FormItem>
155
-            <FormItem
156
-              label="归属合作社"
157
-              name="orgId"
158
-              rules={[{ required: true, message: '请选择归属合作社' }]}
159
-            >
160
-              <Select style={{ width: '350px' }}>
161
-                {cooperativeList.map((item) => (
162
-                  <Option value={item.orgId} key={item.orgId}>
163
-                    {item.name}
164
-                  </Option>
165
-                ))}
166
-              </Select>
167
-            </FormItem>
168
-            <FormItem label="单价" name="price" rules={[{ required: true, message: '请输入价格' }]}>
169
-              <Money style={{ width: '350px' }} />
170
-            </FormItem>
171
-            <FormItem label="购买时间" name="buyDate">
172
-              <DatePicker format="YYYY-MM-DD" onChange={onDateChange} style={{ width: '350px' }} />
173
-            </FormItem>
174
-            <FormItem label="状态" name="status" rules={[{ required: true, message: '请选择' }]}>
175
-              <Select placeholder="请选择是否发布" style={{ width: '350px' }}>
176
-                <Option value={1}>发布</Option>
177
-                <Option value={0}>未发布</Option>
178
-              </Select>
179
-            </FormItem>
180
-            {id && (
181
-              <FormItem label="详细信息" colon={false}>
182
-                <ExtendContent targetType="machinery" targetId={id} onCancel={goBack} />
183
-              </FormItem>
184
-            )}
185
-            <FormItem label=" " colon={false}>
186
-              <Button type="default" onClick={goBack}>
187
-                返回
188
-              </Button>
189
-              <Button
190
-                type="primary"
191
-                loading={loading}
192
-                htmlType="submit"
193
-                style={{ marginLeft: '4em' }}
194
-              >
195
-                保存
196
-              </Button>
197
-            </FormItem>
198
-          </Form>
199
-        </ProCard.TabPane>
200
-      </ProCard>
201
-    </Card>
202
-  );
203
-};

+ 1
- 1
src/pages/Machinery/Machinery/index.jsx 查看文件

@@ -17,7 +17,7 @@ export default (props) => {
17 17
 
18 18
   const gotoEdit = (id) => {
19 19
     const queryStr = id ? `?id=${id}` : '';
20
-    history.push(`./machinery/edit.jsx${queryStr}`);
20
+    history.push(`./machinery/Edit${queryStr}`);
21 21
   };
22 22
   const handleDelete = (id) => {
23 23
     deleteMachinery(id).then(() => {

+ 9
- 7
src/pages/Machinery/Person/index.jsx 查看文件

@@ -93,6 +93,12 @@ export default (props) => {
93 93
       setLoading(false);
94 94
       return false;
95 95
     }
96
+    if (!/^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/.test(newData.idCard)) {
97
+      message.warning('请输入正确的身份证号');
98
+      setLoading(false);
99
+      return false;
100
+    }
101
+
96 102
     if (userId) {
97 103
       updateUser(userId, newData).then(() => {
98 104
         setLoading(false);
@@ -100,6 +106,7 @@ export default (props) => {
100 106
         onCancel();
101 107
         actionRef.current.reload();
102 108
       }).catch((err) => {
109
+        setLoading(false);
103 110
         console.log(err.message)
104 111
       });
105 112
     } else {
@@ -115,6 +122,7 @@ export default (props) => {
115 122
           message.error(err.message || err);
116 123
         });
117 124
     }
125
+
118 126
   };
119 127
   //表单点击取消按钮
120 128
   const onCancel = () => {
@@ -286,12 +294,6 @@ export default (props) => {
286 294
       key: 'phone',
287 295
       width: 120,
288 296
     },
289
-    {
290
-      title: '邮箱',
291
-      dataIndex: 'email',
292
-      key: 'email',
293
-      search: false,
294
-    },
295 297
     {
296 298
       title: '注册时间',
297 299
       dataIndex: 'createDate',
@@ -399,7 +401,7 @@ export default (props) => {
399 401
           <FormItem label="手机号" name="phone" rules={[{ required: true, message: '请输入' }]}>
400 402
             <Input maxLength="11" placeholder="请输入" />
401 403
           </FormItem>
402
-          <FormItem label="邮箱" name="email" rules={[{ required: true, message: '请输入' }]}>
404
+          <FormItem label="身份证" name="idCard" rules={[{ required: true, message: '请输入' }]}>
403 405
             <Input placeholder="请输入" />
404 406
           </FormItem>
405 407
           <FormItem label="登录账号" name="loginName" rules={[{ required: true, message: '请输入登录账号' }]}>

+ 19
- 12
src/pages/OrderManage/dispatch.jsx 查看文件

@@ -1,5 +1,5 @@
1 1
 import React, { useState, useEffect } from 'react';
2
-import { Card, Form, Button, Select, message } from 'antd';
2
+import { Card, Form, Button, Select, message, Modal } from 'antd';
3 3
 import ProCard from '@ant-design/pro-card';
4 4
 import { getOrderDetail } from '@/services/order'
5 5
 import { getMachineryList, getduty } from '@/services/machinery';
@@ -46,7 +46,7 @@ export default (props) => {
46 46
   const changeMachinery = (e) => {
47 47
     getduty(e, { date: dispatch.appointmentDate.substr(0, 10) }).then((res => {
48 48
       if (res.length != 0) {
49
-        message.info('该农机天已有' + res.length + '条调度信息');
49
+        message.info('该农机天已有' + res.length + '条调度信息');
50 50
       }
51 51
       setDispatch({ ...dispatch, machineryId: e })
52 52
     })).catch((err) => {
@@ -57,15 +57,22 @@ export default (props) => {
57 57
     setDispatch({ ...dispatch, workerId: e })
58 58
   }
59 59
   const onCancel = () => {
60
-    setCancelLoading(true)
61
-    cancelDispatch(dispatchId).then(() => {
62
-      setCancelLoading(false)
63
-      setDispatchId()
64
-      setDispatch({ ...dispatch, machineryId: null, workerId: null })
65
-      message.success('取消成功');
66
-    }).catch((err) => {
67
-      setCancelLoading(false);
68
-      message.error(err.message || err);
60
+    Modal.confirm({
61
+      title: '确认取消?',
62
+      okText: '确认',
63
+      cancelText: '取消',
64
+      onOk() {
65
+        setCancelLoading(true)
66
+        cancelDispatch(dispatchId).then(() => {
67
+          setCancelLoading(false)
68
+          setDispatchId()
69
+          setDispatch({ ...dispatch, machineryId: null, workerId: null })
70
+          message.success('取消成功');
71
+        }).catch((err) => {
72
+          setCancelLoading(false);
73
+          message.error(err.message || err);
74
+        });
75
+      },
69 76
     });
70 77
   }
71 78
   useEffect(() => {
@@ -144,7 +151,7 @@ export default (props) => {
144 151
               {
145 152
                 dispatchId ?
146 153
                   <Button loading={cancelLoading} onClick={onCancel} style={{ marginLeft: '4em' }}>
147
-                    取消
154
+                    取消调度
148 155
                   </Button> :
149 156
                   <Button type="primary" loading={loading} onClick={submit} style={{ marginLeft: '4em' }}>
150 157
                     保存

+ 1
- 0
src/pages/SystemManagement/Region/index.jsx 查看文件

@@ -28,6 +28,7 @@ export default (props) => {
28 28
         onCancel();
29 29
         actionRef.current.reload();
30 30
       }).catch((err) => {
31
+        setLoading(false);
31 32
         console.log(err.message)
32 33
       });
33 34
     } else {

+ 2
- 2
src/pages/Welcome.jsx 查看文件

@@ -123,7 +123,7 @@ const Welcome = () => {
123 123
                   <div style={{ height: '448px', width: '100%' }}>
124 124
                     {dispatchList.map(item =>
125 125
                       <div style={{ height: '60px' }} key={item.orderId} onClick={() => goDispatch(item)} >
126
-                        {item.personName + ' 于 ' + item.createDate + ' 下了一单请您尽快处理!'}
126
+                        {(item.personName || item.phone) + ' 于 ' + item.createDate + ' 下了一单请您尽快处理!'}
127 127
                       </div>
128 128
                     )}
129 129
                   </div> :
@@ -141,7 +141,7 @@ const Welcome = () => {
141 141
                   >
142 142
                     {dispatchList.map((item) => (
143 143
                       <SwiperSlide key={item.orderId} onClick={() => goDispatch(item)}>
144
-                        {item.personName + ' 于 ' + item.createDate + ' 下了一单请您尽快处理!'}
144
+                        {(item.personName || item.phone) + ' 于 ' + item.createDate + ' 下了一单请您尽快处理!'}
145 145
                       </SwiperSlide>
146 146
                     ))}
147 147
                   </Swiper>

+ 86
- 0
src/pages/customer/index.jsx 查看文件

@@ -0,0 +1,86 @@
1
+import React, { useState, useRef } from 'react';
2
+import { DatePicker } from 'antd';
3
+import { PageHeaderWrapper } from '@ant-design/pro-layout';
4
+import moment from 'moment';
5
+import PageTable from '@/components/PageTable';
6
+import { getUserList } from '@/services/user'
7
+
8
+const formatterTime = (val) => {
9
+  return val ? moment(val).format('YYYY-MM-DD HH:mm') : '';
10
+};
11
+const { RangePicker } = DatePicker;
12
+
13
+export default (props) => {
14
+  const [start, setStartDate] = useState()
15
+  const [end, setEndDate] = useState()
16
+
17
+  const handelChange = (date, dateStrings) => {
18
+    setStartDate(dateStrings[0])
19
+    setEndDate(dateStrings[1])
20
+  }
21
+  const ref = useRef();
22
+  const Reset = () => {
23
+    setStartDate()
24
+    setEndDate()
25
+    ref.current.reload();
26
+  }
27
+
28
+  const columns = [
29
+    {
30
+      title: '姓名',
31
+      dataIndex: 'name',
32
+      key: 'name',
33
+    },
34
+    {
35
+      title: '头像',
36
+      dataIndex: 'avatar',
37
+      key: 'avatar',
38
+      search: false
39
+    },
40
+    {
41
+      title: '手机号',
42
+      dataIndex: 'phone',
43
+      key: 'phone',
44
+    },
45
+    {
46
+      title: '身份',
47
+      dataIndex: 'type',
48
+      key: 'type',
49
+      dataIndex: 'position',
50
+      render: (_, record) => {
51
+        return record.position === 'farmer'
52
+          ? '农户'
53
+          : record.position === 'worker'
54
+            ? '农机手' : ''
55
+      },
56
+      valueType: 'select',
57
+      valueEnum: {
58
+        'farmer': { text: '农户' },
59
+        'worker': { text: '农机手' },
60
+      },
61
+    },
62
+
63
+    {
64
+      title: '注册时间',
65
+      dataIndex: 'createDate',
66
+      key: 'createDate',
67
+      render: (t, render) => formatterTime(render.createDate),
68
+      renderFormItem: (_, record) => <RangePicker placeholder={['开始日期', '结束日期']} format='YYYY-MM-DD' onChange={handelChange} />
69
+    },
70
+  ];
71
+
72
+  return (
73
+    <PageHeaderWrapper>
74
+      <PageTable
75
+        actionRef={ref}
76
+        request={getUserList}
77
+        // expfunc={exportPersonList}
78
+        columns={columns}
79
+        rowKey="userId"
80
+        params={{ start, end }}
81
+        onReset={Reset}
82
+        options={false}
83
+      />
84
+    </PageHeaderWrapper>
85
+  );
86
+};

+ 32
- 0
src/services/device.js 查看文件

@@ -0,0 +1,32 @@
1
+import request from '@/utils/request';
2
+
3
+/**
4
+ * 设备列表
5
+ * @param {*} params
6
+ * @returns
7
+ */
8
+export const getDeviceList = (params) => request('/hatc-device', { params });
9
+
10
+/**
11
+ * 通过设备号查询相关设备列表  选好了点击绑定时根据当前选择的设备id查询
12
+ * 同终端列表
13
+ * @param {*} params
14
+ * @returns
15
+ */
16
+export const getTerminalDeviceList = (id) => request(`/hatc-device/${id}`);
17
+
18
+/**
19
+ * 设备相关信息
20
+ * 查询农机Id详情
21
+ * @param {*} params
22
+ * @returns
23
+ */
24
+export const getdeviceDetail = (id) => request(`/machinery/${id}/device`);
25
+
26
+//  新增修改设备信息
27
+/**
28
+ * 新增设备信息
29
+ * @param {*} data
30
+ * @returns
31
+ */
32
+export const addDevice = (data) => request('/device', { method: 'post', data });