@mu-cabin/opms-permission 0.8.27 → 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 +21 -1
- package/dist/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.mjs +21 -1
- 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"));
|
@@ -464,8 +483,9 @@ var Permission = class {
|
|
464
483
|
orgId: item.orgId
|
465
484
|
};
|
466
485
|
});
|
486
|
+
const { orgTree, orgNoAuthMap } = handleOrgTreeByPermission(newTree);
|
467
487
|
this._orgTree = newTree;
|
468
|
-
return newTree;
|
488
|
+
return { orgTree: newTree, orgNoAuthMap, authOrgTree: orgTree };
|
469
489
|
} catch (error) {
|
470
490
|
console.log(error);
|
471
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";
|
@@ -425,8 +444,9 @@ var Permission = class {
|
|
425
444
|
orgId: item.orgId
|
426
445
|
};
|
427
446
|
});
|
447
|
+
const { orgTree, orgNoAuthMap } = handleOrgTreeByPermission(newTree);
|
428
448
|
this._orgTree = newTree;
|
429
|
-
return newTree;
|
449
|
+
return { orgTree: newTree, orgNoAuthMap, authOrgTree: orgTree };
|
430
450
|
} catch (error) {
|
431
451
|
console.log(error);
|
432
452
|
return null;
|