@mu-cabin/opms-permission 0.8.26 → 0.8.28
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 +22 -3
- package/dist/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.mjs +22 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
@@ -204,6 +204,25 @@ function findFirstEnableNode(data) {
|
|
204
204
|
}
|
205
205
|
return null;
|
206
206
|
}
|
207
|
+
function handleOrgTreeByPermission(data) {
|
208
|
+
const orgNoAuthMap = {};
|
209
|
+
function processNode(node) {
|
210
|
+
if (node.disabled) {
|
211
|
+
orgNoAuthMap[node.orgId] = node;
|
212
|
+
return null;
|
213
|
+
}
|
214
|
+
const processedChildren = node.children?.map((child) => processNode(child)).filter((child) => child !== null);
|
215
|
+
return {
|
216
|
+
...node,
|
217
|
+
children: processedChildren || []
|
218
|
+
};
|
219
|
+
}
|
220
|
+
const orgTree = data.map((node) => processNode(node)).filter((node) => node !== null);
|
221
|
+
return {
|
222
|
+
orgTree,
|
223
|
+
orgNoAuthMap
|
224
|
+
};
|
225
|
+
}
|
207
226
|
|
208
227
|
// src/api.ts
|
209
228
|
var import_axios = __toESM(require("axios"));
|
@@ -459,14 +478,14 @@ var Permission = class {
|
|
459
478
|
nodeLevel: item.nodeLevel,
|
460
479
|
children: item.children,
|
461
480
|
// TODO: 新接口只返回有权限的节点
|
462
|
-
|
463
|
-
disabled: false,
|
481
|
+
disabled: !item.hasPermission,
|
464
482
|
orgType: item.orgType,
|
465
483
|
orgId: item.orgId
|
466
484
|
};
|
467
485
|
});
|
486
|
+
const { orgTree, orgNoAuthMap } = handleOrgTreeByPermission(newTree);
|
468
487
|
this._orgTree = newTree;
|
469
|
-
return newTree;
|
488
|
+
return { orgTree: newTree, orgNoAuthMap, authOrgTree: orgTree };
|
470
489
|
} catch (error) {
|
471
490
|
console.log(error);
|
472
491
|
return null;
|
package/dist/index.d.mts
CHANGED
@@ -167,7 +167,11 @@ declare class Permission {
|
|
167
167
|
/**
|
168
168
|
* Query and process organization tree
|
169
169
|
*/
|
170
|
-
queryUserOrgs(): Promise<
|
170
|
+
queryUserOrgs(): Promise<{
|
171
|
+
orgTree: any[];
|
172
|
+
orgNoAuthMap: Record<number, OrgTreeItem>;
|
173
|
+
authOrgTree: OrgTreeItem[];
|
174
|
+
} | null>;
|
171
175
|
queryCompanies(): Promise<OrgRecord[]>;
|
172
176
|
isLogin(): boolean;
|
173
177
|
getToken(): string | null;
|
package/dist/index.d.ts
CHANGED
@@ -167,7 +167,11 @@ declare class Permission {
|
|
167
167
|
/**
|
168
168
|
* Query and process organization tree
|
169
169
|
*/
|
170
|
-
queryUserOrgs(): Promise<
|
170
|
+
queryUserOrgs(): Promise<{
|
171
|
+
orgTree: any[];
|
172
|
+
orgNoAuthMap: Record<number, OrgTreeItem>;
|
173
|
+
authOrgTree: OrgTreeItem[];
|
174
|
+
} | null>;
|
171
175
|
queryCompanies(): Promise<OrgRecord[]>;
|
172
176
|
isLogin(): boolean;
|
173
177
|
getToken(): string | null;
|
package/dist/index.mjs
CHANGED
@@ -165,6 +165,25 @@ function findFirstEnableNode(data) {
|
|
165
165
|
}
|
166
166
|
return null;
|
167
167
|
}
|
168
|
+
function handleOrgTreeByPermission(data) {
|
169
|
+
const orgNoAuthMap = {};
|
170
|
+
function processNode(node) {
|
171
|
+
if (node.disabled) {
|
172
|
+
orgNoAuthMap[node.orgId] = node;
|
173
|
+
return null;
|
174
|
+
}
|
175
|
+
const processedChildren = node.children?.map((child) => processNode(child)).filter((child) => child !== null);
|
176
|
+
return {
|
177
|
+
...node,
|
178
|
+
children: processedChildren || []
|
179
|
+
};
|
180
|
+
}
|
181
|
+
const orgTree = data.map((node) => processNode(node)).filter((node) => node !== null);
|
182
|
+
return {
|
183
|
+
orgTree,
|
184
|
+
orgNoAuthMap
|
185
|
+
};
|
186
|
+
}
|
168
187
|
|
169
188
|
// src/api.ts
|
170
189
|
import axios from "axios";
|
@@ -420,14 +439,14 @@ var Permission = class {
|
|
420
439
|
nodeLevel: item.nodeLevel,
|
421
440
|
children: item.children,
|
422
441
|
// TODO: 新接口只返回有权限的节点
|
423
|
-
|
424
|
-
disabled: false,
|
442
|
+
disabled: !item.hasPermission,
|
425
443
|
orgType: item.orgType,
|
426
444
|
orgId: item.orgId
|
427
445
|
};
|
428
446
|
});
|
447
|
+
const { orgTree, orgNoAuthMap } = handleOrgTreeByPermission(newTree);
|
429
448
|
this._orgTree = newTree;
|
430
|
-
return newTree;
|
449
|
+
return { orgTree: newTree, orgNoAuthMap, authOrgTree: orgTree };
|
431
450
|
} catch (error) {
|
432
451
|
console.log(error);
|
433
452
|
return null;
|