ls-pro-common 3.1.48 → 3.1.50
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.js +26 -19
- package/es/http/index.d.ts +34 -28
- package/es/http/index.js +153 -153
- 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.js +26 -19
- package/lib/http/index.d.ts +34 -28
- package/lib/http/index.js +153 -153
- 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/lib/http/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
2
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
4
4
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
5
5
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
6
6
|
import { extend } from 'umi-request';
|
|
@@ -359,116 +359,6 @@ export function httpDelete(url, data) {
|
|
|
359
359
|
var timeout = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 60000;
|
|
360
360
|
return ajax(url, data, 'delete', needGateWay, true, timeout);
|
|
361
361
|
}
|
|
362
|
-
/**
|
|
363
|
-
* 读取数据字典
|
|
364
|
-
*
|
|
365
|
-
* @param dictCode 字典编码
|
|
366
|
-
* @param showValue 是否显示值
|
|
367
|
-
* @param needGateWay 是否需要网关 默认为true
|
|
368
|
-
* @param timeout 超时时间,默认60000毫秒
|
|
369
|
-
* @param isGet 是否Get请求
|
|
370
|
-
* @param valueIsNumber 返回值是否为数字,默认false
|
|
371
|
-
* @returns Promise<Record<string,string>[]>
|
|
372
|
-
*/
|
|
373
|
-
export function getDict(dictCodes) {
|
|
374
|
-
var showValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
375
|
-
var needGateWay = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
376
|
-
var timeout = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 60000;
|
|
377
|
-
var isGet = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
378
|
-
var valueIsNumber = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
|
379
|
-
var api = '/lesoon-petrel-integration-api/sysDictDtl/listByProperties';
|
|
380
|
-
var param = {
|
|
381
|
-
dictCodes: (dictCodes || '').split(',')
|
|
382
|
-
};
|
|
383
|
-
return fetchOptions(api, param, 'dictValue', 'displayName', showValue, needGateWay, timeout, isGet, valueIsNumber);
|
|
384
|
-
}
|
|
385
|
-
/**
|
|
386
|
-
* 加载下拉框的数据源
|
|
387
|
-
*
|
|
388
|
-
* @param url 后端接口
|
|
389
|
-
* @param param 请求参数
|
|
390
|
-
* @param valueField 值字段
|
|
391
|
-
* @param labelField 显示字段
|
|
392
|
-
* @param showValue 显示值
|
|
393
|
-
* @param needGateWay 是否需要网关 默认为true
|
|
394
|
-
* @param timeout
|
|
395
|
-
* @param isGet = true 是否get请求,默认true
|
|
396
|
-
* @param valueIsNumber 返回值是否为数字,默认false
|
|
397
|
-
* @returns
|
|
398
|
-
*/
|
|
399
|
-
export function fetchOptions(_x3, _x4, _x5, _x6) {
|
|
400
|
-
return _fetchOptions.apply(this, arguments);
|
|
401
|
-
}
|
|
402
|
-
function _fetchOptions() {
|
|
403
|
-
_fetchOptions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(url, param, valueField, labelField) {
|
|
404
|
-
var showValue,
|
|
405
|
-
needGateWay,
|
|
406
|
-
timeout,
|
|
407
|
-
isGet,
|
|
408
|
-
valueIsNumber,
|
|
409
|
-
rows,
|
|
410
|
-
data,
|
|
411
|
-
_args4 = arguments;
|
|
412
|
-
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
413
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
414
|
-
case 0:
|
|
415
|
-
showValue = _args4.length > 4 && _args4[4] !== undefined ? _args4[4] : true;
|
|
416
|
-
needGateWay = _args4.length > 5 && _args4[5] !== undefined ? _args4[5] : true;
|
|
417
|
-
timeout = _args4.length > 6 && _args4[6] !== undefined ? _args4[6] : 60000;
|
|
418
|
-
isGet = _args4.length > 7 && _args4[7] !== undefined ? _args4[7] : true;
|
|
419
|
-
valueIsNumber = _args4.length > 8 && _args4[8] !== undefined ? _args4[8] : false;
|
|
420
|
-
if (!isGet) {
|
|
421
|
-
_context4.next = 14;
|
|
422
|
-
break;
|
|
423
|
-
}
|
|
424
|
-
_context4.next = 8;
|
|
425
|
-
return httpBatchGet(url, param, needGateWay, timeout);
|
|
426
|
-
case 8:
|
|
427
|
-
_context4.t0 = _context4.sent.rows;
|
|
428
|
-
if (_context4.t0) {
|
|
429
|
-
_context4.next = 11;
|
|
430
|
-
break;
|
|
431
|
-
}
|
|
432
|
-
_context4.t0 = [];
|
|
433
|
-
case 11:
|
|
434
|
-
rows = _context4.t0;
|
|
435
|
-
_context4.next = 20;
|
|
436
|
-
break;
|
|
437
|
-
case 14:
|
|
438
|
-
_context4.next = 16;
|
|
439
|
-
return httpBatchPost(url, param, needGateWay, timeout);
|
|
440
|
-
case 16:
|
|
441
|
-
_context4.t1 = _context4.sent.rows;
|
|
442
|
-
if (_context4.t1) {
|
|
443
|
-
_context4.next = 19;
|
|
444
|
-
break;
|
|
445
|
-
}
|
|
446
|
-
_context4.t1 = [];
|
|
447
|
-
case 19:
|
|
448
|
-
rows = _context4.t1;
|
|
449
|
-
case 20:
|
|
450
|
-
data = (rows || []).map(function (o) {
|
|
451
|
-
return _objectSpread(_objectSpread({}, o), {}, {
|
|
452
|
-
value: valueIsNumber && !isNaN(o[valueField]) ? Number(o[valueField]) : o[valueField],
|
|
453
|
-
text: o[labelField],
|
|
454
|
-
label: (showValue ? o[valueField] + '→' : '') + o[labelField]
|
|
455
|
-
});
|
|
456
|
-
});
|
|
457
|
-
return _context4.abrupt("return", data);
|
|
458
|
-
case 22:
|
|
459
|
-
case "end":
|
|
460
|
-
return _context4.stop();
|
|
461
|
-
}
|
|
462
|
-
}, _callee4);
|
|
463
|
-
}));
|
|
464
|
-
return _fetchOptions.apply(this, arguments);
|
|
465
|
-
}
|
|
466
|
-
export var getResourceRight = function getResourceRight(ids) {
|
|
467
|
-
var url = '/lesoon/lesoon-petrel-permission-api/sysUserRole/selectResourceIds';
|
|
468
|
-
return httpPost(url, {
|
|
469
|
-
resourceIds: ids
|
|
470
|
-
}, true, false);
|
|
471
|
-
};
|
|
472
362
|
/**
|
|
473
363
|
* 上传文件,因fetch不支持进度回调,使用XMLHttpRequest实现上传文件
|
|
474
364
|
*
|
|
@@ -725,7 +615,7 @@ var defaultPageSize = 2000;
|
|
|
725
615
|
* @param timeout
|
|
726
616
|
* @returns
|
|
727
617
|
*/
|
|
728
|
-
function httpBatchRequest(
|
|
618
|
+
function httpBatchRequest(_x3) {
|
|
729
619
|
return _httpBatchRequest.apply(this, arguments);
|
|
730
620
|
}
|
|
731
621
|
/**
|
|
@@ -740,7 +630,7 @@ function httpBatchRequest(_x7) {
|
|
|
740
630
|
* @returns
|
|
741
631
|
*/
|
|
742
632
|
function _httpBatchRequest() {
|
|
743
|
-
_httpBatchRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
633
|
+
_httpBatchRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(url) {
|
|
744
634
|
var params,
|
|
745
635
|
method,
|
|
746
636
|
needGateWay,
|
|
@@ -772,24 +662,24 @@ function _httpBatchRequest() {
|
|
|
772
662
|
batchPages,
|
|
773
663
|
batchRequests,
|
|
774
664
|
batchResponses,
|
|
775
|
-
|
|
776
|
-
return _regeneratorRuntime.wrap(function
|
|
777
|
-
while (1) switch (
|
|
665
|
+
_args4 = arguments;
|
|
666
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
667
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
778
668
|
case 0:
|
|
779
|
-
params =
|
|
780
|
-
method =
|
|
781
|
-
needGateWay =
|
|
782
|
-
timeout =
|
|
669
|
+
params = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
|
|
670
|
+
method = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : 'get';
|
|
671
|
+
needGateWay = _args4.length > 3 && _args4[3] !== undefined ? _args4[3] : true;
|
|
672
|
+
timeout = _args4.length > 4 && _args4[4] !== undefined ? _args4[4] : 60000;
|
|
783
673
|
// 从URL中获取pageSize和page参数
|
|
784
674
|
urlPageSize = getUrlQuery('pageSize', url) || getUrlQuery('page.size', url);
|
|
785
675
|
urlPageNum = getUrlQuery('page', url) || getUrlQuery('page.pn', url) || '1'; // 优先使用params中的分页参数,其次使用URL中的分页参数
|
|
786
676
|
pageSize = (params === null || params === void 0 ? void 0 : params.pageSize) || (params === null || params === void 0 ? void 0 : params['page.size']) || (urlPageSize ? parseInt(urlPageSize) : defaultPageSize);
|
|
787
677
|
pageNum = (params === null || params === void 0 ? void 0 : params.page) || (params === null || params === void 0 ? void 0 : params['page.pn']) || parseInt(urlPageNum); // 如果pageSize小于等于defaultPageSize,或不是取第一页数据时,直接使用普通请求
|
|
788
678
|
if (!(pageSize <= defaultPageSize || pageNum !== 1)) {
|
|
789
|
-
|
|
679
|
+
_context4.next = 10;
|
|
790
680
|
break;
|
|
791
681
|
}
|
|
792
|
-
return
|
|
682
|
+
return _context4.abrupt("return", ajax(url, params, method, needGateWay, true, timeout));
|
|
793
683
|
case 10:
|
|
794
684
|
// 是否为 2.0版本的api。
|
|
795
685
|
isV2 = url.includes('page.size') || (params === null || params === void 0 ? void 0 : params['page.size']) ? true : false; // 不同版本api的请求分页关键字处理,
|
|
@@ -807,23 +697,23 @@ function _httpBatchRequest() {
|
|
|
807
697
|
allRows = [];
|
|
808
698
|
total = 0;
|
|
809
699
|
currentPage = pageNum;
|
|
810
|
-
|
|
700
|
+
_context4.prev = 20;
|
|
811
701
|
// 第一次请求,获取总数
|
|
812
702
|
firstParams = _objectSpread(_objectSpread({}, params), {}, (_objectSpread2 = {}, _defineProperty(_objectSpread2, PAGE_SIZE, batchSize), _defineProperty(_objectSpread2, PAGE_NUM, currentPage), _objectSpread2)); // 如果是 post 请求,body 和 query 里都传入分页参数
|
|
813
703
|
api = cleanUrl;
|
|
814
704
|
if (method === 'post') {
|
|
815
705
|
api = setUrlQuery(cleanUrl, (_setUrlQuery3 = {}, _defineProperty(_setUrlQuery3, PAGE_SIZE, batchSize), _defineProperty(_setUrlQuery3, PAGE_NUM, currentPage), _setUrlQuery3));
|
|
816
706
|
}
|
|
817
|
-
|
|
707
|
+
_context4.next = 26;
|
|
818
708
|
return ajax(api, firstParams, method, needGateWay, true, timeout);
|
|
819
709
|
case 26:
|
|
820
|
-
firstResponse =
|
|
710
|
+
firstResponse = _context4.sent;
|
|
821
711
|
firstData = firstResponse; // 如果返回值没有 rows 或 total,直接返回普通请求
|
|
822
712
|
if (!(!('rows' in firstData) || !('total' in firstData))) {
|
|
823
|
-
|
|
713
|
+
_context4.next = 30;
|
|
824
714
|
break;
|
|
825
715
|
}
|
|
826
|
-
return
|
|
716
|
+
return _context4.abrupt("return", ajax(url, params, method, needGateWay, true, timeout));
|
|
827
717
|
case 30:
|
|
828
718
|
if (firstData.rows) {
|
|
829
719
|
allRows.push.apply(allRows, _toConsumableArray(firstData.rows));
|
|
@@ -831,16 +721,16 @@ function _httpBatchRequest() {
|
|
|
831
721
|
}
|
|
832
722
|
// 如果total小于等于defaultPageSize,不需要分批获取,直接返回
|
|
833
723
|
if (!(total <= defaultPageSize)) {
|
|
834
|
-
|
|
724
|
+
_context4.next = 33;
|
|
835
725
|
break;
|
|
836
726
|
}
|
|
837
|
-
return
|
|
727
|
+
return _context4.abrupt("return", firstResponse);
|
|
838
728
|
case 33:
|
|
839
729
|
// 计算实际需要获取的数据量(不超过用户传入的pageSize)
|
|
840
730
|
actualPageSize = Math.min(pageSize, total); // 计算需要请求的总页数(基于实际需要的数据量)
|
|
841
731
|
totalPages = Math.ceil(actualPageSize / batchSize); // 如果还有更多数据需要获取
|
|
842
732
|
if (!(totalPages > 1)) {
|
|
843
|
-
|
|
733
|
+
_context4.next = 50;
|
|
844
734
|
break;
|
|
845
735
|
}
|
|
846
736
|
// 分批并发请求,每次最多6个并发
|
|
@@ -853,30 +743,24 @@ function _httpBatchRequest() {
|
|
|
853
743
|
_i = 0;
|
|
854
744
|
case 40:
|
|
855
745
|
if (!(_i < remainingPages.length)) {
|
|
856
|
-
|
|
746
|
+
_context4.next = 50;
|
|
857
747
|
break;
|
|
858
748
|
}
|
|
859
749
|
batchPages = remainingPages.slice(_i, _i + maxConcurrent);
|
|
860
|
-
batchRequests = batchPages.map(function (
|
|
750
|
+
batchRequests = batchPages.map(function (page) {
|
|
861
751
|
var _objectSpread3;
|
|
862
|
-
|
|
863
|
-
var
|
|
864
|
-
// 如果是最后一页,计算实际需要的数据量
|
|
865
|
-
if (pageNum === totalPages) {
|
|
866
|
-
var remainingData = actualPageSize - (pageNum - 1) * batchSize;
|
|
867
|
-
currentPageSize = Math.max(0, remainingData);
|
|
868
|
-
}
|
|
869
|
-
var requestParams = _objectSpread(_objectSpread({}, params), {}, (_objectSpread3 = {}, _defineProperty(_objectSpread3, PAGE_SIZE, currentPageSize), _defineProperty(_objectSpread3, PAGE_NUM, pageNum), _objectSpread3));
|
|
752
|
+
var requestParams = _objectSpread(_objectSpread({}, params), {}, (_objectSpread3 = {}, _defineProperty(_objectSpread3, PAGE_SIZE, batchSize), _defineProperty(_objectSpread3, PAGE_NUM, page), _objectSpread3));
|
|
753
|
+
var requestApi = cleanUrl;
|
|
870
754
|
if (method === 'post') {
|
|
871
755
|
var _setUrlQuery4;
|
|
872
|
-
|
|
756
|
+
requestApi = setUrlQuery(cleanUrl, (_setUrlQuery4 = {}, _defineProperty(_setUrlQuery4, PAGE_SIZE, batchSize), _defineProperty(_setUrlQuery4, PAGE_NUM, page), _setUrlQuery4));
|
|
873
757
|
}
|
|
874
|
-
return ajax(
|
|
758
|
+
return ajax(requestApi, requestParams, method, needGateWay, true, timeout);
|
|
875
759
|
}); // 并发执行当前批次的请求
|
|
876
|
-
|
|
760
|
+
_context4.next = 45;
|
|
877
761
|
return Promise.all(batchRequests);
|
|
878
762
|
case 45:
|
|
879
|
-
batchResponses =
|
|
763
|
+
batchResponses = _context4.sent;
|
|
880
764
|
// 合并当前批次的响应数据
|
|
881
765
|
batchResponses.forEach(function (response) {
|
|
882
766
|
var data = response;
|
|
@@ -886,7 +770,7 @@ function _httpBatchRequest() {
|
|
|
886
770
|
});
|
|
887
771
|
case 47:
|
|
888
772
|
_i += maxConcurrent;
|
|
889
|
-
|
|
773
|
+
_context4.next = 40;
|
|
890
774
|
break;
|
|
891
775
|
case 50:
|
|
892
776
|
// 如果获取的数据超过了用户要求的pageSize,进行截取
|
|
@@ -894,19 +778,19 @@ function _httpBatchRequest() {
|
|
|
894
778
|
allRows.splice(actualPageSize);
|
|
895
779
|
}
|
|
896
780
|
// 返回合并后的数据,保持与原始响应格式一致
|
|
897
|
-
return
|
|
781
|
+
return _context4.abrupt("return", _objectSpread(_objectSpread({}, firstResponse), {}, {
|
|
898
782
|
rows: allRows,
|
|
899
783
|
total: total // 保持原始的total值
|
|
900
784
|
}));
|
|
901
785
|
case 54:
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
throw
|
|
786
|
+
_context4.prev = 54;
|
|
787
|
+
_context4.t0 = _context4["catch"](20);
|
|
788
|
+
throw _context4.t0;
|
|
905
789
|
case 57:
|
|
906
790
|
case "end":
|
|
907
|
-
return
|
|
791
|
+
return _context4.stop();
|
|
908
792
|
}
|
|
909
|
-
},
|
|
793
|
+
}, _callee4, null, [[20, 54]]);
|
|
910
794
|
}));
|
|
911
795
|
return _httpBatchRequest.apply(this, arguments);
|
|
912
796
|
}
|
|
@@ -929,7 +813,7 @@ export var httpBatchGet = /*#__PURE__*/function () {
|
|
|
929
813
|
}
|
|
930
814
|
}, _callee2);
|
|
931
815
|
}));
|
|
932
|
-
return function httpBatchGet(
|
|
816
|
+
return function httpBatchGet(_x4) {
|
|
933
817
|
return _ref2.apply(this, arguments);
|
|
934
818
|
};
|
|
935
819
|
}();
|
|
@@ -963,8 +847,124 @@ export var httpBatchPost = /*#__PURE__*/function () {
|
|
|
963
847
|
}
|
|
964
848
|
}, _callee3);
|
|
965
849
|
}));
|
|
966
|
-
return function httpBatchPost(
|
|
850
|
+
return function httpBatchPost(_x5) {
|
|
967
851
|
return _ref3.apply(this, arguments);
|
|
968
852
|
};
|
|
969
853
|
}();
|
|
854
|
+
/**
|
|
855
|
+
* 读取数据字典
|
|
856
|
+
*
|
|
857
|
+
* @param dictCode 字典编码
|
|
858
|
+
* @param showValue 是否显示值
|
|
859
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
860
|
+
* @param timeout 超时时间,默认60000毫秒
|
|
861
|
+
* @param isGet 是否Get请求
|
|
862
|
+
* @param valueIsNumber 返回值是否为数字,默认false
|
|
863
|
+
* @returns Promise<Record<string,string>[]>
|
|
864
|
+
*/
|
|
865
|
+
export function getDict(dictCodes) {
|
|
866
|
+
var showValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
867
|
+
var needGateWay = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
868
|
+
var timeout = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 60000;
|
|
869
|
+
var isGet = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
870
|
+
var valueIsNumber = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
|
871
|
+
var api = '/lesoon-petrel-integration-api/sysDictDtl/listByProperties';
|
|
872
|
+
var param = {
|
|
873
|
+
dictCodes: (dictCodes || '').split(',')
|
|
874
|
+
};
|
|
875
|
+
return fetchOptions(api, param, 'dictValue', 'displayName', showValue, needGateWay, timeout, isGet, valueIsNumber);
|
|
876
|
+
}
|
|
877
|
+
/**
|
|
878
|
+
* 加载下拉框的数据源
|
|
879
|
+
*
|
|
880
|
+
* @param url 后端接口
|
|
881
|
+
* @param param 请求参数
|
|
882
|
+
* @param valueField 值字段
|
|
883
|
+
* @param labelField 显示字段
|
|
884
|
+
* @param showValue 显示值
|
|
885
|
+
* @param needGateWay 是否需要网关 默认为true
|
|
886
|
+
* @param timeout
|
|
887
|
+
* @param isGet = true 是否get请求,默认true
|
|
888
|
+
* @param valueIsNumber 返回值是否为数字,默认false
|
|
889
|
+
* @returns
|
|
890
|
+
*/
|
|
891
|
+
export function fetchOptions(_x6, _x7, _x8, _x9) {
|
|
892
|
+
return _fetchOptions.apply(this, arguments);
|
|
893
|
+
}
|
|
894
|
+
/**
|
|
895
|
+
* 获取用户资源Id对应的权限值
|
|
896
|
+
*
|
|
897
|
+
* @param ids 资源id
|
|
898
|
+
* @returns
|
|
899
|
+
*/
|
|
900
|
+
function _fetchOptions() {
|
|
901
|
+
_fetchOptions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(url, param, valueField, labelField) {
|
|
902
|
+
var showValue,
|
|
903
|
+
needGateWay,
|
|
904
|
+
timeout,
|
|
905
|
+
isGet,
|
|
906
|
+
valueIsNumber,
|
|
907
|
+
rows,
|
|
908
|
+
data,
|
|
909
|
+
_args5 = arguments;
|
|
910
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
911
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
912
|
+
case 0:
|
|
913
|
+
showValue = _args5.length > 4 && _args5[4] !== undefined ? _args5[4] : true;
|
|
914
|
+
needGateWay = _args5.length > 5 && _args5[5] !== undefined ? _args5[5] : true;
|
|
915
|
+
timeout = _args5.length > 6 && _args5[6] !== undefined ? _args5[6] : 60000;
|
|
916
|
+
isGet = _args5.length > 7 && _args5[7] !== undefined ? _args5[7] : true;
|
|
917
|
+
valueIsNumber = _args5.length > 8 && _args5[8] !== undefined ? _args5[8] : false;
|
|
918
|
+
if (!isGet) {
|
|
919
|
+
_context5.next = 14;
|
|
920
|
+
break;
|
|
921
|
+
}
|
|
922
|
+
_context5.next = 8;
|
|
923
|
+
return httpBatchGet(url, param, needGateWay, timeout);
|
|
924
|
+
case 8:
|
|
925
|
+
_context5.t0 = _context5.sent.rows;
|
|
926
|
+
if (_context5.t0) {
|
|
927
|
+
_context5.next = 11;
|
|
928
|
+
break;
|
|
929
|
+
}
|
|
930
|
+
_context5.t0 = [];
|
|
931
|
+
case 11:
|
|
932
|
+
rows = _context5.t0;
|
|
933
|
+
_context5.next = 20;
|
|
934
|
+
break;
|
|
935
|
+
case 14:
|
|
936
|
+
_context5.next = 16;
|
|
937
|
+
return httpBatchPost(url, param, needGateWay, timeout);
|
|
938
|
+
case 16:
|
|
939
|
+
_context5.t1 = _context5.sent.rows;
|
|
940
|
+
if (_context5.t1) {
|
|
941
|
+
_context5.next = 19;
|
|
942
|
+
break;
|
|
943
|
+
}
|
|
944
|
+
_context5.t1 = [];
|
|
945
|
+
case 19:
|
|
946
|
+
rows = _context5.t1;
|
|
947
|
+
case 20:
|
|
948
|
+
data = (rows || []).map(function (o) {
|
|
949
|
+
return _objectSpread(_objectSpread({}, o), {}, {
|
|
950
|
+
value: valueIsNumber && !isNaN(o[valueField]) ? Number(o[valueField]) : o[valueField],
|
|
951
|
+
text: o[labelField],
|
|
952
|
+
label: (showValue ? o[valueField] + '→' : '') + o[labelField]
|
|
953
|
+
});
|
|
954
|
+
});
|
|
955
|
+
return _context5.abrupt("return", data);
|
|
956
|
+
case 22:
|
|
957
|
+
case "end":
|
|
958
|
+
return _context5.stop();
|
|
959
|
+
}
|
|
960
|
+
}, _callee5);
|
|
961
|
+
}));
|
|
962
|
+
return _fetchOptions.apply(this, arguments);
|
|
963
|
+
}
|
|
964
|
+
export var getResourceRight = function getResourceRight(ids) {
|
|
965
|
+
var url = '/lesoon/lesoon-petrel-permission-api/sysUserRole/selectResourceIds';
|
|
966
|
+
return httpPost(url, {
|
|
967
|
+
resourceIds: ids
|
|
968
|
+
}, true, false);
|
|
969
|
+
};
|
|
970
970
|
export default request;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 设置本地缓存
|
|
3
|
+
*
|
|
4
|
+
* @param {String} key 关键字
|
|
5
|
+
* @param {Object} data 值
|
|
6
|
+
* @param {Boolean} session 保存到 sessionStorage 还是 localStorage,默认 localStorage
|
|
7
|
+
*/
|
|
8
|
+
export declare const setCache: (key: string, data: any, session?: boolean) => void;
|
|
9
|
+
/**
|
|
10
|
+
* 读取本地缓存
|
|
11
|
+
*
|
|
12
|
+
* @param {String} key 关键字
|
|
13
|
+
* @param {boolean} session 从 sessionStorage 取数还是从 localStorage 中取数 默认从 localStorage
|
|
14
|
+
* @returns 关键字对应的值
|
|
15
|
+
*/
|
|
16
|
+
export declare const getCache: any;
|
|
17
|
+
/**
|
|
18
|
+
* 读取本地缓存,优先从sessionStorage 取,取不到时再从 localStorage取
|
|
19
|
+
*
|
|
20
|
+
* @param key
|
|
21
|
+
* @returns
|
|
22
|
+
*/
|
|
23
|
+
export declare const getCacheSessionFirst: (key: string) => any;
|
|
24
|
+
/**
|
|
25
|
+
* @param key 关键字,不传清除所有
|
|
26
|
+
* @param session 是否session storage , 默认 localStorage
|
|
27
|
+
*/
|
|
28
|
+
export declare const clearCache: (key?: string | undefined, session?: boolean) => void;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
2
|
+
/**
|
|
3
|
+
* 设置本地缓存
|
|
4
|
+
*
|
|
5
|
+
* @param {String} key 关键字
|
|
6
|
+
* @param {Object} data 值
|
|
7
|
+
* @param {Boolean} session 保存到 sessionStorage 还是 localStorage,默认 localStorage
|
|
8
|
+
*/
|
|
9
|
+
export var setCache = function setCache(key, data) {
|
|
10
|
+
var session = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
11
|
+
if (_typeof(data) === 'object') {
|
|
12
|
+
data = JSON.stringify(data);
|
|
13
|
+
}
|
|
14
|
+
if (session) {
|
|
15
|
+
sessionStorage.setItem(key, data);
|
|
16
|
+
} else {
|
|
17
|
+
localStorage.setItem(key, data);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* 读取本地缓存
|
|
22
|
+
*
|
|
23
|
+
* @param {String} key 关键字
|
|
24
|
+
* @param {boolean} session 从 sessionStorage 取数还是从 localStorage 中取数 默认从 localStorage
|
|
25
|
+
* @returns 关键字对应的值
|
|
26
|
+
*/
|
|
27
|
+
export var getCache = function getCache(key) {
|
|
28
|
+
var session = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
29
|
+
var data = session ? sessionStorage.getItem(key) : localStorage.getItem(key);
|
|
30
|
+
if (data && (data.startsWith('{') || data.startsWith('['))) {
|
|
31
|
+
data = JSON.parse(data);
|
|
32
|
+
}
|
|
33
|
+
return data;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* 读取本地缓存,优先从sessionStorage 取,取不到时再从 localStorage取
|
|
37
|
+
*
|
|
38
|
+
* @param key
|
|
39
|
+
* @returns
|
|
40
|
+
*/
|
|
41
|
+
export var getCacheSessionFirst = function getCacheSessionFirst(key) {
|
|
42
|
+
return getCache(key, true) || getCache(key);
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* @param key 关键字,不传清除所有
|
|
46
|
+
* @param session 是否session storage , 默认 localStorage
|
|
47
|
+
*/
|
|
48
|
+
export var clearCache = function clearCache(key) {
|
|
49
|
+
var session = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
50
|
+
if (key) {
|
|
51
|
+
if (session) {
|
|
52
|
+
sessionStorage.removeItem(key);
|
|
53
|
+
} else {
|
|
54
|
+
localStorage.removeItem(key);
|
|
55
|
+
}
|
|
56
|
+
} else {
|
|
57
|
+
if (session) {
|
|
58
|
+
sessionStorage.clear();
|
|
59
|
+
} else {
|
|
60
|
+
localStorage.clear();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** @name 状态列表 */
|
|
2
|
+
export var statusList = [{
|
|
3
|
+
value: 1,
|
|
4
|
+
text: '启用',
|
|
5
|
+
label: '1→启用'
|
|
6
|
+
}, {
|
|
7
|
+
value: 0,
|
|
8
|
+
text: '禁用',
|
|
9
|
+
label: '0→禁用'
|
|
10
|
+
}];
|
|
11
|
+
/** @name 是否列表 */
|
|
12
|
+
export var yesnoList = [{
|
|
13
|
+
value: 1,
|
|
14
|
+
text: '是',
|
|
15
|
+
label: '1→是'
|
|
16
|
+
}, {
|
|
17
|
+
value: 0,
|
|
18
|
+
text: '否',
|
|
19
|
+
label: '0→否'
|
|
20
|
+
}];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 获取Cookie
|
|
3
|
+
*
|
|
4
|
+
* @param {String} name Cookie名
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
export declare const getCookie: (name: string) => string | null;
|
|
8
|
+
/**
|
|
9
|
+
* 设置Cookie
|
|
10
|
+
*
|
|
11
|
+
* @param {any} key Cookie名称
|
|
12
|
+
* @param {any} value Cookie 值
|
|
13
|
+
* @param {Number} day 有效天数 默认1天,
|
|
14
|
+
*/
|
|
15
|
+
export declare const setCookie: (key: string, value: string | number, day?: number, sameSite?: boolean) => void;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 获取Cookie
|
|
3
|
+
*
|
|
4
|
+
* @param {String} name Cookie名
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
export var getCookie = function getCookie(name) {
|
|
8
|
+
var arr;
|
|
9
|
+
var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)');
|
|
10
|
+
if (arr = document.cookie.match(reg)) return arr[2];else return null;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* 设置Cookie
|
|
14
|
+
*
|
|
15
|
+
* @param {any} key Cookie名称
|
|
16
|
+
* @param {any} value Cookie 值
|
|
17
|
+
* @param {Number} day 有效天数 默认1天,
|
|
18
|
+
*/
|
|
19
|
+
export var setCookie = function setCookie(key, value) {
|
|
20
|
+
var day = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
21
|
+
var sameSite = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
22
|
+
if (day !== 0) {
|
|
23
|
+
var d = new Date(Date.now() + day * 24 * 60 * 60 * 1000);
|
|
24
|
+
if (sameSite) {
|
|
25
|
+
document.cookie = "".concat(key, "=").concat(value, ";expires=").concat(d.toUTCString(), ";path=/;sameSite=None;secure=true");
|
|
26
|
+
} else {
|
|
27
|
+
document.cookie = "".concat(key, "=").concat(value, ";expires=").concat(d.toUTCString(), ";path=/");
|
|
28
|
+
}
|
|
29
|
+
} else {
|
|
30
|
+
if (sameSite) {
|
|
31
|
+
document.cookie = key + '=' + value + ';path=/;sameSite=None;secure=true';
|
|
32
|
+
} else {
|
|
33
|
+
document.cookie = key + '=' + value + ';path=/';
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 绑定事件
|
|
3
|
+
*
|
|
4
|
+
* @param eventName 事件名
|
|
5
|
+
* @param fn 调用函数
|
|
6
|
+
* @param el 源对象,默认为window
|
|
7
|
+
*/
|
|
8
|
+
export declare const on: (eventName: string, fn: Function, el: any | undefined) => void;
|
|
9
|
+
/**
|
|
10
|
+
* 解绑事件
|
|
11
|
+
*
|
|
12
|
+
* @param eventName 事件名
|
|
13
|
+
* @param fn 调用函数
|
|
14
|
+
* @param el 源对象,默认为window
|
|
15
|
+
*/
|
|
16
|
+
export declare const off: (eventName: string, fn: Function, el: any | undefined) => void;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 绑定事件
|
|
3
|
+
*
|
|
4
|
+
* @param eventName 事件名
|
|
5
|
+
* @param fn 调用函数
|
|
6
|
+
* @param el 源对象,默认为window
|
|
7
|
+
*/
|
|
8
|
+
export var on = function on(eventName, fn, el) {
|
|
9
|
+
if (!el) {
|
|
10
|
+
el = window;
|
|
11
|
+
}
|
|
12
|
+
el.addEventListener(eventName, fn);
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* 解绑事件
|
|
16
|
+
*
|
|
17
|
+
* @param eventName 事件名
|
|
18
|
+
* @param fn 调用函数
|
|
19
|
+
* @param el 源对象,默认为window
|
|
20
|
+
*/
|
|
21
|
+
export var off = function off(eventName, fn, el) {
|
|
22
|
+
if (!el) {
|
|
23
|
+
el = window;
|
|
24
|
+
}
|
|
25
|
+
el.removeEventListener(eventName, fn);
|
|
26
|
+
};
|