@cfmm/umi-plugins-ui-v2 0.0.5 → 0.0.7
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/cjs/components/CrudTable.tpl +1 -1
- package/dist/cjs/components/DataPermissionSelect.tpl +223 -0
- package/dist/cjs/components/EditMultiLangForm.tpl +1 -1
- package/dist/cjs/components/PermissionSelect.tpl +29 -17
- package/dist/cjs/locales/en-US.d.ts +11 -0
- package/dist/cjs/locales/enUS/DataPermissionSelect.d.ts +14 -0
- package/dist/cjs/locales/enUS/DataPermissionSelect.js +19 -0
- package/dist/cjs/locales/enUS/index.d.ts +11 -0
- package/dist/cjs/locales/enUS/index.js +2 -1
- package/dist/cjs/locales/th-TH.d.ts +11 -0
- package/dist/cjs/locales/zh-CN.d.ts +11 -0
- package/dist/cjs/locales/zh-TW.d.ts +11 -0
- package/dist/cjs/locales/zhCN/DataPermissionSelect.d.ts +14 -0
- package/dist/cjs/locales/zhCN/DataPermissionSelect.js +19 -0
- package/dist/cjs/locales/zhCN/index.d.ts +11 -0
- package/dist/cjs/locales/zhCN/index.js +2 -1
- package/dist/cjs/locales/zhTW/DataPermissionSelect.d.ts +14 -0
- package/dist/cjs/locales/zhTW/DataPermissionSelect.js +19 -0
- package/dist/cjs/locales/zhTW/index.d.ts +11 -0
- package/dist/cjs/locales/zhTW/index.js +2 -1
- package/dist/cjs/types/DataPermissionSelectTypes.d.ts +1 -0
- package/dist/cjs/types/DataPermissionSelectTypes.js +7 -0
- package/dist/cjs/types/PermissionSelectTypes.d.ts +1 -1
- package/dist/cjs/types/PermissionSelectTypes.js +1 -1
- package/dist/cjs/types/index.d.ts +1 -0
- package/dist/cjs/types/index.js +7 -0
- package/dist/cjs/utils/utils.tpl +93 -1
- package/dist/cjs/writeTmpFile/writeIndex.js +1 -1
- package/dist/cjs/writeTmpFile/writeTypes.js +1 -1
- package/dist/esm/components/CrudTable.tpl +1 -1
- package/dist/esm/components/DataPermissionSelect.tpl +223 -0
- package/dist/esm/components/EditMultiLangForm.tpl +1 -1
- package/dist/esm/components/PermissionSelect.tpl +29 -17
- package/dist/esm/locales/en-US.d.ts +11 -0
- package/dist/esm/locales/enUS/DataPermissionSelect.d.ts +14 -0
- package/dist/esm/locales/enUS/DataPermissionSelect.js +13 -0
- package/dist/esm/locales/enUS/index.d.ts +11 -0
- package/dist/esm/locales/enUS/index.js +2 -1
- package/dist/esm/locales/th-TH.d.ts +11 -0
- package/dist/esm/locales/zh-CN.d.ts +11 -0
- package/dist/esm/locales/zh-TW.d.ts +11 -0
- package/dist/esm/locales/zhCN/DataPermissionSelect.d.ts +14 -0
- package/dist/esm/locales/zhCN/DataPermissionSelect.js +13 -0
- package/dist/esm/locales/zhCN/index.d.ts +11 -0
- package/dist/esm/locales/zhCN/index.js +2 -1
- package/dist/esm/locales/zhTW/DataPermissionSelect.d.ts +14 -0
- package/dist/esm/locales/zhTW/DataPermissionSelect.js +13 -0
- package/dist/esm/locales/zhTW/index.d.ts +11 -0
- package/dist/esm/locales/zhTW/index.js +2 -1
- package/dist/esm/types/DataPermissionSelectTypes.d.ts +1 -0
- package/dist/esm/types/DataPermissionSelectTypes.js +1 -0
- package/dist/esm/types/PermissionSelectTypes.d.ts +1 -1
- package/dist/esm/types/PermissionSelectTypes.js +1 -1
- package/dist/esm/types/index.d.ts +1 -0
- package/dist/esm/types/index.js +1 -0
- package/dist/esm/utils/utils.tpl +93 -1
- package/dist/esm/writeTmpFile/writeIndex.js +1 -1
- package/dist/esm/writeTmpFile/writeTypes.js +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.DataPermissionSelectTypes = void 0;
|
|
7
|
+
var DataPermissionSelectTypes = exports.DataPermissionSelectTypes = "\n /** \u6570\u636E\u6743\u9650\u8303\u56F4\u679A\u4E3E */\n export enum DataScopeEnum {\n /** \u5168\u90E8\u6570\u636E\u6743\u9650 */\n ALL = '1',\n /** \u81EA\u5B9A\u4E49\u6570\u636E\u6743\u9650 */\n CUSTOM = '2',\n /** \u672C\u90E8\u95E8\u6570\u636E\u6743\u9650 */\n DEPT = '3',\n /** \u672C\u90E8\u95E8\u53CA\u4EE5\u4E0B\u6570\u636E\u6743\u9650 */\n DEPT_AND_SUB = '4',\n /** \u4EC5\u672C\u4EBA\u6570\u636E\u6743\u9650 */\n ONLY_SELF = '5',\n }\n\n /** \u662F\u5426\u7236\u5B50\u8054\u52A8\u679A\u4E3E */\n export enum DeptCheckStrictlyEnum {\n /** \u6298\u53E0/\u5C55\u5F00 */\n FOLD = '1',\n /** \u5168\u9009/\u5168\u4E0D\u9009 */\n SELECT_ALL = '2',\n /** \u7236\u5B50\u8054\u52A8 */\n PARENT_CHILD = '3',\n }\n\n /** \u6570\u636E\u6743\u9650\u9009\u62E9\u8868\u5355\u6570\u636E */\n export interface DataPermissionValues {\n /** \u7EC4\u7EC7ID\u5217\u8868 */\n deptIds?: React.Key[];\n /** \u6570\u636E\u6743\u9650\u8303\u56F4 */\n dataScope?: DataScopeEnum;\n /** \u662F\u5426\u7236\u5B50\u8054\u52A8 */\n deptCheckStrictly?: boolean;\n }\n\n /** \u6570\u636E\u6743\u9650\u9009\u62E9\u7EC4\u4EF6Props */\n export interface DataPermissionSelectProps extends ModalFormProps<DataPermissionValues> {\n authorizeName?: string;\n rootParentKey?: number | string;\n values?: DataPermissionValues | null;\n treeList?: any[];\n }\n";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PermissionSelectTypes = "\n export interface UserListItem {\n deptEntity: any;\n userId: string;\n userCode: string;\n userName: string;\n password: string;\n nickName: string;\n userType?: string;\n email?: string;\n phone?: string;\n sex: string;\n status: string;\n avatar?: string;\n remark?: string;\n roles: RoleListItem[];\n permissions: any[];\n }\n\n export interface RoleListItem {\n userIds: any;\n roleId: string;\n roleCode: string;\n roleName: string;\n status: string;\n remark?: string;\n\n users: UserListItem[];\n permissions: any[];\n }\n\n export interface MenuItem {\n menuId: string;\n menuCode: string;\n menuName: string;\n icon: string;\n parentId: string;\n seqNo: number;\n path: string;\n menuType: string;\n status: string;\n remark?: string;\n }\n\n export interface PermissionItem {\n permissionId: string;\n permissionCode: string;\n permissionName: string;\n menuId: string;\n status: string;\n remark?: string;\n }\n\n /**\n * \u9ED8\u8BA4\u4F20\u5165\u7684\u6570\u636E\uFF0C\u9700\u8981\u4F20\u5165\u6743\u9650\u5217\u8868\n * \u4E5F\u53EF\u4EE5\u4F20\u5165\u89D2\u8272ID\u6216\u662F\u7528\u6237ID\n */\n export interface PermissionSelectItem {\n permissionIds: string[];\n }\n\n /**\n * \u9009\u62E9\u6743\u9650\u7EC4\u4EF6\u7684props\n */\n export interface PermissionSelectFormProps {\n rootParentKey?: number | string;\n modalFormVisible: boolean;\n setModalFormVisible: (visible: boolean) => void;\n onSubmit: (values: FormValueType) => Promise<void>;\n values?: PermissionSelectItem | any;\n onCancel: any;\n }\n\n export interface CurrentUser {\n userId: string;\n userCode: string;\n userName?: string;\n avatar?: string;\n status?: string;\n nickName: string;\n\n menus?: MenuItem[];\n permissions?: PermissionItem[];\n\n [prop: string]: any;\n }\n";
|
|
1
|
+
export declare const PermissionSelectTypes = "\n export interface UserListItem {\n deptEntity: any;\n userId: string;\n userCode: string;\n userName: string;\n password: string;\n nickName: string;\n userType?: string;\n email?: string;\n phone?: string;\n sex: string;\n status: string;\n avatar?: string;\n remark?: string;\n roles: RoleListItem[];\n permissions: any[];\n }\n\n export interface RoleListItem {\n userIds: any;\n roleId: string;\n roleCode: string;\n roleName: string;\n status: string;\n remark?: string;\n\n users: UserListItem[];\n permissions: any[];\n }\n\n export interface MenuItem {\n menuId: string;\n menuCode: string;\n menuName: string;\n icon: string;\n parentId: string;\n seqNo: number;\n path: string;\n menuType: string;\n status: string;\n remark?: string;\n }\n\n export interface PermissionItem {\n permissionId: string;\n permissionCode: string;\n permissionName: string;\n menuId: string;\n status: string;\n remark?: string;\n }\n\n /**\n * \u9ED8\u8BA4\u4F20\u5165\u7684\u6570\u636E\uFF0C\u9700\u8981\u4F20\u5165\u6743\u9650\u5217\u8868\n * \u4E5F\u53EF\u4EE5\u4F20\u5165\u89D2\u8272ID\u6216\u662F\u7528\u6237ID\n */\n export interface PermissionSelectItem {\n permissionIds: string[];\n }\n\n /**\n * \u9009\u62E9\u6743\u9650\u7EC4\u4EF6\u7684props\n */\n export interface PermissionSelectFormProps {\n authorizeName?: string;\n rootParentKey?: number | string;\n modalFormVisible: boolean;\n setModalFormVisible: (visible: boolean) => void;\n onSubmit: (values: FormValueType) => Promise<void>;\n values?: PermissionSelectItem | any;\n onCancel: any;\n }\n\n export interface CurrentUser {\n userId: string;\n userCode: string;\n userName?: string;\n avatar?: string;\n status?: string;\n nickName: string;\n\n menus?: MenuItem[];\n permissions?: PermissionItem[];\n\n [prop: string]: any;\n }\n";
|
|
@@ -4,4 +4,4 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.PermissionSelectTypes = void 0;
|
|
7
|
-
var PermissionSelectTypes = exports.PermissionSelectTypes = "\n export interface UserListItem {\n deptEntity: any;\n userId: string;\n userCode: string;\n userName: string;\n password: string;\n nickName: string;\n userType?: string;\n email?: string;\n phone?: string;\n sex: string;\n status: string;\n avatar?: string;\n remark?: string;\n roles: RoleListItem[];\n permissions: any[];\n }\n\n export interface RoleListItem {\n userIds: any;\n roleId: string;\n roleCode: string;\n roleName: string;\n status: string;\n remark?: string;\n\n users: UserListItem[];\n permissions: any[];\n }\n\n export interface MenuItem {\n menuId: string;\n menuCode: string;\n menuName: string;\n icon: string;\n parentId: string;\n seqNo: number;\n path: string;\n menuType: string;\n status: string;\n remark?: string;\n }\n\n export interface PermissionItem {\n permissionId: string;\n permissionCode: string;\n permissionName: string;\n menuId: string;\n status: string;\n remark?: string;\n }\n\n /**\n * \u9ED8\u8BA4\u4F20\u5165\u7684\u6570\u636E\uFF0C\u9700\u8981\u4F20\u5165\u6743\u9650\u5217\u8868\n * \u4E5F\u53EF\u4EE5\u4F20\u5165\u89D2\u8272ID\u6216\u662F\u7528\u6237ID\n */\n export interface PermissionSelectItem {\n permissionIds: string[];\n }\n\n /**\n * \u9009\u62E9\u6743\u9650\u7EC4\u4EF6\u7684props\n */\n export interface PermissionSelectFormProps {\n rootParentKey?: number | string;\n modalFormVisible: boolean;\n setModalFormVisible: (visible: boolean) => void;\n onSubmit: (values: FormValueType) => Promise<void>;\n values?: PermissionSelectItem | any;\n onCancel: any;\n }\n\n export interface CurrentUser {\n userId: string;\n userCode: string;\n userName?: string;\n avatar?: string;\n status?: string;\n nickName: string;\n\n menus?: MenuItem[];\n permissions?: PermissionItem[];\n\n [prop: string]: any;\n }\n";
|
|
7
|
+
var PermissionSelectTypes = exports.PermissionSelectTypes = "\n export interface UserListItem {\n deptEntity: any;\n userId: string;\n userCode: string;\n userName: string;\n password: string;\n nickName: string;\n userType?: string;\n email?: string;\n phone?: string;\n sex: string;\n status: string;\n avatar?: string;\n remark?: string;\n roles: RoleListItem[];\n permissions: any[];\n }\n\n export interface RoleListItem {\n userIds: any;\n roleId: string;\n roleCode: string;\n roleName: string;\n status: string;\n remark?: string;\n\n users: UserListItem[];\n permissions: any[];\n }\n\n export interface MenuItem {\n menuId: string;\n menuCode: string;\n menuName: string;\n icon: string;\n parentId: string;\n seqNo: number;\n path: string;\n menuType: string;\n status: string;\n remark?: string;\n }\n\n export interface PermissionItem {\n permissionId: string;\n permissionCode: string;\n permissionName: string;\n menuId: string;\n status: string;\n remark?: string;\n }\n\n /**\n * \u9ED8\u8BA4\u4F20\u5165\u7684\u6570\u636E\uFF0C\u9700\u8981\u4F20\u5165\u6743\u9650\u5217\u8868\n * \u4E5F\u53EF\u4EE5\u4F20\u5165\u89D2\u8272ID\u6216\u662F\u7528\u6237ID\n */\n export interface PermissionSelectItem {\n permissionIds: string[];\n }\n\n /**\n * \u9009\u62E9\u6743\u9650\u7EC4\u4EF6\u7684props\n */\n export interface PermissionSelectFormProps {\n authorizeName?: string;\n rootParentKey?: number | string;\n modalFormVisible: boolean;\n setModalFormVisible: (visible: boolean) => void;\n onSubmit: (values: FormValueType) => Promise<void>;\n values?: PermissionSelectItem | any;\n onCancel: any;\n }\n\n export interface CurrentUser {\n userId: string;\n userCode: string;\n userName?: string;\n avatar?: string;\n status?: string;\n nickName: string;\n\n menus?: MenuItem[];\n permissions?: PermissionItem[];\n\n [prop: string]: any;\n }\n";
|
|
@@ -8,6 +8,7 @@ export { EditMultiLangFormTypes } from "./EditMultiLangFormTypes";
|
|
|
8
8
|
export { MySelectTypes } from "./MySelectTypes";
|
|
9
9
|
export { MySelectLangTypes } from "./MySelectLangTypes";
|
|
10
10
|
export { PermissionSelectTypes } from "./PermissionSelectTypes";
|
|
11
|
+
export { DataPermissionSelectTypes } from "./DataPermissionSelectTypes";
|
|
11
12
|
export { DatePickerTypes } from "./DatePickerTypes";
|
|
12
13
|
export { RandomAvatarTypes } from "./RandomAvatarTypes";
|
|
13
14
|
export { RefDrawerFormTypes } from "./RefDrawerFormTypes";
|
package/dist/cjs/types/index.js
CHANGED
|
@@ -21,6 +21,12 @@ Object.defineProperty(exports, "CrudTableTypes", {
|
|
|
21
21
|
return _CrudTableTypes.CrudTableTypes;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
|
+
Object.defineProperty(exports, "DataPermissionSelectTypes", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function get() {
|
|
27
|
+
return _DataPermissionSelectTypes.DataPermissionSelectTypes;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
24
30
|
Object.defineProperty(exports, "DatePickerTypes", {
|
|
25
31
|
enumerable: true,
|
|
26
32
|
get: function get() {
|
|
@@ -223,6 +229,7 @@ var _EditMultiLangFormTypes = require("./EditMultiLangFormTypes");
|
|
|
223
229
|
var _MySelectTypes = require("./MySelectTypes");
|
|
224
230
|
var _MySelectLangTypes = require("./MySelectLangTypes");
|
|
225
231
|
var _PermissionSelectTypes = require("./PermissionSelectTypes");
|
|
232
|
+
var _DataPermissionSelectTypes = require("./DataPermissionSelectTypes");
|
|
226
233
|
var _DatePickerTypes = require("./DatePickerTypes");
|
|
227
234
|
var _RandomAvatarTypes = require("./RandomAvatarTypes");
|
|
228
235
|
var _RefDrawerFormTypes = require("./RefDrawerFormTypes");
|
package/dist/cjs/utils/utils.tpl
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { parse } from 'querystring';
|
|
2
|
-
import { getIntl, MenuItem } from '@umijs/max';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* 获取url参数,即浏览器地址栏问号后面的参数
|
|
@@ -24,3 +23,96 @@ export const getQueryToken = () => getPageQuery()?.token;
|
|
|
24
23
|
* @returns {boolean}
|
|
25
24
|
*/
|
|
26
25
|
export const isFullPage = () => getPageQuery()?.s?.slice(0, 1) === 'f' || isSharePage();
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
type ArrayToTreeOptions<T = unknown, R = T> = {
|
|
29
|
+
id?: string;
|
|
30
|
+
parentId?: string;
|
|
31
|
+
rootId?: string | number;
|
|
32
|
+
/**
|
|
33
|
+
* 将每个节点映射为自定义结构(如 Ant Design Tree 的 { title, key, children })。
|
|
34
|
+
* 先递归处理子节点再调用本函数;叶子节点 mappedChildren 为 undefined。
|
|
35
|
+
*/
|
|
36
|
+
mapNode?: (item: T, mappedChildren: R[] | undefined) => R;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* 深度优先遍历节点列表,并映射为自定义结构
|
|
41
|
+
* @param nodes 节点列表
|
|
42
|
+
* @param mapNode 映射函数
|
|
43
|
+
* @returns 映射后的节点列表
|
|
44
|
+
*/
|
|
45
|
+
function mapTreeDepthFirst<T, R>(nodes: Array<T & { children?: T[] }>, mapNode: (item: T, mappedChildren: R[] | undefined) => R): R[] {
|
|
46
|
+
return nodes.map((n) => {
|
|
47
|
+
const rawChildren = n.children;
|
|
48
|
+
const hasChildren = Array.isArray(rawChildren) && rawChildren.length > 0;
|
|
49
|
+
const mappedChildren = hasChildren
|
|
50
|
+
? mapTreeDepthFirst(rawChildren as Array<T & { children?: T[] }>, mapNode)
|
|
51
|
+
: undefined;
|
|
52
|
+
|
|
53
|
+
// 移除 children 属性,保留item其他属性
|
|
54
|
+
const { children: _omit, ...rest } = n as T & { children?: T[] };
|
|
55
|
+
return mapNode(rest as T, mappedChildren?.length ? mappedChildren : undefined);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const defaultArrayToTreeOptions = {
|
|
60
|
+
id: 'id',
|
|
61
|
+
parentId: 'parentId',
|
|
62
|
+
rootId: 0,
|
|
63
|
+
} as const;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* 列表转树节点
|
|
67
|
+
* @param items
|
|
68
|
+
* @param options id / parentId / rootId;可选 mapNode 映射为业务结构(如 DataNode)
|
|
69
|
+
* @returns 未传 mapNode 时为带 children 的 T[];传入 mapNode 时为 R[]
|
|
70
|
+
*/
|
|
71
|
+
export function arrayToTree<T, R = T>(
|
|
72
|
+
items: T[],
|
|
73
|
+
options: ArrayToTreeOptions<T, R> = defaultArrayToTreeOptions as ArrayToTreeOptions<T, R>,
|
|
74
|
+
): R[] {
|
|
75
|
+
const { mapNode, rootId: optRootId, id: idKey = 'id', parentId: parentKey = 'parentId' } = options;
|
|
76
|
+
const rootId = (optRootId ?? 0).toString();
|
|
77
|
+
|
|
78
|
+
const result: T[] = []; // 存放结果集
|
|
79
|
+
const itemMap: any = {};
|
|
80
|
+
items.forEach((item: any) => {
|
|
81
|
+
const id = item[idKey as string]?.toString();
|
|
82
|
+
const pid = item[parentKey as string]?.toString();
|
|
83
|
+
|
|
84
|
+
if (!itemMap[id]) {
|
|
85
|
+
itemMap[id] = {
|
|
86
|
+
children: [],
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
itemMap[id] = {
|
|
91
|
+
...item,
|
|
92
|
+
children: itemMap[id]['children'],
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const treeItem = itemMap[id];
|
|
96
|
+
|
|
97
|
+
if (pid === rootId || !pid) {
|
|
98
|
+
//根节点
|
|
99
|
+
result.push(treeItem);
|
|
100
|
+
} else {
|
|
101
|
+
//非节点
|
|
102
|
+
if (!itemMap[pid]) {
|
|
103
|
+
itemMap[pid] = {
|
|
104
|
+
children: [],
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
//由于itemMap是引用值,有映射关系,因此此处push进去后result也有
|
|
108
|
+
itemMap[pid].children.push(treeItem);
|
|
109
|
+
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
if (mapNode) {
|
|
114
|
+
return mapTreeDepthFirst(result as Array<T & { children?: T[] }>, mapNode);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return result as unknown as R[];
|
|
118
|
+
}
|
|
@@ -6,5 +6,5 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _default = exports.default = {
|
|
8
8
|
path: "index.tsx",
|
|
9
|
-
content: "\n // \u5BFC\u5165\u7EC4\u4EF6\n import QrCodeModal from \"./components/QrCodeModal\";\n import CreateForm from \"./components/AddDrawerForm\";\n import MyFooterToolbar from \"./components/MyFooterToolbar\";\n import DropdownButton from \"./components/DropdownButton\";\n import DynamicIcon, { getAntdIconList } from \"./components/DynamicIcon\";\n import DynamicIconModal from \"./components/DynamicIconModal\";\n import HighlightStr from \"./components/HighlightStr\";\n import EditMultiLangForm from \"./components/EditMultiLangForm\";\n import MyColorPicker from \"./components/MyColorPicker\";\n import MySelect from \"./components/MySelect\";\n import MySelectLang from \"./components/MySelectLang\";\n import PermissionSelect from \"./components/PermissionSelect\";\n import UTCDatePicker from \"./components/UTCDatePicker\";\n import ProFormUTCDatePicker from \"./components/ProFormUTCDatePicker\";\n import UTCRangePicker from \"./components/UTCRangePicker\";\n import ProFormUTCRangePicker from \"./components/ProFormUTCRangePicker\";\n import RandomAvatar from \"./components/RandomAvatar\";\n import RefDrawerForm from \"./components/RefDrawerForm\";\n import UpdateForm from \"./components/UpdateForm\";\n import ViewTableItemDrawer from \"./components/ViewTableItemDrawer\";\n import WangEditor from \"./components/WangEditor\";\n import WangEditorView from \"./components/WangEditorView\";\n import MyUpload from \"./components/MyUpload\";\n import CopyButton from \"./components/CopyButton\";\n import ImportExecl from \"./components/ImportExecl\";\n import MyPageContainer from \"./components/MyPageContainer\";\n import MyReactEcharts from \"./components/MyReactEcharts\";\n import MyTagList from \"./components/MyTagList\";\n import VolumeFormItem from \"./components/VolumeFormItem\";\n import ReportTable from \"./components/ReportTable\";\n import DicDropDownList from \"./components/DicDropDownList\";\n import ActionLogDrawer from \"./components/ActionLogDrawer\";\n import DndTabs from \"./components/DndTabs\";\n import DndTag from \"./components/DndTag\";\n import TimeTypeSelect from \"./components/TimeTypeSelect\";\n import ImportDataUpload from \"./components/ImportDataUpload\";\n import PDFWrapper from \"./components/PDFWrapper\";\n import ExportPageWrapper from \"./components/ExportPageWrapper\";\n import { PageExporter } from \"./utils/exportPage\";\n import MySetps from \"./components/MySetps\";\n import CrudTable from \"./components/CrudTable\";\n\n import MenuFooter from \"./components/MenuFooter\";\n import GlobalHeader from \"./components/GlobalHeader\";\n import GlobalFooter from \"./components/GlobalFooter\";\n import AvatarDropdown from \"./components/AvatarDropdown\";\n import HeaderSearch from \"./components/HeaderSearch\";\n import ThemeSwitch from \"./components/ThemeSwitch\";\n import KeepAliveTabs from \"./components/KeepAliveTabs\";\n import KeepAliveDndTabs from \"./components/KeepAliveDndTabs\";\n\n import Authorized from \"./components/Authorized\";\n import AuthorizedRoute from \"./components/AuthorizedRoute\";\n import AuthorizeRender from \"./components/AuthorizeRender\";\n import CheckPermissions from \"./components/CheckPermissions\";\n import PromiseRender from \"./components/PromiseRender\";\n import Secured from \"./components/Secured\";\n import renderAuthorize from \"./components/renderAuthorize\";\n import { getAuthorityFunction } from \"./utils/authorityFunction\";\n\n import LoadingSvg from \"./components/LoadingSvg\";\n import PageLoading from \"./components/PageLoading\";\n import NoFoundPage from \"./components/NoFoundPage\";\n import UserDisable from \"./components/UserDisable\";\n import UserNoPermission from \"./components/UserNoPermission\";\n import UserNoPagePermission from \"./components/UserNoPagePermission\";\n\n import useAction from \"./hooks/useAction\";\n import useFormatLocale from \"./hooks/useFormatLocale\";\n import useActionLocales from \"./hooks/useActionLocales\";\n import useQueryTableList from \"./hooks/useQueryTableList\";\n import useAuthority from \"./hooks/useAuthority\";\n import useColumnTitle, { useBatchColumnTitles } from \"./hooks/useColumnTitle\";\n import useMemoizedFn from \"./hooks/useMemoizedFn\";\n import { useKeepAliveTabs } from \"./hooks/useKeepAliveTabs\";\n import { usePageExport } from \"./hooks/usePageExport\";\n import { useRouteAuth } from \"./hooks/useRouteAuth\";\n\n // \u5BFC\u51FAhooks\n export {\n useAction,\n useFormatLocale,\n useActionLocales,\n useQueryTableList,\n useAuthority,\n useColumnTitle,\n useBatchColumnTitles,\n useMemoizedFn,\n useKeepAliveTabs,\n usePageExport,\n useRouteAuth,\n }\n\n // \u5BFC\u51FA\u7EC4\u4EF6\n export { \n QrCodeModal, \n CreateForm, \n MyFooterToolbar,\n DropdownButton,\n DynamicIcon,\n DynamicIconModal,\n HighlightStr,\n getAntdIconList,\n EditMultiLangForm,\n MyColorPicker,\n MySelect,\n MySelectLang,\n PermissionSelect,\n UTCDatePicker,\n ProFormUTCDatePicker,\n UTCRangePicker,\n ProFormUTCRangePicker,\n RandomAvatar,\n RefDrawerForm,\n UpdateForm,\n ViewTableItemDrawer,\n WangEditor,\n WangEditorView,\n MyUpload,\n CopyButton,\n ImportExecl,\n MyPageContainer,\n MyReactEcharts,\n MyTagList,\n VolumeFormItem,\n ReportTable,\n DicDropDownList,\n ActionLogDrawer,\n DndTabs,\n DndTag,\n TimeTypeSelect,\n ImportDataUpload,\n PDFWrapper,\n ExportPageWrapper,\n PageExporter,\n MySetps,\n CrudTable,\n\n MenuFooter,\n GlobalHeader,\n GlobalFooter,\n AvatarDropdown,\n HeaderSearch,\n ThemeSwitch,\n KeepAliveTabs,\n KeepAliveDndTabs,\n \n Authorized,\n AuthorizedRoute,\n AuthorizeRender,\n CheckPermissions,\n PromiseRender,\n Secured,\n renderAuthorize,\n getAuthorityFunction,\n\n PageLoading,\n LoadingSvg,\n NoFoundPage,\n UserDisable,\n UserNoPermission,\n UserNoPagePermission,\n };\n "
|
|
9
|
+
content: "\n // \u5BFC\u5165\u7EC4\u4EF6\n import QrCodeModal from \"./components/QrCodeModal\";\n import CreateForm from \"./components/AddDrawerForm\";\n import MyFooterToolbar from \"./components/MyFooterToolbar\";\n import DropdownButton from \"./components/DropdownButton\";\n import DynamicIcon, { getAntdIconList } from \"./components/DynamicIcon\";\n import DynamicIconModal from \"./components/DynamicIconModal\";\n import HighlightStr from \"./components/HighlightStr\";\n import EditMultiLangForm from \"./components/EditMultiLangForm\";\n import MyColorPicker from \"./components/MyColorPicker\";\n import MySelect from \"./components/MySelect\";\n import MySelectLang from \"./components/MySelectLang\";\n import PermissionSelect from \"./components/PermissionSelect\";\n import DataPermissionSelect from \"./components/DataPermissionSelect\";\n import UTCDatePicker from \"./components/UTCDatePicker\";\n import ProFormUTCDatePicker from \"./components/ProFormUTCDatePicker\";\n import UTCRangePicker from \"./components/UTCRangePicker\";\n import ProFormUTCRangePicker from \"./components/ProFormUTCRangePicker\";\n import RandomAvatar from \"./components/RandomAvatar\";\n import RefDrawerForm from \"./components/RefDrawerForm\";\n import UpdateForm from \"./components/UpdateForm\";\n import ViewTableItemDrawer from \"./components/ViewTableItemDrawer\";\n import WangEditor from \"./components/WangEditor\";\n import WangEditorView from \"./components/WangEditorView\";\n import MyUpload from \"./components/MyUpload\";\n import CopyButton from \"./components/CopyButton\";\n import ImportExecl from \"./components/ImportExecl\";\n import MyPageContainer from \"./components/MyPageContainer\";\n import MyReactEcharts from \"./components/MyReactEcharts\";\n import MyTagList from \"./components/MyTagList\";\n import VolumeFormItem from \"./components/VolumeFormItem\";\n import ReportTable from \"./components/ReportTable\";\n import DicDropDownList from \"./components/DicDropDownList\";\n import ActionLogDrawer from \"./components/ActionLogDrawer\";\n import DndTabs from \"./components/DndTabs\";\n import DndTag from \"./components/DndTag\";\n import TimeTypeSelect from \"./components/TimeTypeSelect\";\n import ImportDataUpload from \"./components/ImportDataUpload\";\n import PDFWrapper from \"./components/PDFWrapper\";\n import ExportPageWrapper from \"./components/ExportPageWrapper\";\n import { PageExporter } from \"./utils/exportPage\";\n import MySetps from \"./components/MySetps\";\n import CrudTable from \"./components/CrudTable\";\n\n import MenuFooter from \"./components/MenuFooter\";\n import GlobalHeader from \"./components/GlobalHeader\";\n import GlobalFooter from \"./components/GlobalFooter\";\n import AvatarDropdown from \"./components/AvatarDropdown\";\n import HeaderSearch from \"./components/HeaderSearch\";\n import ThemeSwitch from \"./components/ThemeSwitch\";\n import KeepAliveTabs from \"./components/KeepAliveTabs\";\n import KeepAliveDndTabs from \"./components/KeepAliveDndTabs\";\n\n import Authorized from \"./components/Authorized\";\n import AuthorizedRoute from \"./components/AuthorizedRoute\";\n import AuthorizeRender from \"./components/AuthorizeRender\";\n import CheckPermissions from \"./components/CheckPermissions\";\n import PromiseRender from \"./components/PromiseRender\";\n import Secured from \"./components/Secured\";\n import renderAuthorize from \"./components/renderAuthorize\";\n import { getAuthorityFunction } from \"./utils/authorityFunction\";\n\n import LoadingSvg from \"./components/LoadingSvg\";\n import PageLoading from \"./components/PageLoading\";\n import NoFoundPage from \"./components/NoFoundPage\";\n import UserDisable from \"./components/UserDisable\";\n import UserNoPermission from \"./components/UserNoPermission\";\n import UserNoPagePermission from \"./components/UserNoPagePermission\";\n\n import useAction from \"./hooks/useAction\";\n import useFormatLocale from \"./hooks/useFormatLocale\";\n import useActionLocales from \"./hooks/useActionLocales\";\n import useQueryTableList from \"./hooks/useQueryTableList\";\n import useAuthority from \"./hooks/useAuthority\";\n import useColumnTitle, { useBatchColumnTitles } from \"./hooks/useColumnTitle\";\n import useMemoizedFn from \"./hooks/useMemoizedFn\";\n import { useKeepAliveTabs } from \"./hooks/useKeepAliveTabs\";\n import { usePageExport } from \"./hooks/usePageExport\";\n import { useRouteAuth } from \"./hooks/useRouteAuth\";\n\n // \u5BFC\u51FAhooks\n export {\n useAction,\n useFormatLocale,\n useActionLocales,\n useQueryTableList,\n useAuthority,\n useColumnTitle,\n useBatchColumnTitles,\n useMemoizedFn,\n useKeepAliveTabs,\n usePageExport,\n useRouteAuth,\n }\n\n // \u5BFC\u51FA\u7EC4\u4EF6\n export { \n QrCodeModal, \n CreateForm, \n MyFooterToolbar,\n DropdownButton,\n DynamicIcon,\n DynamicIconModal,\n HighlightStr,\n getAntdIconList,\n EditMultiLangForm,\n MyColorPicker,\n MySelect,\n MySelectLang,\n PermissionSelect,\n DataPermissionSelect,\n UTCDatePicker,\n ProFormUTCDatePicker,\n UTCRangePicker,\n ProFormUTCRangePicker,\n RandomAvatar,\n RefDrawerForm,\n UpdateForm,\n ViewTableItemDrawer,\n WangEditor,\n WangEditorView,\n MyUpload,\n CopyButton,\n ImportExecl,\n MyPageContainer,\n MyReactEcharts,\n MyTagList,\n VolumeFormItem,\n ReportTable,\n DicDropDownList,\n ActionLogDrawer,\n DndTabs,\n DndTag,\n TimeTypeSelect,\n ImportDataUpload,\n PDFWrapper,\n ExportPageWrapper,\n PageExporter,\n MySetps,\n CrudTable,\n\n MenuFooter,\n GlobalHeader,\n GlobalFooter,\n AvatarDropdown,\n HeaderSearch,\n ThemeSwitch,\n KeepAliveTabs,\n KeepAliveDndTabs,\n \n Authorized,\n AuthorizedRoute,\n AuthorizeRender,\n CheckPermissions,\n PromiseRender,\n Secured,\n renderAuthorize,\n getAuthorityFunction,\n\n PageLoading,\n LoadingSvg,\n NoFoundPage,\n UserDisable,\n UserNoPermission,\n UserNoPagePermission,\n };\n "
|
|
10
10
|
};
|
|
@@ -8,5 +8,5 @@ var _types = require("../types");
|
|
|
8
8
|
// 修改方法,不再尝试读取外部文件
|
|
9
9
|
var _default = exports.default = {
|
|
10
10
|
path: 'types.d.ts',
|
|
11
|
-
content: "\n import React from 'react';\n import { ModalProps, DrawerProps, SelectProps, DatePickerProps, UploadProps, UploadFile, TooltipProps, ButtonProps, TabsProps, SwitchProps, FloatButtonProps, StepsProps, FlexProps, TagProps } from 'antd';\n import { PresetColorType, PresetStatusColorType } from \"antd/lib/_util/colors\";\n import { AutoCompleteProps } from 'antd/es/auto-complete';\n import { RangePickerProps } from 'antd/lib/date-picker';\n import { LiteralUnion } from \"antd/lib/_util/type\";\n import { IconComponentProps } from '@ant-design/icons/lib/components/Icon';\n import { ActionType, ProFormItemProps, ProColumns, ProTableProps, DrawerFormProps, PageContainerProps } from '@ant-design/pro-components';\n import dayjs, { OpUnitType } from 'dayjs';\n import { IEditorConfig, IToolbarConfig } from '@wangeditor/editor';\n import type { DragEndEvent } from '@dnd-kit/core';\n import { fileTypeMap } from './components'; \n\n\n ".concat(_types.servicesTypes, "\n\n ").concat(_types.HighlightStrTypes, "\n\n ").concat(_types.DropdownButtonTypes, "\n\n ").concat(_types.DynamicIconTypes, "\n\n ").concat(_types.MyFooterToolbarTypes, "\n\n ").concat(_types.QrCodeModalTypes, "\n\n ").concat(_types.MenuFooterTypes, "\n\n ").concat(_types.EditMultiLangFormTypes, "\n\n ").concat(_types.MySelectTypes, "\n\n ").concat(_types.MySelectLangTypes, "\n\n ").concat(_types.PermissionSelectTypes, "\n\n ").concat(_types.DatePickerTypes, "\n\n ").concat(_types.RandomAvatarTypes, "\n\n ").concat(_types.RefDrawerFormTypes, "\n\n ").concat(_types.ViewTableItemDrawerTypes, "\n\n ").concat(_types.WangEditorTypes, "\n\n ").concat(_types.MyPageContainerTypes, "\n\n ").concat(_types.MyTagListTypes, "\n\n ").concat(_types.VolumeFormItemTypes, "\n\n ").concat(_types.ImportExeclTypes, "\n\n ").concat(_types.MyUploadTypes, "\n\n ").concat(_types.ReportTableTypes, "\n\n ").concat(_types.DicDropDownListTypes, "\n\n ").concat(_types.ActionLogDrawerTypes, "\n\n ").concat(_types.DndTabsTypes, "\n\n ").concat(_types.ImportDataUploadTypes, "\n\n ").concat(_types.AvatarDropdownTypes, "\n\n ").concat(_types.HeaderSearchTypes, "\n\n ").concat(_types.ThemeSwitchTypes, "\n\n ").concat(_types.GlobalHeaderTypes, "\n\n ").concat(_types.KeepAliveTabsTypes, "\n\n ").concat(_types.ExportPageWrapperTypes, "\n\n ").concat(_types.MySetpsTypes, "\n\n ").concat(_types.CrudTableTypes, "\n\n ").concat(_types.DndTagTypes, "\n ")
|
|
11
|
+
content: "\n import React from 'react';\n import { ModalProps, DrawerProps, SelectProps, DatePickerProps, UploadProps, UploadFile, TooltipProps, ButtonProps, TabsProps, SwitchProps, FloatButtonProps, StepsProps, FlexProps, TagProps } from 'antd';\n import { PresetColorType, PresetStatusColorType } from \"antd/lib/_util/colors\";\n import { AutoCompleteProps } from 'antd/es/auto-complete';\n import { RangePickerProps } from 'antd/lib/date-picker';\n import { LiteralUnion } from \"antd/lib/_util/type\";\n import { IconComponentProps } from '@ant-design/icons/lib/components/Icon';\n import { ActionType, ProFormItemProps, ProColumns, ProTableProps, DrawerFormProps, ModalFormProps, PageContainerProps } from '@ant-design/pro-components';\n import dayjs, { OpUnitType } from 'dayjs';\n import { IEditorConfig, IToolbarConfig } from '@wangeditor/editor';\n import type { DragEndEvent } from '@dnd-kit/core';\n import { fileTypeMap } from './components'; \n\n\n ".concat(_types.servicesTypes, "\n\n ").concat(_types.HighlightStrTypes, "\n\n ").concat(_types.DropdownButtonTypes, "\n\n ").concat(_types.DynamicIconTypes, "\n\n ").concat(_types.MyFooterToolbarTypes, "\n\n ").concat(_types.QrCodeModalTypes, "\n\n ").concat(_types.MenuFooterTypes, "\n\n ").concat(_types.EditMultiLangFormTypes, "\n\n ").concat(_types.MySelectTypes, "\n\n ").concat(_types.MySelectLangTypes, "\n\n ").concat(_types.PermissionSelectTypes, "\n\n ").concat(_types.DataPermissionSelectTypes, "\n\n ").concat(_types.DatePickerTypes, "\n\n ").concat(_types.RandomAvatarTypes, "\n\n ").concat(_types.RefDrawerFormTypes, "\n\n ").concat(_types.ViewTableItemDrawerTypes, "\n\n ").concat(_types.WangEditorTypes, "\n\n ").concat(_types.MyPageContainerTypes, "\n\n ").concat(_types.MyTagListTypes, "\n\n ").concat(_types.VolumeFormItemTypes, "\n\n ").concat(_types.ImportExeclTypes, "\n\n ").concat(_types.MyUploadTypes, "\n\n ").concat(_types.ReportTableTypes, "\n\n ").concat(_types.DicDropDownListTypes, "\n\n ").concat(_types.ActionLogDrawerTypes, "\n\n ").concat(_types.DndTabsTypes, "\n\n ").concat(_types.ImportDataUploadTypes, "\n\n ").concat(_types.AvatarDropdownTypes, "\n\n ").concat(_types.HeaderSearchTypes, "\n\n ").concat(_types.ThemeSwitchTypes, "\n\n ").concat(_types.GlobalHeaderTypes, "\n\n ").concat(_types.KeepAliveTabsTypes, "\n\n ").concat(_types.ExportPageWrapperTypes, "\n\n ").concat(_types.MySetpsTypes, "\n\n ").concat(_types.CrudTableTypes, "\n\n ").concat(_types.DndTagTypes, "\n ")
|
|
12
12
|
};
|
|
@@ -699,7 +699,7 @@ function CrudTable<T extends Record<string, any>, U = {}, C = {}>(
|
|
|
699
699
|
label: (
|
|
700
700
|
<a onClick={handleDownloadTemplate} key="templateDownload">
|
|
701
701
|
<DownloadOutlined style={{ marginRight: 6 }} />
|
|
702
|
-
{formatMessage({ id: 'cfmmUI.common.button.
|
|
702
|
+
{formatMessage({ id: 'cfmmUI.common.button.templateDownload', defaultMessage: '下载模板' })}
|
|
703
703
|
</a>
|
|
704
704
|
),
|
|
705
705
|
},
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { ModalForm, ProFormCheckbox, ProFormSelect } from '@ant-design/pro-components';
|
|
2
|
+
import { useIntl } from '@umijs/max';
|
|
3
|
+
import { Form, Tree } from 'antd';
|
|
4
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
5
|
+
import { arrayToTree } from '../utils/utils';
|
|
6
|
+
import { DataPermissionSelectProps, DataScopeEnum, DeptCheckStrictlyEnum } from "../types.d";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 数据权限选择组件
|
|
10
|
+
* @param {DataPermissionSelectProps} props
|
|
11
|
+
* @param {string} props.authorizeName 授权名称
|
|
12
|
+
* @param {number | string} props.rootParentKey 根节点ID
|
|
13
|
+
* @param {any[]} props.treeList 组织树列表
|
|
14
|
+
* @param {Function} props.onFinish 提交回调
|
|
15
|
+
* @param {ModalFormProps} restProps ModalForm其他属性
|
|
16
|
+
*/
|
|
17
|
+
const DataPermissionSelect = (props: DataPermissionSelectProps) => {
|
|
18
|
+
const [form] = Form.useForm();
|
|
19
|
+
const { formatMessage } = useIntl();
|
|
20
|
+
const { values, authorizeName, rootParentKey, treeList, onFinish, ...restProps } = props;
|
|
21
|
+
const [selectPermissionList, setSelectPermissionList] = useState<React.Key[]>([]);
|
|
22
|
+
const [expandedKeys, setExpandedKeys] = useState<React.Key[]>([]);
|
|
23
|
+
// 父子联动
|
|
24
|
+
const [deptCheckStrictly, setDeptCheckStrictly] = useState<boolean>(false);
|
|
25
|
+
// 是否显示树
|
|
26
|
+
const [showTree, setShowTree] = useState<boolean>(true);
|
|
27
|
+
const [submitting, setSubmitting] = useState<boolean>(false);
|
|
28
|
+
|
|
29
|
+
const menuTreeDate = useMemo(() => {
|
|
30
|
+
if (!treeList) return [];
|
|
31
|
+
|
|
32
|
+
return arrayToTree(treeList, {
|
|
33
|
+
id: 'deptId',
|
|
34
|
+
rootId: rootParentKey,
|
|
35
|
+
mapNode: (item, children) => ({
|
|
36
|
+
title: item.deptName,
|
|
37
|
+
key: item.deptId,
|
|
38
|
+
children: children?.length ? children : undefined,
|
|
39
|
+
}),
|
|
40
|
+
});
|
|
41
|
+
}, [treeList]);
|
|
42
|
+
|
|
43
|
+
const allKeys = useMemo(() => treeList?.map((item) => item.deptId) ?? [], [treeList]);
|
|
44
|
+
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
if (values) {
|
|
47
|
+
setSelectPermissionList(values.deptIds ?? []);
|
|
48
|
+
|
|
49
|
+
const deptCheckStrictlyValues = values.deptCheckStrictly ?
|
|
50
|
+
[DeptCheckStrictlyEnum.FOLD, DeptCheckStrictlyEnum.SELECT_ALL] :
|
|
51
|
+
[DeptCheckStrictlyEnum.FOLD];
|
|
52
|
+
|
|
53
|
+
setDeptCheckStrictly(deptCheckStrictlyValues.includes(DeptCheckStrictlyEnum.SELECT_ALL));
|
|
54
|
+
setShowTree(values.dataScope === DataScopeEnum.CUSTOM);
|
|
55
|
+
|
|
56
|
+
form.setFieldsValue({
|
|
57
|
+
dataScope: values.dataScope ?? DataScopeEnum.CUSTOM,
|
|
58
|
+
deptCheckStrictly: deptCheckStrictlyValues,
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
}, [values]);
|
|
62
|
+
|
|
63
|
+
// 数据加载后默认展开全部
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
setExpandedKeys(allKeys);
|
|
66
|
+
}, [allKeys]);
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* 提交方法
|
|
70
|
+
*/
|
|
71
|
+
const handleSubmit = async () => {
|
|
72
|
+
if (submitting) {
|
|
73
|
+
return; //如果在提交 就直接返回
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
setSubmitting(true);
|
|
77
|
+
|
|
78
|
+
const values = form.getFieldsValue();
|
|
79
|
+
|
|
80
|
+
const submitParams = {
|
|
81
|
+
...values,
|
|
82
|
+
deptCheckStrictly,
|
|
83
|
+
deptIds: selectPermissionList
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
//调用父级的方法
|
|
87
|
+
const success = await onFinish?.(submitParams);
|
|
88
|
+
|
|
89
|
+
setSubmitting(false);
|
|
90
|
+
|
|
91
|
+
if (success) {
|
|
92
|
+
//弹出框关闭后,清除选择的数据
|
|
93
|
+
setSelectPermissionList([]);
|
|
94
|
+
}
|
|
95
|
+
return success;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
return (
|
|
99
|
+
<ModalForm form={form}
|
|
100
|
+
width={700}
|
|
101
|
+
title={authorizeName ? `${formatMessage({
|
|
102
|
+
id: 'cfmmUI.DataPermissionSelect.title',
|
|
103
|
+
defaultMessage: '选择数据权限范围',
|
|
104
|
+
})} - ${authorizeName}` : `${formatMessage({
|
|
105
|
+
id: 'cfmmUI.DataPermissionSelect.title',
|
|
106
|
+
defaultMessage: '选择数据权限范围',
|
|
107
|
+
})}`}
|
|
108
|
+
//关闭弹窗清除数据
|
|
109
|
+
modalProps={{
|
|
110
|
+
destroyOnHidden: true,
|
|
111
|
+
}}
|
|
112
|
+
layout="horizontal"
|
|
113
|
+
labelCol={{ span: 5 }}
|
|
114
|
+
wrapperCol={{ span: 16 }}
|
|
115
|
+
onFinish={handleSubmit}
|
|
116
|
+
{...restProps}
|
|
117
|
+
>
|
|
118
|
+
<ProFormSelect
|
|
119
|
+
name="dataScope"
|
|
120
|
+
label={formatMessage({
|
|
121
|
+
id: 'cfmmUI.DataPermissionSelect.dataScope',
|
|
122
|
+
defaultMessage: '权限范围',
|
|
123
|
+
})}
|
|
124
|
+
initialValue={DataScopeEnum.CUSTOM}
|
|
125
|
+
allowClear={false}
|
|
126
|
+
fieldProps={{
|
|
127
|
+
options: [
|
|
128
|
+
{ label: formatMessage({
|
|
129
|
+
id: 'cfmmUI.DataPermissionSelect.dataScope.all',
|
|
130
|
+
defaultMessage: '全部数据权限',
|
|
131
|
+
}), value: DataScopeEnum.ALL },
|
|
132
|
+
{ label: formatMessage({
|
|
133
|
+
id: 'cfmmUI.DataPermissionSelect.dataScope.custom',
|
|
134
|
+
defaultMessage: '自定义数据权限',
|
|
135
|
+
}), value: DataScopeEnum.CUSTOM },
|
|
136
|
+
{ label: formatMessage({
|
|
137
|
+
id: 'cfmmUI.DataPermissionSelect.dataScope.dept',
|
|
138
|
+
defaultMessage: '本部门数据权限',
|
|
139
|
+
}), value: DataScopeEnum.DEPT },
|
|
140
|
+
{ label: formatMessage({
|
|
141
|
+
id: 'cfmmUI.DataPermissionSelect.dataScope.deptAndSub',
|
|
142
|
+
defaultMessage: '本部门及以下数据权限',
|
|
143
|
+
}), value: DataScopeEnum.DEPT_AND_SUB },
|
|
144
|
+
{ label: formatMessage({
|
|
145
|
+
id: 'cfmmUI.DataPermissionSelect.dataScope.onlySelf',
|
|
146
|
+
defaultMessage: '仅本人数据权限',
|
|
147
|
+
}), value: DataScopeEnum.ONLY_SELF },
|
|
148
|
+
],
|
|
149
|
+
onChange: (value) => {
|
|
150
|
+
if (value === DataScopeEnum.CUSTOM) {
|
|
151
|
+
setShowTree(true);
|
|
152
|
+
} else {
|
|
153
|
+
setShowTree(false);
|
|
154
|
+
setSelectPermissionList([]);
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
}} />
|
|
158
|
+
|
|
159
|
+
{
|
|
160
|
+
showTree && (
|
|
161
|
+
<>
|
|
162
|
+
<ProFormCheckbox.Group
|
|
163
|
+
name="deptCheckStrictly"
|
|
164
|
+
label={formatMessage({
|
|
165
|
+
id: 'cfmmUI.DataPermissionSelect.dataPermission',
|
|
166
|
+
defaultMessage: '数据权限',
|
|
167
|
+
})}
|
|
168
|
+
initialValue={[DeptCheckStrictlyEnum.FOLD]}
|
|
169
|
+
fieldProps={{
|
|
170
|
+
// defaultValue: [DeptCheckStrictlyEnum.FOLD],
|
|
171
|
+
options: [
|
|
172
|
+
{ label: formatMessage({
|
|
173
|
+
id: 'cfmmUI.DataPermissionSelect.dataPermission.fold',
|
|
174
|
+
defaultMessage: '折叠/展开',
|
|
175
|
+
}), value: DeptCheckStrictlyEnum.FOLD },
|
|
176
|
+
{ label: formatMessage({
|
|
177
|
+
id: 'cfmmUI.DataPermissionSelect.dataPermission.selectAll',
|
|
178
|
+
defaultMessage: '全选/全不选',
|
|
179
|
+
}), value: DeptCheckStrictlyEnum.SELECT_ALL },
|
|
180
|
+
{ label: formatMessage({
|
|
181
|
+
id: 'cfmmUI.DataPermissionSelect.dataPermission.parentChild',
|
|
182
|
+
defaultMessage: '父子联动',
|
|
183
|
+
}), value: DeptCheckStrictlyEnum.PARENT_CHILD },
|
|
184
|
+
],
|
|
185
|
+
onChange: (checkedValues) => {
|
|
186
|
+
setExpandedKeys(checkedValues.includes(DeptCheckStrictlyEnum.FOLD) ? allKeys : []);
|
|
187
|
+
setSelectPermissionList(checkedValues.includes(DeptCheckStrictlyEnum.SELECT_ALL) ? allKeys : []);
|
|
188
|
+
setDeptCheckStrictly(checkedValues.includes(DeptCheckStrictlyEnum.PARENT_CHILD));
|
|
189
|
+
},
|
|
190
|
+
}}
|
|
191
|
+
/>
|
|
192
|
+
<Form.Item
|
|
193
|
+
// name="deptIds"
|
|
194
|
+
wrapperCol={{ offset: 5, span: 16 }}
|
|
195
|
+
>
|
|
196
|
+
<Tree
|
|
197
|
+
style={{
|
|
198
|
+
border: '1px solid #d9d9d9',
|
|
199
|
+
borderRadius: 8,
|
|
200
|
+
maxHeight: "calc(100vh - 450px)",
|
|
201
|
+
overflow: 'auto',
|
|
202
|
+
}}
|
|
203
|
+
checkable
|
|
204
|
+
expandedKeys={expandedKeys}
|
|
205
|
+
onExpand={setExpandedKeys}
|
|
206
|
+
checkedKeys={selectPermissionList}
|
|
207
|
+
treeData={menuTreeDate}
|
|
208
|
+
checkStrictly={true}
|
|
209
|
+
// @ts-ignore
|
|
210
|
+
onCheck={(checkedKeys) => {
|
|
211
|
+
const keys = Array.isArray(checkedKeys) ? checkedKeys : checkedKeys.checked;
|
|
212
|
+
setSelectPermissionList(keys)
|
|
213
|
+
}}
|
|
214
|
+
/>
|
|
215
|
+
</Form.Item>
|
|
216
|
+
</>
|
|
217
|
+
)
|
|
218
|
+
}
|
|
219
|
+
</ModalForm>
|
|
220
|
+
);
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
export default React.memo(DataPermissionSelect) as typeof DataPermissionSelect;
|
|
@@ -18,13 +18,17 @@ export async function queryAllPermissions() {
|
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
const checkStatus = (status: string): boolean => {
|
|
22
|
+
return status.toUpperCase() === 'Y';
|
|
23
|
+
}
|
|
24
|
+
|
|
21
25
|
/**
|
|
22
26
|
* 选择权限组件
|
|
23
27
|
* @param props
|
|
24
28
|
* @returns
|
|
25
29
|
*/
|
|
26
30
|
const PermissionSelect: React.FC<PermissionSelectFormProps> = (props) => {
|
|
27
|
-
const { values, modalFormVisible, rootParentKey = '0', onSubmit, setModalFormVisible } = props;
|
|
31
|
+
const { values, authorizeName, modalFormVisible, rootParentKey = '0', onSubmit, setModalFormVisible } = props;
|
|
28
32
|
const { formatMessage } = useIntl();
|
|
29
33
|
const [form] = Form.useForm();
|
|
30
34
|
|
|
@@ -58,7 +62,7 @@ const PermissionSelect: React.FC<PermissionSelectFormProps> = (props) => {
|
|
|
58
62
|
/**
|
|
59
63
|
* 找出父级菜单下的所有菜单
|
|
60
64
|
*/
|
|
61
|
-
let filterSonMenuList = allMenuData.filter((item) => item.parentId === parentKey);
|
|
65
|
+
let filterSonMenuList = allMenuData.filter((item) => item.parentId.toString() === parentKey.toString());
|
|
62
66
|
const findSonMenuSortList = filterSonMenuList.sort((a, b) => Number(a.seqNo) - Number(b.seqNo));
|
|
63
67
|
|
|
64
68
|
/**
|
|
@@ -66,18 +70,23 @@ const PermissionSelect: React.FC<PermissionSelectFormProps> = (props) => {
|
|
|
66
70
|
*/
|
|
67
71
|
findSonMenuSortList.forEach((menuItem) => {
|
|
68
72
|
let sunItem = GetMenuTree(menuItem.menuId, allMenuData, allPermissionData);
|
|
73
|
+
const menuEnabled = checkStatus(menuItem.status);
|
|
69
74
|
|
|
70
75
|
/**
|
|
71
76
|
* 找出菜单对应的权限
|
|
72
77
|
* 如果菜单无效或者菜单权限无效,则节点不可用
|
|
73
78
|
*/
|
|
74
79
|
const filterPermissions = allPermissionData.filter((item) => item.menuId === menuItem.menuId);
|
|
75
|
-
let PermissionNodes = filterPermissions.map((item) =>
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
80
|
+
let PermissionNodes = filterPermissions.map((item) => {
|
|
81
|
+
const permissionEnabled = checkStatus(item.status);
|
|
82
|
+
|
|
83
|
+
return ({
|
|
84
|
+
title: item.permissionName,
|
|
85
|
+
key: item.permissionId,
|
|
86
|
+
disableCheckbox: !menuEnabled && !permissionEnabled,
|
|
87
|
+
disabled: !menuEnabled && !permissionEnabled,
|
|
88
|
+
})
|
|
89
|
+
});
|
|
81
90
|
|
|
82
91
|
if (sunItem && sunItem.length > 0) {
|
|
83
92
|
/**
|
|
@@ -89,7 +98,7 @@ const PermissionSelect: React.FC<PermissionSelectFormProps> = (props) => {
|
|
|
89
98
|
title: (
|
|
90
99
|
<span
|
|
91
100
|
style={{
|
|
92
|
-
color:
|
|
101
|
+
color: menuEnabled ? '#1890ff' : '#cccccc',
|
|
93
102
|
fontWeight: 'bold',
|
|
94
103
|
}}
|
|
95
104
|
>
|
|
@@ -98,8 +107,8 @@ const PermissionSelect: React.FC<PermissionSelectFormProps> = (props) => {
|
|
|
98
107
|
</span>
|
|
99
108
|
),
|
|
100
109
|
//菜单不可用,则将颜色设置为灰色,且菜单不可用
|
|
101
|
-
disableCheckbox:
|
|
102
|
-
disabled:
|
|
110
|
+
disableCheckbox: !menuEnabled,
|
|
111
|
+
disabled: !menuEnabled,
|
|
103
112
|
key: `Menu-${menuItem.menuId.toString()}`,
|
|
104
113
|
children: sunItem,
|
|
105
114
|
});
|
|
@@ -108,7 +117,7 @@ const PermissionSelect: React.FC<PermissionSelectFormProps> = (props) => {
|
|
|
108
117
|
title: (
|
|
109
118
|
<span
|
|
110
119
|
style={{
|
|
111
|
-
color:
|
|
120
|
+
color: menuEnabled ? '#1890ff' : '#cccccc',
|
|
112
121
|
fontWeight: 'bold',
|
|
113
122
|
}}
|
|
114
123
|
>
|
|
@@ -116,8 +125,8 @@ const PermissionSelect: React.FC<PermissionSelectFormProps> = (props) => {
|
|
|
116
125
|
</span>
|
|
117
126
|
),
|
|
118
127
|
//菜单不可用,则将颜色设置为灰色,且菜单不可用
|
|
119
|
-
disableCheckbox:
|
|
120
|
-
disabled:
|
|
128
|
+
disableCheckbox: !menuEnabled,
|
|
129
|
+
disabled: !menuEnabled,
|
|
121
130
|
key: `Menu-${menuItem.menuId.toString()}`,
|
|
122
131
|
children: PermissionNodes,
|
|
123
132
|
});
|
|
@@ -139,7 +148,7 @@ const PermissionSelect: React.FC<PermissionSelectFormProps> = (props) => {
|
|
|
139
148
|
*/
|
|
140
149
|
const handleSearchAllMenu = async () => {
|
|
141
150
|
const getAllMenus = await queryAllMenus();
|
|
142
|
-
|
|
151
|
+
|
|
143
152
|
const getAllPermissions = await queryAllPermissions();
|
|
144
153
|
|
|
145
154
|
/**
|
|
@@ -204,10 +213,13 @@ const PermissionSelect: React.FC<PermissionSelectFormProps> = (props) => {
|
|
|
204
213
|
<ModalForm
|
|
205
214
|
form={form}
|
|
206
215
|
width={500}
|
|
207
|
-
title={formatMessage({
|
|
216
|
+
title={authorizeName ? `${formatMessage({
|
|
217
|
+
id: 'cfmmUI.PermissionSelect.title',
|
|
218
|
+
defaultMessage: '选择权限',
|
|
219
|
+
})} - ${authorizeName}` : `${formatMessage({
|
|
208
220
|
id: 'cfmmUI.PermissionSelect.title',
|
|
209
221
|
defaultMessage: '选择权限',
|
|
210
|
-
})}
|
|
222
|
+
})}`}
|
|
211
223
|
open={modalFormVisible}
|
|
212
224
|
onOpenChange={setModalFormVisible}
|
|
213
225
|
onFinish={handleSubmit}
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
|
+
"cfmmUI.DataPermissionSelect.title": string;
|
|
3
|
+
"cfmmUI.DataPermissionSelect.dataScope": string;
|
|
4
|
+
"cfmmUI.DataPermissionSelect.dataScope.all": string;
|
|
5
|
+
"cfmmUI.DataPermissionSelect.dataScope.custom": string;
|
|
6
|
+
"cfmmUI.DataPermissionSelect.dataScope.dept": string;
|
|
7
|
+
"cfmmUI.DataPermissionSelect.dataScope.deptAndSub": string;
|
|
8
|
+
"cfmmUI.DataPermissionSelect.dataScope.onlySelf": string;
|
|
9
|
+
"cfmmUI.DataPermissionSelect.dataPermission": string;
|
|
10
|
+
"cfmmUI.DataPermissionSelect.dataPermission.fold": string;
|
|
11
|
+
"cfmmUI.DataPermissionSelect.dataPermission.selectAll": string;
|
|
12
|
+
"cfmmUI.DataPermissionSelect.dataPermission.parentChild": string;
|
|
2
13
|
"cfmmUI.TimeTypeSelect.time.hour": string;
|
|
3
14
|
"cfmmUI.TimeTypeSelect.time.minute": string;
|
|
4
15
|
"cfmmUI.TimeTypeSelect.time.second": string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
"cfmmUI.DataPermissionSelect.title": string;
|
|
3
|
+
"cfmmUI.DataPermissionSelect.dataScope": string;
|
|
4
|
+
"cfmmUI.DataPermissionSelect.dataScope.all": string;
|
|
5
|
+
"cfmmUI.DataPermissionSelect.dataScope.custom": string;
|
|
6
|
+
"cfmmUI.DataPermissionSelect.dataScope.dept": string;
|
|
7
|
+
"cfmmUI.DataPermissionSelect.dataScope.deptAndSub": string;
|
|
8
|
+
"cfmmUI.DataPermissionSelect.dataScope.onlySelf": string;
|
|
9
|
+
"cfmmUI.DataPermissionSelect.dataPermission": string;
|
|
10
|
+
"cfmmUI.DataPermissionSelect.dataPermission.fold": string;
|
|
11
|
+
"cfmmUI.DataPermissionSelect.dataPermission.selectAll": string;
|
|
12
|
+
"cfmmUI.DataPermissionSelect.dataPermission.parentChild": string;
|
|
13
|
+
};
|
|
14
|
+
export default _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
"cfmmUI.DataPermissionSelect.title": "Select Data Permission Range",
|
|
3
|
+
"cfmmUI.DataPermissionSelect.dataScope": "Permission Range",
|
|
4
|
+
"cfmmUI.DataPermissionSelect.dataScope.all": "All Data Permission",
|
|
5
|
+
"cfmmUI.DataPermissionSelect.dataScope.custom": "Custom Data Permission",
|
|
6
|
+
"cfmmUI.DataPermissionSelect.dataScope.dept": "Department Data Permission",
|
|
7
|
+
"cfmmUI.DataPermissionSelect.dataScope.deptAndSub": "Department and Subordinate Data Permission",
|
|
8
|
+
"cfmmUI.DataPermissionSelect.dataScope.onlySelf": "Only Self Data Permission",
|
|
9
|
+
"cfmmUI.DataPermissionSelect.dataPermission": "Data Permission",
|
|
10
|
+
"cfmmUI.DataPermissionSelect.dataPermission.fold": "Fold/Expand",
|
|
11
|
+
"cfmmUI.DataPermissionSelect.dataPermission.selectAll": "Select All/Select None",
|
|
12
|
+
"cfmmUI.DataPermissionSelect.dataPermission.parentChild": "Parent-Child"
|
|
13
|
+
};
|