Yansen 2 лет назад
Родитель
Сommit
f2d6c59ece

+ 21
- 22
src/pages/Machinery/JobList/index.jsx Просмотреть файл

@@ -1,49 +1,47 @@
1 1
 import React, { useState, useEffect, useRef } from 'react';
2
-import { Button, Popconfirm, Modal, Form, Input, message } from 'antd';
3 2
 import { PageHeaderWrapper } from '@ant-design/pro-layout';
4 3
 import PageTable from '@/components/PageTable';
4
+import { getDeviceJobList } from '@/services/job';
5 5
 
6 6
 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 7
   const actionRef = useRef();
13 8
 
14 9
   const columns = [
15 10
     {
16
-      title: '名称',
17
-      dataIndex: 'name',
18
-      key: 'name',
11
+      title: '设备类型',
12
+      dataIndex: 'deviceKind',
13
+      key: 'deviceKind',
14
+      valueEnum: {
15
+        shensong: {
16
+          text: '深松',
17
+        },
18
+        feifang: {
19
+          text: '飞防',
20
+        },
21
+      },
19 22
     },
20 23
     {
21 24
       title: '设备编号',
22
-      dataIndex: 'createDate',
23
-      key: 'createDate',
25
+      dataIndex: 'deviceNo',
26
+      key: 'deviceNo',
24 27
       width: 340,
25 28
     },
26
-    {
27
-      title: '设备类型',
28
-      dataIndex: 'status',
29
-      key: 'status',
30
-    },
31 29
     {
32 30
       title: '作业面积(亩)',
33
-      dataIndex: 'status',
34
-      key: 'status',
31
+      dataIndex: 'jobArea',
32
+      key: 'jobArea',
35 33
       search: false,
36 34
     },
37 35
     {
38 36
       title: '作业时间',
39
-      dataIndex: 'status',
40
-      key: 'status',
37
+      dataIndex: 'jobDate',
38
+      key: 'jobDate',
41 39
       search: false,
42 40
     },
43 41
     {
44 42
       title: '绑定农机',
45
-      dataIndex: 'status',
46
-      key: 'status',
43
+      dataIndex: 'machineryName',
44
+      key: 'machineryName',
47 45
       search: false,
48 46
     },
49 47
   ];
@@ -54,6 +52,7 @@ export default (props) => {
54 52
         columns={columns}
55 53
         actionRef={actionRef}
56 54
         options={false}
55
+        request={getDeviceJobList}
57 56
         // toolBarRender={actions}
58 57
         scroll={{ x: 1000 }}
59 58
       />

+ 34
- 0
src/pages/Machinery/OperationStatistics/components/search/Form.jsx Просмотреть файл

@@ -0,0 +1,34 @@
1
+import React from 'react';
2
+import { Button, Form, Col, Row } from 'antd';
3
+
4
+export function FormItem(props) {
5
+  return (
6
+    <Col span={6}>
7
+      <Form.Item {...props}>{props.children}</Form.Item>
8
+    </Col>
9
+  );
10
+}
11
+
12
+export default (props) => {
13
+  const { initialValues, onFinish } = props;
14
+
15
+  const [form] = Form.useForm();
16
+
17
+  const onReset = () => {
18
+    form.resetFields();
19
+  };
20
+
21
+  return (
22
+    <Form form={form} initialValues={initialValues} onFinish={onFinish}>
23
+      <Row gutter={24}>
24
+        {props.children}
25
+        <Col span={6} offset={18} style={{ textAlign: 'right' }}>
26
+          <Button onClick={onReset}>重置</Button>
27
+          <Button type="primary" htmlType="submit" style={{ margin: '0 8px' }}>
28
+            查询
29
+          </Button>
30
+        </Col>
31
+      </Row>
32
+    </Form>
33
+  );
34
+};

+ 60
- 0
src/pages/Machinery/OperationStatistics/components/search/index.jsx Просмотреть файл

@@ -0,0 +1,60 @@
1
+import React from 'react';
2
+import { Card, Input, Select, DatePicker } from 'antd';
3
+import moment from 'moment';
4
+import Form, { FormItem } from './Form';
5
+
6
+const { RangePicker } = DatePicker;
7
+
8
+const initialValues = {
9
+  jobDate: [moment().startOf('year'), moment()],
10
+};
11
+
12
+const options = [
13
+  {
14
+    value: 'shensong',
15
+    label: '深松',
16
+  },
17
+  {
18
+    value: 'feifang',
19
+    label: '飞防',
20
+  },
21
+];
22
+
23
+export default (props) => {
24
+  const { onFinish } = props;
25
+
26
+  const handleFinish = (values) => {
27
+    // 转换日期格式
28
+    const { jobDate, ...otherValues } = values;
29
+
30
+    onFinish({
31
+      startDate: jobDate[0].format('YYYY-MM-DD'),
32
+      endDate: jobDate[1].format('YYYY-MM-DD'),
33
+      ...otherValues,
34
+    });
35
+  };
36
+
37
+  React.useEffect(() => {
38
+    // 开始就触发查询
39
+    handleFinish(initialValues);
40
+  }, []);
41
+
42
+  return (
43
+    <Card>
44
+      <Form onFinish={handleFinish} initialValues={initialValues}>
45
+        <FormItem name="orgName" label="合作社">
46
+          <Input placeholder="请输入" />
47
+        </FormItem>
48
+        <FormItem name="deviceNo" label="设备编号">
49
+          <Input placeholder="请输入" />
50
+        </FormItem>
51
+        <FormItem name="deviceKind" label="设备类型">
52
+          <Select options={options} />
53
+        </FormItem>
54
+        <FormItem name="jobDate" label="作业时间">
55
+          <RangePicker />
56
+        </FormItem>
57
+      </Form>
58
+    </Card>
59
+  );
60
+};

+ 107
- 60
src/pages/Machinery/OperationStatistics/index.jsx Просмотреть файл

@@ -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
 };

