Yansen před 2 roky
rodič
revize
ab6307dbce

+ 4
- 3
config/routes.js Zobrazit soubor

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

+ 10
- 8
src/pages/Machinery/OperationStatistics/components/search/index.jsx Zobrazit soubor

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

+ 4
- 1
src/pages/Machinery/OperationStatistics/index.jsx Zobrazit soubor

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

+ 18
- 5
src/pages/Machinery/Sensing/components/List.jsx Zobrazit soubor

@@ -1,10 +1,9 @@
1 1
 import React from 'react';
2 2
 import { Link } from 'umi';
3 3
 import moment from 'moment';
4
-import { Button, Popconfirm, Dropdown, Menu } from 'antd';
4
+import { Button, Popconfirm, Dropdown, Menu, message } from 'antd';
5 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 8
 const formatterTime = (val) => {
10 9
   return val && val !== '-' ? moment(val).format('YYYY-MM-DD') : '-';
@@ -18,7 +17,7 @@ const menus = (
18 17
 );
19 18
 
20 19
 const List = (props, ref) => {
21
-  const { onBindOpt, onSyncDevice } = props;
20
+  const { onBindOpt } = props;
22 21
 
23 22
   const columns = [
24 23
     {
@@ -91,8 +90,22 @@ const List = (props, ref) => {
91 90
     },
92 91
   ];
93 92
 
93
+  const [syncing, setSyncing] = React.useState(false);
94 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 109
   React.useImperativeHandle(ref, () => {
97 110
     return {
98 111
       reload: () => actionRef.current.reload(),
@@ -107,7 +120,7 @@ const List = (props, ref) => {
107 120
       rowKey={(row) => `${row.deviceType}-${row.deviceNo}`}
108 121
       options={false}
109 122
       toolBarRender={() => [
110
-        <Button key={1} type="primary">
123
+        <Button key={1} type="primary" loading={syncing} onClick={onSyncShenSong}>
111 124
           同步深松
112 125
         </Button>,
113 126
         <Button key={3} type="primary">

+ 1
- 1
src/pages/Machinery/Sensing/index.jsx Zobrazit soubor

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

+ 6
- 0
src/services/device.js Zobrazit soubor

@@ -58,3 +58,9 @@ export const deleteDevice = (id) => request(`/device/${id}`, { method: 'delete'
58 58
  * @returns
59 59
  */
60 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' });