Browse Source

[完善]角色分配菜单

beijing
邵佳豪 2 years ago
parent
commit
87ea391ffd
  1. 4
      proxy.config.json
  2. 2
      src/app/pages/audit/audit-ing/audit-ing.component.html
  3. 2
      src/app/pages/audit/audit-record/audit-record.component.html
  4. 2
      src/app/pages/init3D.guard.ts
  5. 2
      src/app/pages/plan-admin/file-license-list/file-license-list.component.html
  6. 4
      src/app/pages/plan-admin/oil-station-list/oil-station-list.component.html
  7. 2
      src/app/pages/plan-admin/update-license-list/update-license-list.component.html
  8. 2
      src/app/pages/records/criminal-records-admin/criminal-records-admin.component.html
  9. 2
      src/app/pages/records/warning-statistics-list/warning-statistics-list.component.html
  10. 2
      src/app/pages/today-warning-admin/today-warning-admin.component.html
  11. 10
      src/app/system-management/organization/organization.component.html
  12. 14
      src/app/system-management/role/addrole/addrole.component.html
  13. 26
      src/app/system-management/role/addrole/addrole.component.ts
  14. 18
      src/app/system-management/role/editrole/editrole.component.html
  15. 28
      src/app/system-management/role/editrole/editrole.component.ts
  16. 20
      src/app/system-management/role/menus/menus.component.html
  17. 0
      src/app/system-management/role/menus/menus.component.scss
  18. 71
      src/app/system-management/role/menus/menus.component.ts
  19. 5
      src/app/system-management/role/role.component.html
  20. 60
      src/app/system-management/role/role.component.ts
  21. 5
      src/app/system-management/system-management.module.ts

4
proxy.config.json

