ls-pro-common 3.0.87 → 3.0.89
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/AreaCascader.js +9 -6
- package/es/components/AreaCascaderPanel.js +9 -6
- package/es/components/InputTable.d.ts +6 -0
- package/es/components/InputTable.js +18 -14
- package/es/hooks/useDict.d.ts +26 -0
- package/es/hooks/useDict.js +60 -0
- package/es/http/index.js +4 -1
- package/es/index.d.ts +4 -2
- package/es/index.js +2 -1
- package/es/utils/index.d.ts +1 -0
- package/es/utils/index.js +3 -0
- package/lib/components/AreaCascader.js +9 -6
- package/lib/components/AreaCascaderPanel.js +9 -6
- package/lib/components/InputTable.d.ts +6 -0
- package/lib/components/InputTable.js +18 -14
- package/lib/hooks/useDict.d.ts +26 -0
- package/lib/hooks/useDict.js +60 -0
- package/lib/http/index.js +4 -1
- package/lib/index.d.ts +4 -2
- package/lib/index.js +2 -1
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +3 -0
- package/package.json +1 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
declare type TOption = {
|
|
2
|
+
label: string;
|
|
3
|
+
value: any;
|
|
4
|
+
text?: string;
|
|
5
|
+
status?: number;
|
|
6
|
+
};
|
|
7
|
+
declare type TDictItem = {
|
|
8
|
+
dict: string;
|
|
9
|
+
showValue?: boolean;
|
|
10
|
+
/** 是否转换数字 */
|
|
11
|
+
isValNum?: boolean;
|
|
12
|
+
transform?: (data: TOption[]) => TOption[];
|
|
13
|
+
};
|
|
14
|
+
declare type TDictParams = Record<string, string | (() => Promise<TOption[]>) | TDictItem>;
|
|
15
|
+
/** 字典类型 */
|
|
16
|
+
export declare type TDict<T extends TDictParams> = {
|
|
17
|
+
[key in keyof T]?: TOption[];
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* 获取字典
|
|
21
|
+
*
|
|
22
|
+
* @param dicts 字典列表
|
|
23
|
+
* @param type 字典类型 默认 tenant
|
|
24
|
+
*/
|
|
25
|
+
export declare function useDict<T extends TDictParams>(dicts: T): { [key in keyof T]?: TOption[] | undefined; };
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
|
+
import { getDict } from '../http';
|
|
4
|
+
import { useEffect, useState } from 'react';
|
|
5
|
+
/** Value转换数字 */
|
|
6
|
+
var transformNum = function transformNum(options) {
|
|
7
|
+
return options.map(function (v) {
|
|
8
|
+
return _objectSpread(_objectSpread({}, v), {}, {
|
|
9
|
+
value: Number(v.value)
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* 获取字典
|
|
15
|
+
*
|
|
16
|
+
* @param dicts 字典列表
|
|
17
|
+
* @param type 字典类型 默认 tenant
|
|
18
|
+
*/
|
|
19
|
+
export function useDict(dicts) {
|
|
20
|
+
var _useState = useState({}),
|
|
21
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
22
|
+
dictList = _useState2[0],
|
|
23
|
+
setDictList = _useState2[1];
|
|
24
|
+
useEffect(function () {
|
|
25
|
+
var keys = Object.keys(dicts);
|
|
26
|
+
var pList = [];
|
|
27
|
+
var result = {};
|
|
28
|
+
keys.forEach(function (k) {
|
|
29
|
+
if (typeof dicts[k] === 'string') {
|
|
30
|
+
pList.push(getDict(dicts[k]));
|
|
31
|
+
} else if (typeof dicts[k] === 'function') {
|
|
32
|
+
var fn = dicts[k];
|
|
33
|
+
pList.push(fn());
|
|
34
|
+
} else {
|
|
35
|
+
var _dicts$k = dicts[k],
|
|
36
|
+
dict = _dicts$k.dict,
|
|
37
|
+
showValue = _dicts$k.showValue,
|
|
38
|
+
isValNum = _dicts$k.isValNum,
|
|
39
|
+
_dicts$k$transform = _dicts$k.transform,
|
|
40
|
+
transform = _dicts$k$transform === void 0 ? function (d) {
|
|
41
|
+
return d;
|
|
42
|
+
} : _dicts$k$transform;
|
|
43
|
+
var _transform = transform;
|
|
44
|
+
if (isValNum) _transform = transformNum;
|
|
45
|
+
pList.push(getDict(dict, showValue).then(_transform));
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
Promise.allSettled(pList).then(function (res) {
|
|
49
|
+
res.forEach(function (v, i) {
|
|
50
|
+
if (v.status === 'fulfilled') {
|
|
51
|
+
result[keys[i]] = v.value;
|
|
52
|
+
} else {
|
|
53
|
+
result[keys[i]] = [];
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
setDictList(result);
|
|
57
|
+
});
|
|
58
|
+
}, []);
|
|
59
|
+
return dictList;
|
|
60
|
+
}
|
package/lib/http/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
2
2
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
3
|
import { extend } from 'umi-request';
|
|
4
|
-
import { getCache, getUrlQuery, setUrlQuery, getCookie, getResourceProps, showError, httpError, toGatewayUrl, reLogin, showLoading, exitLoading } from '../utils';
|
|
4
|
+
import { getCache, getUrlQuery, setUrlQuery, getCookie, getResourceProps, showError, httpError, toGatewayUrl, reLogin, showLoading, exitLoading, isSaasVersion } from '../utils';
|
|
5
5
|
//默认超时时间为1分钟
|
|
6
6
|
var request = extend({
|
|
7
7
|
timeout: 60000
|
|
@@ -277,6 +277,9 @@ export function getDict(dictCode) {
|
|
|
277
277
|
var needGateWay = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
278
278
|
var timeout = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 60000;
|
|
279
279
|
var api = '/lesoon-integration/sysDictDtl/listByProperties';
|
|
280
|
+
if (isSaasVersion()) {
|
|
281
|
+
api = '/tenant-lesoon-integration-api/sysDictDtl/listByProperties';
|
|
282
|
+
}
|
|
280
283
|
var param = {
|
|
281
284
|
dictCode: dictCode
|
|
282
285
|
};
|
package/lib/index.d.ts
CHANGED
|
@@ -31,10 +31,12 @@ import useBaseDict from './hooks/useBaseDict';
|
|
|
31
31
|
import useSelectOptions from './hooks/useSelectOptions';
|
|
32
32
|
import showConfirmFun from './hooks/useShowConfirm';
|
|
33
33
|
import useQueue from './hooks/useQueue';
|
|
34
|
+
import { useDict } from './hooks/useDict';
|
|
34
35
|
/** Type */
|
|
35
36
|
import type { ApiResponse, TableToolbar, BaseApiType, MethodType } from './typing';
|
|
36
37
|
import type { DtlLyaoutProps } from './components/DtlLayout';
|
|
37
38
|
import type { DescritionCardProps } from './components/DescritionCard';
|
|
38
39
|
import type { PermissionProps } from './components/Permission';
|
|
39
|
-
|
|
40
|
-
export {
|
|
40
|
+
import type { TDict } from './hooks/useDict';
|
|
41
|
+
export type { ApiResponse, TableToolbar, BaseApiType, MethodType, DtlLyaoutProps, DescritionCardProps, PermissionProps, TDict, };
|
|
42
|
+
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, utils, useSingle, useDtl, usePermission, useGetState, useFilterLocal, useQueue, useBaseDict, useSelectOptions, useDict, showConfirmFun, exportProcess, };
|
package/lib/index.js
CHANGED
|
@@ -31,4 +31,5 @@ import useBaseDict from './hooks/useBaseDict';
|
|
|
31
31
|
import useSelectOptions from './hooks/useSelectOptions';
|
|
32
32
|
import showConfirmFun from './hooks/useShowConfirm';
|
|
33
33
|
import useQueue from './hooks/useQueue';
|
|
34
|
-
|
|
34
|
+
import { useDict } from './hooks/useDict';
|
|
35
|
+
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, utils, useSingle, useDtl, usePermission, useGetState, useFilterLocal, useQueue, useBaseDict, useSelectOptions, useDict, showConfirmFun, exportProcess };
|
package/lib/utils/index.d.ts
CHANGED
|
@@ -316,3 +316,4 @@ export declare const exitLoading: () => void;
|
|
|
316
316
|
export declare const handleTheme: () => void;
|
|
317
317
|
export declare const sleep: (secord: number) => Promise<unknown>;
|
|
318
318
|
export declare const downloadFile: (url: string, fileName?: string | undefined) => void;
|
|
319
|
+
export declare const isSaasVersion: () => boolean;
|
package/lib/utils/index.js
CHANGED
|
@@ -915,4 +915,7 @@ export var downloadFile = function downloadFile(url, fileName) {
|
|
|
915
915
|
document.body.appendChild(a);
|
|
916
916
|
a.click();
|
|
917
917
|
document.body.removeChild(a);
|
|
918
|
+
};
|
|
919
|
+
export var isSaasVersion = function isSaasVersion() {
|
|
920
|
+
return (getCache('poi-center-api') || '').includes('/tenant-lesoon-basic-api/');
|
|
918
921
|
};
|