This commit is contained in:
Taric Xin
2022-04-26 15:33:01 +08:00
parent e3b9b79ff0
commit d9dff2cbf7
15 changed files with 487 additions and 10 deletions

View File

@ -8,6 +8,7 @@
*/
import { Injectable, Injector } from '@angular/core';
import { BaseService } from 'src/app/shared/services';
import { TreeNodeInterface } from '../../menu-manager/services/menu-manager.service';
@Injectable({
providedIn: 'root'
@ -45,6 +46,9 @@ export class SystemService extends BaseService {
// 获取角色列表
$api_getAppRoleList = '/api/mdc/cuc/roleInfo/getRoleList';
// 获取组织角色树列表
$api_get_organization_role_list = '/api/mdc/cuc/roleInfo/getOrganizationRoleList';
// 查询字典选项列表
$api_get_dict_page = '/api/mdc/pbc/dictItems/list/page';
// 根据id批量删除字典选项
@ -191,4 +195,49 @@ export class SystemService extends BaseService {
constructor(public injector: Injector) {
super(injector);
}
collapse(array: TreeNodeInterface[], data: TreeNodeInterface, $event: boolean): void {
if (!$event) {
if (data.children) {
data.children.forEach(d => {
const target = array.find(a => a.key === d.key)!;
target.expand = false;
this.collapse(array, target, false);
});
} else {
return;
}
}
}
convertTreeToList(root: TreeNodeInterface): TreeNodeInterface[] {
const stack: TreeNodeInterface[] = [];
const array: TreeNodeInterface[] = [];
const hashMap = {};
stack.push({ ...root, level: 0, expand: true });
while (stack.length !== 0) {
const node = stack.pop()!;
this.visitNode(node, hashMap, array);
if (node.children) {
for (let i = node.children.length - 1; i >= 0; i--) {
stack.push({
...node.children[i],
level: node.level! + 1,
expand: false,
parent: node
});
}
}
}
return array;
}
visitNode(node: TreeNodeInterface, hashMap: { [key: string]: boolean }, array: TreeNodeInterface[]): void {
if (!hashMap[node.key]) {
hashMap[node.key] = true;
array.push(node);
}
}
}