ls-pro-common 3.0.14 → 3.0.15
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/CHANGELOG.md +746 -0
- package/es/components/404.d.ts +3 -0
- package/es/components/404.jpg +0 -0
- package/es/components/404.js +9 -0
- package/es/components/AreaCascader.d.ts +4 -0
- package/es/components/AreaCascader.js +76 -0
- package/es/components/AreaCascaderPanel.d.ts +5 -0
- package/es/components/AreaCascaderPanel.js +230 -0
- package/es/components/DescritionCard.d.ts +11 -0
- package/es/components/DescritionCard.js +79 -0
- package/es/components/DtlLayout.d.ts +44 -0
- package/es/components/DtlLayout.js +116 -0
- package/es/components/GroupTip.d.ts +10 -0
- package/es/components/GroupTip.js +31 -0
- package/es/components/IconBack.d.ts +3 -0
- package/es/components/IconBack.js +20 -0
- package/es/components/IconBell.d.ts +3 -0
- package/es/components/IconBell.js +22 -0
- package/es/components/IconQuestion.d.ts +3 -0
- package/es/components/IconQuestion.js +26 -0
- package/es/components/IconSearch.d.ts +3 -0
- package/es/components/IconSearch.js +22 -0
- package/es/components/IconSelector.d.ts +14 -0
- package/es/components/IconSelector.js +222 -0
- package/es/components/IconText.d.ts +3 -0
- package/es/components/IconText.js +30 -0
- package/es/components/ImageSelector.d.ts +31 -0
- package/es/components/ImageSelector.js +437 -0
- package/es/components/InputMultiLine.d.ts +46 -0
- package/es/components/InputMultiLine.js +139 -0
- package/es/components/InputTable.d.ts +106 -0
- package/es/components/InputTable.js +473 -0
- package/es/components/Loading.d.ts +8 -0
- package/es/components/Loading.js +20 -0
- package/es/components/Permission.d.ts +6 -0
- package/es/components/Permission.js +13 -0
- package/es/components/antd-custom.less +356 -0
- package/es/components/common.less +474 -0
- package/es/hooks/useDtl/index.d.ts +47 -0
- package/es/hooks/useDtl/index.js +949 -0
- package/es/hooks/useGetState.d.ts +1 -0
- package/es/hooks/useGetState.js +17 -0
- package/es/hooks/usePermission/index.d.ts +15 -0
- package/es/hooks/usePermission/index.js +58 -0
- package/es/hooks/useSingle/index.d.ts +54 -0
- package/es/hooks/useSingle/index.js +662 -0
- package/es/http/index.d.ts +53 -0
- package/es/http/index.js +309 -0
- package/es/index.d.ts +32 -0
- package/es/index.js +26 -0
- package/es/service/BaseService.d.ts +24 -0
- package/es/service/BaseService.js +214 -0
- package/es/typing.d.ts +53 -0
- package/es/typing.js +1 -0
- package/es/utils/index.d.ts +258 -0
- package/es/utils/index.js +682 -0
- package/lib/components/404.d.ts +3 -0
- package/lib/components/404.jpg +0 -0
- package/lib/components/404.js +17 -0
- package/lib/components/AreaCascader.d.ts +4 -0
- package/lib/components/AreaCascader.js +85 -0
- package/lib/components/AreaCascaderPanel.d.ts +5 -0
- package/lib/components/AreaCascaderPanel.js +239 -0
- package/lib/components/DescritionCard.d.ts +11 -0
- package/lib/components/DescritionCard.js +88 -0
- package/lib/components/DtlLayout.d.ts +44 -0
- package/lib/components/DtlLayout.js +125 -0
- package/lib/components/GroupTip.d.ts +10 -0
- package/lib/components/GroupTip.js +39 -0
- package/lib/components/IconBack.d.ts +3 -0
- package/lib/components/IconBack.js +28 -0
- package/lib/components/IconBell.d.ts +3 -0
- package/lib/components/IconBell.js +30 -0
- package/lib/components/IconQuestion.d.ts +3 -0
- package/lib/components/IconQuestion.js +34 -0
- package/lib/components/IconSearch.d.ts +3 -0
- package/lib/components/IconSearch.js +30 -0
- package/lib/components/IconSelector.d.ts +14 -0
- package/lib/components/IconSelector.js +230 -0
- package/lib/components/IconText.d.ts +3 -0
- package/lib/components/IconText.js +38 -0
- package/lib/components/ImageSelector.d.ts +31 -0
- package/lib/components/ImageSelector.js +445 -0
- package/lib/components/InputMultiLine.d.ts +46 -0
- package/lib/components/InputMultiLine.js +148 -0
- package/lib/components/InputTable.d.ts +106 -0
- package/lib/components/InputTable.js +482 -0
- package/lib/components/Loading.d.ts +8 -0
- package/lib/components/Loading.js +28 -0
- package/lib/components/Permission.d.ts +6 -0
- package/lib/components/Permission.js +21 -0
- package/lib/components/antd-custom.less +356 -0
- package/lib/components/common.less +474 -0
- package/lib/hooks/useDtl/index.d.ts +47 -0
- package/lib/hooks/useDtl/index.js +957 -0
- package/lib/hooks/useGetState.d.ts +1 -0
- package/lib/hooks/useGetState.js +24 -0
- package/lib/hooks/usePermission/index.d.ts +15 -0
- package/lib/hooks/usePermission/index.js +65 -0
- package/lib/hooks/useSingle/index.d.ts +54 -0
- package/lib/hooks/useSingle/index.js +670 -0
- package/lib/http/index.d.ts +53 -0
- package/lib/http/index.js +323 -0
- package/lib/index.d.ts +32 -0
- package/lib/service/BaseService.d.ts +24 -0
- package/lib/service/BaseService.js +222 -0
- package/lib/typing.d.ts +53 -0
- package/lib/typing.js +5 -0
- package/lib/utils/index.d.ts +258 -0
- package/lib/utils/index.js +779 -0
- package/package.json +5 -13
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function (initVal: any): any[];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import { useState, useRef } from "react";
|
|
3
|
+
export default function (initVal) {
|
|
4
|
+
var _useState = useState(initVal),
|
|
5
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
6
|
+
state = _useState2[0],
|
|
7
|
+
setState = _useState2[1];
|
|
8
|
+
var ref = useRef(initVal);
|
|
9
|
+
var shangeState = function shangeState(newVal) {
|
|
10
|
+
ref.current = newVal;
|
|
11
|
+
setState(newVal);
|
|
12
|
+
};
|
|
13
|
+
var getState = function getState() {
|
|
14
|
+
return ref.current;
|
|
15
|
+
};
|
|
16
|
+
return [state, shangeState, getState];
|
|
17
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare function usePermission(): {
|
|
2
|
+
resourceId: any;
|
|
3
|
+
permissionVal: number;
|
|
4
|
+
resRightVal: number;
|
|
5
|
+
loginName: string | undefined;
|
|
6
|
+
checkRight: (val: number) => boolean;
|
|
7
|
+
canAdd: boolean;
|
|
8
|
+
canEdit: boolean;
|
|
9
|
+
canDelete: boolean;
|
|
10
|
+
canAudit: boolean;
|
|
11
|
+
canImport: boolean;
|
|
12
|
+
canExport: boolean;
|
|
13
|
+
canPrint: boolean;
|
|
14
|
+
};
|
|
15
|
+
export default usePermission;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { useMemo, useCallback } from 'react';
|
|
2
|
+
import { useLocation } from 'react-router-dom';
|
|
3
|
+
import { getUrlQuery, getResourceProps, getCache, getLoginName } from '../../utils';
|
|
4
|
+
function usePermission() {
|
|
5
|
+
var routeLocation = useLocation();
|
|
6
|
+
/** @name 资源ID */
|
|
7
|
+
var resourceId = useMemo(function () {
|
|
8
|
+
var _routeLocation$query;
|
|
9
|
+
//@ts-ignore
|
|
10
|
+
var resId = routeLocation === null || routeLocation === void 0 ? void 0 : (_routeLocation$query = routeLocation.query) === null || _routeLocation$query === void 0 ? void 0 : _routeLocation$query.resCode;
|
|
11
|
+
if (resId) return resId;
|
|
12
|
+
return getUrlQuery('resCode') || getUrlQuery('resourceId') || getResourceProps('resourceId');
|
|
13
|
+
}, []);
|
|
14
|
+
var loginName = useMemo(function () {
|
|
15
|
+
return getLoginName();
|
|
16
|
+
}, []);
|
|
17
|
+
/** @name 用户权限 */
|
|
18
|
+
var permissionVal = useMemo(function () {
|
|
19
|
+
var _routeLocation$query2;
|
|
20
|
+
//@ts-ignore
|
|
21
|
+
var right = routeLocation === null || routeLocation === void 0 ? void 0 : (_routeLocation$query2 = routeLocation.query) === null || _routeLocation$query2 === void 0 ? void 0 : _routeLocation$query2.right;
|
|
22
|
+
if (right) return Number(right);
|
|
23
|
+
return Number(getUrlQuery('right') || getResourceProps('userPermissionVal') || getCache('right') || 0);
|
|
24
|
+
}, []);
|
|
25
|
+
/** @name 资源权限 */
|
|
26
|
+
var resRightVal = useMemo(function () {
|
|
27
|
+
var _routeLocation$query3;
|
|
28
|
+
//@ts-ignore
|
|
29
|
+
var right = routeLocation === null || routeLocation === void 0 ? void 0 : (_routeLocation$query3 = routeLocation.query) === null || _routeLocation$query3 === void 0 ? void 0 : _routeLocation$query3.resRight;
|
|
30
|
+
if (right) return Number(right);
|
|
31
|
+
return Number(getUrlQuery('resRight') || getResourceProps('permissionVal') || getCache('right') || 0);
|
|
32
|
+
}, []);
|
|
33
|
+
/**
|
|
34
|
+
* 检查是否有权限
|
|
35
|
+
* @param val 权限值
|
|
36
|
+
*/
|
|
37
|
+
var checkRight = useCallback(function (val) {
|
|
38
|
+
if (!val) return true;
|
|
39
|
+
if (location.href.includes("//localhost")) return true;
|
|
40
|
+
return (permissionVal & val) === val && (resRightVal & val) === val;
|
|
41
|
+
}, []);
|
|
42
|
+
return {
|
|
43
|
+
resourceId: resourceId,
|
|
44
|
+
permissionVal: permissionVal,
|
|
45
|
+
resRightVal: resRightVal,
|
|
46
|
+
loginName: loginName,
|
|
47
|
+
checkRight: checkRight,
|
|
48
|
+
canAdd: checkRight(2),
|
|
49
|
+
canEdit: checkRight(4),
|
|
50
|
+
canDelete: checkRight(8) || checkRight(32),
|
|
51
|
+
canAudit: checkRight(64),
|
|
52
|
+
canImport: checkRight(128),
|
|
53
|
+
canExport: checkRight(256),
|
|
54
|
+
canPrint: checkRight(512)
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
;
|
|
58
|
+
export default usePermission;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { ActionType } from 'ls-pro-table';
|
|
2
|
+
import type { ProFormInstance } from 'ls-pro-form';
|
|
3
|
+
import type { ApiResponse, TableToolbar } from '../../typing';
|
|
4
|
+
export declare type SingleParamType = {
|
|
5
|
+
service: any;
|
|
6
|
+
toolConfig?: TableToolbar;
|
|
7
|
+
initItem?: any;
|
|
8
|
+
statusField?: string;
|
|
9
|
+
auditStatus?: number;
|
|
10
|
+
beforeLoad?: (param: Record<string, any>) => Promise<boolean>;
|
|
11
|
+
beforeRemove?: (rows: any[]) => Promise<any>;
|
|
12
|
+
beforeAudit?: (rows: any[]) => Promise<any>;
|
|
13
|
+
beforeAdd?: (item: any) => Promise<any>;
|
|
14
|
+
beforeEdit?: (item: any) => Promise<any>;
|
|
15
|
+
beforeSave?: (item: any, isDtl?: boolean) => Promise<any>;
|
|
16
|
+
afterRemove?: (result: ApiResponse, rows?: any | any[]) => Promise<boolean>;
|
|
17
|
+
afterSave?: (result: ApiResponse, item?: any, isDtl?: boolean) => Promise<boolean>;
|
|
18
|
+
afterAudit?: (result: ApiResponse, item?: any | any[]) => Promise<boolean>;
|
|
19
|
+
btnStatus?: (btnKey: string) => boolean | undefined;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* 单表基本增删改查 hooks
|
|
23
|
+
* @param service 单表服务
|
|
24
|
+
* @param toolConfig 定义基础功能按钮
|
|
25
|
+
* @param initItem 对象初始值,新增时设置默认值
|
|
26
|
+
* @param onBeforeRemove 删除之前方法,开放给每个模块重写
|
|
27
|
+
* @returns
|
|
28
|
+
*/
|
|
29
|
+
declare function useSingle(inParam: SingleParamType): {
|
|
30
|
+
formRef: import("react").MutableRefObject<ProFormInstance<any> | undefined>;
|
|
31
|
+
editFormRef: import("react").MutableRefObject<ProFormInstance<any> | undefined>;
|
|
32
|
+
tableRef: import("react").MutableRefObject<ActionType | undefined>;
|
|
33
|
+
selectedRows: any;
|
|
34
|
+
showEdit: boolean;
|
|
35
|
+
editItem: any;
|
|
36
|
+
tableTools: (boolean | JSX.Element)[];
|
|
37
|
+
setSelectedRows: import("react").Dispatch<any>;
|
|
38
|
+
setShowEdit: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
39
|
+
setEditItem: import("react").Dispatch<any>;
|
|
40
|
+
onRemove: (row: any) => void;
|
|
41
|
+
onSave: (formData: any) => Promise<boolean>;
|
|
42
|
+
onLoad: (params: Record<string, any>, sort: Record<string, any>, filter: Record<string, any>, isHistory: any) => Promise<any>;
|
|
43
|
+
onAdd: (item: any) => Promise<void>;
|
|
44
|
+
onEdit: (item: any) => Promise<void>;
|
|
45
|
+
onExport: (url: string, param: any) => Promise<boolean>;
|
|
46
|
+
onAudit: (row: any) => Promise<void>;
|
|
47
|
+
resourceId: any;
|
|
48
|
+
checkRight: (val: number) => boolean;
|
|
49
|
+
loginName: string | undefined;
|
|
50
|
+
isAudit: (row?: any) => boolean;
|
|
51
|
+
ifHistory: 0 | 1;
|
|
52
|
+
setIfHistory: import("react").Dispatch<import("react").SetStateAction<0 | 1>>;
|
|
53
|
+
};
|
|
54
|
+
export default useSingle;
|