|
@@ -1,10 +1,10 @@
|
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
|
6
|
import { } from '@/services/device';
|
|
7
|
+import { getDeviceList, syncShenSong } from '@/services/device';
|
8
|
8
|
|
9
|
9
|
const formatterTime = (val) => {
|
10
|
10
|
return val && val !== '-' ? moment(val).format('YYYY-MM-DD') : '-';
|
|
@@ -18,8 +18,7 @@ const menus = (
|
18
|
18
|
);
|
19
|
19
|
|
20
|
20
|
const List = (props, ref) => {
|
21
|
|
- const { onBindOpt, onSyncDevice, onFeiFang } = props;
|
22
|
|
-
|
|
21
|
+ const { onBindOpt, onFeiFang } = props;
|
23
|
22
|
const columns = [
|
24
|
23
|
{
|
25
|
24
|
title: '设备类型',
|
|
@@ -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(),
|
|
@@ -106,7 +119,7 @@ const List = (props, ref) => {
|
106
|
119
|
rowKey={(row) => `${row.deviceType}-${row.deviceNo}`}
|
107
|
120
|
options={false}
|
108
|
121
|
toolBarRender={() => [
|
109
|
|
- <Button key={1} type="primary">
|
|
122
|
+ <Button key={1} type="primary" loading={syncing} onClick={onSyncShenSong}>
|
110
|
123
|
同步深松
|
111
|
124
|
</Button>,
|
112
|
125
|
<Button key={3} type="primary" onClick={() => { onFeiFang() }}>
|