+ 2
- 17
src/pages/MonitoringScreen2/components/map/index.jsx Просмотреть файл

@@ -5,23 +5,8 @@ import Map from './map';
5 5
 export default (props) => {
6 6
   return (
7 7
     <div className={Styles['geo-map-container']}>
8
-      {/* 占位图片 */}
9
-      <div className={Styles['geo-map-header']}>
10
-        <div />
11
-        <div />
12
-        <div />
13
-      </div>
14
-
15
-      <div className={Styles['geo-map-body']}>
16
-        <Map />
17
-      </div>
18
-
19
-      {/* 占位图片 */}
20
-      <div className={Styles['geo-map-footer']}>
21
-        <div />
22
-        <div />
23
-        <div />
24
-      </div>
8
+      <Map style={{ height: '100%' }} />
9
+      {props.children}
25 10
     </div>
26 11
   );
27 12
 };

+ 8
- 4
src/pages/MonitoringScreen2/index.jsx Просмотреть файл

@@ -199,12 +199,16 @@ export default (props) => {
199 199
               />
200 200
             </div>
201 201
             {/* <GeoMap machineTypeList={machineTypeList} orgList={orgList} machineList={machineList} /> */}
202
-            <Map />
202
+            <Map>
203
+              <div
204
+                className={Styles['map-addon']}
205
+                style={{ right: '20px', bottom: '100px', width: '600px' }}
206
+              >
207
+                <DeviceList />
208
+              </div>
209
+            </Map>
203 210
           </div>
204 211
         </div>
205
-        <div>
206
-          <DeviceList />
207
-        </div>
208 212
       </div>
209 213
     </div>
210 214
   );

+ 5
- 0
src/pages/MonitoringScreen2/style.less Просмотреть файл

@@ -86,3 +86,8 @@
86 86
 .mg-tp-30 {
87 87
   margin-top: 30px;
88 88
 }
89
+
90
+.map-addon {
91
+  position: absolute;
92
+  z-index: 20;
93
+}

+ 21
- 0
src/services/job.js Просмотреть файл

@@ -20,3 +20,24 @@ export const getJobDetail = (id) => request(`/work-job/${id}`);
20 20
  * @returns
21 21
  */
22 22
 export const getJobGISDetail = (params) => request(`/machinery-gps`, { params });
23
+
24
+/**
25
+ * 查询作业列表2
26
+ * @param {*} params
27
+ * @returns
28
+ */
29
+export const getDeviceJobList = (params) => request('/device-job', { params });
30
+
31
+/**
32
+ * 作业统计
33
+ * @param {*} params
34
+ * @returns
35
+ */
36
+export const getDeviceJobByOrg = (params) => request('/device-job/by-org', { params });
37
+
38
+/**
39
+ * 作业统计导出
40
+ * @param {*} params
41
+ * @returns
42
+ */
43
+export const exportDeviceJobByOrg = (params) => request('/device-job/by-org/export', { params });