ls-pro-common 3.1.1 → 3.1.3
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.js +1 -1
- package/dist/common.min.js +1 -1
- package/es/components/RecordLog/index.d.ts +3 -1
- package/es/components/RecordLog/index.js +12 -3
- package/es/components/ViewOffice.d.ts +2 -2
- package/es/components/ViewOffice.js +4 -3
- package/es/hooks/usePermission/index.js +10 -4
- package/es/utils/index.js +6 -0
- package/lib/components/RecordLog/index.d.ts +3 -1
- package/lib/components/RecordLog/index.js +12 -3
- package/lib/components/ViewOffice.d.ts +2 -2
- package/lib/components/ViewOffice.js +4 -3
- package/lib/hooks/usePermission/index.js +10 -4
- package/lib/utils/index.js +6 -0
- package/package.json +1 -1
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import './index.less';
|
|
8
8
|
export interface RecordLogProps {
|
|
9
|
-
recordKey
|
|
9
|
+
recordKey?: string;
|
|
10
|
+
bizNo?: string;
|
|
11
|
+
param?: any;
|
|
10
12
|
fieldsMap?: Record<string, string>;
|
|
11
13
|
showResourceName?: boolean;
|
|
12
14
|
style?: React.CSSProperties;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import "antd/es/empty/style";
|
|
2
2
|
import _Empty from "antd/es/empty";
|
|
3
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
4
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
5
|
/**
|
|
5
6
|
* 记录变更日志
|
|
@@ -22,6 +23,10 @@ var RecordLog = function RecordLog(props) {
|
|
|
22
23
|
setLogData = _useState2[1];
|
|
23
24
|
var _props$recordKey = props.recordKey,
|
|
24
25
|
recordKey = _props$recordKey === void 0 ? '' : _props$recordKey,
|
|
26
|
+
_props$bizNo = props.bizNo,
|
|
27
|
+
bizNo = _props$bizNo === void 0 ? '' : _props$bizNo,
|
|
28
|
+
_props$param = props.param,
|
|
29
|
+
param = _props$param === void 0 ? {} : _props$param,
|
|
25
30
|
_props$fieldsMap = props.fieldsMap,
|
|
26
31
|
fieldsMap = _props$fieldsMap === void 0 ? {} : _props$fieldsMap,
|
|
27
32
|
_props$showResourceNa = props.showResourceName,
|
|
@@ -34,10 +39,14 @@ var RecordLog = function RecordLog(props) {
|
|
|
34
39
|
var params = {
|
|
35
40
|
pageSize: 5000,
|
|
36
41
|
sort: 'createTime desc',
|
|
37
|
-
where: {
|
|
38
|
-
dataCode: recordKey
|
|
39
|
-
}
|
|
42
|
+
where: _objectSpread({}, param)
|
|
40
43
|
};
|
|
44
|
+
if (recordKey) {
|
|
45
|
+
params.where.dataCode = recordKey;
|
|
46
|
+
}
|
|
47
|
+
if (bizNo) {
|
|
48
|
+
params.where.bizNo = bizNo;
|
|
49
|
+
}
|
|
41
50
|
httpGet(url, params).then(function (res) {
|
|
42
51
|
var rows = (res === null || res === void 0 ? void 0 : res.rows) || [];
|
|
43
52
|
rows.forEach(function (row) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
declare const
|
|
2
|
+
declare const ViewDocment: (props: {
|
|
3
3
|
open?: boolean;
|
|
4
4
|
onCancel?: () => void;
|
|
5
5
|
title?: string;
|
|
@@ -9,4 +9,4 @@ declare const TagCheck: (props: {
|
|
|
9
9
|
trigger?: JSX.Element;
|
|
10
10
|
url: string;
|
|
11
11
|
}) => JSX.Element;
|
|
12
|
-
export default
|
|
12
|
+
export default ViewDocment;
|
|
@@ -7,7 +7,8 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
7
7
|
import React, { useState, useMemo } from 'react';
|
|
8
8
|
import { EyeOutlined } from '@ant-design/icons';
|
|
9
9
|
import { getCookie } from '../utils';
|
|
10
|
-
|
|
10
|
+
// import { base64Encode } from 'ls-pro-tools';
|
|
11
|
+
var ViewDocment = function ViewDocment(props) {
|
|
11
12
|
var _props$open = props.open,
|
|
12
13
|
open = _props$open === void 0 ? false : _props$open,
|
|
13
14
|
_onCancel = props.onCancel,
|
|
@@ -27,7 +28,7 @@ var TagCheck = function TagCheck(props) {
|
|
|
27
28
|
var src = useMemo(function () {
|
|
28
29
|
var token = getCookie('token');
|
|
29
30
|
var doc = url + (url.includes('?') ? '&' : '?') + 'token=' + token;
|
|
30
|
-
return 'https://
|
|
31
|
+
return 'https://dowload.lesoon.cloud/lesoon/lesoon-kkfileview-api/onlinePreview?url=' + encodeURIComponent(doc);
|
|
31
32
|
}, [url]);
|
|
32
33
|
var triggerDom = /*#__PURE__*/React.createElement(React.Fragment, {
|
|
33
34
|
key: "trigger"
|
|
@@ -71,4 +72,4 @@ var TagCheck = function TagCheck(props) {
|
|
|
71
72
|
src: src
|
|
72
73
|
})));
|
|
73
74
|
};
|
|
74
|
-
export default
|
|
75
|
+
export default ViewDocment;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { useMemo, useCallback } from 'react';
|
|
1
|
+
import { useMemo, useCallback, useEffect } from 'react';
|
|
2
2
|
import { useLocation } from 'react-router-dom';
|
|
3
|
-
import { getUrlQuery, getResourceProps, getCache, getLoginName } from '../../utils';
|
|
3
|
+
import { getUrlQuery, getResourceProps, getCache, getLoginName, getCookie, setCookie } from '../../utils';
|
|
4
4
|
function usePermission() {
|
|
5
5
|
var routeLocation = useLocation();
|
|
6
6
|
/** @name 资源ID */
|
|
@@ -32,13 +32,20 @@ function usePermission() {
|
|
|
32
32
|
}, []);
|
|
33
33
|
/**
|
|
34
34
|
* 检查是否有权限
|
|
35
|
+
*
|
|
35
36
|
* @param val 权限值
|
|
36
37
|
*/
|
|
37
38
|
var checkRight = useCallback(function (val) {
|
|
38
39
|
if (!val) return true;
|
|
39
|
-
if (location.href.includes(
|
|
40
|
+
if (location.href.includes('//localhost')) return true;
|
|
40
41
|
return (permissionVal & val) === val && (resRightVal & val) === val;
|
|
41
42
|
}, []);
|
|
43
|
+
useEffect(function () {
|
|
44
|
+
// 如果外部转入token,而cookie中没有,则设置cookie。
|
|
45
|
+
if (getUrlQuery('token') && !getCookie('token')) {
|
|
46
|
+
setCookie('token', getUrlQuery('token'));
|
|
47
|
+
}
|
|
48
|
+
}, []);
|
|
42
49
|
return {
|
|
43
50
|
resourceId: resourceId,
|
|
44
51
|
permissionVal: permissionVal,
|
|
@@ -54,5 +61,4 @@ function usePermission() {
|
|
|
54
61
|
canPrint: checkRight(512)
|
|
55
62
|
};
|
|
56
63
|
}
|
|
57
|
-
;
|
|
58
64
|
export default usePermission;
|
package/es/utils/index.js
CHANGED
|
@@ -31,6 +31,12 @@ export var getResourceProps = function getResourceProps(name) {
|
|
|
31
31
|
// window.lsResourceList 为主工程写入的资源
|
|
32
32
|
// @ts-ignore
|
|
33
33
|
var resList = window.lsResourceList || parent.window.lsResourceList || [];
|
|
34
|
+
if (resList.length === 0) {
|
|
35
|
+
resList = getCache('allRes') || [];
|
|
36
|
+
if (!Array.isArray(resList)) {
|
|
37
|
+
resList = [];
|
|
38
|
+
}
|
|
39
|
+
}
|
|
34
40
|
if (id) {
|
|
35
41
|
obj = resList.find(function (o) {
|
|
36
42
|
return o.resourceId === id;
|
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import './index.less';
|
|
8
8
|
export interface RecordLogProps {
|
|
9
|
-
recordKey
|
|
9
|
+
recordKey?: string;
|
|
10
|
+
bizNo?: string;
|
|
11
|
+
param?: any;
|
|
10
12
|
fieldsMap?: Record<string, string>;
|
|
11
13
|
showResourceName?: boolean;
|
|
12
14
|
style?: React.CSSProperties;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import "antd/es/empty/style";
|
|
2
2
|
import _Empty from "antd/es/empty";
|
|
3
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
4
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
5
|
/**
|
|
5
6
|
* 记录变更日志
|
|
@@ -22,6 +23,10 @@ var RecordLog = function RecordLog(props) {
|
|
|
22
23
|
setLogData = _useState2[1];
|
|
23
24
|
var _props$recordKey = props.recordKey,
|
|
24
25
|
recordKey = _props$recordKey === void 0 ? '' : _props$recordKey,
|
|
26
|
+
_props$bizNo = props.bizNo,
|
|
27
|
+
bizNo = _props$bizNo === void 0 ? '' : _props$bizNo,
|
|
28
|
+
_props$param = props.param,
|
|
29
|
+
param = _props$param === void 0 ? {} : _props$param,
|
|
25
30
|
_props$fieldsMap = props.fieldsMap,
|
|
26
31
|
fieldsMap = _props$fieldsMap === void 0 ? {} : _props$fieldsMap,
|
|
27
32
|
_props$showResourceNa = props.showResourceName,
|
|
@@ -34,10 +39,14 @@ var RecordLog = function RecordLog(props) {
|
|
|
34
39
|
var params = {
|
|
35
40
|
pageSize: 5000,
|
|
36
41
|
sort: 'createTime desc',
|
|
37
|
-
where: {
|
|
38
|
-
dataCode: recordKey
|
|
39
|
-
}
|
|
42
|
+
where: _objectSpread({}, param)
|
|
40
43
|
};
|
|
44
|
+
if (recordKey) {
|
|
45
|
+
params.where.dataCode = recordKey;
|
|
46
|
+
}
|
|
47
|
+
if (bizNo) {
|
|
48
|
+
params.where.bizNo = bizNo;
|
|
49
|
+
}
|
|
41
50
|
httpGet(url, params).then(function (res) {
|
|
42
51
|
var rows = (res === null || res === void 0 ? void 0 : res.rows) || [];
|
|
43
52
|
rows.forEach(function (row) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
declare const
|
|
2
|
+
declare const ViewDocment: (props: {
|
|
3
3
|
open?: boolean;
|
|
4
4
|
onCancel?: () => void;
|
|
5
5
|
title?: string;
|
|
@@ -9,4 +9,4 @@ declare const TagCheck: (props: {
|
|
|
9
9
|
trigger?: JSX.Element;
|
|
10
10
|
url: string;
|
|
11
11
|
}) => JSX.Element;
|
|
12
|
-
export default
|
|
12
|
+
export default ViewDocment;
|
|
@@ -7,7 +7,8 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
7
7
|
import React, { useState, useMemo } from 'react';
|
|
8
8
|
import { EyeOutlined } from '@ant-design/icons';
|
|
9
9
|
import { getCookie } from '../utils';
|
|
10
|
-
|
|
10
|
+
// import { base64Encode } from 'ls-pro-tools';
|
|
11
|
+
var ViewDocment = function ViewDocment(props) {
|
|
11
12
|
var _props$open = props.open,
|
|
12
13
|
open = _props$open === void 0 ? false : _props$open,
|
|
13
14
|
_onCancel = props.onCancel,
|
|
@@ -27,7 +28,7 @@ var TagCheck = function TagCheck(props) {
|
|
|
27
28
|
var src = useMemo(function () {
|
|
28
29
|
var token = getCookie('token');
|
|
29
30
|
var doc = url + (url.includes('?') ? '&' : '?') + 'token=' + token;
|
|
30
|
-
return 'https://
|
|
31
|
+
return 'https://dowload.lesoon.cloud/lesoon/lesoon-kkfileview-api/onlinePreview?url=' + encodeURIComponent(doc);
|
|
31
32
|
}, [url]);
|
|
32
33
|
var triggerDom = /*#__PURE__*/React.createElement(React.Fragment, {
|
|
33
34
|
key: "trigger"
|
|
@@ -71,4 +72,4 @@ var TagCheck = function TagCheck(props) {
|
|
|
71
72
|
src: src
|
|
72
73
|
})));
|
|
73
74
|
};
|
|
74
|
-
export default
|
|
75
|
+
export default ViewDocment;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { useMemo, useCallback } from 'react';
|
|
1
|
+
import { useMemo, useCallback, useEffect } from 'react';
|
|
2
2
|
import { useLocation } from 'react-router-dom';
|
|
3
|
-
import { getUrlQuery, getResourceProps, getCache, getLoginName } from '../../utils';
|
|
3
|
+
import { getUrlQuery, getResourceProps, getCache, getLoginName, getCookie, setCookie } from '../../utils';
|
|
4
4
|
function usePermission() {
|
|
5
5
|
var routeLocation = useLocation();
|
|
6
6
|
/** @name 资源ID */
|
|
@@ -32,13 +32,20 @@ function usePermission() {
|
|
|
32
32
|
}, []);
|
|
33
33
|
/**
|
|
34
34
|
* 检查是否有权限
|
|
35
|
+
*
|
|
35
36
|
* @param val 权限值
|
|
36
37
|
*/
|
|
37
38
|
var checkRight = useCallback(function (val) {
|
|
38
39
|
if (!val) return true;
|
|
39
|
-
if (location.href.includes(
|
|
40
|
+
if (location.href.includes('//localhost')) return true;
|
|
40
41
|
return (permissionVal & val) === val && (resRightVal & val) === val;
|
|
41
42
|
}, []);
|
|
43
|
+
useEffect(function () {
|
|
44
|
+
// 如果外部转入token,而cookie中没有,则设置cookie。
|
|
45
|
+
if (getUrlQuery('token') && !getCookie('token')) {
|
|
46
|
+
setCookie('token', getUrlQuery('token'));
|
|
47
|
+
}
|
|
48
|
+
}, []);
|
|
42
49
|
return {
|
|
43
50
|
resourceId: resourceId,
|
|
44
51
|
permissionVal: permissionVal,
|
|
@@ -54,5 +61,4 @@ function usePermission() {
|
|
|
54
61
|
canPrint: checkRight(512)
|
|
55
62
|
};
|
|
56
63
|
}
|
|
57
|
-
;
|
|
58
64
|
export default usePermission;
|
package/lib/utils/index.js
CHANGED
|
@@ -31,6 +31,12 @@ export var getResourceProps = function getResourceProps(name) {
|
|
|
31
31
|
// window.lsResourceList 为主工程写入的资源
|
|
32
32
|
// @ts-ignore
|
|
33
33
|
var resList = window.lsResourceList || parent.window.lsResourceList || [];
|
|
34
|
+
if (resList.length === 0) {
|
|
35
|
+
resList = getCache('allRes') || [];
|
|
36
|
+
if (!Array.isArray(resList)) {
|
|
37
|
+
resList = [];
|
|
38
|
+
}
|
|
39
|
+
}
|
|
34
40
|
if (id) {
|
|
35
41
|
obj = resList.find(function (o) {
|
|
36
42
|
return o.resourceId === id;
|