|
|
|
import { HttpClient } from '@angular/common/http';
|
|
|
|
import { Component, OnInit, ViewContainerRef } from '@angular/core';
|
|
|
|
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
|
|
|
import { NzModalService } from 'ng-zorro-antd/modal';
|
|
|
|
import { NzMessageService } from 'ng-zorro-antd/message';
|
|
|
|
import { EditPushItemComponent } from './edit-push-item/edit-push-item.component';
|
|
|
|
@Component({
|
|
|
|
selector: 'app-push',
|
|
|
|
templateUrl: './push.component.html',
|
|
|
|
styleUrls: ['./push.component.scss']
|
|
|
|
})
|
|
|
|
|
|
|
|
export class PushComponent implements OnInit {
|
|
|
|
|
|
|
|
validateForm!: FormGroup;
|
|
|
|
constructor(private modal: NzModalService, private viewContainerRef: ViewContainerRef, private fb: FormBuilder, private http: HttpClient, private message: NzMessageService) { }
|
|
|
|
|
|
|
|
async ngOnInit(): Promise<void> {
|
|
|
|
this.validateForm = this.fb.group({
|
|
|
|
search: [null]
|
|
|
|
});
|
|
|
|
|
|
|
|
await this.getPutRoles()
|
|
|
|
await this.getHandleRoles()
|
|
|
|
this.getViolation()
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//获取预警类型
|
|
|
|
list: any
|
|
|
|
getViolation() {
|
|
|
|
this.http.get('/api/services/app/Violation/GetAllList').subscribe((data: any) => {
|
|
|
|
|
|
|
|
data.result.forEach(element => {
|
|
|
|
element.pushRoleNames = []
|
|
|
|
element.pushRoleIds.forEach(item => {
|
|
|
|
this.pushRoleIds.forEach(i => {
|
|
|
|
if (i.id == item) {
|
|
|
|
element.pushRoleNames.push(i.displayName)
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
element.handleRoleNames = []
|
|
|
|
element.handleRoleIds.forEach(item => {
|
|
|
|
this.handleRoleIds.forEach(i => {
|
|
|
|
if (i.id == item) {
|
|
|
|
element.handleRoleNames.push(i.displayName)
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
this.list = data.result
|
|
|
|
console.log('预警类型', this.list)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
//获取推送的角色列表
|
|
|
|
pushRoleIds
|
|
|
|
async getPutRoles() {
|
|
|
|
await new Promise<void>((resolve, reject) => {
|
|
|
|
this.http.get('/api/services/app/Violation/GetPutRoles').subscribe((data: any) => {
|
|
|
|
this.pushRoleIds = data.result
|
|
|
|
resolve(data)
|
|
|
|
console.log('推送角色', data)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
handleRoleIds
|
|
|
|
//获取处置的角色列表
|
|
|
|
async getHandleRoles() {
|
|
|
|
await new Promise<void>((resolve, reject) => {
|
|
|
|
this.http.get('/api/services/app/Violation/GetHandleRoles').subscribe((data: any) => {
|
|
|
|
this.handleRoleIds = data.result
|
|
|
|
resolve(data)
|
|
|
|
console.log('处置角色', data)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
edititem(item) {
|
|
|
|
const modal = this.modal.create({
|
|
|
|
nzTitle: '编辑推送设置',
|
|
|
|
nzContent: EditPushItemComponent,
|
|
|
|
nzViewContainerRef: this.viewContainerRef,
|
|
|
|
nzWidth: 300,
|
|
|
|
nzComponentParams: {
|
|
|
|
data: item,
|
|
|
|
pushRoleIds: this.pushRoleIds,
|
|
|
|
handleRoleIds: this.handleRoleIds
|
|
|
|
},
|
|
|
|
nzOnOk: async () => {
|
|
|
|
if (instance.validateForm.valid) {
|
|
|
|
await new Promise(resolve => {
|
|
|
|
console.log('表单信息', instance.validateForm)
|
|
|
|
let body = {
|
|
|
|
id: item.id,
|
|
|
|
pushRoleIds: instance.validateForm.value.push,
|
|
|
|
handleRoleIds: instance.validateForm.value.handle,
|
|
|
|
}
|
|
|
|
this.http.put('/api/services/app/Violation/UpdateRoles', body).subscribe(data => {
|
|
|
|
resolve(data)
|
|
|
|
this.message.create('success', '修改成功!');
|
|
|
|
this.getViolation()
|
|
|
|
return true
|
|
|
|
})
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
this.message.create('warning', '请填写完整!');
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
const instance = modal.getContentComponent();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//搜索框提交
|
|
|
|
submitForm(): void {
|
|
|
|
for (const i in this.validateForm.controls) {
|
|
|
|
this.validateForm.controls[i].markAsDirty();
|
|
|
|
this.validateForm.controls[i].updateValueAndValidity();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|