ls-pro-common 3.0.81 → 3.0.83
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common.css +21 -0
- package/dist/common.js +1 -1
- package/dist/common.min.css +21 -0
- package/dist/common.min.js +1 -1
- package/es/components/common.less +23 -0
- package/es/utils/exportProcess.js +87 -30
- package/lib/components/common.less +23 -0
- package/lib/utils/exportProcess.js +87 -30
- package/package.json +1 -1
|
@@ -524,3 +524,26 @@ a:hover {
|
|
|
524
524
|
@import url('./antd-custom.less');
|
|
525
525
|
|
|
526
526
|
//-------------------省市区组件样式-----------
|
|
527
|
+
|
|
528
|
+
.ant-notification-notice.export-process-notification {
|
|
529
|
+
width: 250px;
|
|
530
|
+
padding: 12px;
|
|
531
|
+
.ant-notification-notice-message {
|
|
532
|
+
margin-bottom: 0;
|
|
533
|
+
padding-right: 12px;
|
|
534
|
+
font-size: 14px;
|
|
535
|
+
}
|
|
536
|
+
.ant-notification-notice-close {
|
|
537
|
+
top: 12px;
|
|
538
|
+
right: 12px;
|
|
539
|
+
}
|
|
540
|
+
.export-process-handle {
|
|
541
|
+
display: inline-block;
|
|
542
|
+
width: 100%;
|
|
543
|
+
cursor: move;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
.move-unselect {
|
|
548
|
+
user-select: none;
|
|
549
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import "antd/es/
|
|
2
|
-
import
|
|
1
|
+
import "antd/es/progress/style";
|
|
2
|
+
import _Progress from "antd/es/progress";
|
|
3
|
+
import "antd/es/notification/style";
|
|
4
|
+
import _notification from "antd/es/notification";
|
|
3
5
|
import React from "react";
|
|
4
|
-
import { CloseOutlined } from '@ant-design/icons';
|
|
5
6
|
import { showSuccess, showError, sleep, downloadFile } from '.';
|
|
6
7
|
import { httpGet } from '../http';
|
|
7
8
|
/**
|
|
@@ -11,34 +12,85 @@ import { httpGet } from '../http';
|
|
|
11
12
|
* @returns
|
|
12
13
|
*/
|
|
13
14
|
var exportProcess = function exportProcess(apiResult) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
var taskId = apiResult.taskId,
|
|
16
|
+
flag = apiResult.flag;
|
|
17
|
+
if (!taskId) {
|
|
18
|
+
showSuccess((flag === null || flag === void 0 ? void 0 : flag.retMsg) || '导出成功');
|
|
17
19
|
return;
|
|
18
20
|
}
|
|
19
21
|
var time = 0;
|
|
20
22
|
var exit = false;
|
|
21
23
|
var win = top || window;
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
var errorTryCount = 3;
|
|
25
|
+
var key = 'task' + taskId;
|
|
26
|
+
var dom = null;
|
|
27
|
+
var moveState = {
|
|
28
|
+
isMove: false,
|
|
29
|
+
startLeft: 0,
|
|
30
|
+
startTop: 0,
|
|
31
|
+
startX: 0,
|
|
32
|
+
startY: 0,
|
|
33
|
+
h: 88,
|
|
34
|
+
w: 250 //组件宽度
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
var onMove = function onMove(e) {
|
|
38
|
+
requestAnimationFrame(function () {
|
|
39
|
+
var startLeft = moveState.startLeft,
|
|
40
|
+
startTop = moveState.startTop,
|
|
41
|
+
startX = moveState.startX,
|
|
42
|
+
startY = moveState.startY,
|
|
43
|
+
isMove = moveState.isMove,
|
|
44
|
+
h = moveState.h,
|
|
45
|
+
w = moveState.w;
|
|
46
|
+
if (!isMove || !dom) return;
|
|
47
|
+
// 通过计算鼠标的移动距离,计算出组件新的坐标。
|
|
48
|
+
var deltaX = document.body.clientWidth - (e.clientX - startX + startLeft) - w;
|
|
49
|
+
var deltaY = e.clientY - startY + startTop;
|
|
50
|
+
var top = Math.max(0, Math.min(document.body.clientHeight - h, deltaY));
|
|
51
|
+
var right = Math.max(0, Math.min(document.body.clientWidth - w - 30, deltaX));
|
|
52
|
+
dom.style.top = top + 'px';
|
|
53
|
+
dom.style.right = right + 'px';
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
var onUp = function onUp() {
|
|
57
|
+
moveState.isMove = false;
|
|
58
|
+
document.body.classList.remove('move-unselect');
|
|
59
|
+
document.removeEventListener('mouseup', onUp);
|
|
60
|
+
document.removeEventListener('mousemove', onMove);
|
|
61
|
+
};
|
|
62
|
+
var loading = function loading(percent) {
|
|
63
|
+
_notification.open({
|
|
64
|
+
className: 'export-process-notification',
|
|
65
|
+
placement: 'topRight',
|
|
66
|
+
key: key,
|
|
67
|
+
duration: 0,
|
|
68
|
+
message: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
|
|
69
|
+
className: "export-process-handle",
|
|
70
|
+
onMouseDown: function onMouseDown(e) {
|
|
71
|
+
dom = e.target.closest('.ant-notification-topRight');
|
|
72
|
+
if (!dom) return;
|
|
73
|
+
var rect = dom.getBoundingClientRect();
|
|
74
|
+
moveState.isMove = true;
|
|
75
|
+
moveState.startX = e.clientX;
|
|
76
|
+
moveState.startY = e.clientY;
|
|
77
|
+
moveState.startLeft = rect.left;
|
|
78
|
+
moveState.startTop = rect.top;
|
|
79
|
+
document.body.classList.add('move-unselect');
|
|
80
|
+
document.addEventListener('mouseup', onUp);
|
|
81
|
+
document.addEventListener('mousemove', onMove);
|
|
82
|
+
}
|
|
83
|
+
}, "\u6B63\u5728\u5BFC\u51FA..."), /*#__PURE__*/React.createElement(_Progress, {
|
|
84
|
+
percent: percent
|
|
85
|
+
})),
|
|
86
|
+
onClose: function onClose() {
|
|
87
|
+
exit = true;
|
|
88
|
+
document.removeEventListener('mouseup', onUp);
|
|
89
|
+
document.removeEventListener('mousemove', onMove);
|
|
32
90
|
}
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
textAlign: 'right'
|
|
37
|
-
},
|
|
38
|
-
onClose: function onClose() {
|
|
39
|
-
exit = true;
|
|
40
|
-
}
|
|
41
|
-
});
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
loading(0);
|
|
42
94
|
var getResult = function getResult() {
|
|
43
95
|
if (exit) return;
|
|
44
96
|
httpGet('/petrel-poi-center-api/sysPoiExportManage/page', {
|
|
@@ -50,7 +102,7 @@ var exportProcess = function exportProcess(apiResult) {
|
|
|
50
102
|
rows = _result$rows === void 0 ? [] : _result$rows;
|
|
51
103
|
var row = rows === null || rows === void 0 ? void 0 : rows[0];
|
|
52
104
|
if (!row) {
|
|
53
|
-
if (time <
|
|
105
|
+
if (time < errorTryCount) {
|
|
54
106
|
time++;
|
|
55
107
|
sleep(5).then(function () {
|
|
56
108
|
return getResult();
|
|
@@ -60,19 +112,22 @@ var exportProcess = function exportProcess(apiResult) {
|
|
|
60
112
|
win.postMessage({
|
|
61
113
|
type: 'exportError'
|
|
62
114
|
});
|
|
63
|
-
|
|
115
|
+
_notification.close(key);
|
|
64
116
|
}
|
|
65
117
|
} else {
|
|
66
118
|
var status = row.status,
|
|
67
|
-
downloadUrl = row.downloadUrl
|
|
119
|
+
downloadUrl = row.downloadUrl,
|
|
120
|
+
progress = row.progress;
|
|
68
121
|
//导出中
|
|
69
122
|
if (status < 30) {
|
|
123
|
+
loading(progress);
|
|
70
124
|
sleep(5).then(function () {
|
|
71
125
|
return getResult();
|
|
72
126
|
});
|
|
73
127
|
} else {
|
|
74
128
|
//导出成功
|
|
75
129
|
if (status === 30 && downloadUrl) {
|
|
130
|
+
loading(100);
|
|
76
131
|
downloadFile(downloadUrl);
|
|
77
132
|
} else {
|
|
78
133
|
//导出失败
|
|
@@ -81,12 +136,14 @@ var exportProcess = function exportProcess(apiResult) {
|
|
|
81
136
|
type: 'exportError'
|
|
82
137
|
});
|
|
83
138
|
}
|
|
84
|
-
|
|
139
|
+
sleep(1.5).then(function () {
|
|
140
|
+
_notification.close(key);
|
|
141
|
+
});
|
|
85
142
|
}
|
|
86
143
|
}
|
|
87
144
|
}).catch(function () {
|
|
88
145
|
showError('获取导出进度失败,请在消息中心查看导出结果');
|
|
89
|
-
|
|
146
|
+
_notification.close(key);
|
|
90
147
|
win.postMessage({
|
|
91
148
|
type: 'exportError'
|
|
92
149
|
});
|
|
@@ -524,3 +524,26 @@ a:hover {
|
|
|
524
524
|
@import url('./antd-custom.less');
|
|
525
525
|
|
|
526
526
|
//-------------------省市区组件样式-----------
|
|
527
|
+
|
|
528
|
+
.ant-notification-notice.export-process-notification {
|
|
529
|
+
width: 250px;
|
|
530
|
+
padding: 12px;
|
|
531
|
+
.ant-notification-notice-message {
|
|
532
|
+
margin-bottom: 0;
|
|
533
|
+
padding-right: 12px;
|
|
534
|
+
font-size: 14px;
|
|
535
|
+
}
|
|
536
|
+
.ant-notification-notice-close {
|
|
537
|
+
top: 12px;
|
|
538
|
+
right: 12px;
|
|
539
|
+
}
|
|
540
|
+
.export-process-handle {
|
|
541
|
+
display: inline-block;
|
|
542
|
+
width: 100%;
|
|
543
|
+
cursor: move;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
.move-unselect {
|
|
548
|
+
user-select: none;
|
|
549
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import "antd/es/
|
|
2
|
-
import
|
|
1
|
+
import "antd/es/progress/style";
|
|
2
|
+
import _Progress from "antd/es/progress";
|
|
3
|
+
import "antd/es/notification/style";
|
|
4
|
+
import _notification from "antd/es/notification";
|
|
3
5
|
import React from "react";
|
|
4
|
-
import { CloseOutlined } from '@ant-design/icons';
|
|
5
6
|
import { showSuccess, showError, sleep, downloadFile } from '.';
|
|
6
7
|
import { httpGet } from '../http';
|
|
7
8
|
/**
|
|
@@ -11,34 +12,85 @@ import { httpGet } from '../http';
|
|
|
11
12
|
* @returns
|
|
12
13
|
*/
|
|
13
14
|
var exportProcess = function exportProcess(apiResult) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
var taskId = apiResult.taskId,
|
|
16
|
+
flag = apiResult.flag;
|
|
17
|
+
if (!taskId) {
|
|
18
|
+
showSuccess((flag === null || flag === void 0 ? void 0 : flag.retMsg) || '导出成功');
|
|
17
19
|
return;
|
|
18
20
|
}
|
|
19
21
|
var time = 0;
|
|
20
22
|
var exit = false;
|
|
21
23
|
var win = top || window;
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
var errorTryCount = 3;
|
|
25
|
+
var key = 'task' + taskId;
|
|
26
|
+
var dom = null;
|
|
27
|
+
var moveState = {
|
|
28
|
+
isMove: false,
|
|
29
|
+
startLeft: 0,
|
|
30
|
+
startTop: 0,
|
|
31
|
+
startX: 0,
|
|
32
|
+
startY: 0,
|
|
33
|
+
h: 88,
|
|
34
|
+
w: 250 //组件宽度
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
var onMove = function onMove(e) {
|
|
38
|
+
requestAnimationFrame(function () {
|
|
39
|
+
var startLeft = moveState.startLeft,
|
|
40
|
+
startTop = moveState.startTop,
|
|
41
|
+
startX = moveState.startX,
|
|
42
|
+
startY = moveState.startY,
|
|
43
|
+
isMove = moveState.isMove,
|
|
44
|
+
h = moveState.h,
|
|
45
|
+
w = moveState.w;
|
|
46
|
+
if (!isMove || !dom) return;
|
|
47
|
+
// 通过计算鼠标的移动距离,计算出组件新的坐标。
|
|
48
|
+
var deltaX = document.body.clientWidth - (e.clientX - startX + startLeft) - w;
|
|
49
|
+
var deltaY = e.clientY - startY + startTop;
|
|
50
|
+
var top = Math.max(0, Math.min(document.body.clientHeight - h, deltaY));
|
|
51
|
+
var right = Math.max(0, Math.min(document.body.clientWidth - w - 30, deltaX));
|
|
52
|
+
dom.style.top = top + 'px';
|
|
53
|
+
dom.style.right = right + 'px';
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
var onUp = function onUp() {
|
|
57
|
+
moveState.isMove = false;
|
|
58
|
+
document.body.classList.remove('move-unselect');
|
|
59
|
+
document.removeEventListener('mouseup', onUp);
|
|
60
|
+
document.removeEventListener('mousemove', onMove);
|
|
61
|
+
};
|
|
62
|
+
var loading = function loading(percent) {
|
|
63
|
+
_notification.open({
|
|
64
|
+
className: 'export-process-notification',
|
|
65
|
+
placement: 'topRight',
|
|
66
|
+
key: key,
|
|
67
|
+
duration: 0,
|
|
68
|
+
message: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
|
|
69
|
+
className: "export-process-handle",
|
|
70
|
+
onMouseDown: function onMouseDown(e) {
|
|
71
|
+
dom = e.target.closest('.ant-notification-topRight');
|
|
72
|
+
if (!dom) return;
|
|
73
|
+
var rect = dom.getBoundingClientRect();
|
|
74
|
+
moveState.isMove = true;
|
|
75
|
+
moveState.startX = e.clientX;
|
|
76
|
+
moveState.startY = e.clientY;
|
|
77
|
+
moveState.startLeft = rect.left;
|
|
78
|
+
moveState.startTop = rect.top;
|
|
79
|
+
document.body.classList.add('move-unselect');
|
|
80
|
+
document.addEventListener('mouseup', onUp);
|
|
81
|
+
document.addEventListener('mousemove', onMove);
|
|
82
|
+
}
|
|
83
|
+
}, "\u6B63\u5728\u5BFC\u51FA..."), /*#__PURE__*/React.createElement(_Progress, {
|
|
84
|
+
percent: percent
|
|
85
|
+
})),
|
|
86
|
+
onClose: function onClose() {
|
|
87
|
+
exit = true;
|
|
88
|
+
document.removeEventListener('mouseup', onUp);
|
|
89
|
+
document.removeEventListener('mousemove', onMove);
|
|
32
90
|
}
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
textAlign: 'right'
|
|
37
|
-
},
|
|
38
|
-
onClose: function onClose() {
|
|
39
|
-
exit = true;
|
|
40
|
-
}
|
|
41
|
-
});
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
loading(0);
|
|
42
94
|
var getResult = function getResult() {
|
|
43
95
|
if (exit) return;
|
|
44
96
|
httpGet('/petrel-poi-center-api/sysPoiExportManage/page', {
|
|
@@ -50,7 +102,7 @@ var exportProcess = function exportProcess(apiResult) {
|
|
|
50
102
|
rows = _result$rows === void 0 ? [] : _result$rows;
|
|
51
103
|
var row = rows === null || rows === void 0 ? void 0 : rows[0];
|
|
52
104
|
if (!row) {
|
|
53
|
-
if (time <
|
|
105
|
+
if (time < errorTryCount) {
|
|
54
106
|
time++;
|
|
55
107
|
sleep(5).then(function () {
|
|
56
108
|
return getResult();
|
|
@@ -60,19 +112,22 @@ var exportProcess = function exportProcess(apiResult) {
|
|
|
60
112
|
win.postMessage({
|
|
61
113
|
type: 'exportError'
|
|
62
114
|
});
|
|
63
|
-
|
|
115
|
+
_notification.close(key);
|
|
64
116
|
}
|
|
65
117
|
} else {
|
|
66
118
|
var status = row.status,
|
|
67
|
-
downloadUrl = row.downloadUrl
|
|
119
|
+
downloadUrl = row.downloadUrl,
|
|
120
|
+
progress = row.progress;
|
|
68
121
|
//导出中
|
|
69
122
|
if (status < 30) {
|
|
123
|
+
loading(progress);
|
|
70
124
|
sleep(5).then(function () {
|
|
71
125
|
return getResult();
|
|
72
126
|
});
|
|
73
127
|
} else {
|
|
74
128
|
//导出成功
|
|
75
129
|
if (status === 30 && downloadUrl) {
|
|
130
|
+
loading(100);
|
|
76
131
|
downloadFile(downloadUrl);
|
|
77
132
|
} else {
|
|
78
133
|
//导出失败
|
|
@@ -81,12 +136,14 @@ var exportProcess = function exportProcess(apiResult) {
|
|
|
81
136
|
type: 'exportError'
|
|
82
137
|
});
|
|
83
138
|
}
|
|
84
|
-
|
|
139
|
+
sleep(1.5).then(function () {
|
|
140
|
+
_notification.close(key);
|
|
141
|
+
});
|
|
85
142
|
}
|
|
86
143
|
}
|
|
87
144
|
}).catch(function () {
|
|
88
145
|
showError('获取导出进度失败,请在消息中心查看导出结果');
|
|
89
|
-
|
|
146
|
+
_notification.close(key);
|
|
90
147
|
win.postMessage({
|
|
91
148
|
type: 'exportError'
|
|
92
149
|
});
|