@mu-cabin/opms-permission 0.8.11 → 0.8.13
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/index.cjs +21 -3
- package/dist/index.d.mts +36 -4
- package/dist/index.d.ts +36 -4
- package/dist/index.mjs +21 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
@@ -144,16 +144,16 @@ function createMenuList(items) {
|
|
144
144
|
return { menuList: menus, menuMap };
|
145
145
|
}
|
146
146
|
function iterateNestedArray(items, callback) {
|
147
|
-
function
|
147
|
+
function travel(items2, parent) {
|
148
148
|
return items2.map((item) => {
|
149
149
|
const handledItem = callback(item, parent);
|
150
150
|
if (handledItem && handledItem.children) {
|
151
|
-
handledItem.children =
|
151
|
+
handledItem.children = travel(handledItem.children, handledItem);
|
152
152
|
}
|
153
153
|
return handledItem;
|
154
154
|
}).filter((v) => v);
|
155
155
|
}
|
156
|
-
return
|
156
|
+
return travel(items);
|
157
157
|
}
|
158
158
|
function findFirstEnableCode(data) {
|
159
159
|
if (!Array.isArray(data) || data.length === 0) {
|
@@ -260,6 +260,21 @@ async function queryOrgCompanies(baseUrl, params) {
|
|
260
260
|
|
261
261
|
// src/permission.ts
|
262
262
|
var DataHandler = {
|
263
|
+
iterateOrgTree(orgTree) {
|
264
|
+
return iterateNestedArray([orgTree], (item) => {
|
265
|
+
return {
|
266
|
+
label: item.orgShortName,
|
267
|
+
value: item.orgCode,
|
268
|
+
title: item.orgShortName,
|
269
|
+
key: item.orgCode,
|
270
|
+
nodeLevel: item.nodeLevel,
|
271
|
+
children: item.children,
|
272
|
+
disabled: !item.hasPermission,
|
273
|
+
orgType: item.orgType,
|
274
|
+
orgId: item.orgId
|
275
|
+
};
|
276
|
+
})?.[0];
|
277
|
+
},
|
263
278
|
// 获取单位组织
|
264
279
|
getUnitOptions(orgTree) {
|
265
280
|
if (!orgTree) return [];
|
@@ -298,6 +313,9 @@ var DataHandler = {
|
|
298
313
|
// 获取菜单数据, 包含菜单列表和菜单map
|
299
314
|
getMenuData(resources) {
|
300
315
|
return createMenuList(resources);
|
316
|
+
},
|
317
|
+
getFirstUnitOrgCode(orgTree) {
|
318
|
+
return findFirstEnableCode([orgTree]) ?? "";
|
301
319
|
}
|
302
320
|
};
|
303
321
|
var Permission = class {
|
package/dist/index.d.mts
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
interface OrgRecord {
|
1
|
+
interface OrgRecord$1 {
|
2
2
|
orgId: number;
|
3
3
|
orgName: string;
|
4
4
|
orgShortName: string;
|
5
5
|
orgCode: string;
|
6
6
|
nodeLevel: number;
|
7
7
|
hasPermission: boolean;
|
8
|
-
children?: OrgRecord[];
|
8
|
+
children?: OrgRecord$1[];
|
9
9
|
}
|
10
10
|
|
11
11
|
interface Resource {
|
@@ -60,6 +60,36 @@ interface OrgTreeItem {
|
|
60
60
|
orgType: string;
|
61
61
|
orgId: string;
|
62
62
|
}
|
63
|
+
interface ChildOrganization {
|
64
|
+
orgId: number;
|
65
|
+
parentOrgId: number;
|
66
|
+
orgCode: string;
|
67
|
+
orgName: string;
|
68
|
+
orgShortName: string;
|
69
|
+
orgType: string;
|
70
|
+
}
|
71
|
+
interface OrgRecord {
|
72
|
+
allOrgTags: boolean;
|
73
|
+
allSystem: boolean;
|
74
|
+
canModify: boolean;
|
75
|
+
children: ChildOrganization[];
|
76
|
+
cosOrgCode: string;
|
77
|
+
csmOrgCode: string | null;
|
78
|
+
hasPermission: boolean;
|
79
|
+
nodeLevel: number;
|
80
|
+
orgBindType: string;
|
81
|
+
orgCode: string;
|
82
|
+
orgId: number;
|
83
|
+
orgName: string;
|
84
|
+
orgShortName: string;
|
85
|
+
orgTags: any[];
|
86
|
+
orgType: string;
|
87
|
+
parentOrgId: number | null;
|
88
|
+
positionInfo: any[];
|
89
|
+
searchPath: string;
|
90
|
+
showOrder: number | null;
|
91
|
+
systemList: any[];
|
92
|
+
}
|
63
93
|
|
64
94
|
interface PermissionOptions {
|
65
95
|
systemId: string;
|
@@ -69,6 +99,7 @@ interface PermissionOptions {
|
|
69
99
|
* 组织树处理工具
|
70
100
|
*/
|
71
101
|
declare const DataHandler: {
|
102
|
+
iterateOrgTree(orgTree: OrgRecord$1): OrgTreeItem;
|
72
103
|
getUnitOptions(orgTree: OrgTreeItem): Option[];
|
73
104
|
getAllUnitOptions(orgTree: OrgTreeItem): Option[];
|
74
105
|
getCompaniesOptions(orgTree: OrgTreeItem, hasRootAuth: boolean): Option[];
|
@@ -87,6 +118,7 @@ declare const DataHandler: {
|
|
87
118
|
[path: string]: MenuItem;
|
88
119
|
};
|
89
120
|
};
|
121
|
+
getFirstUnitOrgCode(orgTree: OrgTreeItem): string;
|
90
122
|
};
|
91
123
|
declare class Permission {
|
92
124
|
private _userInfo;
|
@@ -140,7 +172,7 @@ declare class Permission {
|
|
140
172
|
* Query and process organization tree
|
141
173
|
*/
|
142
174
|
queryOrgs(): Promise<any>;
|
143
|
-
queryCompanies(): Promise<OrgRecord[]>;
|
175
|
+
queryCompanies(): Promise<OrgRecord$1[]>;
|
144
176
|
isLogin(): boolean;
|
145
177
|
getToken(): string | null;
|
146
178
|
setToken(token: string): void;
|
@@ -178,4 +210,4 @@ declare function jumpToSSOLogout({ baseUrl, redirectToUrl, clientId, }: {
|
|
178
210
|
clientId?: string;
|
179
211
|
}): void;
|
180
212
|
|
181
|
-
export { DataHandler, type MenuItem, Permission as OpmsPermission, type Option, type OrgTreeItem, type Resource, type UserInfo, type UserOrganization, jumpToSSOLogin, jumpToSSOLogout };
|
213
|
+
export { type ChildOrganization, DataHandler, type MenuItem, Permission as OpmsPermission, type Option, type OrgRecord, type OrgTreeItem, type Resource, type UserInfo, type UserOrganization, jumpToSSOLogin, jumpToSSOLogout };
|
package/dist/index.d.ts
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
interface OrgRecord {
|
1
|
+
interface OrgRecord$1 {
|
2
2
|
orgId: number;
|
3
3
|
orgName: string;
|
4
4
|
orgShortName: string;
|
5
5
|
orgCode: string;
|
6
6
|
nodeLevel: number;
|
7
7
|
hasPermission: boolean;
|
8
|
-
children?: OrgRecord[];
|
8
|
+
children?: OrgRecord$1[];
|
9
9
|
}
|
10
10
|
|
11
11
|
interface Resource {
|
@@ -60,6 +60,36 @@ interface OrgTreeItem {
|
|
60
60
|
orgType: string;
|
61
61
|
orgId: string;
|
62
62
|
}
|
63
|
+
interface ChildOrganization {
|
64
|
+
orgId: number;
|
65
|
+
parentOrgId: number;
|
66
|
+
orgCode: string;
|
67
|
+
orgName: string;
|
68
|
+
orgShortName: string;
|
69
|
+
orgType: string;
|
70
|
+
}
|
71
|
+
interface OrgRecord {
|
72
|
+
allOrgTags: boolean;
|
73
|
+
allSystem: boolean;
|
74
|
+
canModify: boolean;
|
75
|
+
children: ChildOrganization[];
|
76
|
+
cosOrgCode: string;
|
77
|
+
csmOrgCode: string | null;
|
78
|
+
hasPermission: boolean;
|
79
|
+
nodeLevel: number;
|
80
|
+
orgBindType: string;
|
81
|
+
orgCode: string;
|
82
|
+
orgId: number;
|
83
|
+
orgName: string;
|
84
|
+
orgShortName: string;
|
85
|
+
orgTags: any[];
|
86
|
+
orgType: string;
|
87
|
+
parentOrgId: number | null;
|
88
|
+
positionInfo: any[];
|
89
|
+
searchPath: string;
|
90
|
+
showOrder: number | null;
|
91
|
+
systemList: any[];
|
92
|
+
}
|
63
93
|
|
64
94
|
interface PermissionOptions {
|
65
95
|
systemId: string;
|
@@ -69,6 +99,7 @@ interface PermissionOptions {
|
|
69
99
|
* 组织树处理工具
|
70
100
|
*/
|
71
101
|
declare const DataHandler: {
|
102
|
+
iterateOrgTree(orgTree: OrgRecord$1): OrgTreeItem;
|
72
103
|
getUnitOptions(orgTree: OrgTreeItem): Option[];
|
73
104
|
getAllUnitOptions(orgTree: OrgTreeItem): Option[];
|
74
105
|
getCompaniesOptions(orgTree: OrgTreeItem, hasRootAuth: boolean): Option[];
|
@@ -87,6 +118,7 @@ declare const DataHandler: {
|
|
87
118
|
[path: string]: MenuItem;
|
88
119
|
};
|
89
120
|
};
|
121
|
+
getFirstUnitOrgCode(orgTree: OrgTreeItem): string;
|
90
122
|
};
|
91
123
|
declare class Permission {
|
92
124
|
private _userInfo;
|
@@ -140,7 +172,7 @@ declare class Permission {
|
|
140
172
|
* Query and process organization tree
|
141
173
|
*/
|
142
174
|
queryOrgs(): Promise<any>;
|
143
|
-
queryCompanies(): Promise<OrgRecord[]>;
|
175
|
+
queryCompanies(): Promise<OrgRecord$1[]>;
|
144
176
|
isLogin(): boolean;
|
145
177
|
getToken(): string | null;
|
146
178
|
setToken(token: string): void;
|
@@ -178,4 +210,4 @@ declare function jumpToSSOLogout({ baseUrl, redirectToUrl, clientId, }: {
|
|
178
210
|
clientId?: string;
|
179
211
|
}): void;
|
180
212
|
|
181
|
-
export { DataHandler, type MenuItem, Permission as OpmsPermission, type Option, type OrgTreeItem, type Resource, type UserInfo, type UserOrganization, jumpToSSOLogin, jumpToSSOLogout };
|
213
|
+
export { type ChildOrganization, DataHandler, type MenuItem, Permission as OpmsPermission, type Option, type OrgRecord, type OrgTreeItem, type Resource, type UserInfo, type UserOrganization, jumpToSSOLogin, jumpToSSOLogout };
|
package/dist/index.mjs
CHANGED
@@ -105,16 +105,16 @@ function createMenuList(items) {
|
|
105
105
|
return { menuList: menus, menuMap };
|
106
106
|
}
|
107
107
|
function iterateNestedArray(items, callback) {
|
108
|
-
function
|
108
|
+
function travel(items2, parent) {
|
109
109
|
return items2.map((item) => {
|
110
110
|
const handledItem = callback(item, parent);
|
111
111
|
if (handledItem && handledItem.children) {
|
112
|
-
handledItem.children =
|
112
|
+
handledItem.children = travel(handledItem.children, handledItem);
|
113
113
|
}
|
114
114
|
return handledItem;
|
115
115
|
}).filter((v) => v);
|
116
116
|
}
|
117
|
-
return
|
117
|
+
return travel(items);
|
118
118
|
}
|
119
119
|
function findFirstEnableCode(data) {
|
120
120
|
if (!Array.isArray(data) || data.length === 0) {
|
@@ -221,6 +221,21 @@ async function queryOrgCompanies(baseUrl, params) {
|
|
221
221
|
|
222
222
|
// src/permission.ts
|
223
223
|
var DataHandler = {
|
224
|
+
iterateOrgTree(orgTree) {
|
225
|
+
return iterateNestedArray([orgTree], (item) => {
|
226
|
+
return {
|
227
|
+
label: item.orgShortName,
|
228
|
+
value: item.orgCode,
|
229
|
+
title: item.orgShortName,
|
230
|
+
key: item.orgCode,
|
231
|
+
nodeLevel: item.nodeLevel,
|
232
|
+
children: item.children,
|
233
|
+
disabled: !item.hasPermission,
|
234
|
+
orgType: item.orgType,
|
235
|
+
orgId: item.orgId
|
236
|
+
};
|
237
|
+
})?.[0];
|
238
|
+
},
|
224
239
|
// 获取单位组织
|
225
240
|
getUnitOptions(orgTree) {
|
226
241
|
if (!orgTree) return [];
|
@@ -259,6 +274,9 @@ var DataHandler = {
|
|
259
274
|
// 获取菜单数据, 包含菜单列表和菜单map
|
260
275
|
getMenuData(resources) {
|
261
276
|
return createMenuList(resources);
|
277
|
+
},
|
278
|
+
getFirstUnitOrgCode(orgTree) {
|
279
|
+
return findFirstEnableCode([orgTree]) ?? "";
|
262
280
|
}
|
263
281
|
};
|
264
282
|
var Permission = class {
|