@ -1,11 +1,11 @@
{
"/api": {
"target": "http://39.106.78.171:8906",
"target": "http://121.36.37.70:8906",
"secure": false,
"changeOrigin": true
},
"/signalr": {
"target": "http://39.106.78.171:8906",
"target": "http://121.36.37.70:8906",
"secure": false,
"ws": true,
"logLevel": "debug"

2
src/app/pages/audit/audit-ing/audit-ing.component.html

@ -8,7 +8,7 @@
<span style="margin-left: 30px;">审批信息</span>
</th>
<th>审批类型</th>
<th>油站名称</th>
<th>油站名称</th>
<th [nzWidth]="'16%'">区域名称</th>
<th>公司名称</th>
<!-- <th>提交时间</th> -->

2
src/app/pages/audit/audit-record/audit-record.component.html

@ -94,7 +94,7 @@
<span style="margin-left: 30px;">审批类型</span>
</th>
<th>审批信息</th>
<!-- <th>油站名称</th>
<!-- <th>油站名称</th>
<th [nzWidth]="'16%'">区域</th> -->
<th>公司名称</th>
<th>申请人</th>

2
src/app/pages/init3D.guard.ts

@ -26,7 +26,7 @@ export class init3DGuard implements CanActivate {
if (userdata.userName == 'superadmin' || res.hasBuildingInfo) {
return true
} else {
this.message.info("当前油站未开通!");
// this.message.info("当前油站未开通!");
return false
}
});

2
src/app/pages/plan-admin/file-license-list/file-license-list.component.html

@ -23,7 +23,7 @@
<nz-form-item class="searchParams">
<nz-form-control>
<nz-input-group>
<input required nz-input type="text" formControlName="name" placeholder="请输入油站名称" />
<input required nz-input type="text" formControlName="name" placeholder="请输入油站名称" />
</nz-input-group>
</nz-form-control>
</nz-form-item>

4
src/app/pages/plan-admin/oil-station-list/oil-station-list.component.html

@ -5,7 +5,7 @@
<nz-form-item class="searchParams">
<nz-form-control>
<nz-input-group>
<input required nz-input type="text" formControlName="name" placeholder="请输入油站名称" />
<input required nz-input type="text" formControlName="name" placeholder="请输入油站名称" />
</nz-input-group>
</nz-form-control>
</nz-form-item>
@ -32,7 +32,7 @@
<div
style="width: 20px;height: 20px;display: inline-block;margin-left: 20px;margin-right: 6px;">
</div>油站名称
</div>油站名称
</th>
<th>区域名称</th>
<th>公司名称</th>

2
src/app/pages/plan-admin/update-license-list/update-license-list.component.html

@ -34,7 +34,7 @@
<nz-form-item class="searchParams">
<nz-form-control>
<nz-input-group>
<input required nz-input type="text" formControlName="name" placeholder="请输入油站名称" />
<input required nz-input type="text" formControlName="name" placeholder="请输入油站名称" />
</nz-input-group>
</nz-form-control>
</nz-form-item>

2
src/app/pages/records/criminal-records-admin/criminal-records-admin.component.html

@ -165,7 +165,7 @@
<th>预警事件</th>
<th>公司名称</th>
<th>区域名称</th>
<th>油站</th>
<th>油站名称</th>
<th>预警区域</th>
<th>摄像头名称</th>
<th>预警时间</th>

2
src/app/pages/records/warning-statistics-list/warning-statistics-list.component.html

@ -115,7 +115,7 @@
<th>预警内容</th>
<th>公司名称</th>
<th>区域名称</th>
<th>所属油站</th>
<th>油站名称</th>
<th>证照/消防设施名称</th>
<th>有效期限</th>
<th>操作</th>

2
src/app/pages/today-warning-admin/today-warning-admin.component.html

@ -128,7 +128,7 @@
区域名称
</div>
<div nz-col nzSpan="2">
油站
油站名称
</div>
<div nz-col nzSpan="2">
预警区域

10
src/app/system-management/organization/organization.component.html

@ -6,16 +6,6 @@
{{totalCount}}个单位</span>
</div>
<div class="righttop">
<!-- <form nz-form [formGroup]="validateForm" (ngSubmit)="submitForm()">
<nz-form-item>
<nz-form-control>
<nz-input-group nzPrefixIcon="search">
<input type="text" nz-input placeholder="请输入单位" formControlName="search" [(ngModel)]="searchValue"/>
</nz-input-group>
</nz-form-control>
<button style="display: none;" type="submit"></button>
</nz-form-item>
</form> -->
<nz-input-group nzPrefixIcon="search">
<input type="text" nz-input placeholder="请输入单位" [(ngModel)]="searchValue" />
</nz-input-group>

14
src/app/system-management/role/addrole/addrole.component.html

@ -19,12 +19,20 @@
</ng-template>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<!-- <nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzFor="菜单">菜单</nz-form-label>
<nz-form-control>
<nz-tree-select formControlName="menus" [nzNodes]="nodes" nzShowSearch nzCheckable nzPlaceHolder="请选择菜单">
<nz-tree-select formControlName="menus" [nzNodes]="nodes" nzShowSearch nzCheckable nzPlaceHolder="请选择菜单"
[nzExpandedIcon]="multiExpandedIconTpl">
</nz-tree-select>
</nz-form-control>
</nz-form-item>
<ng-template #multiExpandedIconTpl let-node let-origin="origin">
<ng-container *ngIf="node.children.length == 0; else elseTemplate">
</ng-container>
<ng-template #elseTemplate>
<i nz-icon [nzType]="node.isExpanded ? 'caret-down' : 'caret-right'" class="ant-tree-switcher-line-icon"></i>
</ng-template>
</ng-template>
</nz-form-item> -->
</form>
</div>

26
src/app/system-management/role/addrole/addrole.component.ts

@ -2,6 +2,7 @@ import { Component, OnInit, Input } from '@angular/core';
import { NzModalRef } from 'ng-zorro-antd/modal';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { HttpClient } from '@angular/common/http';
import { TreeService } from 'src/app/service/tree.service';
@Component({
selector: 'app-addrole',
templateUrl: './addrole.component.html',
@ -13,17 +14,38 @@ export class AddroleComponent implements OnInit {
@Input() subtitle?: string;
@Input() nodes?: any;
validateForm!: FormGroup;
constructor(private modal: NzModalRef, private fb: FormBuilder, private http: HttpClient) { }
constructor(private modal: NzModalRef, private fb: FormBuilder, private http: HttpClient, private toTree: TreeService) { }
ngOnInit(): void {
this.nodes.length != 0 ? null : this.getAllMenus()
this.loadMore();
this.validateForm = this.fb.group({
name: [null, [Validators.required]],
power: [null, [Validators.required]],
menus: [null]
// menus: [null]
});
}
totalCount
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)]
})
}
destroyModal(): void {
this.modal.destroy({ data: 'this the result data' });
}

18
src/app/system-management/role/editrole/editrole.component.html

@ -16,5 +16,21 @@
</nz-select>
</nz-form-control>
</nz-form-item>
<!-- <nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzFor="菜单">菜单</nz-form-label>
<nz-form-control>
<nz-tree-select formControlName="menus" [nzNodes]="nodes" nzShowSearch nzCheckable nzPlaceHolder="请选择菜单"
[nzExpandedIcon]="multiExpandedIconTpl">
</nz-tree-select>
<ng-template #multiExpandedIconTpl let-node let-origin="origin">
<ng-container *ngIf="node.children.length == 0; else elseTemplate">
</ng-container>
<ng-template #elseTemplate>
<i nz-icon [nzType]="node.isExpanded ? 'caret-down' : 'caret-right'"
class="ant-tree-switcher-line-icon"></i>
</ng-template>
</ng-template>
</nz-form-control>
</nz-form-item> -->
</form>
</div>
</div>

