diff --git a/src/app/system-management/menu/menu.component.html b/src/app/system-management/menu/menu.component.html index ec58c4a..d684dd0 100644 --- a/src/app/system-management/menu/menu.component.html +++ b/src/app/system-management/menu/menu.component.html @@ -29,7 +29,7 @@ + nzBlockNode [nzExpandedIcon]="multiExpandedIconTpl">
diff --git a/src/app/system-management/menu/menu.component.ts b/src/app/system-management/menu/menu.component.ts index f674b0f..3438330 100644 --- a/src/app/system-management/menu/menu.component.ts +++ b/src/app/system-management/menu/menu.component.ts @@ -41,7 +41,7 @@ export class MenuComponent implements OnInit { allOrList: any getAllOrganization() { - + let OrganizationUnitId = sessionStorage.getItem('isGasStation') == 'true' ? JSON.parse(sessionStorage.getItem('userdataOfgasstation')).organization.id : JSON.parse(sessionStorage.getItem('userdata')).organization.id let params = { OrganizationUnitId: OrganizationUnitId, @@ -50,7 +50,6 @@ export class MenuComponent implements OnInit { this.http.get('/api/services/app/Menu/GetAll', { params: params }).subscribe((data: any) => { - this.totalCount = data.result.totalCount data.result.items.forEach(element => { element.key = element.id @@ -61,10 +60,7 @@ export class MenuComponent implements OnInit { this.nodes = [...this.toTree.toTree(data.result.items)] this.defaultExpandedKeys = [this.nodes[0].id] this.defaultExpandedKeys = [...this.defaultExpandedKeys] - // console.log(...this.nodes,444); - // console.log(this.defaultExpandedKeys,45); - - + }) } @@ -74,8 +70,6 @@ export class MenuComponent implements OnInit { defaultExpandedKeys = []; nodes: any[] = [] - datas:any[]=[{id:0,title:"首页",children:[]},{id:1,title:"数字油站",children:[]},{id:2,title:"今日预警",children:[]},{id:3,title:"预警记录",children:[{title:'预警类型统计',isGasStation:true},{title:'卸油统计',isGasStation:true},{title:'证照预警统计',isGasStation:true}]},{id:4,title:"证照管理",children:[{title:'经营类证照',isGasStation:true},{title:'资产类证照',isGasStation:true},{title:'待办',isGasStation:true},{title:'审批记录',isGasStation:true}]}] - addOr(node?: any) { console.log(node) const modal = this.modal.create({ @@ -85,7 +79,6 @@ export class MenuComponent implements OnInit { nzWidth: 288, nzComponentParams: {}, nzOnOk: async () => { - console.log('hhhhhhh', instance.validateForm) if (instance.validateForm.valid) { await new Promise(resolve => { let body = { @@ -191,133 +184,5 @@ export class MenuComponent implements OnInit { } - - nzEvent(event: NzFormatEmitEvent): void { - console.log('event', event) - if (this.isDrag) { - let parentId - if (this.pos == 0) {//目标节点内部 - parentId = event.node.key - } else { - if (event.node.level == 0) { - parentId = null - } else { - parentId = event.node.origin.parentId - } - } - - let body = { - id: event.dragNode.key, - parentId: parentId, - // code: instance.validateForm.value.code, - displayName: event.dragNode.origin.displayName, - isGasStation: event.dragNode.origin.isGasStation - } - this.http.put('/api/services/app/Organization/Update', body).subscribe(data => { - this.message.create('success', '拖拽成功!'); - this.nzTreeComponent.getExpandedNodeList().forEach((item) => { - this.defaultExpandedKeys.push(item.key) - }) - this.getAllOrganization() - return true - }, err => { - this.message.create('warning', '拖拽失败'); - return false - }) - - - // console.log('this.allOrList', this.allOrList) - // let orders = {} - // let originalData = JSON.parse(JSON.stringify(this.allOrList || [])) //tree原始数据 - // let targetNodeData = []//拖动移入节点的数据,用于遍历求出放在该数组的第几位 - //找到需要重新排序的数组 - // if (this.pos == 0) { - // originalData.forEach(item => { - // if (item.parentId == event.node.key) { - // targetNodeData.push(item) - // } - // }) - // } else { - // if (event.node.origin.parentId) {//如果拖动目标为非一级节点 - // originalData.forEach(item => { - // if (item.parentId == event.node.origin.parentId) { - // targetNodeData.push(item) - // } - // }) - // } else {//如果拖动目标为一级节点 - // originalData.forEach(item => { - // if (!item.parentId) { - // targetNodeData.push(item) - // } - // }) - // } - // } - - - // let idArr = [] - // targetNodeData.forEach(i => { - // idArr.push(i.id) - // }) - // if (this.pos == 0 && event.node.origin.children.length == 1) { - // // console.log("移入,没有兄弟") - // let key = event.dragNode.key - // orders[key] = 0 - // parentId = event.node.key - // } else { - - // let array = [] - // targetNodeData.forEach(item => { - // if (item.id != event.dragNode.key) { //将拖动项先移除掉 - // array.push(item) - // } - // }) - // if (event.dragNode.isEnd[event.dragNode.isEnd.length - 1]) { //如果移入到最后一个 - // // console.log("最后") - // array.push(event.dragNode.origin) - // } else if (event.dragNode.isStart[event.dragNode.isStart.length - 1]) {//如果移入到第一个 - // // console.log("第一") - // array.unshift(event.dragNode.origin) - // } else {//如果移入中间位置 - // // console.log("中间") - // array.splice(event.node.origin.order, 0, event.dragNode.origin) - // } - // array.forEach((item, key) => { - // orders[item.id] = key - // }) - // console.log("移入,多个兄弟",orders) - // } - - // let obj = { - // id: event.dragNode.origin.id, - // parentId: parentId, - // orders: orders - // } - - // this.http.put("/api/DisposalNodes/Sort", obj).subscribe(data => { - // const config = new MatSnackBarConfig(); - // config.verticalPosition = 'top'; - // config.duration = 3000 - // this.snackBar.open('排序成功', '确定', config) - // this.refurbishTreeData() - // }) - - - - } - } - isDrag //是否可以拖动 - pos//放置位置 - beforeDrop = (arg: NzFormatBeforeDropEvent) => { - console.log('arg', arg) - if (arg.node.level === 0) {//如果为数据节点则不允许拖到一级节点 - this.message.create('warning', '不允许拖拽到一级节点'); - this.isDrag = false - return of(false); - } else { - this.isDrag = true - this.pos = arg.pos - return of(true) - } - } } diff --git a/src/app/system-management/role/addrole/addrole.component.ts b/src/app/system-management/role/addrole/addrole.component.ts index 4601464..4d76d33 100644 --- a/src/app/system-management/role/addrole/addrole.component.ts +++ b/src/app/system-management/role/addrole/addrole.component.ts @@ -11,9 +11,11 @@ export class AddroleComponent implements OnInit { @Input() title?: string; @Input() subtitle?: string; + @Input() nodes?: any; validateForm!: FormGroup; constructor(private modal: NzModalRef, private fb: FormBuilder, private http: HttpClient) { } + ngOnInit(): void { this.loadMore(); this.validateForm = this.fb.group({ @@ -37,44 +39,4 @@ export class AddroleComponent implements OnInit { }) } - nodes = [ - { - title: 'Node1', - value: '0-0', - key: '0-0', - children: [ - { - title: 'Child Node1', - value: '0-0-0', - key: '0-0-0', - isLeaf: true - } - ] - }, - { - title: 'Node2', - value: '0-1', - key: '0-1', - children: [ - { - title: 'Child Node3', - value: '0-1-0', - key: '0-1-0', - isLeaf: true - }, - { - title: 'Child Node4', - value: '0-1-1', - key: '0-1-1', - isLeaf: true - }, - { - title: 'Child Node5', - value: '0-1-2', - key: '0-1-2', - isLeaf: true - } - ] - } - ]; } diff --git a/src/app/system-management/role/role.component.ts b/src/app/system-management/role/role.component.ts index 01af6c6..5e0642a 100644 --- a/src/app/system-management/role/role.component.ts +++ b/src/app/system-management/role/role.component.ts @@ -5,6 +5,7 @@ import { NzMessageService } from 'ng-zorro-antd/message'; import { HttpClient } from '@angular/common/http'; import { AddroleComponent } from './addrole/addrole.component'; import { EditroleComponent } from './editrole/editrole.component'; +import { TreeService } from 'src/app/service/tree.service'; @Component({ selector: 'app-role', templateUrl: './role.component.html', @@ -13,12 +14,14 @@ import { EditroleComponent } from './editrole/editrole.component'; export class RoleComponent implements OnInit { - constructor(private modal: NzModalService, private viewContainerRef: ViewContainerRef, private message: NzMessageService, private http: HttpClient) { } + constructor(private modal: NzModalService, private viewContainerRef: ViewContainerRef, private message: NzMessageService, private http: HttpClient, private toTree: TreeService) { } ngOnInit(): void { this.getAllRoles() this.loadMore() + + this.getAllMenus() } listOfData: any[] = []; @@ -37,8 +40,26 @@ export class RoleComponent implements OnInit { this.listOfData = data.result.items }) } - getAllMenus() { + totalCount + nodes + getAllMenus() { + let params = { + SkipCount: '0', + MaxResultCount: '999' + } + this.http.get('/api/services/app/Menu/GetAll', { + params: params + }).subscribe((data: any) => { + console.log(666, data) + this.totalCount = data.result.totalCount + data.result.items.forEach(element => { + element.key = element.id + element.title = element.name + element.selectable = false + }); + this.nodes = [...this.toTree.toTree(data.result.items)] + }) } addRole(): void { @@ -47,7 +68,9 @@ export class RoleComponent implements OnInit { nzContent: AddroleComponent, nzViewContainerRef: this.viewContainerRef, nzWidth: 400, - nzComponentParams: {}, + nzComponentParams: { + nodes: this.nodes + }, nzMaskClosable: false, nzOnOk: async () => { if (instance.validateForm.valid) {