ls-pro-common 3.1.61 → 3.1.63
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 +43 -17
- package/dist/common.js +1 -1
- package/dist/common.min.css +43 -17
- package/dist/common.min.js +1 -1
- package/es/components/DtlLayout.d.ts +1 -1
- package/es/components/ViewOffice.js +35 -12
- package/es/components/common.less +9 -0
- package/es/http/bizAjax.d.ts +7 -2
- package/es/index.d.ts +2 -0
- package/es/index.js +2 -0
- package/es/utils/taskProcess.d.ts +9 -0
- package/es/utils/taskProcess.js +139 -0
- package/lib/components/DtlLayout.d.ts +1 -1
- package/lib/components/ViewOffice.js +35 -12
- package/lib/components/common.less +9 -0
- package/lib/http/bizAjax.d.ts +7 -2
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/utils/taskProcess.d.ts +9 -0
- package/lib/utils/taskProcess.js +139 -0
- package/package.json +1 -1
|
@@ -4,10 +4,11 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
|
4
4
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
5
5
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
6
6
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
7
|
-
import React, { useState, useMemo } from 'react';
|
|
7
|
+
import React, { useState, useMemo, useRef } from 'react';
|
|
8
8
|
import { EyeOutlined } from '@ant-design/icons';
|
|
9
|
-
import { getCookie,
|
|
9
|
+
import { getCookie, getUrlQuery } from '../utils';
|
|
10
10
|
import { base64Encode } from 'ls-pro-tools';
|
|
11
|
+
import Loading from './Loading';
|
|
11
12
|
var ViewDocment = function ViewDocment(props) {
|
|
12
13
|
var _props$open = props.open,
|
|
13
14
|
open = _props$open === void 0 ? false : _props$open,
|
|
@@ -27,6 +28,15 @@ var ViewDocment = function ViewDocment(props) {
|
|
|
27
28
|
_useState2 = _slicedToArray(_useState, 2),
|
|
28
29
|
visible = _useState2[0],
|
|
29
30
|
setVisible = _useState2[1];
|
|
31
|
+
var _useState3 = useState(false),
|
|
32
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
33
|
+
isZip = _useState4[0],
|
|
34
|
+
setIsZip = _useState4[1];
|
|
35
|
+
var _useState5 = useState(mode !== 'modal'),
|
|
36
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
37
|
+
loading = _useState6[0],
|
|
38
|
+
setLoading = _useState6[1];
|
|
39
|
+
var iframeRef = useRef(null);
|
|
30
40
|
var src = useMemo(function () {
|
|
31
41
|
var token = getCookie('token');
|
|
32
42
|
var filename = getUrlQuery('fileName', url); //文件名,上传的文件名为xxx?fileName=xxx.pdf
|
|
@@ -46,13 +56,13 @@ var ViewDocment = function ViewDocment(props) {
|
|
|
46
56
|
filename = filename.replace(/[^a-zA-Z0-9\u4e00-\u9fa5.]/g, '');
|
|
47
57
|
href = href + (href.includes('?') ? '&' : '?') + 'fullfilename=' + filename;
|
|
48
58
|
}
|
|
59
|
+
if (filename.endsWith('.zip')) {
|
|
60
|
+
setIsZip(true);
|
|
61
|
+
}
|
|
49
62
|
var doc = base64Encode(href);
|
|
50
|
-
|
|
63
|
+
// 统一使用生产环境来预览文件
|
|
64
|
+
// const exportUrl = getCache('exportUrl');
|
|
51
65
|
var domain = 'https://download.lesoon.cloud';
|
|
52
|
-
// if (exportUrl && exportUrl.includes('//')) {
|
|
53
|
-
// // 如果配置了下载域名,则走下载域名,否则走原来域名
|
|
54
|
-
// domain = exportUrl;
|
|
55
|
-
// }
|
|
56
66
|
return domain + '/lesoon/lesoon-kkfileview-api/onlinePreview?url=' + doc;
|
|
57
67
|
}, [url]);
|
|
58
68
|
var triggerDom = /*#__PURE__*/React.createElement(React.Fragment, {
|
|
@@ -64,13 +74,14 @@ var ViewDocment = function ViewDocment(props) {
|
|
|
64
74
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
65
75
|
while (1) switch (_context.prev = _context.next) {
|
|
66
76
|
case 0:
|
|
67
|
-
setVisible(
|
|
77
|
+
setVisible(true);
|
|
78
|
+
setLoading(true);
|
|
68
79
|
(_trigger$props = trigger.props) === null || _trigger$props === void 0 ? void 0 : (_trigger$props$onClic = _trigger$props.onClick) === null || _trigger$props$onClic === void 0 ? void 0 : _trigger$props$onClic.call(_trigger$props, e);
|
|
69
80
|
// 新页签打开
|
|
70
81
|
if (mode === 'urlOpen') {
|
|
71
82
|
window.open(src, '_blank');
|
|
72
83
|
}
|
|
73
|
-
case
|
|
84
|
+
case 4:
|
|
74
85
|
case "end":
|
|
75
86
|
return _context.stop();
|
|
76
87
|
}
|
|
@@ -85,7 +96,7 @@ var ViewDocment = function ViewDocment(props) {
|
|
|
85
96
|
if (mode === 'urlOpen') {
|
|
86
97
|
return /*#__PURE__*/React.createElement(React.Fragment, null, props.children, triggerDom);
|
|
87
98
|
} else if (mode === 'iframe') {
|
|
88
|
-
/*#__PURE__*/React.createElement(React.Fragment, null, props.children, /*#__PURE__*/React.createElement("div", {
|
|
99
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, props.children, /*#__PURE__*/React.createElement("div", {
|
|
89
100
|
className: "view-office-modal",
|
|
90
101
|
style: {
|
|
91
102
|
width: width,
|
|
@@ -109,9 +120,21 @@ var ViewDocment = function ViewDocment(props) {
|
|
|
109
120
|
bodyStyle: {
|
|
110
121
|
height: height
|
|
111
122
|
},
|
|
112
|
-
footer: null
|
|
123
|
+
footer: null,
|
|
124
|
+
destroyOnClose: true
|
|
113
125
|
}, /*#__PURE__*/React.createElement("iframe", {
|
|
114
|
-
src: src
|
|
126
|
+
src: src,
|
|
127
|
+
onLoad: function onLoad() {
|
|
128
|
+
setLoading(false);
|
|
129
|
+
},
|
|
130
|
+
onError: function onError() {
|
|
131
|
+
setLoading(false);
|
|
132
|
+
setIsZip(false);
|
|
133
|
+
},
|
|
134
|
+
ref: iframeRef,
|
|
135
|
+
id: "view-office-iframe"
|
|
136
|
+
}), loading && /*#__PURE__*/React.createElement(Loading, {
|
|
137
|
+
className: "file-loading"
|
|
115
138
|
})));
|
|
116
139
|
};
|
|
117
140
|
export default ViewDocment;
|
|
@@ -516,7 +516,9 @@ a:hover {
|
|
|
516
516
|
}
|
|
517
517
|
|
|
518
518
|
.view-office-modal {
|
|
519
|
+
position: relative;
|
|
519
520
|
.ant-modal-body {
|
|
521
|
+
position: relative;
|
|
520
522
|
padding: 0;
|
|
521
523
|
}
|
|
522
524
|
iframe {
|
|
@@ -524,6 +526,13 @@ a:hover {
|
|
|
524
526
|
height: 100%;
|
|
525
527
|
border: none;
|
|
526
528
|
}
|
|
529
|
+
.file-loading {
|
|
530
|
+
position: absolute;
|
|
531
|
+
top: 0;
|
|
532
|
+
left: 0;
|
|
533
|
+
width: 100%;
|
|
534
|
+
height: 100%;
|
|
535
|
+
}
|
|
527
536
|
}
|
|
528
537
|
|
|
529
538
|
@import url('./antd-custom.less');
|
package/es/http/bizAjax.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
export declare type OptionItemType = {
|
|
2
|
+
value: string | number;
|
|
3
|
+
label: string;
|
|
4
|
+
[key: string]: string | number;
|
|
5
|
+
};
|
|
1
6
|
/**
|
|
2
7
|
* 读取数据字典
|
|
3
8
|
*
|
|
@@ -9,7 +14,7 @@
|
|
|
9
14
|
* @param valueIsNumber 返回值是否为数字,默认false
|
|
10
15
|
* @returns Promise<Record<string,string>[]>
|
|
11
16
|
*/
|
|
12
|
-
export declare function getDict(dictCodes: string, showValue?: boolean, needGateWay?: boolean, timeout?: number, isGet?: boolean, valueIsNumber?: boolean): Promise<
|
|
17
|
+
export declare function getDict(dictCodes: string, showValue?: boolean, needGateWay?: boolean, timeout?: number, isGet?: boolean, valueIsNumber?: boolean): Promise<OptionItemType[]>;
|
|
13
18
|
/**
|
|
14
19
|
* 加载下拉框的数据源
|
|
15
20
|
*
|
|
@@ -24,7 +29,7 @@ export declare function getDict(dictCodes: string, showValue?: boolean, needGate
|
|
|
24
29
|
* @param valueIsNumber 返回值是否为数字,默认false
|
|
25
30
|
* @returns
|
|
26
31
|
*/
|
|
27
|
-
export declare function fetchOptions(url: string, param: any, valueField: string, labelField: string, showValue?: boolean, needGateWay?: boolean, timeout?: number, isGet?: boolean, valueIsNumber?: boolean): Promise<
|
|
32
|
+
export declare function fetchOptions(url: string, param: any, valueField: string, labelField: string, showValue?: boolean, needGateWay?: boolean, timeout?: number, isGet?: boolean, valueIsNumber?: boolean): Promise<OptionItemType[]>;
|
|
28
33
|
/**
|
|
29
34
|
* 获取用户资源Id对应的权限值
|
|
30
35
|
*
|
package/es/index.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ export * from './http';
|
|
|
9
9
|
export { default as BaseService } from './service/BaseService';
|
|
10
10
|
/** 导出进度及完成后自动下载 */
|
|
11
11
|
export { default as exportProcess } from './utils/exportProcess';
|
|
12
|
+
/** 后台任务进度查看 */
|
|
13
|
+
export { default as taskProcess } from './utils/taskProcess';
|
|
12
14
|
/** Utils 方法,放在第一层级,方便调用 */
|
|
13
15
|
export * from './utils';
|
|
14
16
|
/** 主数据请求 */
|
package/es/index.js
CHANGED
|
@@ -9,6 +9,8 @@ export * from './http';
|
|
|
9
9
|
export { default as BaseService } from './service/BaseService';
|
|
10
10
|
/** 导出进度及完成后自动下载 */
|
|
11
11
|
export { default as exportProcess } from './utils/exportProcess';
|
|
12
|
+
/** 后台任务进度查看 */
|
|
13
|
+
export { default as taskProcess } from './utils/taskProcess';
|
|
12
14
|
/** Utils 方法,放在第一层级,方便调用 */
|
|
13
15
|
export * from './utils';
|
|
14
16
|
/** 主数据请求 */
|
|
@@ -0,0 +1,139 @@
|
|
|
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";
|
|
5
|
+
import React from "react";
|
|
6
|
+
import { showSuccess, showError, sleep, showWarn } from '.';
|
|
7
|
+
import { httpGet } from '../http';
|
|
8
|
+
/**
|
|
9
|
+
* 后台任务进度查看
|
|
10
|
+
*
|
|
11
|
+
* @param taskId 后台任务id,
|
|
12
|
+
* @param taskName 后台任务名称,
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
15
|
+
var taskProcess = function taskProcess(taskId) {
|
|
16
|
+
var taskName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
17
|
+
if (!taskId) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
var exit = false;
|
|
21
|
+
var key = 'task-' + taskId;
|
|
22
|
+
var dom = null;
|
|
23
|
+
var moveState = {
|
|
24
|
+
isMove: false,
|
|
25
|
+
startLeft: 0,
|
|
26
|
+
startTop: 0,
|
|
27
|
+
startX: 0,
|
|
28
|
+
startY: 0,
|
|
29
|
+
h: 88,
|
|
30
|
+
w: 250 //组件宽度
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
var onMove = function onMove(e) {
|
|
34
|
+
requestAnimationFrame(function () {
|
|
35
|
+
var startLeft = moveState.startLeft,
|
|
36
|
+
startTop = moveState.startTop,
|
|
37
|
+
startX = moveState.startX,
|
|
38
|
+
startY = moveState.startY,
|
|
39
|
+
isMove = moveState.isMove,
|
|
40
|
+
h = moveState.h,
|
|
41
|
+
w = moveState.w;
|
|
42
|
+
if (!isMove || !dom) return;
|
|
43
|
+
// 通过计算鼠标的移动距离,计算出组件新的坐标。
|
|
44
|
+
var deltaX = document.body.clientWidth - (e.clientX - startX + startLeft) - w;
|
|
45
|
+
var deltaY = e.clientY - startY + startTop;
|
|
46
|
+
var top = Math.max(0, Math.min(document.body.clientHeight - h, deltaY));
|
|
47
|
+
var right = Math.max(0, Math.min(document.body.clientWidth - w - 30, deltaX));
|
|
48
|
+
dom.style.top = top + 'px';
|
|
49
|
+
dom.style.right = right + 'px';
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
var onUp = function onUp() {
|
|
53
|
+
moveState.isMove = false;
|
|
54
|
+
document.body.classList.remove('move-unselect');
|
|
55
|
+
document.removeEventListener('mouseup', onUp);
|
|
56
|
+
document.removeEventListener('mousemove', onMove);
|
|
57
|
+
};
|
|
58
|
+
var loading = function loading(percent) {
|
|
59
|
+
_notification.open({
|
|
60
|
+
className: 'export-process-notification',
|
|
61
|
+
placement: 'topRight',
|
|
62
|
+
key: key,
|
|
63
|
+
duration: 0,
|
|
64
|
+
message: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
|
|
65
|
+
className: "export-process-handle",
|
|
66
|
+
onMouseDown: function onMouseDown(e) {
|
|
67
|
+
dom = e.target.closest('.ant-notification-topRight');
|
|
68
|
+
if (!dom) return;
|
|
69
|
+
var rect = dom.getBoundingClientRect();
|
|
70
|
+
moveState.isMove = true;
|
|
71
|
+
moveState.startX = e.clientX;
|
|
72
|
+
moveState.startY = e.clientY;
|
|
73
|
+
moveState.startLeft = rect.left;
|
|
74
|
+
moveState.startTop = rect.top;
|
|
75
|
+
document.body.classList.add('move-unselect');
|
|
76
|
+
document.addEventListener('mouseup', onUp);
|
|
77
|
+
document.addEventListener('mousemove', onMove);
|
|
78
|
+
}
|
|
79
|
+
}, "".concat(taskName || '任务', " \u5904\u7406\u4E2D...")), /*#__PURE__*/React.createElement(_Progress, {
|
|
80
|
+
percent: percent
|
|
81
|
+
})),
|
|
82
|
+
onClose: function onClose() {
|
|
83
|
+
exit = true;
|
|
84
|
+
document.removeEventListener('mouseup', onUp);
|
|
85
|
+
document.removeEventListener('mousemove', onMove);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
loading(0);
|
|
90
|
+
var getResult = function getResult() {
|
|
91
|
+
if (exit) return;
|
|
92
|
+
var url = '/lesoon/lesoon-msg-center-api/bizAsyncTaskManage/page';
|
|
93
|
+
httpGet(url, {
|
|
94
|
+
'page': 1,
|
|
95
|
+
'pageSize': 1,
|
|
96
|
+
where: {
|
|
97
|
+
taskId: taskId
|
|
98
|
+
}
|
|
99
|
+
}, false).then(function (result) {
|
|
100
|
+
var _result$rows = result.rows,
|
|
101
|
+
rows = _result$rows === void 0 ? [] : _result$rows;
|
|
102
|
+
var row = rows === null || rows === void 0 ? void 0 : rows[0];
|
|
103
|
+
if (!row) {
|
|
104
|
+
showError('获取任务进度失败,请在消息中心查看任务结果');
|
|
105
|
+
_notification.close(key);
|
|
106
|
+
} else {
|
|
107
|
+
var status = row.status,
|
|
108
|
+
progress = row.progress;
|
|
109
|
+
if (status < 30) {
|
|
110
|
+
//任务处理中,过3秒后再次获取任务进度。
|
|
111
|
+
loading(progress);
|
|
112
|
+
sleep(3).then(function () {
|
|
113
|
+
return getResult();
|
|
114
|
+
});
|
|
115
|
+
} else {
|
|
116
|
+
// 任务已处理完成或失败或终止,关闭通知。
|
|
117
|
+
if (status === 30) {
|
|
118
|
+
loading(100);
|
|
119
|
+
showSuccess('任务处理完成');
|
|
120
|
+
} else if (status === 40) {
|
|
121
|
+
showError('任务处理失败,请在消息中心查看失败原因');
|
|
122
|
+
} else if (status === 50) {
|
|
123
|
+
showWarn('任务已终止,请在消息中心查看任务结果');
|
|
124
|
+
}
|
|
125
|
+
sleep(1.5).then(function () {
|
|
126
|
+
_notification.close(key);
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}).catch(function () {
|
|
131
|
+
showError('获取任务进度失败,请在消息中心查看任务结果');
|
|
132
|
+
_notification.close(key);
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
sleep(1).then(function () {
|
|
136
|
+
return getResult();
|
|
137
|
+
});
|
|
138
|
+
};
|
|
139
|
+
export default taskProcess;
|
|
@@ -4,10 +4,11 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
|
4
4
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
5
5
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
6
6
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
7
|
-
import React, { useState, useMemo } from 'react';
|
|
7
|
+
import React, { useState, useMemo, useRef } from 'react';
|
|
8
8
|
import { EyeOutlined } from '@ant-design/icons';
|
|
9
|
-
import { getCookie,
|
|
9
|
+
import { getCookie, getUrlQuery } from '../utils';
|
|
10
10
|
import { base64Encode } from 'ls-pro-tools';
|
|
11
|
+
import Loading from './Loading';
|
|
11
12
|
var ViewDocment = function ViewDocment(props) {
|
|
12
13
|
var _props$open = props.open,
|
|
13
14
|
open = _props$open === void 0 ? false : _props$open,
|
|
@@ -27,6 +28,15 @@ var ViewDocment = function ViewDocment(props) {
|
|
|
27
28
|
_useState2 = _slicedToArray(_useState, 2),
|
|
28
29
|
visible = _useState2[0],
|
|
29
30
|
setVisible = _useState2[1];
|
|
31
|
+
var _useState3 = useState(false),
|
|
32
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
33
|
+
isZip = _useState4[0],
|
|
34
|
+
setIsZip = _useState4[1];
|
|
35
|
+
var _useState5 = useState(mode !== 'modal'),
|
|
36
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
37
|
+
loading = _useState6[0],
|
|
38
|
+
setLoading = _useState6[1];
|
|
39
|
+
var iframeRef = useRef(null);
|
|
30
40
|
var src = useMemo(function () {
|
|
31
41
|
var token = getCookie('token');
|
|
32
42
|
var filename = getUrlQuery('fileName', url); //文件名,上传的文件名为xxx?fileName=xxx.pdf
|
|
@@ -46,13 +56,13 @@ var ViewDocment = function ViewDocment(props) {
|
|
|
46
56
|
filename = filename.replace(/[^a-zA-Z0-9\u4e00-\u9fa5.]/g, '');
|
|
47
57
|
href = href + (href.includes('?') ? '&' : '?') + 'fullfilename=' + filename;
|
|
48
58
|
}
|
|
59
|
+
if (filename.endsWith('.zip')) {
|
|
60
|
+
setIsZip(true);
|
|
61
|
+
}
|
|
49
62
|
var doc = base64Encode(href);
|
|
50
|
-
|
|
63
|
+
// 统一使用生产环境来预览文件
|
|
64
|
+
// const exportUrl = getCache('exportUrl');
|
|
51
65
|
var domain = 'https://download.lesoon.cloud';
|
|
52
|
-
// if (exportUrl && exportUrl.includes('//')) {
|
|
53
|
-
// // 如果配置了下载域名,则走下载域名,否则走原来域名
|
|
54
|
-
// domain = exportUrl;
|
|
55
|
-
// }
|
|
56
66
|
return domain + '/lesoon/lesoon-kkfileview-api/onlinePreview?url=' + doc;
|
|
57
67
|
}, [url]);
|
|
58
68
|
var triggerDom = /*#__PURE__*/React.createElement(React.Fragment, {
|
|
@@ -64,13 +74,14 @@ var ViewDocment = function ViewDocment(props) {
|
|
|
64
74
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
65
75
|
while (1) switch (_context.prev = _context.next) {
|
|
66
76
|
case 0:
|
|
67
|
-
setVisible(
|
|
77
|
+
setVisible(true);
|
|
78
|
+
setLoading(true);
|
|
68
79
|
(_trigger$props = trigger.props) === null || _trigger$props === void 0 ? void 0 : (_trigger$props$onClic = _trigger$props.onClick) === null || _trigger$props$onClic === void 0 ? void 0 : _trigger$props$onClic.call(_trigger$props, e);
|
|
69
80
|
// 新页签打开
|
|
70
81
|
if (mode === 'urlOpen') {
|
|
71
82
|
window.open(src, '_blank');
|
|
72
83
|
}
|
|
73
|
-
case
|
|
84
|
+
case 4:
|
|
74
85
|
case "end":
|
|
75
86
|
return _context.stop();
|
|
76
87
|
}
|
|
@@ -85,7 +96,7 @@ var ViewDocment = function ViewDocment(props) {
|
|
|
85
96
|
if (mode === 'urlOpen') {
|
|
86
97
|
return /*#__PURE__*/React.createElement(React.Fragment, null, props.children, triggerDom);
|
|
87
98
|
} else if (mode === 'iframe') {
|
|
88
|
-
/*#__PURE__*/React.createElement(React.Fragment, null, props.children, /*#__PURE__*/React.createElement("div", {
|
|
99
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, props.children, /*#__PURE__*/React.createElement("div", {
|
|
89
100
|
className: "view-office-modal",
|
|
90
101
|
style: {
|
|
91
102
|
width: width,
|
|
@@ -109,9 +120,21 @@ var ViewDocment = function ViewDocment(props) {
|
|
|
109
120
|
bodyStyle: {
|
|
110
121
|
height: height
|
|
111
122
|
},
|
|
112
|
-
footer: null
|
|
123
|
+
footer: null,
|
|
124
|
+
destroyOnClose: true
|
|
113
125
|
}, /*#__PURE__*/React.createElement("iframe", {
|
|
114
|
-
src: src
|
|
126
|
+
src: src,
|
|
127
|
+
onLoad: function onLoad() {
|
|
128
|
+
setLoading(false);
|
|
129
|
+
},
|
|
130
|
+
onError: function onError() {
|
|
131
|
+
setLoading(false);
|
|
132
|
+
setIsZip(false);
|
|
133
|
+
},
|
|
134
|
+
ref: iframeRef,
|
|
135
|
+
id: "view-office-iframe"
|
|
136
|
+
}), loading && /*#__PURE__*/React.createElement(Loading, {
|
|
137
|
+
className: "file-loading"
|
|
115
138
|
})));
|
|
116
139
|
};
|
|
117
140
|
export default ViewDocment;
|
|
@@ -516,7 +516,9 @@ a:hover {
|
|
|
516
516
|
}
|
|
517
517
|
|
|
518
518
|
.view-office-modal {
|
|
519
|
+
position: relative;
|
|
519
520
|
.ant-modal-body {
|
|
521
|
+
position: relative;
|
|
520
522
|
padding: 0;
|
|
521
523
|
}
|
|
522
524
|
iframe {
|
|
@@ -524,6 +526,13 @@ a:hover {
|
|
|
524
526
|
height: 100%;
|
|
525
527
|
border: none;
|
|
526
528
|
}
|
|
529
|
+
.file-loading {
|
|
530
|
+
position: absolute;
|
|
531
|
+
top: 0;
|
|
532
|
+
left: 0;
|
|
533
|
+
width: 100%;
|
|
534
|
+
height: 100%;
|
|
535
|
+
}
|
|
527
536
|
}
|
|
528
537
|
|
|
529
538
|
@import url('./antd-custom.less');
|
package/lib/http/bizAjax.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
export declare type OptionItemType = {
|
|
2
|
+
value: string | number;
|
|
3
|
+
label: string;
|
|
4
|
+
[key: string]: string | number;
|
|
5
|
+
};
|
|
1
6
|
/**
|
|
2
7
|
* 读取数据字典
|
|
3
8
|
*
|
|
@@ -9,7 +14,7 @@
|
|
|
9
14
|
* @param valueIsNumber 返回值是否为数字,默认false
|
|
10
15
|
* @returns Promise<Record<string,string>[]>
|
|
11
16
|
*/
|
|
12
|
-
export declare function getDict(dictCodes: string, showValue?: boolean, needGateWay?: boolean, timeout?: number, isGet?: boolean, valueIsNumber?: boolean): Promise<
|
|
17
|
+
export declare function getDict(dictCodes: string, showValue?: boolean, needGateWay?: boolean, timeout?: number, isGet?: boolean, valueIsNumber?: boolean): Promise<OptionItemType[]>;
|
|
13
18
|
/**
|
|
14
19
|
* 加载下拉框的数据源
|
|
15
20
|
*
|
|
@@ -24,7 +29,7 @@ export declare function getDict(dictCodes: string, showValue?: boolean, needGate
|
|
|
24
29
|
* @param valueIsNumber 返回值是否为数字,默认false
|
|
25
30
|
* @returns
|
|
26
31
|
*/
|
|
27
|
-
export declare function fetchOptions(url: string, param: any, valueField: string, labelField: string, showValue?: boolean, needGateWay?: boolean, timeout?: number, isGet?: boolean, valueIsNumber?: boolean): Promise<
|
|
32
|
+
export declare function fetchOptions(url: string, param: any, valueField: string, labelField: string, showValue?: boolean, needGateWay?: boolean, timeout?: number, isGet?: boolean, valueIsNumber?: boolean): Promise<OptionItemType[]>;
|
|
28
33
|
/**
|
|
29
34
|
* 获取用户资源Id对应的权限值
|
|
30
35
|
*
|
package/lib/index.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ export * from './http';
|
|
|
9
9
|
export { default as BaseService } from './service/BaseService';
|
|
10
10
|
/** 导出进度及完成后自动下载 */
|
|
11
11
|
export { default as exportProcess } from './utils/exportProcess';
|
|
12
|
+
/** 后台任务进度查看 */
|
|
13
|
+
export { default as taskProcess } from './utils/taskProcess';
|
|
12
14
|
/** Utils 方法,放在第一层级,方便调用 */
|
|
13
15
|
export * from './utils';
|
|
14
16
|
/** 主数据请求 */
|
package/lib/index.js
CHANGED
|
@@ -9,6 +9,8 @@ export * from './http';
|
|
|
9
9
|
export { default as BaseService } from './service/BaseService';
|
|
10
10
|
/** 导出进度及完成后自动下载 */
|
|
11
11
|
export { default as exportProcess } from './utils/exportProcess';
|
|
12
|
+
/** 后台任务进度查看 */
|
|
13
|
+
export { default as taskProcess } from './utils/taskProcess';
|
|
12
14
|
/** Utils 方法,放在第一层级,方便调用 */
|
|
13
15
|
export * from './utils';
|
|
14
16
|
/** 主数据请求 */
|
|
@@ -0,0 +1,139 @@
|
|
|
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";
|
|
5
|
+
import React from "react";
|
|
6
|
+
import { showSuccess, showError, sleep, showWarn } from '.';
|
|
7
|
+
import { httpGet } from '../http';
|
|
8
|
+
/**
|
|
9
|
+
* 后台任务进度查看
|
|
10
|
+
*
|
|
11
|
+
* @param taskId 后台任务id,
|
|
12
|
+
* @param taskName 后台任务名称,
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
15
|
+
var taskProcess = function taskProcess(taskId) {
|
|
16
|
+
var taskName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
17
|
+
if (!taskId) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
var exit = false;
|
|
21
|
+
var key = 'task-' + taskId;
|
|
22
|
+
var dom = null;
|
|
23
|
+
var moveState = {
|
|
24
|
+
isMove: false,
|
|
25
|
+
startLeft: 0,
|
|
26
|
+
startTop: 0,
|
|
27
|
+
startX: 0,
|
|
28
|
+
startY: 0,
|
|
29
|
+
h: 88,
|
|
30
|
+
w: 250 //组件宽度
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
var onMove = function onMove(e) {
|
|
34
|
+
requestAnimationFrame(function () {
|
|
35
|
+
var startLeft = moveState.startLeft,
|
|
36
|
+
startTop = moveState.startTop,
|
|
37
|
+
startX = moveState.startX,
|
|
38
|
+
startY = moveState.startY,
|
|
39
|
+
isMove = moveState.isMove,
|
|
40
|
+
h = moveState.h,
|
|
41
|
+
w = moveState.w;
|
|
42
|
+
if (!isMove || !dom) return;
|
|
43
|
+
// 通过计算鼠标的移动距离,计算出组件新的坐标。
|
|
44
|
+
var deltaX = document.body.clientWidth - (e.clientX - startX + startLeft) - w;
|
|
45
|
+
var deltaY = e.clientY - startY + startTop;
|
|
46
|
+
var top = Math.max(0, Math.min(document.body.clientHeight - h, deltaY));
|
|
47
|
+
var right = Math.max(0, Math.min(document.body.clientWidth - w - 30, deltaX));
|
|
48
|
+
dom.style.top = top + 'px';
|
|
49
|
+
dom.style.right = right + 'px';
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
var onUp = function onUp() {
|
|
53
|
+
moveState.isMove = false;
|
|
54
|
+
document.body.classList.remove('move-unselect');
|
|
55
|
+
document.removeEventListener('mouseup', onUp);
|
|
56
|
+
document.removeEventListener('mousemove', onMove);
|
|
57
|
+
};
|
|
58
|
+
var loading = function loading(percent) {
|
|
59
|
+
_notification.open({
|
|
60
|
+
className: 'export-process-notification',
|
|
61
|
+
placement: 'topRight',
|
|
62
|
+
key: key,
|
|
63
|
+
duration: 0,
|
|
64
|
+
message: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
|
|
65
|
+
className: "export-process-handle",
|
|
66
|
+
onMouseDown: function onMouseDown(e) {
|
|
67
|
+
dom = e.target.closest('.ant-notification-topRight');
|
|
68
|
+
if (!dom) return;
|
|
69
|
+
var rect = dom.getBoundingClientRect();
|
|
70
|
+
moveState.isMove = true;
|
|
71
|
+
moveState.startX = e.clientX;
|
|
72
|
+
moveState.startY = e.clientY;
|
|
73
|
+
moveState.startLeft = rect.left;
|
|
74
|
+
moveState.startTop = rect.top;
|
|
75
|
+
document.body.classList.add('move-unselect');
|
|
76
|
+
document.addEventListener('mouseup', onUp);
|
|
77
|
+
document.addEventListener('mousemove', onMove);
|
|
78
|
+
}
|
|
79
|
+
}, "".concat(taskName || '任务', " \u5904\u7406\u4E2D...")), /*#__PURE__*/React.createElement(_Progress, {
|
|
80
|
+
percent: percent
|
|
81
|
+
})),
|
|
82
|
+
onClose: function onClose() {
|
|
83
|
+
exit = true;
|
|
84
|
+
document.removeEventListener('mouseup', onUp);
|
|
85
|
+
document.removeEventListener('mousemove', onMove);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
loading(0);
|
|
90
|
+
var getResult = function getResult() {
|
|
91
|
+
if (exit) return;
|
|
92
|
+
var url = '/lesoon/lesoon-msg-center-api/bizAsyncTaskManage/page';
|
|
93
|
+
httpGet(url, {
|
|
94
|
+
'page': 1,
|
|
95
|
+
'pageSize': 1,
|
|
96
|
+
where: {
|
|
97
|
+
taskId: taskId
|
|
98
|
+
}
|
|
99
|
+
}, false).then(function (result) {
|
|
100
|
+
var _result$rows = result.rows,
|
|
101
|
+
rows = _result$rows === void 0 ? [] : _result$rows;
|
|
102
|
+
var row = rows === null || rows === void 0 ? void 0 : rows[0];
|
|
103
|
+
if (!row) {
|
|
104
|
+
showError('获取任务进度失败,请在消息中心查看任务结果');
|
|
105
|
+
_notification.close(key);
|
|
106
|
+
} else {
|
|
107
|
+
var status = row.status,
|
|
108
|
+
progress = row.progress;
|
|
109
|
+
if (status < 30) {
|
|
110
|
+
//任务处理中,过3秒后再次获取任务进度。
|
|
111
|
+
loading(progress);
|
|
112
|
+
sleep(3).then(function () {
|
|
113
|
+
return getResult();
|
|
114
|
+
});
|
|
115
|
+
} else {
|
|
116
|
+
// 任务已处理完成或失败或终止,关闭通知。
|
|
117
|
+
if (status === 30) {
|
|
118
|
+
loading(100);
|
|
119
|
+
showSuccess('任务处理完成');
|
|
120
|
+
} else if (status === 40) {
|
|
121
|
+
showError('任务处理失败,请在消息中心查看失败原因');
|
|
122
|
+
} else if (status === 50) {
|
|
123
|
+
showWarn('任务已终止,请在消息中心查看任务结果');
|
|
124
|
+
}
|
|
125
|
+
sleep(1.5).then(function () {
|
|
126
|
+
_notification.close(key);
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}).catch(function () {
|
|
131
|
+
showError('获取任务进度失败,请在消息中心查看任务结果');
|
|
132
|
+
_notification.close(key);
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
sleep(1).then(function () {
|
|
136
|
+
return getResult();
|
|
137
|
+
});
|
|
138
|
+
};
|
|
139
|
+
export default taskProcess;
|