28
src/app/system-management/role/editrole/editrole.component.ts

@ -2,6 +2,7 @@ import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Component, OnInit, Input } from '@angular/core';
import { NzModalRef } from 'ng-zorro-antd/modal';
import { HttpClient } from '@angular/common/http';
import { TreeService } from 'src/app/service/tree.service';
@Component({
selector: 'app-editrole',
templateUrl: './editrole.component.html',
@ -11,21 +12,42 @@ export class EditroleComponent implements OnInit {
@Input() data?: any;
@Input() optionList?: any;
@Input() nodes?: any;
validateForm!: FormGroup;
constructor(private modal: NzModalRef, private fb: FormBuilder, private http: HttpClient) { }
constructor(private modal: NzModalRef, private fb: FormBuilder, private http: HttpClient, private toTree: TreeService) { }
multipleValue: any
ngOnInit(): void {
this.nodes.length != 0 ? null : this.getAllMenus()
this.multipleValue = this.data.grantedPermissions
this.validateForm = this.fb.group({
name: [null, [Validators.required]],
power: [null, [Validators.required]]
power: [null, [Validators.required]],
// menus: [null]
});
if (this.optionList.length == 0) {
this.loadMore()
}
}
totalCount
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)]
})
}
destroyModal(): void {
this.modal.destroy({ data: 'this the result data' });
}

20
src/app/system-management/role/menus/menus.component.html

@ -0,0 +1,20 @@
<div class="box">
<form nz-form [formGroup]="validateForm">
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzFor="菜单">菜单</nz-form-label>
<nz-form-control>
<nz-tree-select #nzTreeComponent formControlName="menus" [nzNodes]="nodes" nzShowSearch nzCheckable nzPlaceHolder="请选择菜单"
[nzExpandedIcon]="multiExpandedIconTpl">
</nz-tree-select>
</nz-form-control>
<ng-template #multiExpandedIconTpl let-node let-origin="origin">
<ng-container *ngIf="node.children.length == 0; else elseTemplate">
</ng-container>
<ng-template #elseTemplate>
<i nz-icon [nzType]="node.isExpanded ? 'caret-down' : 'caret-right'"
class="ant-tree-switcher-line-icon"></i>
</ng-template>
</ng-template>
</nz-form-item>
</form>
</div>

0
src/app/system-management/role/menus/menus.component.scss

71
src/app/system-management/role/menus/menus.component.ts

@ -0,0 +1,71 @@
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Component, OnInit, Input, ViewChild } from '@angular/core';
import { NzModalRef } from 'ng-zorro-antd/modal';
import { HttpClient } from '@angular/common/http';
import { TreeService } from 'src/app/service/tree.service';
import { NzTreeComponent } from 'ng-zorro-antd/tree';
@Component({
selector: 'app-menus',
templateUrl: './menus.component.html',
styleUrls: ['./menus.component.scss']
})
export class MenusComponent implements OnInit {
@ViewChild('nzTreeComponent', { static: false }) nzTreeComponent!: NzTreeComponent;
@Input() data?: any;
@Input() nodes?: any;
validateForm!: FormGroup;
constructor(private modal: NzModalRef, private fb: FormBuilder, private http: HttpClient, private toTree: TreeService) { }
ngOnInit(): void {
this.nodes.length != 0 ? null : this.getAllMenus()
this.getMenus()
this.validateForm = this.fb.group({
menus: []
});
}
getMenus() {
let params = {
Id: this.data.id,
}
this.http.get('/api/services/app/Role/Get', {
params: params
}).subscribe((data: any) => {
// console.log(666, data)
let arr = []
data.result.menus.forEach(element => {
arr.push(element.id)
});
this.validateForm.patchValue({
menus: arr
});
})
}
totalCount
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)]
})
}
destroyModal(): void {
this.modal.destroy({ data: 'this the result data' });
}
}

5
src/app/system-management/role/role.component.html

@ -13,7 +13,7 @@
<thead>
<tr>
<th style="padding-left: 40px;">角色</th>
<th>权限</th>
<th [nzWidth]="'60%'">权限</th>
<th>创建/修改时间</th>
<th>操作</th>
</tr>
@ -29,10 +29,11 @@
</td>
<td class="operation">
<a (click)="edit(data)">编辑</a>
<a (click)="allotMenus(data)">分配菜单</a>
<a (click)="delete(data)">删除</a>
</td>
</tr>
</tbody>
</nz-table>
</div>
</div>
</div>

60
src/app/system-management/role/role.component.ts

