|
@@ -1,89 +1,136 @@
|
1
|
|
-import React, { useState, useEffect, useRef } from 'react';
|
2
|
|
-import { Button, Popconfirm, Modal, Form, Input, message, Descriptions } from 'antd';
|
|
1
|
+import React, { useState, useRef, useMemo } from 'react';
|
|
2
|
+import { Button, Card, Table, message, Descriptions, Col, Row } from 'antd';
|
3
|
3
|
import { PageHeaderWrapper } from '@ant-design/pro-layout';
|
4
|
|
-import PageTable from '@/components/PageTable';
|
|
4
|
+import { getDeviceJobByOrg, exportDeviceJobByOrg } from '@/services/job';
|
|
5
|
+import Search from './components/search';
|
5
|
6
|
|
6
|
7
|
export default (props) => {
|
7
|
|
- const formItemLayout = { labelCol: { span: 6 }, wrapperCol: { span: 14 } };
|
8
|
|
- const [form] = Form.useForm();
|
9
|
|
- const [editModal, setEditModal] = useState(false);
|
10
|
|
- const [loading, setLoading] = useState(false);
|
11
|
|
- const [regionId, setRegionId] = useState();
|
12
|
|
- const actionRef = useRef();
|
13
|
|
-
|
14
|
|
- const exports = () => [
|
15
|
|
- <Button key="add" type="primary">
|
16
|
|
- 导出
|
17
|
|
- </Button>,
|
18
|
|
- ];
|
19
|
|
-
|
20
|
8
|
const columns = [
|
21
|
9
|
{
|
22
|
|
- title: '合作社名称',
|
23
|
|
- dataIndex: 'name',
|
24
|
|
- key: 'name',
|
|
10
|
+ title: '合作社',
|
|
11
|
+ dataIndex: 'orgName',
|
|
12
|
+ key: 'orgName',
|
25
|
13
|
},
|
26
|
14
|
{
|
27
|
15
|
title: '设备编号',
|
28
|
|
- dataIndex: 'createDate',
|
29
|
|
- key: 'createDate',
|
|
16
|
+ dataIndex: 'deviceNo',
|
|
17
|
+ key: 'deviceNo',
|
30
|
18
|
width: 340,
|
31
|
19
|
},
|
32
|
20
|
{
|
33
|
21
|
title: '设备类型',
|
34
|
|
- dataIndex: 'status',
|
35
|
|
- key: 'status',
|
|
22
|
+ dataIndex: 'deviceKind',
|
|
23
|
+ key: 'deviceKind',
|
|
24
|
+ render: (t) => (t === 'shensong' ? '深松' : t === 'feifang' ? '飞防' : '-'),
|
36
|
25
|
},
|
37
|
26
|
{
|
38
|
27
|
title: '作业面积(亩)',
|
39
|
|
- dataIndex: 'status',
|
40
|
|
- key: 'status',
|
41
|
|
- search: false,
|
|
28
|
+ dataIndex: 'jobArea',
|
|
29
|
+ key: 'jobArea',
|
42
|
30
|
},
|
43
|
31
|
{
|
44
|
32
|
title: '作业时间',
|
45
|
|
- dataIndex: 'status',
|
46
|
|
- key: 'status',
|
47
|
|
- search: false,
|
|
33
|
+ dataIndex: 'jobDate',
|
|
34
|
+ key: 'jobDate',
|
48
|
35
|
},
|
49
|
36
|
{
|
50
|
37
|
title: '绑定农机',
|
51
|
|
- dataIndex: 'status',
|
52
|
|
- key: 'status',
|
|
38
|
+ dataIndex: 'machineryName',
|
|
39
|
+ key: 'machineryName',
|
53
|
40
|
search: false,
|
54
|
41
|
},
|
55
|
|
- {
|
56
|
|
- title: '时间选择',
|
57
|
|
- dataIndex: 'created_at',
|
58
|
|
- valueType: 'dateRange',
|
59
|
|
- hideInTable: true,
|
60
|
|
- search: {
|
61
|
|
- transform: (value) => {
|
62
|
|
- return {
|
63
|
|
- startTime: value[0],
|
64
|
|
- endTime: value[1],
|
65
|
|
- };
|
66
|
|
- },
|
67
|
|
- },
|
68
|
|
- },
|
69
|
42
|
];
|
70
|
43
|
|
|
44
|
+ const [loading, setLoading] = useState(false);
|
|
45
|
+ const [list, setList] = useState([]);
|
|
46
|
+ const [total, setTotal] = useState(0);
|
|
47
|
+ const [page, setPage] = useState({ current: 1, pageSize: 10, total: 0 });
|
|
48
|
+ const searchValue = useRef({});
|
|
49
|
+
|
|
50
|
+ const pagination = useMemo(
|
|
51
|
+ () => ({
|
|
52
|
+ ...page,
|
|
53
|
+ showTotal: (total, range) => `总计 ${total} 条`,
|
|
54
|
+ onChange: (page, pageSize) => {
|
|
55
|
+ setPage({
|
|
56
|
+ current: page,
|
|
57
|
+ pageSize,
|
|
58
|
+ total: 0,
|
|
59
|
+ });
|
|
60
|
+
|
|
61
|
+ queryData({
|
|
62
|
+ ...searchValue.current,
|
|
63
|
+ pageNum: page,
|
|
64
|
+ pageSize,
|
|
65
|
+ });
|
|
66
|
+ },
|
|
67
|
+ }),
|
|
68
|
+ [page],
|
|
69
|
+ );
|
|
70
|
+
|
|
71
|
+ const queryData = (params) => {
|
|
72
|
+ setLoading(true);
|
|
73
|
+ getDeviceJobByOrg(params)
|
|
74
|
+ .then((res) => {
|
|
75
|
+ setLoading(false);
|
|
76
|
+ const { list: dtList, totalArea } = res;
|
|
77
|
+ setList(dtList.records || []);
|
|
78
|
+ setTotal(totalArea || 0);
|
|
79
|
+ setPage({
|
|
80
|
+ current: dtList.current,
|
|
81
|
+ pageSize: dtList.size,
|
|
82
|
+ total: dtList.total,
|
|
83
|
+ });
|
|
84
|
+ })
|
|
85
|
+ .catch((err) => {
|
|
86
|
+ console.error(err);
|
|
87
|
+ setLoading(false);
|
|
88
|
+ });
|
|
89
|
+ };
|
|
90
|
+
|
|
91
|
+ const exportData = () => {
|
|
92
|
+ setLoading(true);
|
|
93
|
+ exportDeviceJobByOrg(searchValue.current)
|
|
94
|
+ .then(() => setLoading(false))
|
|
95
|
+ .catch((err) => {
|
|
96
|
+ console.error(err);
|
|
97
|
+ setLoading(false);
|
|
98
|
+ });
|
|
99
|
+ };
|
|
100
|
+
|
|
101
|
+ const onSearch = (params = {}) => {
|
|
102
|
+ searchValue.current = params;
|
|
103
|
+ queryData({
|
|
104
|
+ ...params,
|
|
105
|
+ pageNum: 1,
|
|
106
|
+ pageSize: page.pageSize,
|
|
107
|
+ });
|
|
108
|
+ };
|
|
109
|
+
|
71
|
110
|
return (
|
72
|
|
- <PageHeaderWrapper
|
73
|
|
- content={
|
74
|
|
- <Descriptions>
|
75
|
|
- <Descriptions.Item label='总作业面积:'>亩</Descriptions.Item>
|
76
|
|
- </Descriptions>
|
77
|
|
- }
|
78
|
|
- >
|
79
|
|
- <PageTable
|
80
|
|
- columns={columns}
|
81
|
|
- actionRef={actionRef}
|
82
|
|
- options={false}
|
83
|
|
- toolBarRender={exports}
|
84
|
|
- // toolBarRender={actions}
|
85
|
|
- scroll={{ x: 1000 }}
|
86
|
|
- />
|
|
111
|
+ <PageHeaderWrapper>
|
|
112
|
+ <div style={{ marginBottom: '16px' }}>
|
|
113
|
+ <Search onFinish={onSearch} />
|
|
114
|
+ </div>
|
|
115
|
+ <Card loading={loading}>
|
|
116
|
+ <Row>
|
|
117
|
+ <Col span={12}>
|
|
118
|
+ <div style={{ textAlign: 'left', marginBottom: '16px', fontSize: '16px' }}>
|
|
119
|
+ <span>总作业面积 </span>
|
|
120
|
+ <strong>{total}</strong>
|
|
121
|
+ <span> 亩</span>
|
|
122
|
+ </div>
|
|
123
|
+ </Col>
|
|
124
|
+ <Col span={12}>
|
|
125
|
+ <div style={{ textAlign: 'right', marginBottom: '16px' }}>
|
|
126
|
+ <Button type="primary" onClick={exportData}>
|
|
127
|
+ 导出
|
|
128
|
+ </Button>
|
|
129
|
+ </div>
|
|
130
|
+ </Col>
|
|
131
|
+ </Row>
|
|
132
|
+ <Table rowKey="jobNo" columns={columns} dataSource={list} pagination={pagination} />
|
|
133
|
+ </Card>
|
87
|
134
|
</PageHeaderWrapper>
|
88
|
135
|
);
|
89
|
136
|
};
|