|
@@ -1,3 +1,155 @@
|
|
1
|
+import React, { useRef, useEffect, useState } from 'react';
|
|
2
|
+import { Button, Select } from 'antd';
|
|
3
|
+import { PageHeaderWrapper } from '@ant-design/pro-layout';
|
|
4
|
+import PageTable from '@/components/PageTable';
|
|
5
|
+import { getMachineryList } from '@/services/machinery';
|
|
6
|
+import { getMachineryTypeList } from '@/services/machineryType';
|
|
7
|
+import { getCooperativeList } from '@/services/cooperative';
|
|
8
|
+import WorkListModel from './components/WorkListModel';
|
|
9
|
+
|
|
10
|
+const { Option } = Select;
|
|
11
|
+
|
1
|
12
|
export default (props) => {
|
2
|
|
- return <div>农机GIS</div>;
|
|
13
|
+ const actionRef = useRef();
|
|
14
|
+ const [machineryTypeList, setMachineryTypeList] = useState([]);
|
|
15
|
+ const [cooperativeList, setCooperativeList] = useState([]);
|
|
16
|
+ const [editModal, setEditModal] = useState(false);
|
|
17
|
+ const [machineryId, setMachineryId] = useState();
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+ const showList = (val) => {
|
|
21
|
+ setMachineryId(val.machineryId)
|
|
22
|
+ setEditModal(true)
|
|
23
|
+ }
|
|
24
|
+ const onCancel = () => {
|
|
25
|
+ setEditModal(false)
|
|
26
|
+ console.log(666);
|
|
27
|
+ }
|
|
28
|
+ useEffect(() => {
|
|
29
|
+ getCooperativeList({ pageSize: 999 }).then((res) => {
|
|
30
|
+ setCooperativeList(res.records);
|
|
31
|
+ }).catch((err) => {
|
|
32
|
+ console.log(err.message)
|
|
33
|
+ });
|
|
34
|
+ getMachineryTypeList({ pageSize: 999 }).then((res) => {
|
|
35
|
+ setMachineryTypeList(res.records);
|
|
36
|
+ }).catch((err) => {
|
|
37
|
+ console.log(err.message)
|
|
38
|
+ });
|
|
39
|
+ }, []);
|
|
40
|
+ const columns = [
|
|
41
|
+ {
|
|
42
|
+ title: '合作社',
|
|
43
|
+ dataIndex: 'orgId',
|
|
44
|
+ key: 'orgId',
|
|
45
|
+ hideInTable: true,
|
|
46
|
+ renderFormItem: (item, field, form) => {
|
|
47
|
+ return (
|
|
48
|
+ <Select>
|
|
49
|
+ {cooperativeList.map((item) => (
|
|
50
|
+ <Option value={item.orgId} key={item.orgId}>
|
|
51
|
+ {item.name}
|
|
52
|
+ </Option>
|
|
53
|
+ ))}
|
|
54
|
+ </Select>
|
|
55
|
+ )
|
|
56
|
+ }
|
|
57
|
+ },
|
|
58
|
+ {
|
|
59
|
+ title: '名称',
|
|
60
|
+ dataIndex: 'name',
|
|
61
|
+ key: 'name',
|
|
62
|
+ },
|
|
63
|
+ {
|
|
64
|
+ title: '合作社',
|
|
65
|
+ dataIndex: 'orgName',
|
|
66
|
+ key: 'orgName',
|
|
67
|
+ search: false
|
|
68
|
+ },
|
|
69
|
+ {
|
|
70
|
+ title: '农机类型',
|
|
71
|
+ dataIndex: 'typeId',
|
|
72
|
+ key: 'typeId',
|
|
73
|
+ renderFormItem: (item, field, form) => {
|
|
74
|
+ return (
|
|
75
|
+ <Select>
|
|
76
|
+ {machineryTypeList.map((item) => (
|
|
77
|
+ <Option value={item.typeId} key={item.typeId}>
|
|
78
|
+ {item.name}
|
|
79
|
+ </Option>
|
|
80
|
+ ))}
|
|
81
|
+ </Select>
|
|
82
|
+ );
|
|
83
|
+ },
|
|
84
|
+ hideInTable: true,
|
|
85
|
+ },
|
|
86
|
+ {
|
|
87
|
+ title: '农机类型',
|
|
88
|
+ dataIndex: 'typeName',
|
|
89
|
+ key: 'typeName',
|
|
90
|
+ search: false,
|
|
91
|
+ },
|
|
92
|
+ {
|
|
93
|
+ title: '区域',
|
|
94
|
+ dataIndex: 'regionName',
|
|
95
|
+ key: 'regionName',
|
|
96
|
+ search: false,
|
|
97
|
+ },
|
|
98
|
+ {
|
|
99
|
+ title: '农机单价',
|
|
100
|
+ dataIndex: 'price',
|
|
101
|
+ key: 'price',
|
|
102
|
+ render: (t) => t / 100,
|
|
103
|
+ search: false,
|
|
104
|
+ },
|
|
105
|
+ {
|
|
106
|
+ title: '主图',
|
|
107
|
+ dataIndex: 'thumb',
|
|
108
|
+ key: 'thumb',
|
|
109
|
+ width: 150,
|
|
110
|
+ render: (t) => <img width={110} src={t} alt="" />,
|
|
111
|
+ search: false,
|
|
112
|
+ },
|
|
113
|
+ {
|
|
114
|
+ title: '工作状态',
|
|
115
|
+ dataIndex: 'jobStatus',
|
|
116
|
+ key: 'jobStatus',
|
|
117
|
+ search: false,
|
|
118
|
+ render: (_, record) => {
|
|
119
|
+ return record.jobStatus == 1 ? '使用中' : '空闲中';
|
|
120
|
+ },
|
|
121
|
+ },
|
|
122
|
+ {
|
|
123
|
+ title: '状态',
|
|
124
|
+ dataIndex: 'status',
|
|
125
|
+ key: 'status',
|
|
126
|
+ search: false,
|
|
127
|
+ render: (_, record) => {
|
|
128
|
+ return record.status === 1 ? '正常' : '维修中';
|
|
129
|
+ },
|
|
130
|
+ },
|
|
131
|
+ {
|
|
132
|
+ title: '操作',
|
|
133
|
+ valueType: 'option',
|
|
134
|
+ render: (_, record) => [
|
|
135
|
+ <Button style={{ padding: 0 }} type="link" key={1} onClick={() => showList(record)}>
|
|
136
|
+ 农机GIS
|
|
137
|
+ </Button>,
|
|
138
|
+ ],
|
|
139
|
+ },
|
|
140
|
+ ];
|
|
141
|
+
|
|
142
|
+ return (
|
|
143
|
+ <PageHeaderWrapper>
|
|
144
|
+ <PageTable
|
|
145
|
+ request={getMachineryList}
|
|
146
|
+ actionRef={actionRef}
|
|
147
|
+ columns={columns}
|
|
148
|
+ rowKey="machineryId"
|
|
149
|
+ options={false}
|
|
150
|
+ scroll={{ x: 1000 }}
|
|
151
|
+ />
|
|
152
|
+ <WorkListModel editModal={editModal} onCancel={onCancel} machineryId={machineryId} />
|
|
153
|
+ </PageHeaderWrapper>
|
|
154
|
+ );
|
3
|
155
|
};
|