李志伟 3 years ago
parent
commit
e4aff441ae

+ 52
- 0
src/components/MachinetySelect/index.jsx View File

@@ -0,0 +1,52 @@
1
+import { useEffect, useState } from 'react';
2
+import { Select } from 'antd'
3
+import { getMachineryList, getMachineryDetail } from '@/services/machinery'
4
+
5
+const Option = Select.Option;
6
+export default (props) => {
7
+  const { value, onChange, ...otherProps } = props;
8
+
9
+  const [list, setList] = useState([])
10
+
11
+  const searchData = (val) => {
12
+    getMachineryList({ name: val, pageSize: 9999 }).then((res) => {
13
+      setList(res.records || [])
14
+    })
15
+  }
16
+
17
+  const handleSearch = (text) => {
18
+    if (text) {
19
+      searchData(text)
20
+    }
21
+  }
22
+
23
+  useEffect(() => {
24
+    if (value) {
25
+      getMachineryDetail(value).then((res) => {
26
+        setList([res])
27
+      })
28
+    }
29
+  }, [value])
30
+
31
+  return (
32
+    <Select
33
+      showSearch
34
+      value={value}
35
+      defaultActiveFirstOption={false}
36
+      showArrow={false}
37
+      filterOption={false}
38
+      onSearch={handleSearch}
39
+      onChange={onChange}
40
+      notFoundContent={null}
41
+      {...otherProps}
42
+    >
43
+      {
44
+        list.map((item) => {
45
+          return (
46
+            <Option key={item.machineryId} value={item.machineryId}>{item.name}</Option>
47
+          )
48
+        })
49
+      }
50
+    </Select>
51
+  )
52
+}

+ 52
- 0
src/components/OrgSelect/index.jsx View File

@@ -0,0 +1,52 @@
1
+import { useEffect, useState } from 'react';
2
+import { Select } from 'antd'
3
+import { getCooperativeList, getCooperativeDetail } from '@/services/cooperative'
4
+
5
+const Option = Select.Option;
6
+export default (props) => {
7
+  const { value, onChange, ...otherProps } = props;
8
+
9
+  const [list, setList] = useState([])
10
+
11
+  const searchData = (val) => {
12
+    getCooperativeList({ name: val, pageSize: 9999 }).then((res) => {
13
+      setList(res.records || [])
14
+    })
15
+  }
16
+
17
+  const handleSearch = (text) => {
18
+    if (text) {
19
+      searchData(text)
20
+    }
21
+  }
22
+
23
+  useEffect(() => {
24
+    if (value) {
25
+      getCooperativeDetail(value).then((res) => {
26
+        setList([res])
27
+      })
28
+    }
29
+  }, [value])
30
+
31
+  return (
32
+    <Select
33
+      showSearch
34
+      value={value}
35
+      defaultActiveFirstOption={false}
36
+      showArrow={false}
37
+      filterOption={false}
38
+      onSearch={handleSearch}
39
+      onChange={onChange}
40
+      notFoundContent={null}
41
+      {...otherProps}
42
+    >
43
+      {
44
+        list.map((item) => {
45
+          return (
46
+            <Option key={item.orgId} value={item.orgId}>{item.name}</Option>
47
+          )
48
+        })
49
+      }
50
+    </Select>
51
+  )
52
+}

+ 52
- 0
src/components/TypeSelect/index.jsx View File

@@ -0,0 +1,52 @@
1
+import { useEffect, useState } from 'react';
2
+import { Select } from 'antd'
3
+import { getMachineryTypeList, getMachineryTypeDetail } from '@/services/machineryType'
4
+
5
+const Option = Select.Option;
6
+export default (props) => {
7
+  const { value, onChange, ...otherProps } = props;
8
+
9
+  const [list, setList] = useState([])
10
+
11
+  const searchData = (val) => {
12
+    getMachineryTypeList({ hotelName: val, pageSize: 9999 }).then((res) => {
13
+      setList(res.records || [])
14
+    })
15
+  }
16
+
17
+  const handleSearch = (text) => {
18
+    if (text) {
19
+      searchData(text)
20
+    }
21
+  }
22
+
23
+  useEffect(() => {
24
+    if (value) {
25
+      getMachineryTypeDetail(value).then((res) => {
26
+        setList([res])
27
+      })
28
+    }
29
+  }, [value])
30
+
31
+  return (
32
+    <Select
33
+      showSearch
34
+      value={value}
35
+      defaultActiveFirstOption={false}
36
+      showArrow={false}
37
+      filterOption={false}
38
+      onSearch={handleSearch}
39
+      onChange={onChange}
40
+      notFoundContent={null}
41
+      {...otherProps}
42
+    >
43
+      {
44
+        list.map((item) => {
45
+          return (
46
+            <Option key={item.typeId} value={item.typeId}>{item.name}</Option>
47
+          )
48
+        })
49
+      }
50
+    </Select>
51
+  )
52
+}

+ 2
- 1
src/pages/OrderManage/dispatch.jsx View File

@@ -1,5 +1,5 @@
1 1
 import React, { useState, useEffect } from 'react';
2
-import { Card, Form, Input, Button, Select, message } from 'antd';
2
+import { Card, Form, 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, getduty } from '@/services/machinery';
@@ -69,6 +69,7 @@ export default (props) => {
69 69
     });
70 70
   }
