Newer
Older
import {Component, OnInit, Output, ViewChild} from '@angular/core';
import {BusinessComponent} from '../modal/business/business.component';
import {TreeNodeInterface} from '../../overAll/basic/basic.component';
import {NzMessageService} from 'ng-zorro-antd';
import {WebModalComponent} from '../../modal/web-modal/web-modal.component';
import {AlarmModalComponent} from '../../modal/alarm-modal/alarm-modal.component';
selector: 'smart-b-config',
templateUrl: './b-config.component.html',
styles: []
//分页
pageNum = 1;
pageCount = pageSize;
totalNum;
searchStatus = false;
searchList;
constructor(private busineSer: BusinessService, private message: NzMessageService,
private commonSer: CommonService) {
dataSet: any[];
expandDataCache = {};
collapse(array: TreeNodeInterface[], data: TreeNodeInterface, $event: boolean): void {
if ($event === false) {
if (data.children) {
data.children.forEach(d => {
const target = array.find(a => a.serviceid === d.serviceid);
target.expand = false;
this.collapse(array, target, false);
});
} else {
return;
}
}
}
convertTreeToList(root: any, index: string, serviceid: string): TreeNodeInterface[] {
while (stack.length !== 0) {
const node = stack.pop();
this.visitNode(node, hashMap, array);
if (node.children) {
for (let i = node.children.length - 1; i >= 0; i--) {
stack.push({...node.children[i], level: node.level + 1, expand: true, parent: node});
}
}
}
return array;
}
visitNode(node: TreeNodeInterface, hashMap: object, array: TreeNodeInterface[]): void {
this.expandDataCache[item.serviceid] = this.convertTreeToList(item, index, serviceid);
/**
* 获取下级
* @param item 当前节点
* @param data 当前节点的根节点
*/
getChildren(item, data) {
if (item.children.length > 0) {
if (item.expand) {
item.expand = false;
} else {
item.expand = true;
}
return false;
}
this.setDateSet(this.dataSet, item, res.data);
this.toTree(data.index, item.serviceid);
} else {
this.message.info('该分组下无资源');
}
this.isLoading = false;
}
if (array.length > 0) {
const target = array.find(a => a.serviceid === data.serviceid);
if (target) {
target.children = insertArr;
} else {
array.forEach(o => {
this.setDateSet(o.children, data, insertArr);
};
data.serviceids.push(item.serviceid);
this.busineSer.deleteService(data).subscribe(
if (res.errCode == 10000) {
this.message.success('删除成功');
this.getList();
} else {
this.message.error(res.errMsg);
}
}
contract(e) {
this.busineSer.relatedHttptest(this.contractId, e.httptestid).subscribe(
(res) => {
if (res.errCode == 10000) {
this.message.success('关联网站成功');
(res) => {
if (res.errCode == 10000) {
if (res.data.now) {
item.now = res.data.now.time;
if (res.data.last) {
item.last = res.data.last.time;
}
} else {
this.message.error(res.errMsg);
}
showEditModal(item) {
this.smartBusiness.showEditModal('编辑业务', item);
showAlarmModal(item) {
this.smartAlarmModal.showAddModal('添加告警推送',item.serviceid);
}
//编辑告警推送
showEditAlarmModal(item){
this.smartAlarmModal.showEditModal("编辑告警推送",item.serviceAction.actionId)
//查询
reset() {
this.searchStatus = true;
this.pageNum = 1;
this.search();
}
//backList
backList() {
this.searchStatus = false;
}
search(){
this.isLoading = true;
const data = {
pageNum:this.pageNum,
pageCount:this.pageCount,
search:this.searchName
}
this.busineSer.findPage(data).subscribe(
(res)=>{
if(res.errCode == 10000){
this.searchList = res.data.data;
this.totalNum = res.data.totalNum;
}
this.isLoading = false;
}
)
}