李志伟 2 年 前
コミット
98d6638218
共有5 個のファイルを変更した326 個の追加8 個の削除を含む
  1. 11
    6
      config/routes.js
  2. 95
    0
      src/pages/Machinery/GIS/components/WorkListModel.jsx
  3. 59
    0
      src/pages/Machinery/GIS/detail.jsx
  4. 153
    1
      src/pages/Machinery/GIS/index.jsx
  5. 8
    1
      src/services/job.js

+ 11
- 6
config/routes.js ファイルの表示

@@ -124,12 +124,17 @@ export default [
124 124
         component: './Machinery/Machinery/Edit',
125 125
         hideInMenu: true,
126 126
       },
127
-      // {
128
-      //   path: '/Machinery/GIS',
129
-      //   name: '农机GIS',
130
-      //   access: 'gis',
131
-      //   component: './Machinery/GIS',
132
-      // },
127
+      {
128
+        path: '/Machinery/GIS',
129
+        name: '农机GIS',
130
+        component: './Machinery/GIS',
131
+      },
132
+      {
133
+        path: '/Machinery/GIS/detail.jsx',
134
+        name: 'GIS详情',
135
+        component: './Machinery/GIS/detail.jsx',
136
+        hideInMenu: true,
137
+      },
133 138
     ],
134 139
   },
