Commit 440e1ebe authored by wangqinghua's avatar wangqinghua

update

parent 476f114c
...@@ -32,7 +32,7 @@ export class AlarmModalComponent implements OnInit { ...@@ -32,7 +32,7 @@ export class AlarmModalComponent implements OnInit {
nodes; nodes;
nodeList; nodeList;
actionid; //告警Id actionid; //告警Id
isEvent = "2"; isEvent = '2';
groupList; groupList;
sendOption = []; sendOption = [];
...@@ -47,7 +47,7 @@ export class AlarmModalComponent implements OnInit { ...@@ -47,7 +47,7 @@ export class AlarmModalComponent implements OnInit {
operatorList = []; //负责人列表 operatorList = []; //负责人列表
constructor(private alarmSer: AlarmService, private message: NzMessageService, constructor(private alarmSer: AlarmService, private message: NzMessageService,
private overAllSer: OverAllService,private workSer: WorkService,) { private overAllSer: OverAllService, private workSer: WorkService,) {
} }
ngOnInit() { ngOnInit() {
...@@ -62,22 +62,22 @@ export class AlarmModalComponent implements OnInit { ...@@ -62,22 +62,22 @@ export class AlarmModalComponent implements OnInit {
//初始化 //初始化
initForm() { initForm() {
this.tabNum = 0; this.tabNum = 0;
this.isEvent = "2"; this.isEvent = '2';
this.selectTreeList = []; this.selectTreeList = [];
this.sendInfoList = []; this.sendInfoList = [];
this.operatorList = []; //负责人列表 this.operatorList = []; //负责人列表
this.validateForm = { this.validateForm = {
name: null, name: null,
alertGroupId: null, alertGroupId: null,
warn:0, warn: 0,
serious:0, serious: 0,
mediaTypeIds:[], mediaTypeIds: [],
def_longdata:"问题 {TRIGGER.NAME} 开始于: {EVENT.TIME} {EVENT.DATE}\n" + def_longdata: '问题 {TRIGGER.NAME} 开始于: {EVENT.TIME} {EVENT.DATE}\n' +
"主机: {HOST.NAME}\n" + '主机: {HOST.NAME}\n' +
"严重程度: {TRIGGER.SEVERITY}\n" + '严重程度: {TRIGGER.SEVERITY}\n' +
"\n" + '\n' +
"原始问题ID: {EVENT.ID}", '原始问题ID: {EVENT.ID}',
r_longdata:'' + r_longdata: '' +
'问题 {TRIGGER.NAME} 恢复于: {EVENT.TIME} {EVENT.DATE} \n' + '问题 {TRIGGER.NAME} 恢复于: {EVENT.TIME} {EVENT.DATE} \n' +
'主机: {HOST.NAME}\n' + '主机: {HOST.NAME}\n' +
'严重程度: {TRIGGER.SEVERITY}\n' + '严重程度: {TRIGGER.SEVERITY}\n' +
...@@ -85,11 +85,11 @@ export class AlarmModalComponent implements OnInit { ...@@ -85,11 +85,11 @@ export class AlarmModalComponent implements OnInit {
'原始问题ID: {EVENT.ID}\n' + '原始问题ID: {EVENT.ID}\n' +
'{TRIGGER.URL}' '{TRIGGER.URL}'
, ,
sendInfos:null, sendInfos: null,
event:{ event: {
eventTypeId:null, //事件分类id eventTypeId: null, //事件分类id
operators:null, //事件负责人 operators: null, //事件负责人
title:null, //事件标题 title: null, //事件标题
} }
}; };
} }
...@@ -126,7 +126,7 @@ export class AlarmModalComponent implements OnInit { ...@@ -126,7 +126,7 @@ export class AlarmModalComponent implements OnInit {
} }
//获取告警分组 //获取告警分组
getGroup(){ getGroup() {
this.alarmSer.alertGroupFind().subscribe( this.alarmSer.alertGroupFind().subscribe(
(res) => { (res) => {
if (res.errCode == 10000) { if (res.errCode == 10000) {
...@@ -144,7 +144,7 @@ export class AlarmModalComponent implements OnInit { ...@@ -144,7 +144,7 @@ export class AlarmModalComponent implements OnInit {
//下级 //下级
mouseAction(name: string, event: NzFormatEmitEvent) { mouseAction(name: string, event: NzFormatEmitEvent) {
if(event.node.children.length > 0){ if (event.node.children.length > 0) {
return false; return false;
} }
const index = <any>event.node.key - 1; const index = <any>event.node.key - 1;
...@@ -158,10 +158,13 @@ export class AlarmModalComponent implements OnInit { ...@@ -158,10 +158,13 @@ export class AlarmModalComponent implements OnInit {
(res) => { (res) => {
if (res.data) { if (res.data) {
const dataSet = res.data; const dataSet = res.data;
dataSet.forEach(res => { dataSet.forEach(e => {
res.title = res.name; e.title = e.name;
res.key = res.groupid; e.key = e.hostid;
res.isLeaf = true; e.isLeaf = true;
if(this.selectTreeList.includes(e.key)){
e.checked = true;
}
}); });
event.node.addChildren(dataSet); event.node.addChildren(dataSet);
} else { } else {
...@@ -208,17 +211,17 @@ export class AlarmModalComponent implements OnInit { ...@@ -208,17 +211,17 @@ export class AlarmModalComponent implements OnInit {
} }
//添加发送方式 //添加发送方式
addOption(){ addOption() {
const data = { const data = {
mediaType:null, mediaType: null,
receiver:"" receiver: ''
}; };
this.sendInfoList.push(data); this.sendInfoList.push(data);
} }
//删除发送方式 //删除发送方式
deleteOption(index){ deleteOption(index) {
this.sendInfoList.splice(index,1); this.sendInfoList.splice(index, 1);
} }
//新增告警 //新增告警
...@@ -228,42 +231,56 @@ export class AlarmModalComponent implements OnInit { ...@@ -228,42 +231,56 @@ export class AlarmModalComponent implements OnInit {
} }
//编辑告警 //编辑告警
showEditModal(title,id) { showEditModal(title, id) {
this.title = title; this.title = title;
this.isShow = true; this.isShow = true;
this.actionid = id; this.actionid = id;
this.alarmSer.getAction(id).subscribe( this.alarmSer.getAction(id).subscribe(
(res)=>{ (res) => {
this.validateForm = res.data; this.viewData(res.data);
//事件负责人回显 }
if(res.data.event){ );
this.isEvent = "1"; }
this.operatorList = res.data.event.operators.map(e=>{
const d = {
username: e.username,
userId: e.userId
};
return d;
})
}
//发送方式回显 //回显数据
if(res.data.sendInfos && res.data.sendInfos.length > 0){ viewData(data) {
this.sendInfoList = res.data.sendInfos.map(e=>{ this.validateForm = data;
const d = { //事件负责人回显
mediaType:e.mediaType, if (data.event) {
receiver:e.receiver this.isEvent = '1';
}; this.operatorList = data.event.operators.map(e => {
return d; const d = {
}) username: e.username,
} userId: e.userId
};
return d;
});
}
//恢复信息 //发送方式回显
if(res.data.r_longdata){ if (data.sendInfos && data.sendInfos.length > 0) {
this.selectModal = true; this.sendInfoList = data.sendInfos.map(e => {
} const d = {
mediaType: e.mediaType,
receiver: e.receiver
};
return d;
});
}
//恢复信息
if (data.r_longdata) {
this.selectModal = true;
}
//
this.selectTreeList = data.hostIds;
this.nodeList.forEach(e => {
if (data.hostIds.includes(e.key)) {
e.checked = true;
} }
) });
this.toNode(this.nodeList);
} }
//取消 //取消
...@@ -278,12 +295,12 @@ export class AlarmModalComponent implements OnInit { ...@@ -278,12 +295,12 @@ export class AlarmModalComponent implements OnInit {
} }
//选择处理人弹窗 //选择处理人弹窗
selectPerson(){ selectPerson() {
this.smartSelectPerson.showModal("选择事件负责人",null); this.smartSelectPerson.showModal('选择事件负责人', null);
} }
//选择事件负责人done //选择事件负责人done
getUser(e){ getUser(e) {
const arr = []; const arr = [];
e.forEach(res => { e.forEach(res => {
const data = { const data = {
...@@ -295,103 +312,103 @@ export class AlarmModalComponent implements OnInit { ...@@ -295,103 +312,103 @@ export class AlarmModalComponent implements OnInit {
this.operatorList = arr; this.operatorList = arr;
} }
deleteOperator(index){ deleteOperator(index) {
this.operatorList.splice(index,1); this.operatorList.splice(index, 1);
} }
//保存 //保存
handEditleOk() { handEditleOk() {
if(!this.check()){ if (!this.check()) {
return false; return false;
} }
const optionArr = []; const optionArr = [];
this.sendOption.forEach(res=>{ this.sendOption.forEach(res => {
if(res.checked){ if (res.checked) {
optionArr.push(res.value); optionArr.push(res.value);
} }
}); });
this.validateForm.warn = this.validateForm.warn == true ? 1:0; this.validateForm.warn = this.validateForm.warn == true ? 1 : 0;
this.validateForm.serious = this.validateForm.serious == true?1:0; this.validateForm.serious = this.validateForm.serious == true ? 1 : 0;
const data = { const data = {
name: this.validateForm.name, name: this.validateForm.name,
alertGroupId: this.validateForm.alertGroupId, alertGroupId: this.validateForm.alertGroupId,
warn:this.validateForm.warn, warn: this.validateForm.warn,
serious:this.validateForm.serious, serious: this.validateForm.serious,
mediaTypeIds:optionArr, mediaTypeIds: optionArr,
sendInfos:this.sendInfoList, sendInfos: this.sendInfoList,
def_longdata:this.validateForm.def_longdata, def_longdata: this.validateForm.def_longdata,
r_longdata:this.validateForm.r_longdata, r_longdata: this.validateForm.r_longdata,
r_shortdata:this.validateForm.r_shortdata, r_shortdata: this.validateForm.r_shortdata,
hostIds:this.selectTreeList, hostIds: this.selectTreeList,
event:{ event: {
eventTypeId:this.validateForm.event.eventTypeId, //事件分类id eventTypeId: this.validateForm.event.eventTypeId, //事件分类id
operators:this.operatorList, //事件负责人 operators: this.operatorList, //事件负责人
title:this.validateForm.event.title, //事件标题 title: this.validateForm.event.title, //事件标题
} }
}; };
if(this.title == '添加告警'){ if (this.title == '添加告警') {
this.create(data) this.create(data);
} }
if(this.title == "编辑告警"){ if (this.title == '编辑告警') {
this.update(data); this.update(data);
} }
} }
//校验 //校验
check(){ check() {
if(!this.validateForm.name){ if (!this.validateForm.name) {
this.message.error("请输入告警名称"); this.message.error('请输入告警名称');
return false; return false;
} }
if(this.sendInfoList.length == 0){ if (this.sendInfoList.length == 0) {
this.message.error("请选择发送对象"); this.message.error('请选择发送对象');
return false; return false;
} }
if(this.selectTreeList.length == 0 ){ if (this.selectTreeList.length == 0) {
this.message.error("请选择告警目标"); this.message.error('请选择告警目标');
return false; return false;
} }
if(!this.validateForm.alertGroupId ){ if (!this.validateForm.alertGroupId) {
this.message.error("请选择告警分组"); this.message.error('请选择告警分组');
return false; return false;
} }
if(!this.validateForm.def_longdata ){ if (!this.validateForm.def_longdata) {
this.message.error("请输入发送信息"); this.message.error('请输入发送信息');
return false; return false;
} }
if(this.isEvent == '1'){ if (this.isEvent == '1') {
if(!this.validateForm.event.title ){ if (!this.validateForm.event.title) {
this.message.error("请输入事件标题"); this.message.error('请输入事件标题');
return false; return false;
} }
if(!this.validateForm.event.eventTypeId ){ if (!this.validateForm.event.eventTypeId) {
this.message.error("请选择事件分类"); this.message.error('请选择事件分类');
return false; return false;
} }
if(this.operatorList.length == 0 ){ if (this.operatorList.length == 0) {
this.message.error("请选择事件负责人"); this.message.error('请选择事件负责人');
return false; return false;
} }
} }
let number = true; let number = true;
this.sendInfoList.map(e=>{ this.sendInfoList.map(e => {
if(!e.mediaType){ if (!e.mediaType) {
number = false; number = false;
} }
if(!e.receiver){ if (!e.receiver) {
number = false; number = false;
} }
}); });
if(!number){ if (!number) {
this.message.error("请输入发送对象"); this.message.error('请输入发送对象');
return false; return false;
} }
...@@ -399,15 +416,15 @@ export class AlarmModalComponent implements OnInit { ...@@ -399,15 +416,15 @@ export class AlarmModalComponent implements OnInit {
} }
//创建 //创建
create(data){ create(data) {
this.alarmSer.actionCreate(data).subscribe( this.alarmSer.actionCreate(data).subscribe(
(res) => { (res) => {
if(res.errCode == 10000){ if (res.errCode == 10000) {
this.isShow = false; this.isShow = false;
this.initForm(); this.initForm();
this.done.emit(); this.done.emit();
this.message.success("创建告警成功"); this.message.success('创建告警成功');
}else{ } else {
this.message.error(res.errMsg); this.message.error(res.errMsg);
} }
} }
...@@ -415,16 +432,16 @@ export class AlarmModalComponent implements OnInit { ...@@ -415,16 +432,16 @@ export class AlarmModalComponent implements OnInit {
} }
//修改 //修改
update(data){ update(data) {
data.actionid = this.actionid; data.actionid = this.actionid;
this.alarmSer.actionUpdate(data).subscribe( this.alarmSer.actionUpdate(data).subscribe(
(res) => { (res) => {
if(res.errCode == 10000){ if (res.errCode == 10000) {
this.isShow = false; this.isShow = false;
this.initForm(); this.initForm();
this.done.emit(); this.done.emit();
this.message.success("编辑告警成功"); this.message.success('编辑告警成功');
}else{ } else {
this.message.error(res.errMsg); this.message.error(res.errMsg);
} }
} }
......
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