71 71
   useEffect(() => {
72
+
72 73
     getOrderDetail(id).then((res) => {
73 74
       res.machineryId = null
74 75
       res.typeId = res.machineryType

+ 84
- 8
src/pages/OrderManage/index.jsx View File

@@ -1,37 +1,100 @@
1 1
 import { history } from 'umi';
2
-import { Button } from 'antd';
3
-import { getDispatchList } from '@/services/dispatch';
2
+import { Button, DatePicker } from 'antd';
3
+import { useState, useRef } from 'react';
4 4
 import { PageHeaderWrapper } from '@ant-design/pro-layout';
5 5
 import moment from 'moment';
6 6
 import PageTable from '@/components/PageTable';
7
+import OrgSelect from '@/components/OrgSelect';
8
+import MachinetySelect from '@/components/MachinetySelect';
9
+import TypeSelect from '@/components/TypeSelect';
10
+import { getDispatchList } from '@/services/dispatch';
7 11
 
12
+const { RangePicker } = DatePicker;
8 13
 const formatterTime = (val) => {
9
-  return val ? moment(val).format('YYYY-MM-DD HH:mm:ss') : '';
14
+  return val ? moment(val).format('YYYY-MM-DD') : '-';
10 15
 };
11 16
 const getDispatch = (val) => {
12
-  history.push(`./dispatch.jsx?id=${val}`);
17
+  history.push(`./dispatch.jsx?id=${val.orderId}&&did=${val.dispatch || null}`);
13 18
 }
19
+
14 20
 export default (props) => {
21
+  const [startDate, setStartDate] = useState()
22
+  const [endDate, setEndDate] = useState()
23
+  const handelChange = (date, dateStrings) => {
24
+    setStartDate(dateStrings[0])
25
+    setEndDate(dateStrings[1])
26
+  }
27
+
28
+  const ref = useRef();
29
+
30
+  const Reset = () => {
31
+    setStartDate()
32
+    setEndDate()
33
+    ref.current.reload();
34
+  }
15 35
   const columns = [
36
+    {
37
+      title: '机构',
38
+      dataIndex: 'orgId',
39
+      key: 'orgId',
40
+      hideInTable: true,
41
+      renderFormItem: (item, field, form) => {
42
+        return <OrgSelect />
43
+      }
44
+    },
45
+    {
46
+      title: '农机',
47
+      dataIndex: 'machineryId',
48
+      key: 'machineryId',
49
+      hideInTable: true,
50
+      renderFormItem: (item, field, form) => {
51
+        return (
52
+          <MachinetySelect />
53
+        )
54
+      }
55
+    },
56
+
16 57
     {
17 58
       title: '机构名',
18 59
       dataIndex: 'orgName',
19 60
       key: 'orgName',
61
+      search: false
20 62
     },
21 63
     {
22 64
       title: '农机名',
23 65
       dataIndex: 'machineryName',
24 66
       key: 'machineryName',
67
+      search: false
25 68
     },
26 69
     {
27 70
       title: '农机型号',
28 71
       dataIndex: 'typeName',
29 72
       key: 'typeName',
73
+      search: false
74
+    },
75
+    {
76
+      title: '农机型号',
77
+      dataIndex: 'typeId',
78
+      key: 'typeId',
79
+      hideInTable: true,
80
+      renderFormItem: (item, field, form) => {
81
+        return (
82
+          <TypeSelect />
83
+        )
84
+      }
85
+    },
86
+    {
87
+      title: '下单人手机',
88
+      dataIndex: 'phone',
89
+      key: 'phone',
90
+      labelWidth: 'auto'
30 91
     },
31 92
     {
32 93
       title: '需求时间',
33 94
       dataIndex: 'appointmentDate',
34 95
       key: 'appointmentDate',
96
+      render: (t) => formatterTime(t),
97
+      renderFormItem: (_, record) => <RangePicker placeholder={['开始日期', '结束日期']} format='YYYY-MM-DD' onChange={handelChange} />
35 98
     },
36 99
     {
37 100
       title: '作业面积',
@@ -54,6 +117,7 @@ export default (props) => {
54 117
       render: (t) => formatterTime(t),
55 118
       width: 200,
56 119
     },
120
+
57 121
     {
58 122
       title: '调度状态',
59 123
       dataIndex: 'dispatchStatus',
@@ -64,6 +128,18 @@ export default (props) => {
64 128
         0: { text: '待调度' },
65 129
         1: { text: '已调度' }
66 130
       },
131
+      search: false
132
+    },
133
+    {
134
+      title: '状态',
135
+      dataIndex: 'status',
136
+      key: 'status',
137
+      hideInTable: true,
138
+      valueType: 'select',
139
+      valueEnum: {
140
+        0: { text: '待调度' },
141
+        1: { text: '已调度' }
142
+      },
67 143
     },
68 144
     {
69 145
       title: '操作',
@@ -73,24 +149,24 @@ export default (props) => {
73 149
           style={{ padding: 0 }}
74 150
           type="link"
75 151
           key={1}
76
-          onClick={() => getDispatch(record.orderId)}
152
+          onClick={() => getDispatch(record)}
77 153
         >
78 154
           调度
79 155
         </Button>
80 156
       ],
81 157
     },
82
-    //操作如果是需求多台机器则需调度 状态为待确认时 状态栏显示调度按钮跳到调度页面
83
-    // 如果是申请退款 则出现处理按钮 显示需求时间 如果未到则退款并且改变已分配农机手状态和农机状态
84
-    // 如果已经服务过了 则可以打电话给农户咨询具体情况看是否退部分款项
85 158
   ];
86 159
 
87 160
   return (
88 161
     <PageHeaderWrapper>
89 162
       <PageTable
163
+        actionRef={ref}
90 164
         request={getDispatchList}
91 165
         // expfunc={exportPersonList}
92 166
         columns={columns}
93 167
         rowKey="orderId"
168
+        params={{ startDate, endDate }}
169
+        onReset={Reset}
94 170
         options={false}
95 171
         scroll={{ x: 1000 }}
96 172
       />