ls-pro-common 3.1.60 → 3.1.62
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 +39 -13
- package/es/components/common.less +9 -0
- package/es/http/bizAjax.d.ts +7 -2
- package/lib/components/DtlLayout.d.ts +1 -1
- package/lib/components/ViewOffice.js +39 -13
- package/lib/components/common.less +9 -0
- package/lib/http/bizAjax.d.ts +7 -2
- 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,12 +28,24 @@ 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
|
|
33
43
|
if (!filename) {
|
|
34
44
|
//外部文件比如,xxx/ddd.docx,兜底直接给个临时的,但好像有问题,因为后端不知道文件类型
|
|
35
45
|
filename = url.split('/').pop() || Date.now().toString(32);
|
|
46
|
+
if (filename.includes('?')) {
|
|
47
|
+
filename = filename.split('?')[0];
|
|
48
|
+
}
|
|
36
49
|
}
|
|
37
50
|
var href = url;
|
|
38
51
|
if (!url.includes('token=')) {
|
|
@@ -40,16 +53,16 @@ var ViewDocment = function ViewDocment(props) {
|
|
|
40
53
|
}
|
|
41
54
|
if (!href.includes('fullfilename=')) {
|
|
42
55
|
//filename只保留中文,英文和数字
|
|
43
|
-
filename = filename.replace(/[^a-zA-Z0-9\u4e00-\u9fa5]/g, '');
|
|
56
|
+
filename = filename.replace(/[^a-zA-Z0-9\u4e00-\u9fa5.]/g, '');
|
|
44
57
|
href = href + (href.includes('?') ? '&' : '?') + 'fullfilename=' + filename;
|
|
45
58
|
}
|
|
59
|
+
if (filename.endsWith('.zip')) {
|
|
60
|
+
setIsZip(true);
|
|
61
|
+
}
|
|
46
62
|
var doc = base64Encode(href);
|
|
47
|
-
|
|
63
|
+
// 统一使用生产环境来预览文件
|
|
64
|
+
// const exportUrl = getCache('exportUrl');
|
|
48
65
|
var domain = 'https://download.lesoon.cloud';
|
|
49
|
-
// if (exportUrl && exportUrl.includes('//')) {
|
|
50
|
-
// // 如果配置了下载域名,则走下载域名,否则走原来域名
|
|
51
|
-
// domain = exportUrl;
|
|
52
|
-
// }
|
|
53
66
|
return domain + '/lesoon/lesoon-kkfileview-api/onlinePreview?url=' + doc;
|
|
54
67
|
}, [url]);
|
|
55
68
|
var triggerDom = /*#__PURE__*/React.createElement(React.Fragment, {
|
|
@@ -61,13 +74,14 @@ var ViewDocment = function ViewDocment(props) {
|
|
|
61
74
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
62
75
|
while (1) switch (_context.prev = _context.next) {
|
|
63
76
|
case 0:
|
|
64
|
-
setVisible(
|
|
77
|
+
setVisible(true);
|
|
78
|
+
setLoading(true);
|
|
65
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);
|
|
66
80
|
// 新页签打开
|
|
67
81
|
if (mode === 'urlOpen') {
|
|
68
82
|
window.open(src, '_blank');
|
|
69
83
|
}
|
|
70
|
-
case
|
|
84
|
+
case 4:
|
|
71
85
|
case "end":
|
|
72
86
|
return _context.stop();
|
|
73
87
|
}
|
|
@@ -82,7 +96,7 @@ var ViewDocment = function ViewDocment(props) {
|
|
|
82
96
|
if (mode === 'urlOpen') {
|
|
83
97
|
return /*#__PURE__*/React.createElement(React.Fragment, null, props.children, triggerDom);
|
|
84
98
|
} else if (mode === 'iframe') {
|
|
85
|
-
/*#__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", {
|
|
86
100
|
className: "view-office-modal",
|
|
87
101
|
style: {
|
|
88
102
|
width: width,
|
|
@@ -106,9 +120,21 @@ var ViewDocment = function ViewDocment(props) {
|
|
|
106
120
|
bodyStyle: {
|
|
107
121
|
height: height
|
|
108
122
|
},
|
|
109
|
-
footer: null
|
|
123
|
+
footer: null,
|
|
124
|
+
destroyOnClose: true
|
|
110
125
|
}, /*#__PURE__*/React.createElement("iframe", {
|
|
111
|
-
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"
|
|
112
138
|
})));
|
|
113
139
|
};
|
|
114
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
|
*
|
|
@@ -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,12 +28,24 @@ 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
|
|
33
43
|
if (!filename) {
|
|
34
44
|
//外部文件比如,xxx/ddd.docx,兜底直接给个临时的,但好像有问题,因为后端不知道文件类型
|
|
35
45
|
filename = url.split('/').pop() || Date.now().toString(32);
|
|
46
|
+
if (filename.includes('?')) {
|
|
47
|
+
filename = filename.split('?')[0];
|
|
48
|
+
}
|
|
36
49
|
}
|
|
37
50
|
var href = url;
|
|
38
51
|
if (!url.includes('token=')) {
|
|
@@ -40,16 +53,16 @@ var ViewDocment = function ViewDocment(props) {
|
|
|
40
53
|
}
|
|
41
54
|
if (!href.includes('fullfilename=')) {
|
|
42
55
|
//filename只保留中文,英文和数字
|
|
43
|
-
filename = filename.replace(/[^a-zA-Z0-9\u4e00-\u9fa5]/g, '');
|
|
56
|
+
filename = filename.replace(/[^a-zA-Z0-9\u4e00-\u9fa5.]/g, '');
|
|
44
57
|
href = href + (href.includes('?') ? '&' : '?') + 'fullfilename=' + filename;
|
|
45
58
|
}
|
|
59
|
+
if (filename.endsWith('.zip')) {
|
|
60
|
+
setIsZip(true);
|
|
61
|
+
}
|
|
46
62
|
var doc = base64Encode(href);
|
|
47
|
-
|
|
63
|
+
// 统一使用生产环境来预览文件
|
|
64
|
+
// const exportUrl = getCache('exportUrl');
|
|
48
65
|
var domain = 'https://download.lesoon.cloud';
|
|
49
|
-
// if (exportUrl && exportUrl.includes('//')) {
|
|
50
|
-
// // 如果配置了下载域名,则走下载域名,否则走原来域名
|
|
51
|
-
// domain = exportUrl;
|
|
52
|
-
// }
|
|
53
66
|
return domain + '/lesoon/lesoon-kkfileview-api/onlinePreview?url=' + doc;
|
|
54
67
|
}, [url]);
|
|
55
68
|
var triggerDom = /*#__PURE__*/React.createElement(React.Fragment, {
|
|
@@ -61,13 +74,14 @@ var ViewDocment = function ViewDocment(props) {
|
|
|
61
74
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
62
75
|
while (1) switch (_context.prev = _context.next) {
|
|
63
76
|
case 0:
|
|
64
|
-
setVisible(
|
|
77
|
+
setVisible(true);
|
|
78
|
+
setLoading(true);
|
|
65
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);
|
|
66
80
|
// 新页签打开
|
|
67
81
|
if (mode === 'urlOpen') {
|
|
68
82
|
window.open(src, '_blank');
|
|
69
83
|
}
|
|
70
|
-
case
|
|
84
|
+
case 4:
|
|
71
85
|
case "end":
|
|
72
86
|
return _context.stop();
|
|
73
87
|
}
|
|
@@ -82,7 +96,7 @@ var ViewDocment = function ViewDocment(props) {
|
|
|
82
96
|
if (mode === 'urlOpen') {
|
|
83
97
|
return /*#__PURE__*/React.createElement(React.Fragment, null, props.children, triggerDom);
|
|
84
98
|
} else if (mode === 'iframe') {
|
|
85
|
-
/*#__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", {
|
|
86
100
|
className: "view-office-modal",
|
|
87
101
|
style: {
|
|
88
102
|
width: width,
|
|
@@ -106,9 +120,21 @@ var ViewDocment = function ViewDocment(props) {
|
|
|
106
120
|
bodyStyle: {
|
|
107
121
|
height: height
|
|
108
122
|
},
|
|
109
|
-
footer: null
|
|
123
|
+
footer: null,
|
|
124
|
+
destroyOnClose: true
|
|
110
125
|
}, /*#__PURE__*/React.createElement("iframe", {
|
|
111
|
-
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"
|
|
112
138
|
})));
|
|
113
139
|
};
|
|
114
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
|
*
|