@ -6,6 +6,7 @@ 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';
import { MenusComponent } from './menus/menus.component';
@Component({
selector: 'app-role',
templateUrl: './role.component.html',
@ -112,7 +113,8 @@ export class RoleComponent implements OnInit {
// nzOkLoading: true,
nzComponentParams: {
data: item,
optionList: this.optionList
optionList: this.optionList,
nodes: this.nodes
},
nzMaskClosable: false,
nzOnOk: async () => {
@ -148,6 +150,62 @@ export class RoleComponent implements OnInit {
modal.afterClose.subscribe(result => console.log('[afterClose] The result is:', result));
}
allotMenus(item) {
// console.log(item)
const modal = this.modal.create({
nzTitle: '分配菜单',
nzContent: MenusComponent,
nzViewContainerRef: this.viewContainerRef,
nzWidth: 400,
nzComponentParams: {
data: item,
nodes: this.nodes
},
nzMaskClosable: false,
nzOnOk: async () => {
await new Promise(resolve => {
console.log('表单信息', instance.validateForm)
console.log('tree', instance.nzTreeComponent.getCheckedNodeList())
let arr = []
let treeData = instance.nzTreeComponent.getCheckedNodeList()
treeData.forEach(element => {
arr.push(element.key)
if (element.origin.children.length != 0) {
element.origin.children.forEach(ele => {
arr.push(ele.key)
})
}
if (element.parentNode) {
arr.push(element.parentNode.key)
}
});
console.log(99999999999, arr)
console.log(777777777777)
return false
// let body = instance.validateForm.value.menus
// this.http.post('/api/services/app/Role/SetRoleMenus', body, {
// params: {
// roleId: item.id
// }
// }).subscribe(data => {
// resolve(data)
// this.message.create('success', '分配成功!');
// this.getAllRoles()
// return true
// })
})
}
});
const instance = modal.getContentComponent();
// modal.afterOpen.subscribe(() => console.log('[afterOpen] emitted!'));
// modal.afterClose.subscribe(result => console.log('[afterClose] The result is:', result));
}
optionList = [];
//获取权限列表
loadMore() {

5
src/app/system-management/system-management.module.ts

@ -43,8 +43,9 @@ import { EditUpdateOfLicenseComponent } from './update-of-license/edit-update-of
import { MenuComponent } from './menu/menu.component';
import { AddmenuComponent } from './menu/addmenu/addmenu.component';
import { EditmenuComponent } from './menu/editmenu/editmenu.component';
import { MenusComponent } from './role/menus/menus.component';
@NgModule({
declarations: [OrganizationComponent, UserComponent, RoleComponent, NavigationComponent, AdduserComponent, EdituserComponent, AddroleComponent, EditroleComponent, AddorComponent, EditorComponent, AnalysisOfTheHostComponent, AddhostComponent, EdithostComponent, AddcameraComponent, EditcameraComponent, PushComponent, EditPushItemComponent, FileOfLicenseComponent, UpdateOfLicenseComponent, AddFileOfLicenseComponent, EditFileOfLicenseComponent, AddUpdateOfLicenseComponent, EditUpdateOfLicenseComponent, MenuComponent, AddmenuComponent, EditmenuComponent],
declarations: [OrganizationComponent, UserComponent, RoleComponent, NavigationComponent, AdduserComponent, EdituserComponent, AddroleComponent, EditroleComponent, AddorComponent, EditorComponent, AnalysisOfTheHostComponent, AddhostComponent, EdithostComponent, AddcameraComponent, EditcameraComponent, PushComponent, EditPushItemComponent, FileOfLicenseComponent, UpdateOfLicenseComponent, AddFileOfLicenseComponent, EditFileOfLicenseComponent, AddUpdateOfLicenseComponent, EditUpdateOfLicenseComponent, MenuComponent, AddmenuComponent, EditmenuComponent, MenusComponent],
imports: [
CommonModule,
SystemRoutingModule,
@ -66,7 +67,7 @@ import { EditmenuComponent } from './menu/editmenu/editmenu.component';
NzTreeSelectModule,
NzCheckboxModule
],
entryComponents: [AdduserComponent, EdituserComponent, AddroleComponent, EditroleComponent, AddorComponent, EditorComponent, AddhostComponent, EdithostComponent, AddcameraComponent, EditcameraComponent, EditPushItemComponent, AddFileOfLicenseComponent, EditFileOfLicenseComponent, AddUpdateOfLicenseComponent, EditUpdateOfLicenseComponent,AddmenuComponent,EditmenuComponent]
entryComponents: [AdduserComponent, EdituserComponent, AddroleComponent, EditroleComponent, AddorComponent, EditorComponent, AddhostComponent, EdithostComponent, AddcameraComponent, EditcameraComponent, EditPushItemComponent, AddFileOfLicenseComponent, EditFileOfLicenseComponent, AddUpdateOfLicenseComponent, EditUpdateOfLicenseComponent, AddmenuComponent, EditmenuComponent, MenusComponent]
})
export class SystemManagementModule { }

Loading…
Cancel
Save