135 140
   {

+ 95
- 0
src/pages/Machinery/GIS/components/WorkListModel.jsx ファイルの表示

@@ -0,0 +1,95 @@
1
+import {
2
+  Button,
3
+  Modal,
4
+  Form,
5
+  Input,
6
+  DatePicker,
7
+  Radio,
8
+  Select,
9
+} from 'antd';
10
+import { useEffect, useState, useRef } from 'react';
11
+import PageTable from '@/components/PageTable';
12
+import moment from 'moment';
13
+import { history } from 'umi';
14
+import { getJobList } from '@/services/job'
15
+
16
+const formatterTime = (val) => {
17
+  return val ? moment(val).format('YYYY-MM-DD HH:mm') : '';
18
+};
19
+const { RangePicker } = DatePicker;
20
+export default (props) => {
21
+  const { editModal, onCancel, machineryId } = props
22
+  const actionRef = useRef();
23
+
24
+  const [start, setStartDate] = useState()
25
+  const [end, setEndDate] = useState()
26
+  const handelChange = (date, dateStrings) => {
27
+    setStartDate(dateStrings[0])
28
+    setEndDate(dateStrings[1])
29
+  }
30
+  const Reset = () => {
31
+    setStartDate()
32
+    setEndDate()
33
+    actionRef.current.reload();
34
+  }
35
+  const goDetail = (id) => {
36
+    history.push(`./GIS/detail.jsx?id=` + id);
37
+  }
38
+
39
+  const columns = [
40
+    {
41
+      title: '订单号',
42
+      dataIndex: 'orderNo',
43
+      key: 'orderNo',
44
+      search: false
45
+    },
46
+    {
47
+      title: '农机手',
48
+      dataIndex: 'workerName',
49
+      key: 'workerName',
50
+      search: false
51
+    },
52
+    {
53
+      title: '作业时间',
54
+      dataIndex: 'endDate',
55
+      key: 'endDate',
56
+      render: (t, render) => formatterTime(render.startDate) + ' ~ ' + formatterTime(render.endDate),
57
+      renderFormItem: (_, record) => <RangePicker placeholder={['开始日期', '结束日期']} format='YYYY-MM-DD' onChange={handelChange} />
58
+    },
59
+    {
60
+      title: '操作',
61
+      valueType: 'option',
62
+      render: (_, record) => [
63
+        <Button
64
+          style={{ padding: 0 }}
65
+          type="link"
66
+          key={1}
67
+          onClick={() => goDetail(record.jobId)}
68
+        >
69
+          查看GIS
70
+        </Button>
71
+      ],
72
+    }
73
+  ]
74
+  return (
75
+    <Modal
76
+      forceRender
77
+      width='1024px'
78
+      title='农机GIS列表'
79
+      visible={editModal}
80
+      onCancel={onCancel}
81
+      destroyOnClose={true}
82
+      footer={null}
83
+    >
84
+      <PageTable
85
+        request={getJobList}
86
+        actionRef={actionRef}
87
+        columns={columns}
88
+        rowKey="jobId"
89
+        options={false}
90
+        params={{ machineryId: machineryId, start, end }}
91
+        onReset={Reset}
92
+      />
93
+    </Modal>
94
+  )
95
+}

+ 59
- 0
src/pages/Machinery/GIS/detail.jsx ファイルの表示

@@ -0,0 +1,59 @@
1
+import { PageHeaderWrapper } from '@ant-design/pro-layout';
2
+import { Card, Form, Button, Descriptions } from 'antd';
3
+import { useEffect, useState } from 'react';
4
+import { getJobDetail } from '@/services/job'
5
+import moment from 'moment';
6
+import { history } from 'umi';
7
+
8
+
9
+
10
+const FormItem = Form.Item;
11
+const goBack = () => {
12
+  history.goBack();
13
+};
14
+const formatterTime = (val) => {
15
+  return val ? moment(val).format('YYYY-MM-DD HH:mm') : '';
16
+};
17
+export default (props) => {
18
+  const { location } = props;
19
+  const { id } = location.query;
20
+  const [workInfo, setWorkInfo] = useState()
21
+
22
+  useEffect(() => {
23
+    if (id) {
24
+      getJobDetail(id).then((res) => {
25
+        setWorkInfo(res)
26
+      })
27
+    }
28
+  }, [id])
29
+  return (
30
+    <PageHeaderWrapper extra={[<Button key={id} type="default" onClick={() => goBack()}>
31
+      返回
32
+    </Button>]}>
33
+      <Card style={{ minHeight: '700px' }}>
34
+        <Descriptions style={{ margin: '0 32px' }}>
35
+          <Descriptions.Item label="订单号">{workInfo?.orderNo}</Descriptions.Item>
36
+          <Descriptions.Item label="合作社">{workInfo?.orgName}</Descriptions.Item>
37
+          <Descriptions.Item label="农机">{workInfo?.machineryName}</Descriptions.Item>
38
+          <Descriptions.Item label="农机手">{workInfo?.workerName}</Descriptions.Item>
39
+          <Descriptions.Item label="作业面积">{workInfo?.area}</Descriptions.Item>
40
+          <Descriptions.Item label="作业时间">{formatterTime(workInfo?.startDate)}~{formatterTime(workInfo?.endDate)}</Descriptions.Item>
41
+        </Descriptions>
42
+        {/* <Form >
43
+          <FormItem label="订单号">{workInfo?.orderNo}</FormItem>
44
+          <FormItem label="合作社">{workInfo?.orgName}</FormItem>
45
+          <FormItem label="农机">{workInfo?.machineryName}</FormItem>
46
+          <FormItem label="农机手">{workInfo?.workerName}</FormItem>
47
+          <FormItem label="作业面积">{workInfo?.area}亩</FormItem>
48
+          <FormItem label="作业时间">{formatterTime(workInfo?.startDate)}~{formatterTime(workInfo?.endDate)}</FormItem>
49
+          <FormItem label=" " colon={false}>
50
+            <Button type="default" onClick={() => goBack()}>
51
+              返回
52
+            </Button>
53
+          </FormItem>
54
+        </Form> */}
55
+
56
+      </Card>
57
+    </PageHeaderWrapper>
58
+  );
59
+};

+ 153
- 1
src/pages/Machinery/GIS/index.jsx ファイルの表示

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

+ 8
- 1
src/services/job.js ファイルの表示

@@ -1,8 +1,15 @@
1 1
 import request from '@/utils/request';
2 2
 
3 3
 /**
4
- * 查询农机列表
4
+ * 查询作业列表
5 5
  * @param {*} params
6 6
  * @returns
7 7
  */
8 8
 export const getJobList = (params) => request('/work-job', { params });
9
+
10
+/**
11
+ * 查询作业详情
12
+ * @param {*} params
13
+ * @returns
14
+ */
15
+export const getJobDetail = (id) => request(`/work-job/${id}`);