ls-pro-common 1.0.10 → 1.0.13
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/http/index.d.ts +10 -4
- package/es/http/index.js +33 -9
- package/es/utils/index.d.ts +1 -22
- package/es/utils/index.js +1 -63
- package/lib/http/index.d.ts +10 -4
- package/lib/http/index.js +33 -9
- package/lib/utils/index.d.ts +1 -22
- package/lib/utils/index.js +36 -77
- package/package.json +2 -2
package/es/http/index.d.ts
CHANGED
|
@@ -3,21 +3,24 @@ declare const request: import("umi-request").RequestMethod<false>;
|
|
|
3
3
|
* get请求
|
|
4
4
|
* @param url 接口
|
|
5
5
|
* @param params 参数{key:value}
|
|
6
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
6
7
|
* @returns Promise<ApiResponse>
|
|
7
8
|
*/
|
|
8
|
-
export declare function httpGet(url: string, params?: Record<string, any
|
|
9
|
+
export declare function httpGet(url: string, params?: Record<string, any>, needGateWay?: boolean): Promise<any>;
|
|
9
10
|
/**
|
|
10
11
|
* post请求
|
|
11
12
|
* @param url 接口
|
|
12
13
|
* @param data 参数{key:value}
|
|
13
14
|
* @param isJson json请求还是form请求,默认为json请求
|
|
15
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
14
16
|
* @returns Promise<ApiResponse>
|
|
15
17
|
*/
|
|
16
|
-
export declare function httpPost(url: string, data?: Record<string, any>, isJson?: boolean): Promise<any>;
|
|
18
|
+
export declare function httpPost(url: string, data?: Record<string, any>, isJson?: boolean, needGateWay?: boolean): Promise<any>;
|
|
17
19
|
/**
|
|
18
20
|
* put 请求
|
|
19
21
|
* @param url 接口
|
|
20
22
|
* @param data 参数{key:value}
|
|
23
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
21
24
|
* @returns Promise<ApiResponse>
|
|
22
25
|
*/
|
|
23
26
|
export declare function httpPut(url: string, data?: Record<string, any>): Promise<any>;
|
|
@@ -25,15 +28,17 @@ export declare function httpPut(url: string, data?: Record<string, any>): Promis
|
|
|
25
28
|
* delete 请求
|
|
26
29
|
* @param url 接口
|
|
27
30
|
* @param data 参数[]
|
|
31
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
28
32
|
* @returns Promise<ApiResponse>
|
|
29
33
|
*/
|
|
30
34
|
export declare function httpDelete(url: string, data: any): Promise<any>;
|
|
31
35
|
/**
|
|
32
36
|
* 读取数据字典
|
|
33
37
|
* @param dictCode 字典编码
|
|
38
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
34
39
|
* @returns Promise<Record<string,string>>
|
|
35
40
|
*/
|
|
36
|
-
export declare function getDict(dictCode: string, showValue?: boolean): Promise<any>;
|
|
41
|
+
export declare function getDict(dictCode: string, showValue?: boolean, needGateWay?: boolean): Promise<any>;
|
|
37
42
|
/**
|
|
38
43
|
* 加载下拉框的数据源
|
|
39
44
|
* @param url 后端接口
|
|
@@ -41,7 +46,8 @@ export declare function getDict(dictCode: string, showValue?: boolean): Promise<
|
|
|
41
46
|
* @param valueField 值字段
|
|
42
47
|
* @param labelField 显示字段
|
|
43
48
|
* @param showValue 显示值
|
|
49
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
44
50
|
* @returns
|
|
45
51
|
*/
|
|
46
|
-
export declare function fetchOptions(url: string, param: any, valueField: string, labelField: string, showValue?: boolean): Promise<any>;
|
|
52
|
+
export declare function fetchOptions(url: string, param: any, valueField: string, labelField: string, showValue?: boolean, needGateWay?: boolean): Promise<any>;
|
|
47
53
|
export default request;
|
package/es/http/index.js
CHANGED
|
@@ -23,7 +23,7 @@ request.interceptors.request.use(function (url, options) {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
return {
|
|
26
|
-
url:
|
|
26
|
+
url: url,
|
|
27
27
|
options: opts
|
|
28
28
|
};
|
|
29
29
|
});
|
|
@@ -84,6 +84,7 @@ request.interceptors.response.use( /*#__PURE__*/function () {
|
|
|
84
84
|
* get请求
|
|
85
85
|
* @param url 接口
|
|
86
86
|
* @param params 参数{key:value}
|
|
87
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
87
88
|
* @returns Promise<ApiResponse>
|
|
88
89
|
*/
|
|
89
90
|
|
|
@@ -95,23 +96,31 @@ export function httpGet(_x3) {
|
|
|
95
96
|
* @param url 接口
|
|
96
97
|
* @param data 参数{key:value}
|
|
97
98
|
* @param isJson json请求还是form请求,默认为json请求
|
|
99
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
98
100
|
* @returns Promise<ApiResponse>
|
|
99
101
|
*/
|
|
100
102
|
|
|
101
103
|
function _httpGet() {
|
|
102
104
|
_httpGet = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(url) {
|
|
103
105
|
var params,
|
|
106
|
+
needGateWay,
|
|
104
107
|
_args2 = arguments;
|
|
105
108
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
106
109
|
while (1) {
|
|
107
110
|
switch (_context2.prev = _context2.next) {
|
|
108
111
|
case 0:
|
|
109
112
|
params = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : {};
|
|
113
|
+
needGateWay = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : true;
|
|
114
|
+
|
|
115
|
+
if (needGateWay) {
|
|
116
|
+
url = toGatewayUrl(url);
|
|
117
|
+
}
|
|
118
|
+
|
|
110
119
|
return _context2.abrupt("return", request.get(url, {
|
|
111
120
|
params: params
|
|
112
121
|
}));
|
|
113
122
|
|
|
114
|
-
case
|
|
123
|
+
case 4:
|
|
115
124
|
case "end":
|
|
116
125
|
return _context2.stop();
|
|
117
126
|
}
|
|
@@ -128,6 +137,7 @@ export function httpPost(_x4) {
|
|
|
128
137
|
* put 请求
|
|
129
138
|
* @param url 接口
|
|
130
139
|
* @param data 参数{key:value}
|
|
140
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
131
141
|
* @returns Promise<ApiResponse>
|
|
132
142
|
*/
|
|
133
143
|
|
|
@@ -135,6 +145,7 @@ function _httpPost() {
|
|
|
135
145
|
_httpPost = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(url) {
|
|
136
146
|
var data,
|
|
137
147
|
isJson,
|
|
148
|
+
needGateWay,
|
|
138
149
|
_args3 = arguments;
|
|
139
150
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
140
151
|
while (1) {
|
|
@@ -142,12 +153,18 @@ function _httpPost() {
|
|
|
142
153
|
case 0:
|
|
143
154
|
data = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {};
|
|
144
155
|
isJson = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : true;
|
|
156
|
+
needGateWay = _args3.length > 3 && _args3[3] !== undefined ? _args3[3] : true;
|
|
157
|
+
|
|
158
|
+
if (needGateWay) {
|
|
159
|
+
url = toGatewayUrl(url);
|
|
160
|
+
}
|
|
161
|
+
|
|
145
162
|
return _context3.abrupt("return", request.post(url, {
|
|
146
163
|
data: data,
|
|
147
164
|
requestType: isJson ? 'json' : 'form'
|
|
148
165
|
}));
|
|
149
166
|
|
|
150
|
-
case
|
|
167
|
+
case 5:
|
|
151
168
|
case "end":
|
|
152
169
|
return _context3.stop();
|
|
153
170
|
}
|
|
@@ -164,6 +181,7 @@ export function httpPut(_x5) {
|
|
|
164
181
|
* delete 请求
|
|
165
182
|
* @param url 接口
|
|
166
183
|
* @param data 参数[]
|
|
184
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
167
185
|
* @returns Promise<ApiResponse>
|
|
168
186
|
*/
|
|
169
187
|
|
|
@@ -196,6 +214,7 @@ export function httpDelete(_x6, _x7) {
|
|
|
196
214
|
/**
|
|
197
215
|
* 读取数据字典
|
|
198
216
|
* @param dictCode 字典编码
|
|
217
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
199
218
|
* @returns Promise<Record<string,string>>
|
|
200
219
|
*/
|
|
201
220
|
|
|
@@ -229,12 +248,14 @@ export function getDict(_x8) {
|
|
|
229
248
|
* @param valueField 值字段
|
|
230
249
|
* @param labelField 显示字段
|
|
231
250
|
* @param showValue 显示值
|
|
251
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
232
252
|
* @returns
|
|
233
253
|
*/
|
|
234
254
|
|
|
235
255
|
function _getDict() {
|
|
236
256
|
_getDict = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(dictCode) {
|
|
237
257
|
var showValue,
|
|
258
|
+
needGateWay,
|
|
238
259
|
api,
|
|
239
260
|
param,
|
|
240
261
|
_args6 = arguments;
|
|
@@ -243,6 +264,7 @@ function _getDict() {
|
|
|
243
264
|
switch (_context6.prev = _context6.next) {
|
|
244
265
|
case 0:
|
|
245
266
|
showValue = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : true;
|
|
267
|
+
needGateWay = _args6.length > 2 && _args6[2] !== undefined ? _args6[2] : true;
|
|
246
268
|
api = '/lesoon-integration/sysDictDtl';
|
|
247
269
|
param = {
|
|
248
270
|
where: {
|
|
@@ -250,9 +272,9 @@ function _getDict() {
|
|
|
250
272
|
},
|
|
251
273
|
ifPage: 0
|
|
252
274
|
};
|
|
253
|
-
return _context6.abrupt("return", fetchOptions(api, param, 'dictValue', 'displayName', showValue));
|
|
275
|
+
return _context6.abrupt("return", fetchOptions(api, param, 'dictValue', 'displayName', showValue, needGateWay));
|
|
254
276
|
|
|
255
|
-
case
|
|
277
|
+
case 5:
|
|
256
278
|
case "end":
|
|
257
279
|
return _context6.stop();
|
|
258
280
|
}
|
|
@@ -269,6 +291,7 @@ export function fetchOptions(_x9, _x10, _x11, _x12) {
|
|
|
269
291
|
function _fetchOptions() {
|
|
270
292
|
_fetchOptions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(url, param, valueField, labelField) {
|
|
271
293
|
var showValue,
|
|
294
|
+
needGateWay,
|
|
272
295
|
_yield$httpGet,
|
|
273
296
|
_yield$httpGet$rows,
|
|
274
297
|
rows,
|
|
@@ -280,10 +303,11 @@ function _fetchOptions() {
|
|
|
280
303
|
switch (_context7.prev = _context7.next) {
|
|
281
304
|
case 0:
|
|
282
305
|
showValue = _args7.length > 4 && _args7[4] !== undefined ? _args7[4] : true;
|
|
283
|
-
|
|
284
|
-
|
|
306
|
+
needGateWay = _args7.length > 5 && _args7[5] !== undefined ? _args7[5] : true;
|
|
307
|
+
_context7.next = 4;
|
|
308
|
+
return httpGet(url, param, needGateWay);
|
|
285
309
|
|
|
286
|
-
case
|
|
310
|
+
case 4:
|
|
287
311
|
_yield$httpGet = _context7.sent;
|
|
288
312
|
_yield$httpGet$rows = _yield$httpGet.rows;
|
|
289
313
|
rows = _yield$httpGet$rows === void 0 ? [] : _yield$httpGet$rows;
|
|
@@ -297,7 +321,7 @@ function _fetchOptions() {
|
|
|
297
321
|
});
|
|
298
322
|
return _context7.abrupt("return", data);
|
|
299
323
|
|
|
300
|
-
case
|
|
324
|
+
case 9:
|
|
301
325
|
case "end":
|
|
302
326
|
return _context7.stop();
|
|
303
327
|
}
|
package/es/utils/index.d.ts
CHANGED
|
@@ -1,18 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
/**
|
|
3
|
-
* 设置url传参
|
|
4
|
-
* @param {*} url
|
|
5
|
-
* @param {*} keyvals
|
|
6
|
-
* @returns
|
|
7
|
-
*/
|
|
8
|
-
export declare const setUrlQuery: (url: string, keyvals?: Record<string, any>) => string;
|
|
9
|
-
/**
|
|
10
|
-
* 给 url 添加网关
|
|
11
|
-
* @param url 原url,以 / 打头
|
|
12
|
-
* @param defGateway 默认网关 /petrel
|
|
13
|
-
* @returns
|
|
14
|
-
*/
|
|
15
|
-
export declare const toGatewayUrl: (url: string, defGateway?: string) => string;
|
|
1
|
+
export { getUrlQuery, setUrlQuery, dateFormat, toGatewayUrl, getResourceProps } from 'ls-pro-table/lib/utils';
|
|
16
2
|
/**
|
|
17
3
|
* 设置文档title
|
|
18
4
|
* @param {*} title
|
|
@@ -49,13 +35,6 @@ export declare const setCache: (key: string, data: any) => void;
|
|
|
49
35
|
* @returns 关键字对应的值
|
|
50
36
|
*/
|
|
51
37
|
export declare const getCache: any;
|
|
52
|
-
/**
|
|
53
|
-
* 简单日期格式化
|
|
54
|
-
* @param {*} dt 传入时间参数,若不传取当前时间
|
|
55
|
-
* @param {*} showTime 是否返回当前时间,默认返回时间
|
|
56
|
-
* @returns xxxx年-xx月-xx日 [xx时:xx分:xx秒]
|
|
57
|
-
*/
|
|
58
|
-
export declare const dateFormat: (dt: Date | undefined | null, showTime?: boolean) => string;
|
|
59
38
|
/** @name 显示错误 */
|
|
60
39
|
export declare const showError: (text: string) => void;
|
|
61
40
|
/** @name 显示警示 */
|
package/es/utils/index.js
CHANGED
|
@@ -6,51 +6,7 @@ import _message from "antd/es/message";
|
|
|
6
6
|
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
7
7
|
import React from "react";
|
|
8
8
|
import { QuestionCircleOutlined } from '@ant-design/icons';
|
|
9
|
-
export
|
|
10
|
-
var url = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : location.search.substr(1) || '';
|
|
11
|
-
var reg = new RegExp('(^|[&|?])' + name + '=([^&]*)(&|$)'),
|
|
12
|
-
r = url.match(reg);
|
|
13
|
-
if (r != null) return unescape(decodeURI(r[2]));
|
|
14
|
-
return '';
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* 设置url传参
|
|
18
|
-
* @param {*} url
|
|
19
|
-
* @param {*} keyvals
|
|
20
|
-
* @returns
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
export var setUrlQuery = function setUrlQuery(url) {
|
|
24
|
-
var keyvals = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
25
|
-
var newUrl = url;
|
|
26
|
-
|
|
27
|
-
for (var name in keyvals) {
|
|
28
|
-
var reg = new RegExp('(^|)' + name + '=([^&]*)(|$)');
|
|
29
|
-
var tmp = name + '=' + keyvals[name];
|
|
30
|
-
|
|
31
|
-
if (newUrl.match(reg) != null) {
|
|
32
|
-
// @ts-ignore
|
|
33
|
-
newUrl = newUrl.replace(eval(reg), tmp);
|
|
34
|
-
} else {
|
|
35
|
-
newUrl = newUrl + (newUrl.match('[\?]') ? '&' : '?') + tmp;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return newUrl;
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* 给 url 添加网关
|
|
43
|
-
* @param url 原url,以 / 打头
|
|
44
|
-
* @param defGateway 默认网关 /petrel
|
|
45
|
-
* @returns
|
|
46
|
-
*/
|
|
47
|
-
|
|
48
|
-
export var toGatewayUrl = function toGatewayUrl(url) {
|
|
49
|
-
var defGateway = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '/petrel';
|
|
50
|
-
if (url.startsWith('http://') || url.startsWith('https://') || url.startsWith('//')) return url;
|
|
51
|
-
var gateway = getUrlQuery('gateway') || location.origin + defGateway;
|
|
52
|
-
return gateway + url;
|
|
53
|
-
};
|
|
9
|
+
export { getUrlQuery, setUrlQuery, dateFormat, toGatewayUrl, getResourceProps } from "ls-pro-table/es/utils";
|
|
54
10
|
/**
|
|
55
11
|
* 设置文档title
|
|
56
12
|
* @param {*} title
|
|
@@ -126,24 +82,6 @@ export var getCache = function getCache(key) {
|
|
|
126
82
|
|
|
127
83
|
return data;
|
|
128
84
|
};
|
|
129
|
-
/**
|
|
130
|
-
* 简单日期格式化
|
|
131
|
-
* @param {*} dt 传入时间参数,若不传取当前时间
|
|
132
|
-
* @param {*} showTime 是否返回当前时间,默认返回时间
|
|
133
|
-
* @returns xxxx年-xx月-xx日 [xx时:xx分:xx秒]
|
|
134
|
-
*/
|
|
135
|
-
|
|
136
|
-
export var dateFormat = function dateFormat(dt) {
|
|
137
|
-
var showTime = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
138
|
-
var ct = dt ? dt : new Date(Date.now());
|
|
139
|
-
var str = ct.getFullYear() + '-' + ('' + (ct.getMonth() + 1)).padStart(2, '0') + '-' + ('' + ct.getDate()).padStart(2, '0');
|
|
140
|
-
|
|
141
|
-
if (showTime) {
|
|
142
|
-
str += ' ' + (ct.getHours() + '').padStart(2, '0') + ':' + (ct.getMinutes() + '').padStart(2, '0') + ":" + (ct.getSeconds() + '').padStart(2, '0');
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
return str;
|
|
146
|
-
};
|
|
147
85
|
/** @name 显示错误 */
|
|
148
86
|
|
|
149
87
|
export var showError = function showError(text) {
|
package/lib/http/index.d.ts
CHANGED
|
@@ -3,21 +3,24 @@ declare const request: import("umi-request").RequestMethod<false>;
|
|
|
3
3
|
* get请求
|
|
4
4
|
* @param url 接口
|
|
5
5
|
* @param params 参数{key:value}
|
|
6
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
6
7
|
* @returns Promise<ApiResponse>
|
|
7
8
|
*/
|
|
8
|
-
export declare function httpGet(url: string, params?: Record<string, any
|
|
9
|
+
export declare function httpGet(url: string, params?: Record<string, any>, needGateWay?: boolean): Promise<any>;
|
|
9
10
|
/**
|
|
10
11
|
* post请求
|
|
11
12
|
* @param url 接口
|
|
12
13
|
* @param data 参数{key:value}
|
|
13
14
|
* @param isJson json请求还是form请求,默认为json请求
|
|
15
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
14
16
|
* @returns Promise<ApiResponse>
|
|
15
17
|
*/
|
|
16
|
-
export declare function httpPost(url: string, data?: Record<string, any>, isJson?: boolean): Promise<any>;
|
|
18
|
+
export declare function httpPost(url: string, data?: Record<string, any>, isJson?: boolean, needGateWay?: boolean): Promise<any>;
|
|
17
19
|
/**
|
|
18
20
|
* put 请求
|
|
19
21
|
* @param url 接口
|
|
20
22
|
* @param data 参数{key:value}
|
|
23
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
21
24
|
* @returns Promise<ApiResponse>
|
|
22
25
|
*/
|
|
23
26
|
export declare function httpPut(url: string, data?: Record<string, any>): Promise<any>;
|
|
@@ -25,15 +28,17 @@ export declare function httpPut(url: string, data?: Record<string, any>): Promis
|
|
|
25
28
|
* delete 请求
|
|
26
29
|
* @param url 接口
|
|
27
30
|
* @param data 参数[]
|
|
31
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
28
32
|
* @returns Promise<ApiResponse>
|
|
29
33
|
*/
|
|
30
34
|
export declare function httpDelete(url: string, data: any): Promise<any>;
|
|
31
35
|
/**
|
|
32
36
|
* 读取数据字典
|
|
33
37
|
* @param dictCode 字典编码
|
|
38
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
34
39
|
* @returns Promise<Record<string,string>>
|
|
35
40
|
*/
|
|
36
|
-
export declare function getDict(dictCode: string, showValue?: boolean): Promise<any>;
|
|
41
|
+
export declare function getDict(dictCode: string, showValue?: boolean, needGateWay?: boolean): Promise<any>;
|
|
37
42
|
/**
|
|
38
43
|
* 加载下拉框的数据源
|
|
39
44
|
* @param url 后端接口
|
|
@@ -41,7 +46,8 @@ export declare function getDict(dictCode: string, showValue?: boolean): Promise<
|
|
|
41
46
|
* @param valueField 值字段
|
|
42
47
|
* @param labelField 显示字段
|
|
43
48
|
* @param showValue 显示值
|
|
49
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
44
50
|
* @returns
|
|
45
51
|
*/
|
|
46
|
-
export declare function fetchOptions(url: string, param: any, valueField: string, labelField: string, showValue?: boolean): Promise<any>;
|
|
52
|
+
export declare function fetchOptions(url: string, param: any, valueField: string, labelField: string, showValue?: boolean, needGateWay?: boolean): Promise<any>;
|
|
47
53
|
export default request;
|
package/lib/http/index.js
CHANGED
|
@@ -42,7 +42,7 @@ request.interceptors.request.use(function (url, options) {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
return {
|
|
45
|
-
url:
|
|
45
|
+
url: url,
|
|
46
46
|
options: opts
|
|
47
47
|
};
|
|
48
48
|
});
|
|
@@ -103,6 +103,7 @@ request.interceptors.response.use( /*#__PURE__*/function () {
|
|
|
103
103
|
* get请求
|
|
104
104
|
* @param url 接口
|
|
105
105
|
* @param params 参数{key:value}
|
|
106
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
106
107
|
* @returns Promise<ApiResponse>
|
|
107
108
|
*/
|
|
108
109
|
|
|
@@ -114,6 +115,7 @@ function httpGet(_x3) {
|
|
|
114
115
|
* @param url 接口
|
|
115
116
|
* @param data 参数{key:value}
|
|
116
117
|
* @param isJson json请求还是form请求,默认为json请求
|
|
118
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
117
119
|
* @returns Promise<ApiResponse>
|
|
118
120
|
*/
|
|
119
121
|
|
|
@@ -121,17 +123,24 @@ function httpGet(_x3) {
|
|
|
121
123
|
function _httpGet() {
|
|
122
124
|
_httpGet = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(url) {
|
|
123
125
|
var params,
|
|
126
|
+
needGateWay,
|
|
124
127
|
_args2 = arguments;
|
|
125
128
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
126
129
|
while (1) {
|
|
127
130
|
switch (_context2.prev = _context2.next) {
|
|
128
131
|
case 0:
|
|
129
132
|
params = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : {};
|
|
133
|
+
needGateWay = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : true;
|
|
134
|
+
|
|
135
|
+
if (needGateWay) {
|
|
136
|
+
url = (0, _utils.toGatewayUrl)(url);
|
|
137
|
+
}
|
|
138
|
+
|
|
130
139
|
return _context2.abrupt("return", request.get(url, {
|
|
131
140
|
params: params
|
|
132
141
|
}));
|
|
133
142
|
|
|
134
|
-
case
|
|
143
|
+
case 4:
|
|
135
144
|
case "end":
|
|
136
145
|
return _context2.stop();
|
|
137
146
|
}
|
|
@@ -148,6 +157,7 @@ function httpPost(_x4) {
|
|
|
148
157
|
* put 请求
|
|
149
158
|
* @param url 接口
|
|
150
159
|
* @param data 参数{key:value}
|
|
160
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
151
161
|
* @returns Promise<ApiResponse>
|
|
152
162
|
*/
|
|
153
163
|
|
|
@@ -156,6 +166,7 @@ function _httpPost() {
|
|
|
156
166
|
_httpPost = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(url) {
|
|
157
167
|
var data,
|
|
158
168
|
isJson,
|
|
169
|
+
needGateWay,
|
|
159
170
|
_args3 = arguments;
|
|
160
171
|
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
161
172
|
while (1) {
|
|
@@ -163,12 +174,18 @@ function _httpPost() {
|
|
|
163
174
|
case 0:
|
|
164
175
|
data = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {};
|
|
165
176
|
isJson = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : true;
|
|
177
|
+
needGateWay = _args3.length > 3 && _args3[3] !== undefined ? _args3[3] : true;
|
|
178
|
+
|
|
179
|
+
if (needGateWay) {
|
|
180
|
+
url = (0, _utils.toGatewayUrl)(url);
|
|
181
|
+
}
|
|
182
|
+
|
|
166
183
|
return _context3.abrupt("return", request.post(url, {
|
|
167
184
|
data: data,
|
|
168
185
|
requestType: isJson ? 'json' : 'form'
|
|
169
186
|
}));
|
|
170
187
|
|
|
171
|
-
case
|
|
188
|
+
case 5:
|
|
172
189
|
case "end":
|
|
173
190
|
return _context3.stop();
|
|
174
191
|
}
|
|
@@ -185,6 +202,7 @@ function httpPut(_x5) {
|
|
|
185
202
|
* delete 请求
|
|
186
203
|
* @param url 接口
|
|
187
204
|
* @param data 参数[]
|
|
205
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
188
206
|
* @returns Promise<ApiResponse>
|
|
189
207
|
*/
|
|
190
208
|
|
|
@@ -218,6 +236,7 @@ function httpDelete(_x6, _x7) {
|
|
|
218
236
|
/**
|
|
219
237
|
* 读取数据字典
|
|
220
238
|
* @param dictCode 字典编码
|
|
239
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
221
240
|
* @returns Promise<Record<string,string>>
|
|
222
241
|
*/
|
|
223
242
|
|
|
@@ -252,6 +271,7 @@ function getDict(_x8) {
|
|
|
252
271
|
* @param valueField 值字段
|
|
253
272
|
* @param labelField 显示字段
|
|
254
273
|
* @param showValue 显示值
|
|
274
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
255
275
|
* @returns
|
|
256
276
|
*/
|
|
257
277
|
|
|
@@ -259,6 +279,7 @@ function getDict(_x8) {
|
|
|
259
279
|
function _getDict() {
|
|
260
280
|
_getDict = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(dictCode) {
|
|
261
281
|
var showValue,
|
|
282
|
+
needGateWay,
|
|
262
283
|
api,
|
|
263
284
|
param,
|
|
264
285
|
_args6 = arguments;
|
|
@@ -267,6 +288,7 @@ function _getDict() {
|
|
|
267
288
|
switch (_context6.prev = _context6.next) {
|
|
268
289
|
case 0:
|
|
269
290
|
showValue = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : true;
|
|
291
|
+
needGateWay = _args6.length > 2 && _args6[2] !== undefined ? _args6[2] : true;
|
|
270
292
|
api = '/lesoon-integration/sysDictDtl';
|
|
271
293
|
param = {
|
|
272
294
|
where: {
|
|
@@ -274,9 +296,9 @@ function _getDict() {
|
|
|
274
296
|
},
|
|
275
297
|
ifPage: 0
|
|
276
298
|
};
|
|
277
|
-
return _context6.abrupt("return", fetchOptions(api, param, 'dictValue', 'displayName', showValue));
|
|
299
|
+
return _context6.abrupt("return", fetchOptions(api, param, 'dictValue', 'displayName', showValue, needGateWay));
|
|
278
300
|
|
|
279
|
-
case
|
|
301
|
+
case 5:
|
|
280
302
|
case "end":
|
|
281
303
|
return _context6.stop();
|
|
282
304
|
}
|
|
@@ -293,6 +315,7 @@ function fetchOptions(_x9, _x10, _x11, _x12) {
|
|
|
293
315
|
function _fetchOptions() {
|
|
294
316
|
_fetchOptions = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(url, param, valueField, labelField) {
|
|
295
317
|
var showValue,
|
|
318
|
+
needGateWay,
|
|
296
319
|
_yield$httpGet,
|
|
297
320
|
_yield$httpGet$rows,
|
|
298
321
|
rows,
|
|
@@ -304,10 +327,11 @@ function _fetchOptions() {
|
|
|
304
327
|
switch (_context7.prev = _context7.next) {
|
|
305
328
|
case 0:
|
|
306
329
|
showValue = _args7.length > 4 && _args7[4] !== undefined ? _args7[4] : true;
|
|
307
|
-
|
|
308
|
-
|
|
330
|
+
needGateWay = _args7.length > 5 && _args7[5] !== undefined ? _args7[5] : true;
|
|
331
|
+
_context7.next = 4;
|
|
332
|
+
return httpGet(url, param, needGateWay);
|
|
309
333
|
|
|
310
|
-
case
|
|
334
|
+
case 4:
|
|
311
335
|
_yield$httpGet = _context7.sent;
|
|
312
336
|
_yield$httpGet$rows = _yield$httpGet.rows;
|
|
313
337
|
rows = _yield$httpGet$rows === void 0 ? [] : _yield$httpGet$rows;
|
|
@@ -321,7 +345,7 @@ function _fetchOptions() {
|
|
|
321
345
|
});
|
|
322
346
|
return _context7.abrupt("return", data);
|
|
323
347
|
|
|
324
|
-
case
|
|
348
|
+
case 9:
|
|
325
349
|
case "end":
|
|
326
350
|
return _context7.stop();
|
|
327
351
|
}
|
package/lib/utils/index.d.ts
CHANGED
|
@@ -1,18 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
/**
|
|
3
|
-
* 设置url传参
|
|
4
|
-
* @param {*} url
|
|
5
|
-
* @param {*} keyvals
|
|
6
|
-
* @returns
|
|
7
|
-
*/
|
|
8
|
-
export declare const setUrlQuery: (url: string, keyvals?: Record<string, any>) => string;
|
|
9
|
-
/**
|
|
10
|
-
* 给 url 添加网关
|
|
11
|
-
* @param url 原url,以 / 打头
|
|
12
|
-
* @param defGateway 默认网关 /petrel
|
|
13
|
-
* @returns
|
|
14
|
-
*/
|
|
15
|
-
export declare const toGatewayUrl: (url: string, defGateway?: string) => string;
|
|
1
|
+
export { getUrlQuery, setUrlQuery, dateFormat, toGatewayUrl, getResourceProps } from 'ls-pro-table/lib/utils';
|
|
16
2
|
/**
|
|
17
3
|
* 设置文档title
|
|
18
4
|
* @param {*} title
|
|
@@ -49,13 +35,6 @@ export declare const setCache: (key: string, data: any) => void;
|
|
|
49
35
|
* @returns 关键字对应的值
|
|
50
36
|
*/
|
|
51
37
|
export declare const getCache: any;
|
|
52
|
-
/**
|
|
53
|
-
* 简单日期格式化
|
|
54
|
-
* @param {*} dt 传入时间参数,若不传取当前时间
|
|
55
|
-
* @param {*} showTime 是否返回当前时间,默认返回时间
|
|
56
|
-
* @returns xxxx年-xx月-xx日 [xx时:xx分:xx秒]
|
|
57
|
-
*/
|
|
58
|
-
export declare const dateFormat: (dt: Date | undefined | null, showTime?: boolean) => string;
|
|
59
38
|
/** @name 显示错误 */
|
|
60
39
|
export declare const showError: (text: string) => void;
|
|
61
40
|
/** @name 显示警示 */
|