ls-pro-common 3.0.57 → 3.0.59
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 +71 -54
- package/dist/common.js +1 -1
- package/dist/common.js.LICENSE.txt +0 -10
- package/dist/common.min.css +71 -54
- package/dist/common.min.js +1 -1
- package/dist/common.min.js.LICENSE.txt +0 -10
- package/es/components/ImageSelector.d.ts +7 -7
- package/es/components/ImageSelector.js +32 -6
- package/es/components/antd-custom.less +59 -61
- package/es/hooks/useGetState.d.ts +1 -0
- package/es/hooks/useGetState.js +4 -3
- package/es/utils/index.d.ts +55 -26
- package/es/utils/index.js +73 -38
- package/lib/components/ImageSelector.d.ts +7 -7
- package/lib/components/ImageSelector.js +32 -6
- package/lib/components/antd-custom.less +59 -61
- package/lib/hooks/useGetState.d.ts +1 -0
- package/lib/hooks/useGetState.js +4 -3
- package/lib/utils/index.d.ts +55 -26
- package/lib/utils/index.js +73 -38
- package/package.json +3 -3
package/lib/utils/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import React from 'react';
|
|
|
4
4
|
export { throttle, debounce } from 'lodash';
|
|
5
5
|
/**
|
|
6
6
|
* 获取 url 参数
|
|
7
|
+
*
|
|
7
8
|
* @param name
|
|
8
9
|
* @param url
|
|
9
10
|
* @returns
|
|
@@ -11,21 +12,24 @@ export { throttle, debounce } from 'lodash';
|
|
|
11
12
|
export declare const getUrlQuery: (name: string, url?: string) => string;
|
|
12
13
|
export declare const getResourceProps: (name: string) => any;
|
|
13
14
|
/**
|
|
14
|
-
* 设置url传参
|
|
15
|
-
|
|
16
|
-
* @param {
|
|
17
|
-
* @
|
|
18
|
-
|
|
15
|
+
* 设置url传参
|
|
16
|
+
*
|
|
17
|
+
* @param {any} url
|
|
18
|
+
* @param {any} keyvals
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
19
21
|
export declare const setUrlQuery: (url: string, keyvals?: Record<string, any>) => string;
|
|
20
22
|
/**
|
|
21
23
|
* 日期格式化
|
|
24
|
+
*
|
|
22
25
|
* @param dt 日期
|
|
23
|
-
* @param showTime 是否显示时间
|
|
26
|
+
* @param showTime 是否显示时间 默认为 true
|
|
24
27
|
* @returns YYYY-MM-DD
|
|
25
28
|
*/
|
|
26
29
|
export declare const dateFormat: (dt?: Date | null | undefined, showTime?: boolean) => string;
|
|
27
30
|
/**
|
|
28
31
|
* 给 url 添加网关
|
|
32
|
+
*
|
|
29
33
|
* @param url 原url,以 / 打头
|
|
30
34
|
* @param gatewayKey 设置gateway关键字 默认为 'gateway'
|
|
31
35
|
* @param defGateway 默认网关 ''
|
|
@@ -34,12 +38,14 @@ export declare const dateFormat: (dt?: Date | null | undefined, showTime?: boole
|
|
|
34
38
|
export declare const toGatewayUrl: (url: string, gatewayKey?: string, defGateway?: string) => string;
|
|
35
39
|
/**
|
|
36
40
|
* 设置文档title
|
|
37
|
-
*
|
|
41
|
+
*
|
|
42
|
+
* @param {any} title
|
|
38
43
|
* @returns
|
|
39
44
|
*/
|
|
40
45
|
export declare const setTitle: (title: string) => void;
|
|
41
46
|
/**
|
|
42
47
|
* 日期格式化
|
|
48
|
+
*
|
|
43
49
|
* @param dt 日期
|
|
44
50
|
* @param showTime 是否显示时间 默认true
|
|
45
51
|
* @returns YYYY-MM-DD hh:mm:ss
|
|
@@ -47,16 +53,19 @@ export declare const setTitle: (title: string) => void;
|
|
|
47
53
|
export declare const formatDate: (dt?: Date | null | undefined, showTime?: boolean) => string;
|
|
48
54
|
/**
|
|
49
55
|
* 返回当前日期
|
|
56
|
+
*
|
|
50
57
|
* @returns YYYY-MM-DD
|
|
51
58
|
*/
|
|
52
59
|
export declare const today: () => string;
|
|
53
60
|
/**
|
|
54
61
|
* 返回当前日期时间
|
|
62
|
+
*
|
|
55
63
|
* @returns YYYY-MM-DD hh:mm:ss
|
|
56
64
|
*/
|
|
57
65
|
export declare const now: () => string;
|
|
58
66
|
/**
|
|
59
67
|
* 时间加减
|
|
68
|
+
*
|
|
60
69
|
* @param dt 原始时间,传 null 为当前时间
|
|
61
70
|
* @param addDay 添加添数,可为负数
|
|
62
71
|
* @param addMonth 添加月数,可为负数
|
|
@@ -66,6 +75,7 @@ export declare const now: () => string;
|
|
|
66
75
|
export declare const dateAdd: (dt: Date | null, addDay: number, addMonth?: number, addYear?: number) => string;
|
|
67
76
|
/**
|
|
68
77
|
* 当前时间加减
|
|
78
|
+
*
|
|
69
79
|
* @param addDay 添加添数,可为负数
|
|
70
80
|
* @param addMonth 添加月数,可为负数
|
|
71
81
|
* @param addYear 添加年数,可以负责
|
|
@@ -74,6 +84,7 @@ export declare const dateAdd: (dt: Date | null, addDay: number, addMonth?: numbe
|
|
|
74
84
|
export declare const nowAdd: (addDay: number, addMonth?: number, addYear?: number) => string;
|
|
75
85
|
/**
|
|
76
86
|
* 当前日期加减
|
|
87
|
+
*
|
|
77
88
|
* @param addDay 添加添数,可为负数
|
|
78
89
|
* @param addMonth 添加月数,可为负数
|
|
79
90
|
* @param addYear 添加年数,可以负责
|
|
@@ -82,52 +93,58 @@ export declare const nowAdd: (addDay: number, addMonth?: number, addYear?: numbe
|
|
|
82
93
|
export declare const todayAdd: (addDay: number, addMonth?: number, addYear?: number) => string;
|
|
83
94
|
/**
|
|
84
95
|
* 千位符格式化数值
|
|
96
|
+
*
|
|
85
97
|
* @param num 数值
|
|
86
98
|
* @param dec 小数位数,默认为2位小数
|
|
87
|
-
* @returns
|
|
99
|
+
* @returns Xx,xxx.xx
|
|
88
100
|
*/
|
|
89
101
|
export declare const formatMoney: (num: number | string, dec?: number) => string;
|
|
90
102
|
/**
|
|
91
103
|
* 获取Cookie
|
|
92
|
-
*
|
|
104
|
+
*
|
|
105
|
+
* @param {String} name Cookie名
|
|
93
106
|
* @returns
|
|
94
107
|
*/
|
|
95
108
|
export declare const getCookie: (name: string) => string | null;
|
|
96
109
|
/**
|
|
97
110
|
* 设置Cookie
|
|
98
|
-
*
|
|
99
|
-
* @param {
|
|
100
|
-
* @param {
|
|
111
|
+
*
|
|
112
|
+
* @param {any} key Cookie名称
|
|
113
|
+
* @param {any} value Cookie 值
|
|
114
|
+
* @param {Number} day 有效天数 默认1天,
|
|
101
115
|
*/
|
|
102
116
|
export declare const setCookie: (key: string, value: string | number, day?: number, sameSite?: boolean) => void;
|
|
103
117
|
/**
|
|
104
118
|
* 判断是否登录
|
|
119
|
+
*
|
|
105
120
|
* @returns
|
|
106
121
|
*/
|
|
107
122
|
export declare const isLogin: () => boolean;
|
|
108
123
|
export declare const getFullScreenElement: () => any;
|
|
109
124
|
/**
|
|
110
125
|
* 设置本地缓存
|
|
111
|
-
*
|
|
112
|
-
* @param {
|
|
113
|
-
* @param {
|
|
126
|
+
*
|
|
127
|
+
* @param {String} key 关键字
|
|
128
|
+
* @param {Object} data 值
|
|
129
|
+
* @param {Boolean} session 保存到 sessionStorage 还是 localStorage,默认 localStorage
|
|
114
130
|
*/
|
|
115
131
|
export declare const setCache: (key: string, data: any, session?: boolean) => void;
|
|
116
132
|
/**
|
|
117
133
|
* 读取本地缓存
|
|
118
|
-
*
|
|
119
|
-
* @param {
|
|
134
|
+
*
|
|
135
|
+
* @param {String} key 关键字
|
|
136
|
+
* @param {boolean} session 从 sessionStorage 取数还是从 localStorage 中取数 默认从 localStorage
|
|
120
137
|
* @returns 关键字对应的值
|
|
121
138
|
*/
|
|
122
139
|
export declare const getCache: (key: string, session?: boolean) => string | null;
|
|
123
140
|
/**
|
|
124
141
|
* 读取本地缓存,优先从sessionStorage 取,取不到时再从 localStorage取
|
|
142
|
+
*
|
|
125
143
|
* @param key
|
|
126
144
|
* @returns
|
|
127
145
|
*/
|
|
128
146
|
export declare const getCacheSessionFirst: (key: string) => string | null;
|
|
129
147
|
/**
|
|
130
|
-
*
|
|
131
148
|
* @param key 关键字,不传清除所有
|
|
132
149
|
* @param session 是否session storage , 默认 localStorage
|
|
133
150
|
*/
|
|
@@ -140,6 +157,7 @@ export declare const showWarn: (text: string, duration?: number) => void;
|
|
|
140
157
|
export declare const showSuccess: (text: string, duration?: number) => void;
|
|
141
158
|
/**
|
|
142
159
|
* 弹框提示
|
|
160
|
+
*
|
|
143
161
|
* @param text 提示信息
|
|
144
162
|
* @param title 标题,默认 系统提示
|
|
145
163
|
* @param type 类型
|
|
@@ -152,15 +170,17 @@ export declare const exitAlert: () => void;
|
|
|
152
170
|
/** @name 显示确认 */
|
|
153
171
|
export declare const showConfirm: (text: string, title?: string) => Promise<unknown>;
|
|
154
172
|
/**
|
|
155
|
-
*
|
|
173
|
+
* Token过期重新登录
|
|
174
|
+
*
|
|
156
175
|
* @returns
|
|
157
176
|
*/
|
|
158
177
|
export declare const reLogin: () => void;
|
|
159
178
|
/**
|
|
160
179
|
* 日期组选择转换
|
|
180
|
+
*
|
|
161
181
|
* @param values 选择的值
|
|
162
|
-
* @param startField
|
|
163
|
-
* @param endField
|
|
182
|
+
* @param startField 第一个字段
|
|
183
|
+
* @param endField 第二个字段
|
|
164
184
|
* @param endSuffix
|
|
165
185
|
* @returns
|
|
166
186
|
*/
|
|
@@ -179,6 +199,7 @@ export declare const yesnoList: {
|
|
|
179
199
|
}[];
|
|
180
200
|
/**
|
|
181
201
|
* 遍历树
|
|
202
|
+
*
|
|
182
203
|
* @param list 树对象
|
|
183
204
|
* @param fn 回调函数
|
|
184
205
|
* @param children 树属性字段
|
|
@@ -186,6 +207,7 @@ export declare const yesnoList: {
|
|
|
186
207
|
export declare const treeEach: (list: any[], fn: (item: any, index: any, list: any[]) => void, children?: string) => void;
|
|
187
208
|
/**
|
|
188
209
|
* 查询数
|
|
210
|
+
*
|
|
189
211
|
* @param list 树对象
|
|
190
212
|
* @param key 查询属性
|
|
191
213
|
* @param val 查询值
|
|
@@ -195,6 +217,7 @@ export declare const treeEach: (list: any[], fn: (item: any, index: any, list: a
|
|
|
195
217
|
export declare const treeFind: (list: any[], key: string, val: any, children?: string) => any;
|
|
196
218
|
/**
|
|
197
219
|
* 处理普通的尺码横排
|
|
220
|
+
*
|
|
198
221
|
* @param orgSizeHeader 后端返回的原始尺码组表头
|
|
199
222
|
* @param typeWidth 尺码组宽 sizeTypeNo,默认120
|
|
200
223
|
* @param sizeWidth 尺码宽f1~f100, 默认100
|
|
@@ -203,13 +226,15 @@ export declare const treeFind: (list: any[], key: string, val: any, children?: s
|
|
|
203
226
|
export declare const handleSizeCols: (orgSizeHeader: any[], typeWidth?: number, sizeWidth?: number) => any[];
|
|
204
227
|
/**
|
|
205
228
|
* 绑定事件
|
|
206
|
-
*
|
|
207
|
-
* @param
|
|
208
|
-
* @param
|
|
229
|
+
*
|
|
230
|
+
* @param eventName 事件名
|
|
231
|
+
* @param fn 调用函数
|
|
232
|
+
* @param el 源对象,默认为window
|
|
209
233
|
*/
|
|
210
234
|
export declare const on: (eventName: string, fn: Function, el: any | undefined) => void;
|
|
211
235
|
/**
|
|
212
236
|
* 解绑事件
|
|
237
|
+
*
|
|
213
238
|
* @param eventName 事件名
|
|
214
239
|
* @param fn 调用函数
|
|
215
240
|
* @param el 源对象,默认为window
|
|
@@ -217,21 +242,23 @@ export declare const on: (eventName: string, fn: Function, el: any | undefined)
|
|
|
217
242
|
export declare const off: (eventName: string, fn: Function, el: any | undefined) => void;
|
|
218
243
|
/**
|
|
219
244
|
* 打印预览
|
|
245
|
+
*
|
|
220
246
|
* @param templateNo 打印模板编码
|
|
221
247
|
* @param reqUrl 业务请求api
|
|
222
248
|
* @param bodyParam Post传参数
|
|
223
|
-
* @param param
|
|
249
|
+
* @param param Get传参数
|
|
224
250
|
* @param method 请求方式,默认post
|
|
225
251
|
* @returns
|
|
226
252
|
*/
|
|
227
253
|
export declare const printView: (templateNo: string, reqUrl: string, bodyParam?: any, param?: any, method?: 'POST' | 'GET') => any;
|
|
228
254
|
/**
|
|
229
255
|
* 直接打印
|
|
256
|
+
*
|
|
230
257
|
* @param taskName 打印任务名
|
|
231
258
|
* @param templateNo 打印模板
|
|
232
259
|
* @param reqUrl 业务请求api
|
|
233
260
|
* @param bodyParam Post传参数
|
|
234
|
-
* @param param
|
|
261
|
+
* @param param Get传参数
|
|
235
262
|
* @param method 请求方式,默认post
|
|
236
263
|
* @returns
|
|
237
264
|
*/
|
|
@@ -268,12 +295,14 @@ export declare const getCompanyId: () => string | undefined;
|
|
|
268
295
|
export declare const appPath: (path?: string) => any;
|
|
269
296
|
/**
|
|
270
297
|
* 深度复制对象
|
|
298
|
+
*
|
|
271
299
|
* @param obj
|
|
272
300
|
* @returns
|
|
273
301
|
*/
|
|
274
302
|
export declare const deepClone: (obj: any) => any;
|
|
275
303
|
/**
|
|
276
304
|
* 在主工程中打开模块
|
|
305
|
+
*
|
|
277
306
|
* @param option {path:模块路由,需要加工程编码, resourceId: 资源Id,两者传一个即可,data:参数}
|
|
278
307
|
*/
|
|
279
308
|
export declare const openPageInMain: (option: {
|
package/lib/utils/index.js
CHANGED
|
@@ -14,6 +14,7 @@ import React from 'react';
|
|
|
14
14
|
export { throttle, debounce } from 'lodash';
|
|
15
15
|
/**
|
|
16
16
|
* 获取 url 参数
|
|
17
|
+
*
|
|
17
18
|
* @param name
|
|
18
19
|
* @param url
|
|
19
20
|
* @returns
|
|
@@ -48,11 +49,12 @@ export var getResourceProps = function getResourceProps(name) {
|
|
|
48
49
|
return obj[name] || '';
|
|
49
50
|
};
|
|
50
51
|
/**
|
|
51
|
-
* 设置url传参
|
|
52
|
-
|
|
53
|
-
* @param {
|
|
54
|
-
* @
|
|
55
|
-
|
|
52
|
+
* 设置url传参
|
|
53
|
+
*
|
|
54
|
+
* @param {any} url
|
|
55
|
+
* @param {any} keyvals
|
|
56
|
+
* @returns
|
|
57
|
+
*/
|
|
56
58
|
export var setUrlQuery = function setUrlQuery(url) {
|
|
57
59
|
var keyvals = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
58
60
|
var newUrl = url;
|
|
@@ -73,8 +75,9 @@ export var setUrlQuery = function setUrlQuery(url) {
|
|
|
73
75
|
};
|
|
74
76
|
/**
|
|
75
77
|
* 日期格式化
|
|
78
|
+
*
|
|
76
79
|
* @param dt 日期
|
|
77
|
-
* @param showTime 是否显示时间
|
|
80
|
+
* @param showTime 是否显示时间 默认为 true
|
|
78
81
|
* @returns YYYY-MM-DD
|
|
79
82
|
*/
|
|
80
83
|
export var dateFormat = function dateFormat(dt) {
|
|
@@ -82,12 +85,13 @@ export var dateFormat = function dateFormat(dt) {
|
|
|
82
85
|
var ct = dt ? dt : new Date(Date.now());
|
|
83
86
|
var str = ct.getFullYear() + '-' + ('' + (ct.getMonth() + 1)).padStart(2, '0') + '-' + ('' + ct.getDate()).padStart(2, '0');
|
|
84
87
|
if (showTime) {
|
|
85
|
-
str += ' ' + (ct.getHours() + '').padStart(2, '0') + ':' + (ct.getMinutes() + '').padStart(2, '0') +
|
|
88
|
+
str += ' ' + (ct.getHours() + '').padStart(2, '0') + ':' + (ct.getMinutes() + '').padStart(2, '0') + ':' + (ct.getSeconds() + '').padStart(2, '0');
|
|
86
89
|
}
|
|
87
90
|
return str;
|
|
88
91
|
};
|
|
89
92
|
/**
|
|
90
93
|
* 给 url 添加网关
|
|
94
|
+
*
|
|
91
95
|
* @param url 原url,以 / 打头
|
|
92
96
|
* @param gatewayKey 设置gateway关键字 默认为 'gateway'
|
|
93
97
|
* @param defGateway 默认网关 ''
|
|
@@ -105,10 +109,10 @@ export var toGatewayUrl = function toGatewayUrl(url) {
|
|
|
105
109
|
}
|
|
106
110
|
// 取网关的顺序, 1.取url里的传参,2.取资源里的网关, 3. 取项目里设置的默认网关
|
|
107
111
|
var gateway = getUrlQuery(gatewayKey) || getResourceProps(gatewayKey) || defGateway;
|
|
108
|
-
// 如果没有找到网关,直接从项目配置中取网关
|
|
112
|
+
// 如果没有找到网关,直接从项目配置中取网关
|
|
109
113
|
if (!gateway) {
|
|
110
114
|
var projects = JSON.parse(sessionStorage.getItem('lsProjects') || '[]');
|
|
111
|
-
var projectKey = localStorage.getItem(
|
|
115
|
+
var projectKey = localStorage.getItem('projectId');
|
|
112
116
|
if (projectKey && projects.length) {
|
|
113
117
|
var project = projects.find(function (o) {
|
|
114
118
|
return o.projectId === projectKey;
|
|
@@ -119,7 +123,7 @@ export var toGatewayUrl = function toGatewayUrl(url) {
|
|
|
119
123
|
}
|
|
120
124
|
}
|
|
121
125
|
// 网关加上域名,避免多次设置
|
|
122
|
-
if (gateway && !gateway.startsWith(
|
|
126
|
+
if (gateway && !gateway.startsWith('http')) {
|
|
123
127
|
var h = location.origin ? location.origin : "".concat(location.protocol, "//").concat(location.hostname).concat(location.port ? ':' + location.port : '');
|
|
124
128
|
gateway = h + gateway;
|
|
125
129
|
}
|
|
@@ -127,7 +131,8 @@ export var toGatewayUrl = function toGatewayUrl(url) {
|
|
|
127
131
|
};
|
|
128
132
|
/**
|
|
129
133
|
* 设置文档title
|
|
130
|
-
*
|
|
134
|
+
*
|
|
135
|
+
* @param {any} title
|
|
131
136
|
* @returns
|
|
132
137
|
*/
|
|
133
138
|
export var setTitle = function setTitle(title) {
|
|
@@ -136,6 +141,7 @@ export var setTitle = function setTitle(title) {
|
|
|
136
141
|
};
|
|
137
142
|
/**
|
|
138
143
|
* 日期格式化
|
|
144
|
+
*
|
|
139
145
|
* @param dt 日期
|
|
140
146
|
* @param showTime 是否显示时间 默认true
|
|
141
147
|
* @returns YYYY-MM-DD hh:mm:ss
|
|
@@ -143,6 +149,7 @@ export var setTitle = function setTitle(title) {
|
|
|
143
149
|
export var formatDate = dateFormat;
|
|
144
150
|
/**
|
|
145
151
|
* 返回当前日期
|
|
152
|
+
*
|
|
146
153
|
* @returns YYYY-MM-DD
|
|
147
154
|
*/
|
|
148
155
|
export var today = function today() {
|
|
@@ -150,6 +157,7 @@ export var today = function today() {
|
|
|
150
157
|
};
|
|
151
158
|
/**
|
|
152
159
|
* 返回当前日期时间
|
|
160
|
+
*
|
|
153
161
|
* @returns YYYY-MM-DD hh:mm:ss
|
|
154
162
|
*/
|
|
155
163
|
export var now = function now() {
|
|
@@ -157,6 +165,7 @@ export var now = function now() {
|
|
|
157
165
|
};
|
|
158
166
|
/**
|
|
159
167
|
* 时间加减
|
|
168
|
+
*
|
|
160
169
|
* @param dt 原始时间,传 null 为当前时间
|
|
161
170
|
* @param addDay 添加添数,可为负数
|
|
162
171
|
* @param addMonth 添加月数,可为负数
|
|
@@ -182,6 +191,7 @@ export var dateAdd = function dateAdd(dt, addDay) {
|
|
|
182
191
|
};
|
|
183
192
|
/**
|
|
184
193
|
* 当前时间加减
|
|
194
|
+
*
|
|
185
195
|
* @param addDay 添加添数,可为负数
|
|
186
196
|
* @param addMonth 添加月数,可为负数
|
|
187
197
|
* @param addYear 添加年数,可以负责
|
|
@@ -194,6 +204,7 @@ export var nowAdd = function nowAdd(addDay) {
|
|
|
194
204
|
};
|
|
195
205
|
/**
|
|
196
206
|
* 当前日期加减
|
|
207
|
+
*
|
|
197
208
|
* @param addDay 添加添数,可为负数
|
|
198
209
|
* @param addMonth 添加月数,可为负数
|
|
199
210
|
* @param addYear 添加年数,可以负责
|
|
@@ -206,9 +217,10 @@ export var todayAdd = function todayAdd(addDay) {
|
|
|
206
217
|
};
|
|
207
218
|
/**
|
|
208
219
|
* 千位符格式化数值
|
|
220
|
+
*
|
|
209
221
|
* @param num 数值
|
|
210
222
|
* @param dec 小数位数,默认为2位小数
|
|
211
|
-
* @returns
|
|
223
|
+
* @returns Xx,xxx.xx
|
|
212
224
|
*/
|
|
213
225
|
export var formatMoney = function formatMoney(num) {
|
|
214
226
|
var dec = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
|
|
@@ -226,19 +238,21 @@ export var formatMoney = function formatMoney(num) {
|
|
|
226
238
|
};
|
|
227
239
|
/**
|
|
228
240
|
* 获取Cookie
|
|
229
|
-
*
|
|
241
|
+
*
|
|
242
|
+
* @param {String} name Cookie名
|
|
230
243
|
* @returns
|
|
231
244
|
*/
|
|
232
245
|
export var getCookie = function getCookie(name) {
|
|
233
246
|
var arr;
|
|
234
|
-
var reg = new RegExp(
|
|
247
|
+
var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)');
|
|
235
248
|
if (arr = document.cookie.match(reg)) return arr[2];else return null;
|
|
236
249
|
};
|
|
237
250
|
/**
|
|
238
251
|
* 设置Cookie
|
|
239
|
-
*
|
|
240
|
-
* @param {
|
|
241
|
-
* @param {
|
|
252
|
+
*
|
|
253
|
+
* @param {any} key Cookie名称
|
|
254
|
+
* @param {any} value Cookie 值
|
|
255
|
+
* @param {Number} day 有效天数 默认1天,
|
|
242
256
|
*/
|
|
243
257
|
export var setCookie = function setCookie(key, value) {
|
|
244
258
|
var day = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
@@ -252,14 +266,15 @@ export var setCookie = function setCookie(key, value) {
|
|
|
252
266
|
}
|
|
253
267
|
} else {
|
|
254
268
|
if (sameSite) {
|
|
255
|
-
document.cookie = key +
|
|
269
|
+
document.cookie = key + '=' + value + ';path=/;sameSite=None;secure=true';
|
|
256
270
|
} else {
|
|
257
|
-
document.cookie = key +
|
|
271
|
+
document.cookie = key + '=' + value + ';path=/';
|
|
258
272
|
}
|
|
259
273
|
}
|
|
260
274
|
};
|
|
261
275
|
/**
|
|
262
276
|
* 判断是否登录
|
|
277
|
+
*
|
|
263
278
|
* @returns
|
|
264
279
|
*/
|
|
265
280
|
export var isLogin = function isLogin() {
|
|
@@ -267,13 +282,20 @@ export var isLogin = function isLogin() {
|
|
|
267
282
|
};
|
|
268
283
|
export var getFullScreenElement = function getFullScreenElement() {
|
|
269
284
|
//@ts-ignore
|
|
270
|
-
return document.fullscreenElement ||
|
|
285
|
+
return document.fullscreenElement ||
|
|
286
|
+
//@ts-ignore
|
|
287
|
+
document.mozFullScreenElement ||
|
|
288
|
+
//@ts-ignore
|
|
289
|
+
document.msFullScreenElement ||
|
|
290
|
+
//@ts-ignore
|
|
291
|
+
document.webkitFullscreenElement || undefined;
|
|
271
292
|
};
|
|
272
293
|
/**
|
|
273
294
|
* 设置本地缓存
|
|
274
|
-
*
|
|
275
|
-
* @param {
|
|
276
|
-
* @param {
|
|
295
|
+
*
|
|
296
|
+
* @param {String} key 关键字
|
|
297
|
+
* @param {Object} data 值
|
|
298
|
+
* @param {Boolean} session 保存到 sessionStorage 还是 localStorage,默认 localStorage
|
|
277
299
|
*/
|
|
278
300
|
export var setCache = function setCache(key, data) {
|
|
279
301
|
var session = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
@@ -288,8 +310,9 @@ export var setCache = function setCache(key, data) {
|
|
|
288
310
|
};
|
|
289
311
|
/**
|
|
290
312
|
* 读取本地缓存
|
|
291
|
-
*
|
|
292
|
-
* @param {
|
|
313
|
+
*
|
|
314
|
+
* @param {String} key 关键字
|
|
315
|
+
* @param {boolean} session 从 sessionStorage 取数还是从 localStorage 中取数 默认从 localStorage
|
|
293
316
|
* @returns 关键字对应的值
|
|
294
317
|
*/
|
|
295
318
|
export var getCache = function getCache(key) {
|
|
@@ -302,6 +325,7 @@ export var getCache = function getCache(key) {
|
|
|
302
325
|
};
|
|
303
326
|
/**
|
|
304
327
|
* 读取本地缓存,优先从sessionStorage 取,取不到时再从 localStorage取
|
|
328
|
+
*
|
|
305
329
|
* @param key
|
|
306
330
|
* @returns
|
|
307
331
|
*/
|
|
@@ -309,7 +333,6 @@ export var getCacheSessionFirst = function getCacheSessionFirst(key) {
|
|
|
309
333
|
return getCache(key, true) || getCache(key);
|
|
310
334
|
};
|
|
311
335
|
/**
|
|
312
|
-
*
|
|
313
336
|
* @param key 关键字,不传清除所有
|
|
314
337
|
* @param session 是否session storage , 默认 localStorage
|
|
315
338
|
*/
|
|
@@ -403,6 +426,7 @@ export var showSuccess = function showSuccess(text) {
|
|
|
403
426
|
};
|
|
404
427
|
/**
|
|
405
428
|
* 弹框提示
|
|
429
|
+
*
|
|
406
430
|
* @param text 提示信息
|
|
407
431
|
* @param title 标题,默认 系统提示
|
|
408
432
|
* @param type 类型
|
|
@@ -470,7 +494,8 @@ export var showConfirm = function showConfirm(text) {
|
|
|
470
494
|
};
|
|
471
495
|
var timeout = false;
|
|
472
496
|
/**
|
|
473
|
-
*
|
|
497
|
+
* Token过期重新登录
|
|
498
|
+
*
|
|
474
499
|
* @returns
|
|
475
500
|
*/
|
|
476
501
|
export var reLogin = function reLogin() {
|
|
@@ -494,9 +519,10 @@ export var reLogin = function reLogin() {
|
|
|
494
519
|
};
|
|
495
520
|
/**
|
|
496
521
|
* 日期组选择转换
|
|
522
|
+
*
|
|
497
523
|
* @param values 选择的值
|
|
498
|
-
* @param startField
|
|
499
|
-
* @param endField
|
|
524
|
+
* @param startField 第一个字段
|
|
525
|
+
* @param endField 第二个字段
|
|
500
526
|
* @param endSuffix
|
|
501
527
|
* @returns
|
|
502
528
|
*/
|
|
@@ -534,12 +560,13 @@ export var yesnoList = [{
|
|
|
534
560
|
}];
|
|
535
561
|
/**
|
|
536
562
|
* 遍历树
|
|
563
|
+
*
|
|
537
564
|
* @param list 树对象
|
|
538
565
|
* @param fn 回调函数
|
|
539
566
|
* @param children 树属性字段
|
|
540
567
|
*/
|
|
541
568
|
export var treeEach = function treeEach(list, fn) {
|
|
542
|
-
var children = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] :
|
|
569
|
+
var children = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'children';
|
|
543
570
|
list.forEach(function (item, index) {
|
|
544
571
|
fn(item, index, list);
|
|
545
572
|
// @ts-ignore
|
|
@@ -551,6 +578,7 @@ export var treeEach = function treeEach(list, fn) {
|
|
|
551
578
|
};
|
|
552
579
|
/**
|
|
553
580
|
* 查询数
|
|
581
|
+
*
|
|
554
582
|
* @param list 树对象
|
|
555
583
|
* @param key 查询属性
|
|
556
584
|
* @param val 查询值
|
|
@@ -558,7 +586,7 @@ export var treeEach = function treeEach(list, fn) {
|
|
|
558
586
|
* @returns 返回符合条件的第一条对象
|
|
559
587
|
*/
|
|
560
588
|
export var treeFind = function treeFind(list, key, val) {
|
|
561
|
-
var children = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] :
|
|
589
|
+
var children = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'children';
|
|
562
590
|
var item = null;
|
|
563
591
|
var _iterator = _createForOfIteratorHelper(list),
|
|
564
592
|
_step;
|
|
@@ -584,6 +612,7 @@ export var treeFind = function treeFind(list, key, val) {
|
|
|
584
612
|
};
|
|
585
613
|
/**
|
|
586
614
|
* 处理普通的尺码横排
|
|
615
|
+
*
|
|
587
616
|
* @param orgSizeHeader 后端返回的原始尺码组表头
|
|
588
617
|
* @param typeWidth 尺码组宽 sizeTypeNo,默认120
|
|
589
618
|
* @param sizeWidth 尺码宽f1~f100, 默认100
|
|
@@ -664,9 +693,10 @@ export var handleSizeCols = function handleSizeCols(orgSizeHeader) {
|
|
|
664
693
|
};
|
|
665
694
|
/**
|
|
666
695
|
* 绑定事件
|
|
667
|
-
*
|
|
668
|
-
* @param
|
|
669
|
-
* @param
|
|
696
|
+
*
|
|
697
|
+
* @param eventName 事件名
|
|
698
|
+
* @param fn 调用函数
|
|
699
|
+
* @param el 源对象,默认为window
|
|
670
700
|
*/
|
|
671
701
|
export var on = function on(eventName, fn, el) {
|
|
672
702
|
if (!el) {
|
|
@@ -676,6 +706,7 @@ export var on = function on(eventName, fn, el) {
|
|
|
676
706
|
};
|
|
677
707
|
/**
|
|
678
708
|
* 解绑事件
|
|
709
|
+
*
|
|
679
710
|
* @param eventName 事件名
|
|
680
711
|
* @param fn 调用函数
|
|
681
712
|
* @param el 源对象,默认为window
|
|
@@ -688,10 +719,11 @@ export var off = function off(eventName, fn, el) {
|
|
|
688
719
|
};
|
|
689
720
|
/**
|
|
690
721
|
* 打印预览
|
|
722
|
+
*
|
|
691
723
|
* @param templateNo 打印模板编码
|
|
692
724
|
* @param reqUrl 业务请求api
|
|
693
725
|
* @param bodyParam Post传参数
|
|
694
|
-
* @param param
|
|
726
|
+
* @param param Get传参数
|
|
695
727
|
* @param method 请求方式,默认post
|
|
696
728
|
* @returns
|
|
697
729
|
*/
|
|
@@ -720,11 +752,12 @@ export var printView = function printView(templateNo, reqUrl) {
|
|
|
720
752
|
};
|
|
721
753
|
/**
|
|
722
754
|
* 直接打印
|
|
755
|
+
*
|
|
723
756
|
* @param taskName 打印任务名
|
|
724
757
|
* @param templateNo 打印模板
|
|
725
758
|
* @param reqUrl 业务请求api
|
|
726
759
|
* @param bodyParam Post传参数
|
|
727
|
-
* @param param
|
|
760
|
+
* @param param Get传参数
|
|
728
761
|
* @param method 请求方式,默认post
|
|
729
762
|
* @returns
|
|
730
763
|
*/
|
|
@@ -756,7 +789,7 @@ export var printAsync = function printAsync(taskName, templateNo, reqUrl) {
|
|
|
756
789
|
var url = 'http://localhost:10050/client/async/print';
|
|
757
790
|
return httpPost(url, data, true, false);
|
|
758
791
|
};
|
|
759
|
-
export var isDev = location.href.includes(
|
|
792
|
+
export var isDev = location.href.includes('//localhost');
|
|
760
793
|
/** @name 用户信息 */
|
|
761
794
|
export var getUserInfo = function getUserInfo() {
|
|
762
795
|
return getCache('user');
|
|
@@ -791,6 +824,7 @@ export var appPath = function appPath() {
|
|
|
791
824
|
};
|
|
792
825
|
/**
|
|
793
826
|
* 深度复制对象
|
|
827
|
+
*
|
|
794
828
|
* @param obj
|
|
795
829
|
* @returns
|
|
796
830
|
*/
|
|
@@ -812,6 +846,7 @@ export var deepClone = function deepClone(obj) {
|
|
|
812
846
|
};
|
|
813
847
|
/**
|
|
814
848
|
* 在主工程中打开模块
|
|
849
|
+
*
|
|
815
850
|
* @param option {path:模块路由,需要加工程编码, resourceId: 资源Id,两者传一个即可,data:参数}
|
|
816
851
|
*/
|
|
817
852
|
export var openPageInMain = function openPageInMain(option) {
|
|
@@ -826,7 +861,7 @@ export var showLoading = function showLoading() {
|
|
|
826
861
|
var loading = document.getElementById('myloading');
|
|
827
862
|
if (loading) return;
|
|
828
863
|
var loadWrapper = document.createElement('div');
|
|
829
|
-
loadWrapper.setAttribute(
|
|
864
|
+
loadWrapper.setAttribute('id', 'myloading');
|
|
830
865
|
ReactDOM.render( /*#__PURE__*/React.createElement(_Spin, {
|
|
831
866
|
tip: text
|
|
832
867
|
}), loadWrapper);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ls-pro-common",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.59",
|
|
4
4
|
"description": "ls-pro-common",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"sideEffects": [
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@ant-design/icons": "^4.3.0",
|
|
24
|
-
"ls-pro-table": "^3.0.
|
|
25
|
-
"ls-pro-form": "^3.0.
|
|
24
|
+
"ls-pro-table": "^3.0.41",
|
|
25
|
+
"ls-pro-form": "^3.0.15",
|
|
26
26
|
"ls-pro-field": "^3.0.6",
|
|
27
27
|
"ls-pro-descriptions": "^3.0.1",
|
|
28
28
|
"ls-pro-card": "^3.0.3",
|