ls-pro-common 3.1.47 → 3.1.49
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/InputTable.d.ts +2 -2
- package/es/components/InputTable.js +85 -32
- package/es/utils/cache.d.ts +28 -0
- package/es/utils/cache.js +63 -0
- package/es/utils/constant.d.ts +12 -0
- package/es/utils/constant.js +20 -0
- package/es/utils/cookie.d.ts +15 -0
- package/es/utils/cookie.js +36 -0
- package/es/utils/event.d.ts +16 -0
- package/es/utils/event.js +26 -0
- package/es/utils/index.d.ts +8 -179
- package/es/utils/index.js +12 -423
- package/es/utils/print.d.ts +24 -0
- package/es/utils/print.js +86 -0
- package/es/utils/project.d.ts +33 -0
- package/es/utils/project.js +66 -0
- package/es/utils/url.d.ts +26 -0
- package/es/utils/url.js +113 -0
- package/es/utils/user.d.ts +29 -0
- package/es/utils/user.js +25 -0
- package/lib/components/InputTable.d.ts +2 -2
- package/lib/components/InputTable.js +85 -32
- package/lib/utils/cache.d.ts +28 -0
- package/lib/utils/cache.js +63 -0
- package/lib/utils/constant.d.ts +12 -0
- package/lib/utils/constant.js +20 -0
- package/lib/utils/cookie.d.ts +15 -0
- package/lib/utils/cookie.js +36 -0
- package/lib/utils/event.d.ts +16 -0
- package/lib/utils/event.js +26 -0
- package/lib/utils/index.d.ts +8 -179
- package/lib/utils/index.js +12 -423
- package/lib/utils/print.d.ts +24 -0
- package/lib/utils/print.js +86 -0
- package/lib/utils/project.d.ts +33 -0
- package/lib/utils/project.js +66 -0
- package/lib/utils/url.d.ts +26 -0
- package/lib/utils/url.js +113 -0
- package/lib/utils/user.d.ts +29 -0
- package/lib/utils/user.js +25 -0
- package/package.json +1 -1
package/es/utils/index.d.ts
CHANGED
|
@@ -7,32 +7,14 @@ export * from './promise';
|
|
|
7
7
|
export * from './clac';
|
|
8
8
|
export { getBrowserId } from 'ls-pro-tools';
|
|
9
9
|
export * from './pasteUpload';
|
|
10
|
-
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
|
|
17
|
-
export
|
|
18
|
-
export declare const getResourceProps: (name: string) => any;
|
|
19
|
-
/**
|
|
20
|
-
* 设置url传参
|
|
21
|
-
*
|
|
22
|
-
* @param {any} url
|
|
23
|
-
* @param {any} keyvals
|
|
24
|
-
* @returns
|
|
25
|
-
*/
|
|
26
|
-
export declare const setUrlQuery: (url: string, keyvals?: Record<string, any>) => string;
|
|
27
|
-
/**
|
|
28
|
-
* 给 url 添加网关
|
|
29
|
-
*
|
|
30
|
-
* @param url 原url,以 / 打头
|
|
31
|
-
* @param gatewayKey 设置gateway关键字 默认为 'gateway'
|
|
32
|
-
* @param defaultGateway 默认网关 ''
|
|
33
|
-
* @returns
|
|
34
|
-
*/
|
|
35
|
-
export declare const toGatewayUrl: (url: string, gatewayKey?: string, defaultGateway?: string) => string;
|
|
10
|
+
export * from './cache';
|
|
11
|
+
export * from './constant';
|
|
12
|
+
export * from './cookie';
|
|
13
|
+
export * from './event';
|
|
14
|
+
export * from './url';
|
|
15
|
+
export * from './print';
|
|
16
|
+
export * from './user';
|
|
17
|
+
export * from './project';
|
|
36
18
|
/**
|
|
37
19
|
* 设置文档title
|
|
38
20
|
*
|
|
@@ -40,55 +22,12 @@ export declare const toGatewayUrl: (url: string, gatewayKey?: string, defaultGat
|
|
|
40
22
|
* @returns
|
|
41
23
|
*/
|
|
42
24
|
export declare const setTitle: (title: string) => void;
|
|
43
|
-
/**
|
|
44
|
-
* 获取Cookie
|
|
45
|
-
*
|
|
46
|
-
* @param {String} name Cookie名
|
|
47
|
-
* @returns
|
|
48
|
-
*/
|
|
49
|
-
export declare const getCookie: (name: string) => string | null;
|
|
50
|
-
/**
|
|
51
|
-
* 设置Cookie
|
|
52
|
-
*
|
|
53
|
-
* @param {any} key Cookie名称
|
|
54
|
-
* @param {any} value Cookie 值
|
|
55
|
-
* @param {Number} day 有效天数 默认1天,
|
|
56
|
-
*/
|
|
57
|
-
export declare const setCookie: (key: string, value: string | number, day?: number, sameSite?: boolean) => void;
|
|
58
25
|
/**
|
|
59
26
|
* 判断是否登录
|
|
60
27
|
*
|
|
61
28
|
* @returns
|
|
62
29
|
*/
|
|
63
30
|
export declare const isLogin: () => boolean;
|
|
64
|
-
/**
|
|
65
|
-
* 设置本地缓存
|
|
66
|
-
*
|
|
67
|
-
* @param {String} key 关键字
|
|
68
|
-
* @param {Object} data 值
|
|
69
|
-
* @param {Boolean} session 保存到 sessionStorage 还是 localStorage,默认 localStorage
|
|
70
|
-
*/
|
|
71
|
-
export declare const setCache: (key: string, data: any, session?: boolean) => void;
|
|
72
|
-
/**
|
|
73
|
-
* 读取本地缓存
|
|
74
|
-
*
|
|
75
|
-
* @param {String} key 关键字
|
|
76
|
-
* @param {boolean} session 从 sessionStorage 取数还是从 localStorage 中取数 默认从 localStorage
|
|
77
|
-
* @returns 关键字对应的值
|
|
78
|
-
*/
|
|
79
|
-
export declare const getCache: any;
|
|
80
|
-
/**
|
|
81
|
-
* 读取本地缓存,优先从sessionStorage 取,取不到时再从 localStorage取
|
|
82
|
-
*
|
|
83
|
-
* @param key
|
|
84
|
-
* @returns
|
|
85
|
-
*/
|
|
86
|
-
export declare const getCacheSessionFirst: (key: string) => any;
|
|
87
|
-
/**
|
|
88
|
-
* @param key 关键字,不传清除所有
|
|
89
|
-
* @param session 是否session storage , 默认 localStorage
|
|
90
|
-
*/
|
|
91
|
-
export declare const clearCache: (key?: string | undefined, session?: boolean) => void;
|
|
92
31
|
/**
|
|
93
32
|
* 日期组选择转换
|
|
94
33
|
*
|
|
@@ -99,94 +38,6 @@ export declare const clearCache: (key?: string | undefined, session?: boolean) =
|
|
|
99
38
|
* @returns
|
|
100
39
|
*/
|
|
101
40
|
export declare const rangeToSearch: (values: any, startField: string, endField: string, endSuffix?: string, startSuffex?: string) => any;
|
|
102
|
-
/** @name 状态列表 */
|
|
103
|
-
export declare const statusList: {
|
|
104
|
-
value: number;
|
|
105
|
-
text: string;
|
|
106
|
-
label: string;
|
|
107
|
-
}[];
|
|
108
|
-
/** @name 是否列表 */
|
|
109
|
-
export declare const yesnoList: {
|
|
110
|
-
value: number;
|
|
111
|
-
text: string;
|
|
112
|
-
label: string;
|
|
113
|
-
}[];
|
|
114
|
-
/**
|
|
115
|
-
* 绑定事件
|
|
116
|
-
*
|
|
117
|
-
* @param eventName 事件名
|
|
118
|
-
* @param fn 调用函数
|
|
119
|
-
* @param el 源对象,默认为window
|
|
120
|
-
*/
|
|
121
|
-
export declare const on: (eventName: string, fn: Function, el: any | undefined) => void;
|
|
122
|
-
/**
|
|
123
|
-
* 解绑事件
|
|
124
|
-
*
|
|
125
|
-
* @param eventName 事件名
|
|
126
|
-
* @param fn 调用函数
|
|
127
|
-
* @param el 源对象,默认为window
|
|
128
|
-
*/
|
|
129
|
-
export declare const off: (eventName: string, fn: Function, el: any | undefined) => void;
|
|
130
|
-
/**
|
|
131
|
-
* 打印预览
|
|
132
|
-
*
|
|
133
|
-
* @param templateNo 打印模板编码
|
|
134
|
-
* @param reqUrl 业务请求api
|
|
135
|
-
* @param bodyParam Post传参数
|
|
136
|
-
* @param param Get传参数
|
|
137
|
-
* @param method 请求方式,默认post
|
|
138
|
-
* @param isNewPrintCenter 是否是新的打印中心,默认false
|
|
139
|
-
* @returns
|
|
140
|
-
*/
|
|
141
|
-
export declare const printView: (templateNo: string, reqUrl: string, bodyParam?: any, param?: any, method?: 'POST' | 'GET', isNewPrintCenter?: boolean) => any;
|
|
142
|
-
/**
|
|
143
|
-
* 直接打印,通过打印组件进行打印。
|
|
144
|
-
*
|
|
145
|
-
* @param taskName 打印任务名
|
|
146
|
-
* @param templateNo 打印模板
|
|
147
|
-
* @param reqUrl 业务请求api
|
|
148
|
-
* @param bodyParam Post传参数
|
|
149
|
-
* @param param Get传参数
|
|
150
|
-
* @param method 请求方式,默认post
|
|
151
|
-
* @returns
|
|
152
|
-
*/
|
|
153
|
-
export declare const printAsync: (taskName: string, templateNo: string, reqUrl: string, bodyParam?: any, param?: any, method?: 'POST' | 'GET', isNewPrintCenter?: boolean) => Promise<any>;
|
|
154
|
-
export declare const isDev: boolean;
|
|
155
|
-
export declare type UserType = {
|
|
156
|
-
id?: string;
|
|
157
|
-
userId?: string;
|
|
158
|
-
userName?: string;
|
|
159
|
-
loginName?: string;
|
|
160
|
-
companyId?: string;
|
|
161
|
-
companyCode?: string;
|
|
162
|
-
companyName?: string;
|
|
163
|
-
email?: string;
|
|
164
|
-
employeeAttr?: string;
|
|
165
|
-
expireTime?: string;
|
|
166
|
-
icon?: string;
|
|
167
|
-
idCard?: string;
|
|
168
|
-
ifAdmin?: number | string;
|
|
169
|
-
orgId?: string;
|
|
170
|
-
orgParentIds?: string;
|
|
171
|
-
phoneNumber?: string;
|
|
172
|
-
remarks?: string;
|
|
173
|
-
};
|
|
174
|
-
/** @name 用户信息 */
|
|
175
|
-
export declare const getUserInfo: () => UserType | null;
|
|
176
|
-
/** @name 用户名 */
|
|
177
|
-
export declare const getUserName: () => string | undefined;
|
|
178
|
-
/** @name 登录名 */
|
|
179
|
-
export declare const getLoginName: () => string | undefined;
|
|
180
|
-
/** @name 公司Id */
|
|
181
|
-
export declare const getCompanyId: () => string | undefined;
|
|
182
|
-
/**
|
|
183
|
-
* 判断是否是微前端子应用
|
|
184
|
-
*
|
|
185
|
-
* @returns String | undefined
|
|
186
|
-
*/
|
|
187
|
-
export declare const isQiankunSubApp: () => any;
|
|
188
|
-
/** @name 微前端原生路径 */
|
|
189
|
-
export declare const appPath: (path?: string) => any;
|
|
190
41
|
/**
|
|
191
42
|
* 深度复制对象
|
|
192
43
|
*
|
|
@@ -194,21 +45,6 @@ export declare const appPath: (path?: string) => any;
|
|
|
194
45
|
* @returns
|
|
195
46
|
*/
|
|
196
47
|
export declare const deepClone: (obj: any) => any;
|
|
197
|
-
/**
|
|
198
|
-
* 在主工程中打开模块
|
|
199
|
-
*
|
|
200
|
-
* @param option {path:模块路由,需要加工程编码, resourceId: 资源Id,两者传一个即可,data:参数,moduleName:模块名称}
|
|
201
|
-
*/
|
|
202
|
-
export declare const openPageInMain: (option: {
|
|
203
|
-
[key: string]: any;
|
|
204
|
-
path?: string | undefined;
|
|
205
|
-
resourceId?: string | undefined;
|
|
206
|
-
data?: any;
|
|
207
|
-
ifRefreshTarget?: boolean | undefined;
|
|
208
|
-
moduleName?: string | undefined;
|
|
209
|
-
}) => void;
|
|
210
|
-
/** 处理主题 */
|
|
211
|
-
export declare const handleTheme: () => void;
|
|
212
48
|
/**
|
|
213
49
|
* 睡眠
|
|
214
50
|
*
|
|
@@ -231,10 +67,3 @@ export declare const urlDownloadDomain: (url: string) => string;
|
|
|
231
67
|
* @param isBlank 是否新开窗口下载,默认新开窗口,不影响原页面展示
|
|
232
68
|
*/
|
|
233
69
|
export declare const downloadFile: (url: string, fileName?: string | undefined, isBlank?: boolean) => void;
|
|
234
|
-
/**
|
|
235
|
-
* 微前端主工程注入子工程时,子工程调用此方法设置资源Id,权限等参数
|
|
236
|
-
*
|
|
237
|
-
* @param props
|
|
238
|
-
*/
|
|
239
|
-
export declare const setCurrentResCode: (props: any) => void;
|
|
240
|
-
export declare const isDingtalk: boolean;
|
package/es/utils/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
2
|
-
import { httpPost } from '../http';
|
|
3
1
|
import { cloneDeep } from 'lodash';
|
|
2
|
+
import { getCache } from './cache';
|
|
3
|
+
import { getCookie } from './cookie';
|
|
4
|
+
import { toGatewayUrl, setUrlQuery } from './url';
|
|
4
5
|
export { throttle, debounce, cloneDeep } from 'lodash';
|
|
5
6
|
export * from './modal';
|
|
6
7
|
export * from './array';
|
|
@@ -10,118 +11,14 @@ export * from './promise';
|
|
|
10
11
|
export * from './clac';
|
|
11
12
|
export { getBrowserId } from 'ls-pro-tools';
|
|
12
13
|
export * from './pasteUpload';
|
|
13
|
-
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
|
|
20
|
-
export
|
|
21
|
-
var url = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : location.search.slice(1) || '';
|
|
22
|
-
if (!name) return '';
|
|
23
|
-
var reg = new RegExp('(^|[&|?])' + name + '=([^&]*)(&|$)');
|
|
24
|
-
var r = url.match(reg);
|
|
25
|
-
if (r != null) {
|
|
26
|
-
return decodeURIComponent(decodeURI(r[2]));
|
|
27
|
-
}
|
|
28
|
-
return '';
|
|
29
|
-
};
|
|
30
|
-
export var getResourceProps = function getResourceProps(name) {
|
|
31
|
-
if (!name) return '';
|
|
32
|
-
var id = window.__currentResCode__ || getUrlQuery('resCode');
|
|
33
|
-
var obj;
|
|
34
|
-
// window.lsResourceList 为主工程写入的资源
|
|
35
|
-
// @ts-ignore
|
|
36
|
-
var resList = window.lsResourceList || parent.window.lsResourceList || [];
|
|
37
|
-
if (resList.length === 0) {
|
|
38
|
-
resList = getCache('allRes') || [];
|
|
39
|
-
if (!Array.isArray(resList)) {
|
|
40
|
-
resList = [];
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
if (id) {
|
|
44
|
-
obj = resList.find(function (o) {
|
|
45
|
-
return o.resourceId === id;
|
|
46
|
-
});
|
|
47
|
-
} else if (location.pathname && location.pathname.length > 3) {
|
|
48
|
-
var url = location.pathname + location.hash;
|
|
49
|
-
obj = resList.find(function (o) {
|
|
50
|
-
return o.microUrl && o.microUrl === location.pathname || o.url === url;
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
if (!obj) return '';
|
|
54
|
-
return obj[name] || '';
|
|
55
|
-
};
|
|
56
|
-
/**
|
|
57
|
-
* 设置url传参
|
|
58
|
-
*
|
|
59
|
-
* @param {any} url
|
|
60
|
-
* @param {any} keyvals
|
|
61
|
-
* @returns
|
|
62
|
-
*/
|
|
63
|
-
export var setUrlQuery = function setUrlQuery(url) {
|
|
64
|
-
var keyvals = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
65
|
-
var newUrl = url;
|
|
66
|
-
for (var name in keyvals) {
|
|
67
|
-
var reg = new RegExp('(^|[&|?])' + name + '=([^&]*)(|$)');
|
|
68
|
-
var tmp = (newUrl.includes('?') ? '&' : '?') + name + '=' + keyvals[name];
|
|
69
|
-
if (newUrl.match(reg) != null) {
|
|
70
|
-
// @ts-ignore
|
|
71
|
-
newUrl = newUrl.replace(eval(reg), tmp);
|
|
72
|
-
if (!newUrl.includes('?')) {
|
|
73
|
-
newUrl = newUrl.replace('&', '?');
|
|
74
|
-
}
|
|
75
|
-
} else {
|
|
76
|
-
newUrl = newUrl + tmp;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return newUrl;
|
|
80
|
-
};
|
|
81
|
-
/**
|
|
82
|
-
* 给 url 添加网关
|
|
83
|
-
*
|
|
84
|
-
* @param url 原url,以 / 打头
|
|
85
|
-
* @param gatewayKey 设置gateway关键字 默认为 'gateway'
|
|
86
|
-
* @param defaultGateway 默认网关 ''
|
|
87
|
-
* @returns
|
|
88
|
-
*/
|
|
89
|
-
export var toGatewayUrl = function toGatewayUrl(url) {
|
|
90
|
-
var gatewayKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'gateway';
|
|
91
|
-
var defaultGateway = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
92
|
-
url = url || '';
|
|
93
|
-
// 如果url带有名称,不需要设置网关
|
|
94
|
-
if (url.startsWith('http://') || url.startsWith('https://') || url.startsWith('//')) return url;
|
|
95
|
-
if (url.startsWith('/lesoon/') || url.startsWith('/petrel/')) {
|
|
96
|
-
return location.origin + url;
|
|
97
|
-
}
|
|
98
|
-
// 读取项目的默认网关
|
|
99
|
-
if (!defaultGateway) {
|
|
100
|
-
var _top;
|
|
101
|
-
// @ts-ignore
|
|
102
|
-
defaultGateway = window.defaultGateway || ((_top = top) === null || _top === void 0 ? void 0 : _top.window.lsMainGateway) || '';
|
|
103
|
-
}
|
|
104
|
-
// 取网关的顺序, 1.取url里的传参,2.取资源里的网关, 3. 取项目里设置的默认网关
|
|
105
|
-
var gateway = getUrlQuery(gatewayKey) || getResourceProps(gatewayKey) || defaultGateway;
|
|
106
|
-
// 如果没有找到网关,直接从项目配置中取网关
|
|
107
|
-
if (!gateway) {
|
|
108
|
-
var projects = JSON.parse(sessionStorage.getItem('lsProjects') || '[]');
|
|
109
|
-
var projectKey = localStorage.getItem('projectId');
|
|
110
|
-
if (projectKey && projects.length) {
|
|
111
|
-
var project = projects.find(function (o) {
|
|
112
|
-
return o.projectId === projectKey;
|
|
113
|
-
});
|
|
114
|
-
if (project) {
|
|
115
|
-
gateway = project.gatewayUrl || '';
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
// 网关加上域名,避免多次设置
|
|
120
|
-
if (gateway && !gateway.startsWith('http')) {
|
|
121
|
-
gateway = location.origin + gateway;
|
|
122
|
-
}
|
|
123
|
-
return gateway + url;
|
|
124
|
-
};
|
|
14
|
+
export * from './cache';
|
|
15
|
+
export * from './constant';
|
|
16
|
+
export * from './cookie';
|
|
17
|
+
export * from './event';
|
|
18
|
+
export * from './url';
|
|
19
|
+
export * from './print';
|
|
20
|
+
export * from './user';
|
|
21
|
+
export * from './project';
|
|
125
22
|
/**
|
|
126
23
|
* 设置文档title
|
|
127
24
|
*
|
|
@@ -132,42 +29,6 @@ export var setTitle = function setTitle(title) {
|
|
|
132
29
|
if (!title) return;
|
|
133
30
|
document.title = title;
|
|
134
31
|
};
|
|
135
|
-
/**
|
|
136
|
-
* 获取Cookie
|
|
137
|
-
*
|
|
138
|
-
* @param {String} name Cookie名
|
|
139
|
-
* @returns
|
|
140
|
-
*/
|
|
141
|
-
export var getCookie = function getCookie(name) {
|
|
142
|
-
var arr;
|
|
143
|
-
var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)');
|
|
144
|
-
if (arr = document.cookie.match(reg)) return arr[2];else return null;
|
|
145
|
-
};
|
|
146
|
-
/**
|
|
147
|
-
* 设置Cookie
|
|
148
|
-
*
|
|
149
|
-
* @param {any} key Cookie名称
|
|
150
|
-
* @param {any} value Cookie 值
|
|
151
|
-
* @param {Number} day 有效天数 默认1天,
|
|
152
|
-
*/
|
|
153
|
-
export var setCookie = function setCookie(key, value) {
|
|
154
|
-
var day = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
155
|
-
var sameSite = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
156
|
-
if (day !== 0) {
|
|
157
|
-
var d = new Date(Date.now() + day * 24 * 60 * 60 * 1000);
|
|
158
|
-
if (sameSite) {
|
|
159
|
-
document.cookie = "".concat(key, "=").concat(value, ";expires=").concat(d.toUTCString(), ";path=/;sameSite=None;secure=true");
|
|
160
|
-
} else {
|
|
161
|
-
document.cookie = "".concat(key, "=").concat(value, ";expires=").concat(d.toUTCString(), ";path=/");
|
|
162
|
-
}
|
|
163
|
-
} else {
|
|
164
|
-
if (sameSite) {
|
|
165
|
-
document.cookie = key + '=' + value + ';path=/;sameSite=None;secure=true';
|
|
166
|
-
} else {
|
|
167
|
-
document.cookie = key + '=' + value + ';path=/';
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
32
|
/**
|
|
172
33
|
* 判断是否登录
|
|
173
34
|
*
|
|
@@ -176,68 +37,6 @@ export var setCookie = function setCookie(key, value) {
|
|
|
176
37
|
export var isLogin = function isLogin() {
|
|
177
38
|
return !!getCookie('online');
|
|
178
39
|
};
|
|
179
|
-
/**
|
|
180
|
-
* 设置本地缓存
|
|
181
|
-
*
|
|
182
|
-
* @param {String} key 关键字
|
|
183
|
-
* @param {Object} data 值
|
|
184
|
-
* @param {Boolean} session 保存到 sessionStorage 还是 localStorage,默认 localStorage
|
|
185
|
-
*/
|
|
186
|
-
export var setCache = function setCache(key, data) {
|
|
187
|
-
var session = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
188
|
-
if (_typeof(data) === 'object') {
|
|
189
|
-
data = JSON.stringify(data);
|
|
190
|
-
}
|
|
191
|
-
if (session) {
|
|
192
|
-
sessionStorage.setItem(key, data);
|
|
193
|
-
} else {
|
|
194
|
-
localStorage.setItem(key, data);
|
|
195
|
-
}
|
|
196
|
-
};
|
|
197
|
-
/**
|
|
198
|
-
* 读取本地缓存
|
|
199
|
-
*
|
|
200
|
-
* @param {String} key 关键字
|
|
201
|
-
* @param {boolean} session 从 sessionStorage 取数还是从 localStorage 中取数 默认从 localStorage
|
|
202
|
-
* @returns 关键字对应的值
|
|
203
|
-
*/
|
|
204
|
-
export var getCache = function getCache(key) {
|
|
205
|
-
var session = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
206
|
-
var data = session ? sessionStorage.getItem(key) : localStorage.getItem(key);
|
|
207
|
-
if (data && (data.startsWith('{') || data.startsWith('['))) {
|
|
208
|
-
data = JSON.parse(data);
|
|
209
|
-
}
|
|
210
|
-
return data;
|
|
211
|
-
};
|
|
212
|
-
/**
|
|
213
|
-
* 读取本地缓存,优先从sessionStorage 取,取不到时再从 localStorage取
|
|
214
|
-
*
|
|
215
|
-
* @param key
|
|
216
|
-
* @returns
|
|
217
|
-
*/
|
|
218
|
-
export var getCacheSessionFirst = function getCacheSessionFirst(key) {
|
|
219
|
-
return getCache(key, true) || getCache(key);
|
|
220
|
-
};
|
|
221
|
-
/**
|
|
222
|
-
* @param key 关键字,不传清除所有
|
|
223
|
-
* @param session 是否session storage , 默认 localStorage
|
|
224
|
-
*/
|
|
225
|
-
export var clearCache = function clearCache(key) {
|
|
226
|
-
var session = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
227
|
-
if (key) {
|
|
228
|
-
if (session) {
|
|
229
|
-
sessionStorage.removeItem(key);
|
|
230
|
-
} else {
|
|
231
|
-
localStorage.removeItem(key);
|
|
232
|
-
}
|
|
233
|
-
} else {
|
|
234
|
-
if (session) {
|
|
235
|
-
sessionStorage.clear();
|
|
236
|
-
} else {
|
|
237
|
-
localStorage.clear();
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
};
|
|
241
40
|
/**
|
|
242
41
|
* 日期组选择转换
|
|
243
42
|
*
|
|
@@ -259,180 +58,6 @@ export var rangeToSearch = function rangeToSearch(values, startField, endField)
|
|
|
259
58
|
}
|
|
260
59
|
return data;
|
|
261
60
|
};
|
|
262
|
-
/** @name 状态列表 */
|
|
263
|
-
export var statusList = [{
|
|
264
|
-
value: 1,
|
|
265
|
-
text: '启用',
|
|
266
|
-
label: '1→启用'
|
|
267
|
-
}, {
|
|
268
|
-
value: 0,
|
|
269
|
-
text: '禁用',
|
|
270
|
-
label: '0→禁用'
|
|
271
|
-
}];
|
|
272
|
-
/** @name 是否列表 */
|
|
273
|
-
export var yesnoList = [{
|
|
274
|
-
value: 1,
|
|
275
|
-
text: '是',
|
|
276
|
-
label: '1→是'
|
|
277
|
-
}, {
|
|
278
|
-
value: 0,
|
|
279
|
-
text: '否',
|
|
280
|
-
label: '0→否'
|
|
281
|
-
}];
|
|
282
|
-
/**
|
|
283
|
-
* 绑定事件
|
|
284
|
-
*
|
|
285
|
-
* @param eventName 事件名
|
|
286
|
-
* @param fn 调用函数
|
|
287
|
-
* @param el 源对象,默认为window
|
|
288
|
-
*/
|
|
289
|
-
export var on = function on(eventName, fn, el) {
|
|
290
|
-
if (!el) {
|
|
291
|
-
el = window;
|
|
292
|
-
}
|
|
293
|
-
el.addEventListener(eventName, fn);
|
|
294
|
-
};
|
|
295
|
-
/**
|
|
296
|
-
* 解绑事件
|
|
297
|
-
*
|
|
298
|
-
* @param eventName 事件名
|
|
299
|
-
* @param fn 调用函数
|
|
300
|
-
* @param el 源对象,默认为window
|
|
301
|
-
*/
|
|
302
|
-
export var off = function off(eventName, fn, el) {
|
|
303
|
-
if (!el) {
|
|
304
|
-
el = window;
|
|
305
|
-
}
|
|
306
|
-
el.removeEventListener(eventName, fn);
|
|
307
|
-
};
|
|
308
|
-
/**
|
|
309
|
-
* 打印预览
|
|
310
|
-
*
|
|
311
|
-
* @param templateNo 打印模板编码
|
|
312
|
-
* @param reqUrl 业务请求api
|
|
313
|
-
* @param bodyParam Post传参数
|
|
314
|
-
* @param param Get传参数
|
|
315
|
-
* @param method 请求方式,默认post
|
|
316
|
-
* @param isNewPrintCenter 是否是新的打印中心,默认false
|
|
317
|
-
* @returns
|
|
318
|
-
*/
|
|
319
|
-
export var printView = function printView(templateNo, reqUrl) {
|
|
320
|
-
var bodyParam = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
321
|
-
var param = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : undefined;
|
|
322
|
-
var method = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 'POST';
|
|
323
|
-
var isNewPrintCenter = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
|
324
|
-
var api = '/petrel-print-center-api/report/remote/print/dataStr';
|
|
325
|
-
if (isNewPrintCenter) {
|
|
326
|
-
api = '/lesoon-basic-api/basic/ireport/preview/print/dataStr';
|
|
327
|
-
}
|
|
328
|
-
var printCenterUrl = toGatewayUrl(api);
|
|
329
|
-
reqUrl = toGatewayUrl(reqUrl);
|
|
330
|
-
if (!reqUrl.includes(location.origin)) {
|
|
331
|
-
reqUrl = location.origin + reqUrl;
|
|
332
|
-
}
|
|
333
|
-
var data = {
|
|
334
|
-
templateNo: templateNo,
|
|
335
|
-
printType: 1,
|
|
336
|
-
reqUrl: reqUrl,
|
|
337
|
-
reqMethodType: method,
|
|
338
|
-
params: param || {},
|
|
339
|
-
body: bodyParam || {}
|
|
340
|
-
};
|
|
341
|
-
var openWin = window.open();
|
|
342
|
-
var formStr = "<form style=\"visibility:hidden;\" method=\"POST\" action=\"".concat(printCenterUrl, "\">\n <input type=\"hidden\" name=\"clientPrintData\" value='").concat(JSON.stringify(data), "' />\n </form>");
|
|
343
|
-
openWin.document.body.innerHTML = formStr;
|
|
344
|
-
openWin.document.forms[0].submit();
|
|
345
|
-
return openWin;
|
|
346
|
-
};
|
|
347
|
-
/**
|
|
348
|
-
* 直接打印,通过打印组件进行打印。
|
|
349
|
-
*
|
|
350
|
-
* @param taskName 打印任务名
|
|
351
|
-
* @param templateNo 打印模板
|
|
352
|
-
* @param reqUrl 业务请求api
|
|
353
|
-
* @param bodyParam Post传参数
|
|
354
|
-
* @param param Get传参数
|
|
355
|
-
* @param method 请求方式,默认post
|
|
356
|
-
* @returns
|
|
357
|
-
*/
|
|
358
|
-
export var printAsync = function printAsync(taskName, templateNo, reqUrl) {
|
|
359
|
-
var bodyParam = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
360
|
-
var param = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : undefined;
|
|
361
|
-
var method = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 'POST';
|
|
362
|
-
var isNewPrintCenter = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
|
363
|
-
var api = '/petrel-print-center-api/report/client/print';
|
|
364
|
-
if (isNewPrintCenter) {
|
|
365
|
-
api = '/lesoon-basic-api/basic/report/client/template/print';
|
|
366
|
-
}
|
|
367
|
-
var printCenterUrl = toGatewayUrl(api);
|
|
368
|
-
if (!printCenterUrl.includes(location.origin)) {
|
|
369
|
-
printCenterUrl = location.origin + printCenterUrl;
|
|
370
|
-
}
|
|
371
|
-
reqUrl = toGatewayUrl(reqUrl);
|
|
372
|
-
if (!reqUrl.includes(location.origin)) {
|
|
373
|
-
reqUrl = location.origin + reqUrl;
|
|
374
|
-
}
|
|
375
|
-
var data = {
|
|
376
|
-
taskName: taskName,
|
|
377
|
-
printReqUrl: printCenterUrl,
|
|
378
|
-
bizVO: {
|
|
379
|
-
templateNo: templateNo,
|
|
380
|
-
printType: 1,
|
|
381
|
-
reqUrl: reqUrl,
|
|
382
|
-
reqMethodType: method,
|
|
383
|
-
params: param || {},
|
|
384
|
-
body: bodyParam || {}
|
|
385
|
-
},
|
|
386
|
-
token: getCache('token') || ''
|
|
387
|
-
};
|
|
388
|
-
var url = 'http://localhost:10050/client/async/print';
|
|
389
|
-
return httpPost(url, data, true, false);
|
|
390
|
-
};
|
|
391
|
-
export var isDev = location.href.includes('//localhost');
|
|
392
|
-
/** @name 用户信息 */
|
|
393
|
-
export var getUserInfo = function getUserInfo() {
|
|
394
|
-
return getCache('user');
|
|
395
|
-
};
|
|
396
|
-
/** @name 用户名 */
|
|
397
|
-
export var getUserName = function getUserName() {
|
|
398
|
-
var _getUserInfo;
|
|
399
|
-
return (_getUserInfo = getUserInfo()) === null || _getUserInfo === void 0 ? void 0 : _getUserInfo.userName;
|
|
400
|
-
};
|
|
401
|
-
/** @name 登录名 */
|
|
402
|
-
export var getLoginName = function getLoginName() {
|
|
403
|
-
var _getUserInfo2;
|
|
404
|
-
return (_getUserInfo2 = getUserInfo()) === null || _getUserInfo2 === void 0 ? void 0 : _getUserInfo2.loginName;
|
|
405
|
-
};
|
|
406
|
-
/** @name 公司Id */
|
|
407
|
-
export var getCompanyId = function getCompanyId() {
|
|
408
|
-
var _getUserInfo3;
|
|
409
|
-
return (_getUserInfo3 = getUserInfo()) === null || _getUserInfo3 === void 0 ? void 0 : _getUserInfo3.companyId;
|
|
410
|
-
};
|
|
411
|
-
/**
|
|
412
|
-
* 判断是否是微前端子应用
|
|
413
|
-
*
|
|
414
|
-
* @returns String | undefined
|
|
415
|
-
*/
|
|
416
|
-
export var isQiankunSubApp = function isQiankunSubApp() {
|
|
417
|
-
// @ts-ignore
|
|
418
|
-
return window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__;
|
|
419
|
-
};
|
|
420
|
-
/** @name 微前端原生路径 */
|
|
421
|
-
export var appPath = function appPath() {
|
|
422
|
-
var path = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
423
|
-
if (isQiankunSubApp()) {
|
|
424
|
-
return isQiankunSubApp();
|
|
425
|
-
}
|
|
426
|
-
if (path) return path;
|
|
427
|
-
//本地开发环境,判断是否hash路由,如果是hash路由,则返回./
|
|
428
|
-
if (isDev) {
|
|
429
|
-
return location.hash ? './' : '/';
|
|
430
|
-
}
|
|
431
|
-
// 生产环境,返回当前路径
|
|
432
|
-
var p = location.pathname || '';
|
|
433
|
-
if (p === '/') return location.origin + '/';
|
|
434
|
-
return location.origin + '/' + p.split('/')[1] + '/';
|
|
435
|
-
};
|
|
436
61
|
/**
|
|
437
62
|
* 深度复制对象
|
|
438
63
|
*
|
|
@@ -442,25 +67,6 @@ export var appPath = function appPath() {
|
|
|
442
67
|
export var deepClone = function deepClone(obj) {
|
|
443
68
|
return cloneDeep(obj);
|
|
444
69
|
};
|
|
445
|
-
/**
|
|
446
|
-
* 在主工程中打开模块
|
|
447
|
-
*
|
|
448
|
-
* @param option {path:模块路由,需要加工程编码, resourceId: 资源Id,两者传一个即可,data:参数,moduleName:模块名称}
|
|
449
|
-
*/
|
|
450
|
-
export var openPageInMain = function openPageInMain(option) {
|
|
451
|
-
var win = top || window;
|
|
452
|
-
win.postMessage({
|
|
453
|
-
type: 'openPage',
|
|
454
|
-
param: option
|
|
455
|
-
});
|
|
456
|
-
};
|
|
457
|
-
/** 处理主题 */
|
|
458
|
-
export var handleTheme = function handleTheme() {
|
|
459
|
-
var theme = getCache('theme');
|
|
460
|
-
if (theme) {
|
|
461
|
-
document.body.classList.add('theme-' + theme);
|
|
462
|
-
}
|
|
463
|
-
};
|
|
464
70
|
/**
|
|
465
71
|
* 睡眠
|
|
466
72
|
*
|
|
@@ -522,21 +128,4 @@ export var downloadFile = function downloadFile(url, fileName) {
|
|
|
522
128
|
document.body.appendChild(a);
|
|
523
129
|
a.click();
|
|
524
130
|
document.body.removeChild(a);
|
|
525
|
-
};
|
|
526
|
-
/**
|
|
527
|
-
* 微前端主工程注入子工程时,子工程调用此方法设置资源Id,权限等参数
|
|
528
|
-
*
|
|
529
|
-
* @param props
|
|
530
|
-
*/
|
|
531
|
-
export var setCurrentResCode = function setCurrentResCode(props) {
|
|
532
|
-
var _props$history;
|
|
533
|
-
var initialValue = props === null || props === void 0 ? void 0 : (_props$history = props.history) === null || _props$history === void 0 ? void 0 : _props$history.initialEntries;
|
|
534
|
-
if (Array.isArray(initialValue) && initialValue.length > 0) {
|
|
535
|
-
var parentParams = initialValue[0];
|
|
536
|
-
window.__initVal__ = parentParams;
|
|
537
|
-
window.__currentResCode__ = getUrlQuery('resCode', parentParams);
|
|
538
|
-
window.__currentRight__ = getUrlQuery('right', parentParams);
|
|
539
|
-
window.__currentResRight__ = getUrlQuery('resRight', parentParams);
|
|
540
|
-
}
|
|
541
|
-
};
|
|
542
|
-
export var isDingtalk = (window.navigator.userAgent || '').toLowerCase().includes('dingtalk');
|
|
131
|
+
};
|