Commit 7958ca9c authored by wangqinghua's avatar wangqinghua

拓扑图增加权限

parent 71069ab4
...@@ -103,7 +103,7 @@ export class AlarmListComponent implements OnInit { ...@@ -103,7 +103,7 @@ export class AlarmListComponent implements OnInit {
this.obj.startTime = this.datePipe.transform(this.dateBegin, 'yyyy-MM-dd HH:mm:ss'); this.obj.startTime = this.datePipe.transform(this.dateBegin, 'yyyy-MM-dd HH:mm:ss');
this.obj.endTime = this.datePipe.transform(this.dateEnd, 'yyyy-MM-dd HH:mm:ss'); this.obj.endTime = this.datePipe.transform(this.dateEnd, 'yyyy-MM-dd HH:mm:ss');
} }
this.warnList.getList(this.obj); this.warnList.outGet(this.obj);
} }
//导出文件 //导出文件
......
...@@ -140,11 +140,10 @@ export class NavbarComponent implements OnInit ,AfterViewChecked{ ...@@ -140,11 +140,10 @@ export class NavbarComponent implements OnInit ,AfterViewChecked{
} }
goOut(){ goOut(){
window.location.href = "http://26.81.99.220/control/user/userlogin.php?userid=sa&userpwd=123456"; window.open('http://26.81.99.220/control/user/userlogin.php?userid=sa&userpwd=123456',"_blank");
timer(10).subscribe( timer(100).subscribe(
()=>{ ()=>{
window.location.href = "http://26.81.0.15/#/app/main/home"; window.open('http://26.81.99.220/views/index.php',"_blank");
window.open('https://cloud.cesgroup.com.cn:8888/oa/index',"_blank");
} }
) )
} }
......
<nz-modal [(nzVisible)]="isVisible" nzTitle="{{title}}" (nzOnCancel)="handleCancel()" (nzOnOk)="handleOk()"> <nz-modal [(nzVisible)]="isVisible" nzTitle="{{title}}" (nzOnCancel)="handleCancel()" (nzOnOk)="handleOk()">
<form [formGroup]="validateForm" nz-form> <form [formGroup]="validateForm" nz-form>
<nz-form-item> <nz-form-item>
<nz-form-label [nzSpan]="7" nzRequired nzFor="name">拓扑图名称</nz-form-label> <nz-form-label [nzSpan]="7" nzRequired nzFor="name">拓扑图名称</nz-form-label>
<nz-form-control [nzSpan]="12"> <nz-form-control [nzSpan]="12">
<input type="text" nz-input name="name" formControlName="name" placeholder="名称" > <input type="text" nz-input name="name" formControlName="name" placeholder="名称">
<nz-form-explain *ngIf="validateForm.get('name').dirty && validateForm.get('name').errors">请输入拓扑图名称</nz-form-explain> <nz-form-explain *ngIf="validateForm.get('name').dirty && validateForm.get('name').errors">请输入拓扑图名称
</nz-form-control> </nz-form-explain>
</nz-form-item> </nz-form-control>
<!--<nz-form-item>--> </nz-form-item>
<!--<nz-form-label [nzSpan]="7" nzRequired nzFor="refreshRete">刷新频率</nz-form-label>--> <!--<nz-form-item>-->
<!--<nz-form-control [nzSpan]="12">--> <!--<nz-form-label [nzSpan]="7" nzRequired nzFor="refreshRete">刷新频率</nz-form-label>-->
<!--<nz-form-control [nzSpan]="12">-->
<!--<input style="width: 100px;margin-right: 10px" type="text" nz-input formControlName="refreshRete" placeholder="名称" >分钟--> <!--<input style="width: 100px;margin-right: 10px" type="text" nz-input formControlName="refreshRete" placeholder="名称" >分钟-->
<!--<nz-form-explain *ngIf="validateForm.get('refreshRete').dirty && validateForm.get('refreshRete').errors">请输入刷新频率</nz-form-explain>--> <!--<nz-form-explain *ngIf="validateForm.get('refreshRete').dirty && validateForm.get('refreshRete').errors">请输入刷新频率</nz-form-explain>-->
<!--</nz-form-control>--> <!--</nz-form-control>-->
<!--</nz-form-item>--> <!--</nz-form-item>-->
<!--<nz-form-item>--> <nz-form-item>
<!--<nz-form-label [nzSpan]="7" nzRequired nzFor="json">共享角色</nz-form-label>--> <nz-form-label [nzSpan]="7" nzRequired nzFor="json">共享角色</nz-form-label>
<!--<nz-form-control [nzSpan]="12">--> <nz-form-control [nzSpan]="12">
<!--<input type="text" nz-input name="json" formControlName="json" placeholder="名称" >--> <div>
<!--<nz-form-explain *ngIf="validateForm.get('json').dirty && validateForm.get('json').errors">请输入分组名称</nz-form-explain>--> <button (click)="add()" nz-button nzType="primary">添加</button>
<!--</nz-form-control>--> </div>
<!--</nz-form-item>--> <nz-row>
</form> <nz-col nzSpan="10">用户角色</nz-col>
<nz-col nzSpan="10">权限</nz-col>
<nz-col nzSpan="4">操作</nz-col>
</nz-row>
<nz-row *ngFor="let user of userGroup;let i = index;">
<nz-col nzSpan="10">{{user.name}}</nz-col>
<nz-col nzSpan="10">
<nz-switch [(ngModel)]="user.permission" nzCheckedChildren="读写" [ngModelOptions]="{standalone: true}"
nzUnCheckedChildren="只读"></nz-switch>
</nz-col>
<nz-col nzSpan="4">
<i (click)="remove(i)" class="anticon anticon-close main-color cursor"></i>
</nz-col>
</nz-row>
</nz-form-control>
</nz-form-item>
</form>
</nz-modal> </nz-modal>
<!--授予角色-->
<smart-select-role #smartSelectRole (done)="setRole($event)"></smart-select-role>
import {Component, EventEmitter, OnInit, Output} from '@angular/core'; import {Component, EventEmitter, OnInit, Output, ViewChild} from '@angular/core';
import {FormBuilder, FormControl, FormGroup, Validators} from '@angular/forms'; import {FormBuilder, FormControl, FormGroup, Validators} from '@angular/forms';
import {TopologyService} from '../../topology.service'; import {TopologyService} from '../../topology.service';
import {NzMessageService} from 'ng-zorro-antd'; import {NzMessageService} from 'ng-zorro-antd';
import {SelectRoleComponent} from '../../../modal/select-role/select-role.component';
@Component({ @Component({
selector: 'smart-topology', selector: 'smart-topology',
...@@ -9,34 +10,38 @@ import {NzMessageService} from 'ng-zorro-antd'; ...@@ -9,34 +10,38 @@ import {NzMessageService} from 'ng-zorro-antd';
styles: [] styles: []
}) })
export class TopologyComponent implements OnInit { export class TopologyComponent implements OnInit {
@ViewChild('smartSelectRole') smartSelectRole: SelectRoleComponent;
@Output() done = new EventEmitter(); @Output() done = new EventEmitter();
isVisible = false; isVisible = false;
title: string; title: string;
validateForm:FormGroup; validateForm: FormGroup;
topoId; topoId;
pageNum; pageNum;
pageCount; pageCount;
constructor(private fb:FormBuilder,private topologySer:TopologyService, userGroup = []; //用户角色组
private message:NzMessageService) {
constructor(private fb: FormBuilder, private topologySer: TopologyService,
private message: NzMessageService) {
} }
ngOnInit() { ngOnInit() {
this.initForm(); this.initForm();
} }
initForm(){ initForm() {
this.validateForm = this.fb.group( this.validateForm = this.fb.group(
{ {
name:['',[Validators.required]], name: ['', [Validators.required]],
refreshRete:[''], refreshRete: [''],
json:[''], json: [''],
users:[[]], users: [[]],
userGroups:[[]] userGroups: [[]]
} }
) );
this.userGroup = [];
} }
showAddMOodal() { showAddMOodal() {
...@@ -51,59 +56,81 @@ export class TopologyComponent implements OnInit { ...@@ -51,59 +56,81 @@ export class TopologyComponent implements OnInit {
this.topologySer.findItem(id).subscribe( this.topologySer.findItem(id).subscribe(
(res) => { (res) => {
if (res.errCode == 10000) { if (res.errCode == 10000) {
this.validateForm.patchValue(res.data); this.validateForm.patchValue(res.data);
}else{ res.data.userGroups.forEach(r => {
this.message.create('error',`${res.errMsg}`); const data = {
userGroupId: r.userGroupId,
name: r.name,
permission: r.permission === 3,
};
this.userGroup.push(data);
});
} else {
this.message.create('error', `${res.errMsg}`);
} }
} }
); );
} }
handleOk(){ //permission 2=只读, 3=读写
for(let i in this.validateForm.controls){ handleOk() {
for (let i in this.validateForm.controls) {
this.validateForm.controls[i].markAsDirty(); this.validateForm.controls[i].markAsDirty();
this.validateForm.controls[i].updateValueAndValidity(); this.validateForm.controls[i].updateValueAndValidity();
} }
if(this.validateForm.invalid){ if (this.validateForm.invalid) {
return false; return false;
} }
if(this.title == "添加拓扑图"){ const userGroup = [];
this.userGroup.forEach(e => {
const data = {
userGroupId: e.userGroupId,
name: e.name,
permission: e.permission == true ? 3 : 2,
};
userGroup.push(data);
});
this.validateForm.patchValue({
userGroups: userGroup
});
if (this.title == '添加拓扑图') {
this.create(); this.create();
} }
if(this.title == "编辑拓扑图"){ if (this.title == '编辑拓扑图') {
this.update(); this.update();
} }
} }
create(){ create() {
this.topologySer.create(this.validateForm.value).subscribe( this.topologySer.create(this.validateForm.value).subscribe(
(res)=>{ (res) => {
if(res.errCode == 10000){ if (res.errCode == 10000) {
this.initForm(); this.initForm();
this.message.create('success', `创建成功`); this.message.create('success', `创建成功`);
this.isVisible = false; this.isVisible = false;
this.done.emit(); this.done.emit();
}else{ } else {
this.message.create('error', `${res.errMsg}`); this.message.create('error', `${res.errMsg}`);
} }
} }
) );
} }
update(){ update() {
this.validateForm.addControl('id',new FormControl(this.topoId)); this.validateForm.addControl('id', new FormControl(this.topoId));
this.topologySer.update(this.validateForm.value).subscribe( this.topologySer.update(this.validateForm.value).subscribe(
(res)=>{ (res) => {
if(res.errCode == 10000){ if (res.errCode == 10000) {
this.initForm(); this.initForm();
this.message.create('success', `编辑成功`); this.message.create('success', `编辑成功`);
this.done.emit(); this.done.emit();
this.isVisible = false; this.isVisible = false;
}else{ } else {
this.message.create('error', `${res.errMsg}`); this.message.create('error', `${res.errMsg}`);
} }
} }
) );
} }
handleCancel() { handleCancel() {
...@@ -111,4 +138,31 @@ export class TopologyComponent implements OnInit { ...@@ -111,4 +138,31 @@ export class TopologyComponent implements OnInit {
this.initForm(); this.initForm();
} }
//选择角色
add() {
this.smartSelectRole.showModal('选择角色', null);
}
//移除
remove(index) {
this.userGroup.splice(index, 1);
}
//permission 2=只读, 3=读写
setRole(e) {
const idArr = this.userGroup.map(m => {
return m.userGroupId;
});
e.forEach(f => {
if (idArr.indexOf(f.id) == -1) {
const data = {
userGroupId: f.id,
name: f.name,
permission: false,
};
this.userGroup.push(data);
}
});
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment