|
@@ -1,11 +1,11 @@
|
1
|
|
-import React, { useState } from 'react';
|
2
|
|
-import { Card, Form, Input, Button, Select } from 'antd';
|
|
1
|
+import React, { useState, useEffect } from 'react';
|
|
2
|
+import { Card, Form, Input, Button, Select, message } from 'antd';
|
3
|
3
|
import ProCard from '@ant-design/pro-card';
|
4
|
|
-
|
|
4
|
+import { getOrderDetail } from '@/services/order'
|
5
|
5
|
import { getMachineryList } from '@/services/machinery';
|
6
|
6
|
import { history } from 'umi';
|
7
|
7
|
import { getUserList } from '@/services/user';
|
8
|
|
-import { useEffect } from 'react';
|
|
8
|
+import { addDispatch } from '@/services/dispatch';
|
9
|
9
|
|
10
|
10
|
const FormItem = Form.Item;
|
11
|
11
|
const formItemLayout = { labelCol: { span: 6 }, wrapperCol: { span: 14 } };
|
|
@@ -21,22 +21,39 @@ export default (props) => {
|
21
|
21
|
const [machineryList, setMachineryList] = useState([]);
|
22
|
22
|
const [userList, setUserList] = useState([])
|
23
|
23
|
const submit = () => {
|
24
|
|
- console.log(order)
|
|
24
|
+ if (!order.machineryId) {
|
|
25
|
+ message.warning('请选择调度的农机');
|
|
26
|
+ return
|
|
27
|
+ }
|
|
28
|
+ if (!order.workerId) {
|
|
29
|
+ message.warning('请选择农机手');
|
|
30
|
+ return
|
|
31
|
+ }
|
|
32
|
+ setLoading(true)
|
|
33
|
+ addDispatch(order).then(res => {
|
|
34
|
+ message.success('调度成功');
|
|
35
|
+ setLoading(false);
|
|
36
|
+ goBack()
|
|
37
|
+ }).catch((err) => {
|
|
38
|
+ setLoading(false);
|
|
39
|
+ message.error(err.message || err);
|
|
40
|
+ });
|
25
|
41
|
};
|
26
|
42
|
const changeMachinery = (e) => {
|
27
|
43
|
setOrder({ ...order, machineryId: e })
|
28
|
44
|
}
|
29
|
45
|
const changeUser = (e) => {
|
30
|
|
- setOrder({ ...order, userId: e })
|
|
46
|
+ setOrder({ ...order, workerId: e })
|
31
|
47
|
}
|
32
|
48
|
useEffect(() => {
|
33
|
|
- console.log(id)
|
34
|
|
-
|
35
|
|
- getMachineryList({ pageSize: 999 }).then((res) => {
|
36
|
|
- setMachineryList(res.records)
|
37
|
|
- })
|
38
|
|
- getUserList().then(res => {
|
39
|
|
- setUserList(res.records)
|
|
49
|
+ getOrderDetail(id).then((res) => {
|
|
50
|
+ setOrder(res)
|
|
51
|
+ getMachineryList({ orgId: res.orgId, pageSize: 999 }).then((res2) => {
|
|
52
|
+ setMachineryList(res2.records)
|
|
53
|
+ })
|
|
54
|
+ getUserList({ org_id: res.orgId, pageSize: 999 }).then(res3 => {
|
|
55
|
+ setUserList(res3.records)
|
|
56
|
+ })
|
40
|
57
|
})
|
41
|
58
|
}, [])
|
42
|
59
|
return (
|
|
@@ -45,7 +62,7 @@ export default (props) => {
|
45
|
62
|
<ProCard.TabPane key={1} tab="订单调度">
|
46
|
63
|
<Form {...formItemLayout}>
|
47
|
64
|
<FormItem label="客户姓名">
|
48
|
|
- {order?.name}
|
|
65
|
+ {order?.personName}
|
49
|
66
|
</FormItem>
|
50
|
67
|
<FormItem label="联系电话">
|
51
|
68
|
{order?.phone}
|
|
@@ -54,7 +71,10 @@ export default (props) => {
|
54
|
71
|
{order?.address}
|
55
|
72
|
</FormItem>
|
56
|
73
|
<FormItem label="预约时间">
|
57
|
|
- {order?.atime}
|
|
74
|
+ {order?.appointmentDate}
|
|
75
|
+ </FormItem>
|
|
76
|
+ <FormItem label="机构名">
|
|
77
|
+ {order?.orgName}
|
58
|
78
|
</FormItem>
|
59
|
79
|
<FormItem label="农机类型">
|
60
|
80
|
{order?.typeName}
|
|
@@ -69,7 +89,7 @@ export default (props) => {
|
69
|
89
|
</Select>
|
70
|
90
|
</FormItem>
|
71
|
91
|
<FormItem label="农机手">
|
72
|
|
- <Select placeholder="请选择" value={order?.userId} onChange={changeUser} allowClear style={{ width: '350px' }}>
|
|
92
|
+ <Select placeholder="请选择" value={order?.workerId} onChange={changeUser} allowClear style={{ width: '350px' }}>
|
73
|
93
|
{userList.map((item) => (
|
74
|
94
|
<Option value={item.userId} key={item.userId}>
|
75
|
95
|
{item.userName}
|