ls-pro-common 3.1.28 → 3.1.30
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/index.d.ts +21 -0
- package/es/components/index.js +21 -0
- package/es/hooks/index.d.ts +13 -0
- package/es/hooks/index.js +13 -0
- package/es/http/index.js +33 -22
- package/es/http/mdmRequest.js +2 -2
- package/es/index.d.ts +21 -43
- package/es/index.js +16 -37
- package/es/utils/index.d.ts +4 -3
- package/es/utils/index.js +6 -1
- package/lib/components/index.d.ts +21 -0
- package/lib/components/index.js +21 -0
- package/lib/hooks/index.d.ts +13 -0
- package/lib/hooks/index.js +13 -0
- package/lib/http/index.js +33 -22
- package/lib/http/mdmRequest.js +2 -2
- package/lib/index.d.ts +21 -43
- package/lib/index.js +16 -37
- package/lib/utils/index.d.ts +4 -3
- package/lib/utils/index.js +6 -1
- package/package.json +1 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export { default as DtlLayout } from './DtlLayout';
|
|
2
|
+
export { default as InputTable } from './InputTable';
|
|
3
|
+
export { default as Page404 } from './404';
|
|
4
|
+
export { default as Loading } from './Loading';
|
|
5
|
+
export { default as IconSelector } from './IconSelector';
|
|
6
|
+
export { default as ImageSelector } from './ImageSelector';
|
|
7
|
+
export { default as InputMultiLine } from './InputMultiLine';
|
|
8
|
+
export { default as AreaCascader } from './AreaCascader';
|
|
9
|
+
export { default as AreaCascaderPanel } from './AreaCascaderPanel';
|
|
10
|
+
export { default as DescritionCard } from './DescritionCard';
|
|
11
|
+
export { default as Permission } from './Permission';
|
|
12
|
+
export { default as GroupTip } from './GroupTip';
|
|
13
|
+
export { default as IconBack } from './IconBack';
|
|
14
|
+
export { default as IconText } from './IconText';
|
|
15
|
+
export { default as IconQuestion } from './IconQuestion';
|
|
16
|
+
export { default as IconBell } from './IconBell';
|
|
17
|
+
export { default as IconSearch } from './IconSearch';
|
|
18
|
+
export { default as TagCheck } from './TagCheck';
|
|
19
|
+
export { default as ViewOffice } from './ViewOffice';
|
|
20
|
+
export { default as ProButton } from './ProButton';
|
|
21
|
+
export { default as RecordLog } from './RecordLog';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export { default as DtlLayout } from './DtlLayout';
|
|
2
|
+
export { default as InputTable } from './InputTable';
|
|
3
|
+
export { default as Page404 } from './404';
|
|
4
|
+
export { default as Loading } from './Loading';
|
|
5
|
+
export { default as IconSelector } from './IconSelector';
|
|
6
|
+
export { default as ImageSelector } from './ImageSelector';
|
|
7
|
+
export { default as InputMultiLine } from './InputMultiLine';
|
|
8
|
+
export { default as AreaCascader } from './AreaCascader';
|
|
9
|
+
export { default as AreaCascaderPanel } from './AreaCascaderPanel';
|
|
10
|
+
export { default as DescritionCard } from './DescritionCard';
|
|
11
|
+
export { default as Permission } from './Permission';
|
|
12
|
+
export { default as GroupTip } from './GroupTip';
|
|
13
|
+
export { default as IconBack } from './IconBack';
|
|
14
|
+
export { default as IconText } from './IconText';
|
|
15
|
+
export { default as IconQuestion } from './IconQuestion';
|
|
16
|
+
export { default as IconBell } from './IconBell';
|
|
17
|
+
export { default as IconSearch } from './IconSearch';
|
|
18
|
+
export { default as TagCheck } from './TagCheck';
|
|
19
|
+
export { default as ViewOffice } from './ViewOffice';
|
|
20
|
+
export { default as ProButton } from './ProButton';
|
|
21
|
+
export { default as RecordLog } from './RecordLog';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { default as useSingle } from './useSingle';
|
|
2
|
+
export { default as useDtl } from './useDtl';
|
|
3
|
+
export { default as usePermission } from './usePermission';
|
|
4
|
+
export { default as useGetState } from './useGetState';
|
|
5
|
+
export { default as useFilterLocal } from './useFilterBack';
|
|
6
|
+
export { default as useBaseDict } from './useBaseDict';
|
|
7
|
+
export { default as useSelectOptions } from './useSelectOptions';
|
|
8
|
+
export { default as showConfirmFun } from './useShowConfirm';
|
|
9
|
+
export { default as useQueue } from './useQueue';
|
|
10
|
+
export { default as useSyncState } from './useSyncState';
|
|
11
|
+
export { useApiLoader } from './useApiLoad';
|
|
12
|
+
export { useDict } from './useDict';
|
|
13
|
+
export { default as useMdm } from './useMdm';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { default as useSingle } from './useSingle';
|
|
2
|
+
export { default as useDtl } from './useDtl';
|
|
3
|
+
export { default as usePermission } from './usePermission';
|
|
4
|
+
export { default as useGetState } from './useGetState';
|
|
5
|
+
export { default as useFilterLocal } from './useFilterBack';
|
|
6
|
+
export { default as useBaseDict } from './useBaseDict';
|
|
7
|
+
export { default as useSelectOptions } from './useSelectOptions';
|
|
8
|
+
export { default as showConfirmFun } from './useShowConfirm';
|
|
9
|
+
export { default as useQueue } from './useQueue';
|
|
10
|
+
export { default as useSyncState } from './useSyncState';
|
|
11
|
+
export { useApiLoader } from './useApiLoad';
|
|
12
|
+
export { useDict } from './useDict';
|
|
13
|
+
export { default as useMdm } from './useMdm';
|
package/es/http/index.js
CHANGED
|
@@ -525,6 +525,8 @@ function _httpBatchRequest() {
|
|
|
525
525
|
currentPage,
|
|
526
526
|
_objectSpread2,
|
|
527
527
|
firstParams,
|
|
528
|
+
api,
|
|
529
|
+
_setUrlQuery3,
|
|
528
530
|
firstResponse,
|
|
529
531
|
firstData,
|
|
530
532
|
actualPageSize,
|
|
@@ -555,7 +557,8 @@ function _httpBatchRequest() {
|
|
|
555
557
|
}
|
|
556
558
|
return _context5.abrupt("return", ajax(url, params, method, needGateWay, true, timeout));
|
|
557
559
|
case 10:
|
|
558
|
-
|
|
560
|
+
// 是否为 2.0版本的api。
|
|
561
|
+
isV2 = url.includes('page.size') || (params === null || params === void 0 ? void 0 : params['page.size']) ? true : false; // 不同版本api的请求分页关键字处理,
|
|
559
562
|
PAGE_SIZE = isV2 ? 'page.size' : 'pageSize';
|
|
560
563
|
PAGE_NUM = isV2 ? 'page.pn' : 'page'; // 分批获取数据时,需要从URL中移除原有的pageSize和page参数
|
|
561
564
|
cleanUrl = url;
|
|
@@ -572,34 +575,38 @@ function _httpBatchRequest() {
|
|
|
572
575
|
currentPage = pageNum;
|
|
573
576
|
_context5.prev = 20;
|
|
574
577
|
// 第一次请求,获取总数
|
|
575
|
-
firstParams = _objectSpread(_objectSpread({}, params), {}, (_objectSpread2 = {}, _defineProperty(_objectSpread2, PAGE_SIZE, batchSize), _defineProperty(_objectSpread2, PAGE_NUM, currentPage), _objectSpread2));
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
578
|
+
firstParams = _objectSpread(_objectSpread({}, params), {}, (_objectSpread2 = {}, _defineProperty(_objectSpread2, PAGE_SIZE, batchSize), _defineProperty(_objectSpread2, PAGE_NUM, currentPage), _objectSpread2)); // 如果是 post 请求,body 和 query 里都传入分页参数
|
|
579
|
+
api = cleanUrl;
|
|
580
|
+
if (method === 'post') {
|
|
581
|
+
api = setUrlQuery(cleanUrl, (_setUrlQuery3 = {}, _defineProperty(_setUrlQuery3, PAGE_SIZE, batchSize), _defineProperty(_setUrlQuery3, PAGE_NUM, currentPage), _setUrlQuery3));
|
|
582
|
+
}
|
|
583
|
+
_context5.next = 26;
|
|
584
|
+
return ajax(api, firstParams, method, needGateWay, true, timeout);
|
|
585
|
+
case 26:
|
|
579
586
|
firstResponse = _context5.sent;
|
|
580
587
|
firstData = firstResponse; // 如果返回值没有 rows 或 total,直接返回普通请求
|
|
581
588
|
if (!(!('rows' in firstData) || !('total' in firstData))) {
|
|
582
|
-
_context5.next =
|
|
589
|
+
_context5.next = 30;
|
|
583
590
|
break;
|
|
584
591
|
}
|
|
585
592
|
return _context5.abrupt("return", ajax(url, params, method, needGateWay, true, timeout));
|
|
586
|
-
case
|
|
593
|
+
case 30:
|
|
587
594
|
if (firstData.rows) {
|
|
588
595
|
allRows.push.apply(allRows, _toConsumableArray(firstData.rows));
|
|
589
596
|
total = firstData.total || 0;
|
|
590
597
|
}
|
|
591
598
|
// 如果total小于等于defaultPageSize,不需要分批获取,直接返回
|
|
592
599
|
if (!(total <= defaultPageSize)) {
|
|
593
|
-
_context5.next =
|
|
600
|
+
_context5.next = 33;
|
|
594
601
|
break;
|
|
595
602
|
}
|
|
596
603
|
return _context5.abrupt("return", firstResponse);
|
|
597
|
-
case
|
|
604
|
+
case 33:
|
|
598
605
|
// 计算实际需要获取的数据量(不超过用户传入的pageSize)
|
|
599
606
|
actualPageSize = Math.min(pageSize, total); // 计算需要请求的总页数(基于实际需要的数据量)
|
|
600
607
|
totalPages = Math.ceil(actualPageSize / batchSize); // 如果还有更多数据需要获取
|
|
601
608
|
if (!(totalPages > 1)) {
|
|
602
|
-
_context5.next =
|
|
609
|
+
_context5.next = 50;
|
|
603
610
|
break;
|
|
604
611
|
}
|
|
605
612
|
// 分批并发请求,每次最多6个并发
|
|
@@ -610,9 +617,9 @@ function _httpBatchRequest() {
|
|
|
610
617
|
}
|
|
611
618
|
// 分批处理请求
|
|
612
619
|
_i = 0;
|
|
613
|
-
case
|
|
620
|
+
case 40:
|
|
614
621
|
if (!(_i < remainingPages.length)) {
|
|
615
|
-
_context5.next =
|
|
622
|
+
_context5.next = 50;
|
|
616
623
|
break;
|
|
617
624
|
}
|
|
618
625
|
batchPages = remainingPages.slice(_i, _i + maxConcurrent);
|
|
@@ -626,11 +633,15 @@ function _httpBatchRequest() {
|
|
|
626
633
|
currentPageSize = Math.max(0, remainingData);
|
|
627
634
|
}
|
|
628
635
|
var requestParams = _objectSpread(_objectSpread({}, params), {}, (_objectSpread3 = {}, _defineProperty(_objectSpread3, PAGE_SIZE, currentPageSize), _defineProperty(_objectSpread3, PAGE_NUM, pageNum), _objectSpread3));
|
|
629
|
-
|
|
636
|
+
if (method === 'post') {
|
|
637
|
+
var _setUrlQuery4;
|
|
638
|
+
api = setUrlQuery(cleanUrl, (_setUrlQuery4 = {}, _defineProperty(_setUrlQuery4, PAGE_SIZE, currentPageSize), _defineProperty(_setUrlQuery4, PAGE_NUM, pageNum), _setUrlQuery4));
|
|
639
|
+
}
|
|
640
|
+
return ajax(api, requestParams, method, needGateWay, true, timeout);
|
|
630
641
|
}); // 并发执行当前批次的请求
|
|
631
|
-
_context5.next =
|
|
642
|
+
_context5.next = 45;
|
|
632
643
|
return Promise.all(batchRequests);
|
|
633
|
-
case
|
|
644
|
+
case 45:
|
|
634
645
|
batchResponses = _context5.sent;
|
|
635
646
|
// 合并当前批次的响应数据
|
|
636
647
|
batchResponses.forEach(function (response) {
|
|
@@ -639,11 +650,11 @@ function _httpBatchRequest() {
|
|
|
639
650
|
allRows.push.apply(allRows, _toConsumableArray(data.rows));
|
|
640
651
|
}
|
|
641
652
|
});
|
|
642
|
-
case
|
|
653
|
+
case 47:
|
|
643
654
|
_i += maxConcurrent;
|
|
644
|
-
_context5.next =
|
|
655
|
+
_context5.next = 40;
|
|
645
656
|
break;
|
|
646
|
-
case
|
|
657
|
+
case 50:
|
|
647
658
|
// 如果获取的数据超过了用户要求的pageSize,进行截取
|
|
648
659
|
if (allRows.length > actualPageSize) {
|
|
649
660
|
allRows.splice(actualPageSize);
|
|
@@ -653,15 +664,15 @@ function _httpBatchRequest() {
|
|
|
653
664
|
rows: allRows,
|
|
654
665
|
total: total // 保持原始的total值
|
|
655
666
|
}));
|
|
656
|
-
case
|
|
657
|
-
_context5.prev =
|
|
667
|
+
case 54:
|
|
668
|
+
_context5.prev = 54;
|
|
658
669
|
_context5.t0 = _context5["catch"](20);
|
|
659
670
|
throw _context5.t0;
|
|
660
|
-
case
|
|
671
|
+
case 57:
|
|
661
672
|
case "end":
|
|
662
673
|
return _context5.stop();
|
|
663
674
|
}
|
|
664
|
-
}, _callee5, null, [[20,
|
|
675
|
+
}, _callee5, null, [[20, 54]]);
|
|
665
676
|
}));
|
|
666
677
|
return _httpBatchRequest.apply(this, arguments);
|
|
667
678
|
}
|
package/es/http/mdmRequest.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
2
2
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
-
import {
|
|
3
|
+
import { httpBatchGet } from '.';
|
|
4
4
|
import { getCache, setCache } from '../utils';
|
|
5
5
|
function setPageSize() {
|
|
6
6
|
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
@@ -37,7 +37,7 @@ function _httpGetWithCache() {
|
|
|
37
37
|
return _context2.abrupt("return", cacheData);
|
|
38
38
|
case 5:
|
|
39
39
|
_context2.next = 7;
|
|
40
|
-
return
|
|
40
|
+
return httpBatchGet(url, params);
|
|
41
41
|
case 7:
|
|
42
42
|
result = _context2.sent;
|
|
43
43
|
if ((result === null || result === void 0 ? void 0 : (_result$flag = result.flag) === null || _result$flag === void 0 ? void 0 : _result$flag.retCode) === '0') {
|
package/es/index.d.ts
CHANGED
|
@@ -1,46 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
import IconQuestion from './components/IconQuestion';
|
|
16
|
-
import IconBell from './components/IconBell';
|
|
17
|
-
import IconSearch from './components/IconSearch';
|
|
18
|
-
import TagCheck from './components/TagCheck';
|
|
19
|
-
import ViewOffice from './components/ViewOffice';
|
|
20
|
-
import ProButton from './components/ProButton';
|
|
21
|
-
import RecordLog from './components/RecordLog';
|
|
22
|
-
import request, { httpGet, httpPut, httpPost, httpDelete, getDict, fetchOptions, httpBatchGet, httpBatchPost, getResourceRight } from './http';
|
|
23
|
-
import BaseService from './service/BaseService';
|
|
1
|
+
/** 组件 */
|
|
2
|
+
export * from './components';
|
|
3
|
+
/** Hooks */
|
|
4
|
+
export * from './hooks';
|
|
5
|
+
/** Http请求 */
|
|
6
|
+
export { default as request } from './http';
|
|
7
|
+
export * from './http';
|
|
8
|
+
/** 基础服务 */
|
|
9
|
+
export { default as BaseService } from './service/BaseService';
|
|
10
|
+
/** 导出进度及完成后自动下载 */
|
|
11
|
+
export { default as exportProcess } from './utils/exportProcess';
|
|
12
|
+
/** Utils 方法,放在第一层级,方便调用 */
|
|
13
|
+
export * from './utils';
|
|
14
|
+
/** 主数据请求 */
|
|
24
15
|
import * as mdmRequest from './http/mdmRequest';
|
|
16
|
+
/** Utils 对象 */
|
|
25
17
|
import * as utils from './utils';
|
|
26
|
-
|
|
27
|
-
/** Hooks */
|
|
28
|
-
import useSingle from './hooks/useSingle';
|
|
29
|
-
import useDtl from './hooks/useDtl';
|
|
30
|
-
import usePermission from './hooks/usePermission';
|
|
31
|
-
import useGetState from './hooks/useGetState';
|
|
32
|
-
import useFilterLocal from './hooks/useFilterBack';
|
|
33
|
-
import useBaseDict from './hooks/useBaseDict';
|
|
34
|
-
import useSelectOptions from './hooks/useSelectOptions';
|
|
35
|
-
import showConfirmFun from './hooks/useShowConfirm';
|
|
36
|
-
import useQueue from './hooks/useQueue';
|
|
37
|
-
import { useDict } from './hooks/useDict';
|
|
38
|
-
import useMdm from './hooks/useMdm';
|
|
18
|
+
export { utils, mdmRequest };
|
|
39
19
|
/** Type */
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
export type { ApiResponse, TableToolbar, BaseApiType, MethodType, DtlLyaoutProps, DescritionCardProps, PermissionProps, TDict, };
|
|
46
|
-
export { DtlLayout, InputTable, Page404, Loading, IconSelector, ImageSelector, InputMultiLine, AreaCascader, AreaCascaderPanel, DescritionCard, Permission, GroupTip, ViewOffice, IconBack, IconText, IconBell, IconQuestion, IconSearch, TagCheck, BaseService, request, httpDelete, httpGet, httpPost, httpPut, getDict, fetchOptions, httpBatchGet, httpBatchPost, getResourceRight, utils, useSingle, useDtl, usePermission, useGetState, useFilterLocal, useQueue, useBaseDict, useSelectOptions, useDict, useMdm, showConfirmFun, exportProcess, mdmRequest, ProButton, RecordLog, };
|
|
20
|
+
export type { ApiResponse, TableToolbar, BaseApiType, MethodType } from './typing';
|
|
21
|
+
export type { DtlLyaoutProps } from './components/DtlLayout';
|
|
22
|
+
export type { DescritionCardProps } from './components/DescritionCard';
|
|
23
|
+
export type { PermissionProps } from './components/Permission';
|
|
24
|
+
export type { TDict } from './hooks/useDict';
|
package/es/index.js
CHANGED
|
@@ -1,39 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
import IconQuestion from './components/IconQuestion';
|
|
16
|
-
import IconBell from './components/IconBell';
|
|
17
|
-
import IconSearch from './components/IconSearch';
|
|
18
|
-
import TagCheck from './components/TagCheck';
|
|
19
|
-
import ViewOffice from './components/ViewOffice';
|
|
20
|
-
import ProButton from './components/ProButton';
|
|
21
|
-
import RecordLog from './components/RecordLog';
|
|
22
|
-
import request, { httpGet, httpPut, httpPost, httpDelete, getDict, fetchOptions, httpBatchGet, httpBatchPost, getResourceRight } from './http';
|
|
23
|
-
import BaseService from './service/BaseService';
|
|
1
|
+
/** 组件 */
|
|
2
|
+
export * from './components';
|
|
3
|
+
/** Hooks */
|
|
4
|
+
export * from './hooks';
|
|
5
|
+
/** Http请求 */
|
|
6
|
+
export { default as request } from './http';
|
|
7
|
+
export * from './http';
|
|
8
|
+
/** 基础服务 */
|
|
9
|
+
export { default as BaseService } from './service/BaseService';
|
|
10
|
+
/** 导出进度及完成后自动下载 */
|
|
11
|
+
export { default as exportProcess } from './utils/exportProcess';
|
|
12
|
+
/** Utils 方法,放在第一层级,方便调用 */
|
|
13
|
+
export * from './utils';
|
|
14
|
+
/** 主数据请求 */
|
|
24
15
|
import * as mdmRequest from './http/mdmRequest';
|
|
16
|
+
/** Utils 对象 */
|
|
25
17
|
import * as utils from './utils';
|
|
26
|
-
|
|
27
|
-
/** Hooks */
|
|
28
|
-
import useSingle from './hooks/useSingle';
|
|
29
|
-
import useDtl from './hooks/useDtl';
|
|
30
|
-
import usePermission from './hooks/usePermission';
|
|
31
|
-
import useGetState from './hooks/useGetState';
|
|
32
|
-
import useFilterLocal from './hooks/useFilterBack';
|
|
33
|
-
import useBaseDict from './hooks/useBaseDict';
|
|
34
|
-
import useSelectOptions from './hooks/useSelectOptions';
|
|
35
|
-
import showConfirmFun from './hooks/useShowConfirm';
|
|
36
|
-
import useQueue from './hooks/useQueue';
|
|
37
|
-
import { useDict } from './hooks/useDict';
|
|
38
|
-
import useMdm from './hooks/useMdm';
|
|
39
|
-
export { DtlLayout, InputTable, Page404, Loading, IconSelector, ImageSelector, InputMultiLine, AreaCascader, AreaCascaderPanel, DescritionCard, Permission, GroupTip, ViewOffice, IconBack, IconText, IconBell, IconQuestion, IconSearch, TagCheck, BaseService, request, httpDelete, httpGet, httpPost, httpPut, getDict, fetchOptions, httpBatchGet, httpBatchPost, getResourceRight, utils, useSingle, useDtl, usePermission, useGetState, useFilterLocal, useQueue, useBaseDict, useSelectOptions, useDict, useMdm, showConfirmFun, exportProcess, mdmRequest, ProButton, RecordLog };
|
|
18
|
+
export { utils, mdmRequest };
|
package/es/utils/index.d.ts
CHANGED
|
@@ -75,14 +75,14 @@ export declare const setCache: (key: string, data: any, session?: boolean) => vo
|
|
|
75
75
|
* @param {boolean} session 从 sessionStorage 取数还是从 localStorage 中取数 默认从 localStorage
|
|
76
76
|
* @returns 关键字对应的值
|
|
77
77
|
*/
|
|
78
|
-
export declare const getCache:
|
|
78
|
+
export declare const getCache: any;
|
|
79
79
|
/**
|
|
80
80
|
* 读取本地缓存,优先从sessionStorage 取,取不到时再从 localStorage取
|
|
81
81
|
*
|
|
82
82
|
* @param key
|
|
83
83
|
* @returns
|
|
84
84
|
*/
|
|
85
|
-
export declare const getCacheSessionFirst: (key: string) =>
|
|
85
|
+
export declare const getCacheSessionFirst: (key: string) => any;
|
|
86
86
|
/**
|
|
87
87
|
* @param key 关键字,不传清除所有
|
|
88
88
|
* @param session 是否session storage , 默认 localStorage
|
|
@@ -226,5 +226,6 @@ export declare const urlDownloadDomain: (url: string) => string;
|
|
|
226
226
|
*
|
|
227
227
|
* @param url 文件地址
|
|
228
228
|
* @param fileName 文件名
|
|
229
|
+
* @param isBlank 是否新开窗口下载,默认新开窗口,不影响原页面展示
|
|
229
230
|
*/
|
|
230
|
-
export declare const downloadFile: (url: string, fileName?: string | undefined) => void;
|
|
231
|
+
export declare const downloadFile: (url: string, fileName?: string | undefined, isBlank?: boolean) => void;
|
package/es/utils/index.js
CHANGED
|
@@ -493,12 +493,17 @@ export var urlDownloadDomain = function urlDownloadDomain(url) {
|
|
|
493
493
|
*
|
|
494
494
|
* @param url 文件地址
|
|
495
495
|
* @param fileName 文件名
|
|
496
|
+
* @param isBlank 是否新开窗口下载,默认新开窗口,不影响原页面展示
|
|
496
497
|
*/
|
|
497
498
|
export var downloadFile = function downloadFile(url, fileName) {
|
|
499
|
+
var isBlank = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
498
500
|
var a = document.createElement('a');
|
|
499
501
|
url = urlDownloadDomain(url);
|
|
500
502
|
a.href = url;
|
|
501
|
-
|
|
503
|
+
if (isBlank) {
|
|
504
|
+
a.target = '_blank'; // 新开屏有闪烁,但不会导致下载文件不存在或无法访问时原始页面出错。
|
|
505
|
+
}
|
|
506
|
+
|
|
502
507
|
if (fileName) {
|
|
503
508
|
a.setAttribute('download', fileName);
|
|
504
509
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export { default as DtlLayout } from './DtlLayout';
|
|
2
|
+
export { default as InputTable } from './InputTable';
|
|
3
|
+
export { default as Page404 } from './404';
|
|
4
|
+
export { default as Loading } from './Loading';
|
|
5
|
+
export { default as IconSelector } from './IconSelector';
|
|
6
|
+
export { default as ImageSelector } from './ImageSelector';
|
|
7
|
+
export { default as InputMultiLine } from './InputMultiLine';
|
|
8
|
+
export { default as AreaCascader } from './AreaCascader';
|
|
9
|
+
export { default as AreaCascaderPanel } from './AreaCascaderPanel';
|
|
10
|
+
export { default as DescritionCard } from './DescritionCard';
|
|
11
|
+
export { default as Permission } from './Permission';
|
|
12
|
+
export { default as GroupTip } from './GroupTip';
|
|
13
|
+
export { default as IconBack } from './IconBack';
|
|
14
|
+
export { default as IconText } from './IconText';
|
|
15
|
+
export { default as IconQuestion } from './IconQuestion';
|
|
16
|
+
export { default as IconBell } from './IconBell';
|
|
17
|
+
export { default as IconSearch } from './IconSearch';
|
|
18
|
+
export { default as TagCheck } from './TagCheck';
|
|
19
|
+
export { default as ViewOffice } from './ViewOffice';
|
|
20
|
+
export { default as ProButton } from './ProButton';
|
|
21
|
+
export { default as RecordLog } from './RecordLog';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export { default as DtlLayout } from './DtlLayout';
|
|
2
|
+
export { default as InputTable } from './InputTable';
|
|
3
|
+
export { default as Page404 } from './404';
|
|
4
|
+
export { default as Loading } from './Loading';
|
|
5
|
+
export { default as IconSelector } from './IconSelector';
|
|
6
|
+
export { default as ImageSelector } from './ImageSelector';
|
|
7
|
+
export { default as InputMultiLine } from './InputMultiLine';
|
|
8
|
+
export { default as AreaCascader } from './AreaCascader';
|
|
9
|
+
export { default as AreaCascaderPanel } from './AreaCascaderPanel';
|
|
10
|
+
export { default as DescritionCard } from './DescritionCard';
|
|
11
|
+
export { default as Permission } from './Permission';
|
|
12
|
+
export { default as GroupTip } from './GroupTip';
|
|
13
|
+
export { default as IconBack } from './IconBack';
|
|
14
|
+
export { default as IconText } from './IconText';
|
|
15
|
+
export { default as IconQuestion } from './IconQuestion';
|
|
16
|
+
export { default as IconBell } from './IconBell';
|
|
17
|
+
export { default as IconSearch } from './IconSearch';
|
|
18
|
+
export { default as TagCheck } from './TagCheck';
|
|
19
|
+
export { default as ViewOffice } from './ViewOffice';
|
|
20
|
+
export { default as ProButton } from './ProButton';
|
|
21
|
+
export { default as RecordLog } from './RecordLog';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { default as useSingle } from './useSingle';
|
|
2
|
+
export { default as useDtl } from './useDtl';
|
|
3
|
+
export { default as usePermission } from './usePermission';
|
|
4
|
+
export { default as useGetState } from './useGetState';
|
|
5
|
+
export { default as useFilterLocal } from './useFilterBack';
|
|
6
|
+
export { default as useBaseDict } from './useBaseDict';
|
|
7
|
+
export { default as useSelectOptions } from './useSelectOptions';
|
|
8
|
+
export { default as showConfirmFun } from './useShowConfirm';
|
|
9
|
+
export { default as useQueue } from './useQueue';
|
|
10
|
+
export { default as useSyncState } from './useSyncState';
|
|
11
|
+
export { useApiLoader } from './useApiLoad';
|
|
12
|
+
export { useDict } from './useDict';
|
|
13
|
+
export { default as useMdm } from './useMdm';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { default as useSingle } from './useSingle';
|
|
2
|
+
export { default as useDtl } from './useDtl';
|
|
3
|
+
export { default as usePermission } from './usePermission';
|
|
4
|
+
export { default as useGetState } from './useGetState';
|
|
5
|
+
export { default as useFilterLocal } from './useFilterBack';
|
|
6
|
+
export { default as useBaseDict } from './useBaseDict';
|
|
7
|
+
export { default as useSelectOptions } from './useSelectOptions';
|
|
8
|
+
export { default as showConfirmFun } from './useShowConfirm';
|
|
9
|
+
export { default as useQueue } from './useQueue';
|
|
10
|
+
export { default as useSyncState } from './useSyncState';
|
|
11
|
+
export { useApiLoader } from './useApiLoad';
|
|
12
|
+
export { useDict } from './useDict';
|
|
13
|
+
export { default as useMdm } from './useMdm';
|
package/lib/http/index.js
CHANGED
|
@@ -525,6 +525,8 @@ function _httpBatchRequest() {
|
|
|
525
525
|
currentPage,
|
|
526
526
|
_objectSpread2,
|
|
527
527
|
firstParams,
|
|
528
|
+
api,
|
|
529
|
+
_setUrlQuery3,
|
|
528
530
|
firstResponse,
|
|
529
531
|
firstData,
|
|
530
532
|
actualPageSize,
|
|
@@ -555,7 +557,8 @@ function _httpBatchRequest() {
|
|
|
555
557
|
}
|
|
556
558
|
return _context5.abrupt("return", ajax(url, params, method, needGateWay, true, timeout));
|
|
557
559
|
case 10:
|
|
558
|
-
|
|
560
|
+
// 是否为 2.0版本的api。
|
|
561
|
+
isV2 = url.includes('page.size') || (params === null || params === void 0 ? void 0 : params['page.size']) ? true : false; // 不同版本api的请求分页关键字处理,
|
|
559
562
|
PAGE_SIZE = isV2 ? 'page.size' : 'pageSize';
|
|
560
563
|
PAGE_NUM = isV2 ? 'page.pn' : 'page'; // 分批获取数据时,需要从URL中移除原有的pageSize和page参数
|
|
561
564
|
cleanUrl = url;
|
|
@@ -572,34 +575,38 @@ function _httpBatchRequest() {
|
|
|
572
575
|
currentPage = pageNum;
|
|
573
576
|
_context5.prev = 20;
|
|
574
577
|
// 第一次请求,获取总数
|
|
575
|
-
firstParams = _objectSpread(_objectSpread({}, params), {}, (_objectSpread2 = {}, _defineProperty(_objectSpread2, PAGE_SIZE, batchSize), _defineProperty(_objectSpread2, PAGE_NUM, currentPage), _objectSpread2));
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
578
|
+
firstParams = _objectSpread(_objectSpread({}, params), {}, (_objectSpread2 = {}, _defineProperty(_objectSpread2, PAGE_SIZE, batchSize), _defineProperty(_objectSpread2, PAGE_NUM, currentPage), _objectSpread2)); // 如果是 post 请求,body 和 query 里都传入分页参数
|
|
579
|
+
api = cleanUrl;
|
|
580
|
+
if (method === 'post') {
|
|
581
|
+
api = setUrlQuery(cleanUrl, (_setUrlQuery3 = {}, _defineProperty(_setUrlQuery3, PAGE_SIZE, batchSize), _defineProperty(_setUrlQuery3, PAGE_NUM, currentPage), _setUrlQuery3));
|
|
582
|
+
}
|
|
583
|
+
_context5.next = 26;
|
|
584
|
+
return ajax(api, firstParams, method, needGateWay, true, timeout);
|
|
585
|
+
case 26:
|
|
579
586
|
firstResponse = _context5.sent;
|
|
580
587
|
firstData = firstResponse; // 如果返回值没有 rows 或 total,直接返回普通请求
|
|
581
588
|
if (!(!('rows' in firstData) || !('total' in firstData))) {
|
|
582
|
-
_context5.next =
|
|
589
|
+
_context5.next = 30;
|
|
583
590
|
break;
|
|
584
591
|
}
|
|
585
592
|
return _context5.abrupt("return", ajax(url, params, method, needGateWay, true, timeout));
|
|
586
|
-
case
|
|
593
|
+
case 30:
|
|
587
594
|
if (firstData.rows) {
|
|
588
595
|
allRows.push.apply(allRows, _toConsumableArray(firstData.rows));
|
|
589
596
|
total = firstData.total || 0;
|
|
590
597
|
}
|
|
591
598
|
// 如果total小于等于defaultPageSize,不需要分批获取,直接返回
|
|
592
599
|
if (!(total <= defaultPageSize)) {
|
|
593
|
-
_context5.next =
|
|
600
|
+
_context5.next = 33;
|
|
594
601
|
break;
|
|
595
602
|
}
|
|
596
603
|
return _context5.abrupt("return", firstResponse);
|
|
597
|
-
case
|
|
604
|
+
case 33:
|
|
598
605
|
// 计算实际需要获取的数据量(不超过用户传入的pageSize)
|
|
599
606
|
actualPageSize = Math.min(pageSize, total); // 计算需要请求的总页数(基于实际需要的数据量)
|
|
600
607
|
totalPages = Math.ceil(actualPageSize / batchSize); // 如果还有更多数据需要获取
|
|
601
608
|
if (!(totalPages > 1)) {
|
|
602
|
-
_context5.next =
|
|
609
|
+
_context5.next = 50;
|
|
603
610
|
break;
|
|
604
611
|
}
|
|
605
612
|
// 分批并发请求,每次最多6个并发
|
|
@@ -610,9 +617,9 @@ function _httpBatchRequest() {
|
|
|
610
617
|
}
|
|
611
618
|
// 分批处理请求
|
|
612
619
|
_i = 0;
|
|
613
|
-
case
|
|
620
|
+
case 40:
|
|
614
621
|
if (!(_i < remainingPages.length)) {
|
|
615
|
-
_context5.next =
|
|
622
|
+
_context5.next = 50;
|
|
616
623
|
break;
|
|
617
624
|
}
|
|
618
625
|
batchPages = remainingPages.slice(_i, _i + maxConcurrent);
|
|
@@ -626,11 +633,15 @@ function _httpBatchRequest() {
|
|
|
626
633
|
currentPageSize = Math.max(0, remainingData);
|
|
627
634
|
}
|
|
628
635
|
var requestParams = _objectSpread(_objectSpread({}, params), {}, (_objectSpread3 = {}, _defineProperty(_objectSpread3, PAGE_SIZE, currentPageSize), _defineProperty(_objectSpread3, PAGE_NUM, pageNum), _objectSpread3));
|
|
629
|
-
|
|
636
|
+
if (method === 'post') {
|
|
637
|
+
var _setUrlQuery4;
|
|
638
|
+
api = setUrlQuery(cleanUrl, (_setUrlQuery4 = {}, _defineProperty(_setUrlQuery4, PAGE_SIZE, currentPageSize), _defineProperty(_setUrlQuery4, PAGE_NUM, pageNum), _setUrlQuery4));
|
|
639
|
+
}
|
|
640
|
+
return ajax(api, requestParams, method, needGateWay, true, timeout);
|
|
630
641
|
}); // 并发执行当前批次的请求
|
|
631
|
-
_context5.next =
|
|
642
|
+
_context5.next = 45;
|
|
632
643
|
return Promise.all(batchRequests);
|
|
633
|
-
case
|
|
644
|
+
case 45:
|
|
634
645
|
batchResponses = _context5.sent;
|
|
635
646
|
// 合并当前批次的响应数据
|
|
636
647
|
batchResponses.forEach(function (response) {
|
|
@@ -639,11 +650,11 @@ function _httpBatchRequest() {
|
|
|
639
650
|
allRows.push.apply(allRows, _toConsumableArray(data.rows));
|
|
640
651
|
}
|
|
641
652
|
});
|
|
642
|
-
case
|
|
653
|
+
case 47:
|
|
643
654
|
_i += maxConcurrent;
|
|
644
|
-
_context5.next =
|
|
655
|
+
_context5.next = 40;
|
|
645
656
|
break;
|
|
646
|
-
case
|
|
657
|
+
case 50:
|
|
647
658
|
// 如果获取的数据超过了用户要求的pageSize,进行截取
|
|
648
659
|
if (allRows.length > actualPageSize) {
|
|
649
660
|
allRows.splice(actualPageSize);
|
|
@@ -653,15 +664,15 @@ function _httpBatchRequest() {
|
|
|
653
664
|
rows: allRows,
|
|
654
665
|
total: total // 保持原始的total值
|
|
655
666
|
}));
|
|
656
|
-
case
|
|
657
|
-
_context5.prev =
|
|
667
|
+
case 54:
|
|
668
|
+
_context5.prev = 54;
|
|
658
669
|
_context5.t0 = _context5["catch"](20);
|
|
659
670
|
throw _context5.t0;
|
|
660
|
-
case
|
|
671
|
+
case 57:
|
|
661
672
|
case "end":
|
|
662
673
|
return _context5.stop();
|
|
663
674
|
}
|
|
664
|
-
}, _callee5, null, [[20,
|
|
675
|
+
}, _callee5, null, [[20, 54]]);
|
|
665
676
|
}));
|
|
666
677
|
return _httpBatchRequest.apply(this, arguments);
|
|
667
678
|
}
|
package/lib/http/mdmRequest.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
2
2
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
-
import {
|
|
3
|
+
import { httpBatchGet } from '.';
|
|
4
4
|
import { getCache, setCache } from '../utils';
|
|
5
5
|
function setPageSize() {
|
|
6
6
|
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
@@ -37,7 +37,7 @@ function _httpGetWithCache() {
|
|
|
37
37
|
return _context2.abrupt("return", cacheData);
|
|
38
38
|
case 5:
|
|
39
39
|
_context2.next = 7;
|
|
40
|
-
return
|
|
40
|
+
return httpBatchGet(url, params);
|
|
41
41
|
case 7:
|
|
42
42
|
result = _context2.sent;
|
|
43
43
|
if ((result === null || result === void 0 ? void 0 : (_result$flag = result.flag) === null || _result$flag === void 0 ? void 0 : _result$flag.retCode) === '0') {
|