Yansen 2 年之前
父節點
當前提交
ab6307dbce

+ 4
- 3
config/routes.js 查看文件

136
         path: '/Machinery/GIS',
136
         path: '/Machinery/GIS',
137
         name: '农机GIS',
137
         name: '农机GIS',
138
         component: './Machinery/GIS',
138
         component: './Machinery/GIS',
139
+        hideInMenu: true,
139
       },
140
       },
140
       {
141
       {
141
         path: '/Machinery/GIS/detail.jsx',
142
         path: '/Machinery/GIS/detail.jsx',
145
       },
146
       },
146
       {
147
       {
147
         path: '/Machinery/JobList',
148
         path: '/Machinery/JobList',
148
-        name: '作业列表',
149
+        name: '设备作业列表',
149
         component: './Machinery/JobList',
150
         component: './Machinery/JobList',
150
       },
151
       },
151
       {
152
       {
152
         path: '/Machinery/OperationStatistics',
153
         path: '/Machinery/OperationStatistics',
153
-        name: '作业统计',
154
+        name: '设备作业统计',
154
         component: './Machinery/OperationStatistics',
155
         component: './Machinery/OperationStatistics',
155
       },
156
       },
156
       {
157
       {
157
         path: '/Machinery/OperationStatistics/Detail',
158
         path: '/Machinery/OperationStatistics/Detail',
158
-        name: '作业详情',
159
+        name: '设备作业详情',
159
         component: './Machinery/OperationStatistics/Detail',
160
         component: './Machinery/OperationStatistics/Detail',
160
         hideInMenu: true,
161
         hideInMenu: true,
161
       },
162
       },

+ 10
- 8
src/pages/Machinery/OperationStatistics/components/search/index.jsx 查看文件

5
 
5
 
6
 const { RangePicker } = DatePicker;
6
 const { RangePicker } = DatePicker;
7
 
7
 
8
-const initialValues = {
8
+const initValues = {
9
   jobDate: [moment().startOf('year'), moment()],
9
   jobDate: [moment().startOf('year'), moment()],
10
 };
10
 };
11
 
11
 
21
 ];
21
 ];
22
 
22
 
23
 export default (props) => {
23
 export default (props) => {
24
-  const { onFinish } = props;
24
+  const { onFinish, initial = {} } = props;
25
+
26
+  const initialValues = { ...initValues, ...initial };
25
 
27
 
26
   const handleFinish = (values) => {
28
   const handleFinish = (values) => {
27
     // 转换日期格式
29
     // 转换日期格式
43
     <Card>
45
     <Card>
44
       <Form onFinish={handleFinish} initialValues={initialValues}>
46
       <Form onFinish={handleFinish} initialValues={initialValues}>
45
         <FormItem name="orgName" label="合作社">
47
         <FormItem name="orgName" label="合作社">
46
-          <Input placeholder="请输入" />
48
+          <Input placeholder="请输入" allowClear />
47
         </FormItem>
49
         </FormItem>
48
         <FormItem name="userName" label="人员">
50
         <FormItem name="userName" label="人员">
49
-          <Input placeholder="请输入" />
51
+          <Input placeholder="请输入" allowClear />
50
         </FormItem>
52
         </FormItem>
51
         <FormItem name="phone" label="手机">
53
         <FormItem name="phone" label="手机">
52
-          <Input placeholder="请输入" />
54
+          <Input placeholder="请输入" allowClear />
53
         </FormItem>
55
         </FormItem>
54
         <FormItem name="machineryName" label="农机">
56
         <FormItem name="machineryName" label="农机">
55
-          <Input placeholder="请输入" />
57
+          <Input placeholder="请输入" allowClear />
56
         </FormItem>
58
         </FormItem>
57
         <FormItem name="deviceNo" label="设备编号">
59
         <FormItem name="deviceNo" label="设备编号">
58
-          <Input placeholder="请输入" />
60
+          <Input placeholder="请输入" allowClear />
59
         </FormItem>
61
         </FormItem>
60
         <FormItem name="deviceKind" label="设备类型">
62
         <FormItem name="deviceKind" label="设备类型">
61
-          <Select options={options} />
63
+          <Select options={options} allowClear />
62
         </FormItem>
64
         </FormItem>
63
         <FormItem name="jobDate" label="作业时间">
65
         <FormItem name="jobDate" label="作业时间">
64
           <RangePicker />
66
           <RangePicker />

+ 4
- 1
src/pages/Machinery/OperationStatistics/index.jsx 查看文件

6
 import Search from './components/search';
6
 import Search from './components/search';
7
 
7
 
8
 export default (props) => {
8
 export default (props) => {
9
+  const { location } = props;
10
+  const { deviceType, deviceNo } = location.query || {};
11
+
9
   const columns = [
12
   const columns = [
10
     {
13
     {
11
       title: '合作社',
14
       title: '合作社',
122
   return (
125
   return (
123
     <PageHeaderWrapper>
126
     <PageHeaderWrapper>
124
       <div style={{ marginBottom: '16px' }}>
127
       <div style={{ marginBottom: '16px' }}>
125
-        <Search onFinish={onSearch} />
128
+        <Search initial={{ deviceKind: deviceType, deviceNo }} onFinish={onSearch} />
126
       </div>
129
       </div>
127
       <Card loading={loading}>
130
       <Card loading={loading}>
128
         <Row>
131
         <Row>

+ 18
- 5
src/pages/Machinery/Sensing/components/List.jsx 查看文件

1
 import React from 'react';
1
 import React from 'react';
2
 import { Link } from 'umi';
2
 import { Link } from 'umi';
3
 import moment from 'moment';
3
 import moment from 'moment';
4
-import { Button, Popconfirm, Dropdown, Menu } from 'antd';
4
+import { Button, Popconfirm, Dropdown, Menu, message } from 'antd';
5
 import PageTable from '@/components/PageTable';
5
 import PageTable from '@/components/PageTable';
6
-import { getDeviceList } from '@/services/device';
7
-import {} from '@/services/device';
6
+import { getDeviceList, syncShenSong } from '@/services/device';
8
 
7
 
9
 const formatterTime = (val) => {
8
 const formatterTime = (val) => {
10
   return val && val !== '-' ? moment(val).format('YYYY-MM-DD') : '-';
9
   return val && val !== '-' ? moment(val).format('YYYY-MM-DD') : '-';
18
 );
17
 );
19
 
18
 
20
 const List = (props, ref) => {
19
 const List = (props, ref) => {
21
-  const { onBindOpt, onSyncDevice } = props;
20
+  const { onBindOpt } = props;
22
 
21
 
23
   const columns = [
22
   const columns = [
24
     {
23
     {
91
     },
90
     },
92
   ];
91
   ];
93
 
92
 
93
+  const [syncing, setSyncing] = React.useState(false);
94
   const actionRef = React.useRef();
94
   const actionRef = React.useRef();
95
 
95
 
96
+  const onSyncShenSong = () => {
97
+    setSyncing(true);
98
+    syncShenSong()
99
+      .then((res) => {
100
+        setSyncing(false);
101
+        actionRef.current.reload();
102
+        message.success('同步完成');
103
+      })
104
+      .catch(() => {
105
+        setSyncing(false);
106
+      });
107
+  };
108
+
96
   React.useImperativeHandle(ref, () => {
109
   React.useImperativeHandle(ref, () => {
97
     return {
110
     return {
98
       reload: () => actionRef.current.reload(),
111
       reload: () => actionRef.current.reload(),
107
       rowKey={(row) => `${row.deviceType}-${row.deviceNo}`}
120
       rowKey={(row) => `${row.deviceType}-${row.deviceNo}`}
108
       options={false}
121
       options={false}
109
       toolBarRender={() => [
122
       toolBarRender={() => [
110
-        <Button key={1} type="primary">
123
+        <Button key={1} type="primary" loading={syncing} onClick={onSyncShenSong}>
111
           同步深松
124
           同步深松
112
         </Button>,
125
         </Button>,
113
         <Button key={3} type="primary">
126
         <Button key={3} type="primary">

+ 1
- 1
src/pages/Machinery/Sensing/index.jsx 查看文件

50
 
50
 
51
   return (
51
   return (
52
     <PageHeaderWrapper>
52
     <PageHeaderWrapper>
53
-      <List ref={listRef} onBindOpt={onBindOpt} onSyncDevice={console.log} />
53
+      <List ref={listRef} onBindOpt={onBindOpt} />
54
       <MaBind open={open} device={device} onCancel={() => setOpen(false)} onFinish={onBind} />
54
       <MaBind open={open} device={device} onCancel={() => setOpen(false)} onFinish={onBind} />
55
     </PageHeaderWrapper>
55
     </PageHeaderWrapper>
56
   );
56
   );

+ 6
- 0
src/services/device.js 查看文件

58
  * @returns
58
  * @returns
59
  */
59
  */
60
 export const getMachineryListByUser = (userId) => request(`/device-job/user/${userId}/machinery`);
60
 export const getMachineryListByUser = (userId) => request(`/device-job/user/${userId}/machinery`);
61
+
62
+/**
63
+ * 同步深松设备
64
+ * @returns
65
+ */
66
+export const syncShenSong = () => request('/raw-device/sync', { method: 'put' });