Newer
Older
import {Component, OnInit, ViewChild} from '@angular/core';
import {OverAllService} from '../../overAll/overAll.service';
import {
FormBuilder,
FormGroup,
Validators
} from '@angular/forms';
import {BasicKeyComponent} from '../basic-key/basic-key.component';
import {NzMessageService} from 'ng-zorro-antd';
import {NewTypeComponent} from '../new-type/new-type.component';
selector: 'smart-basi-check',
templateUrl: './basi-check.component.html',
styles: [
`.tag-button[disabled],
.tag-button {
width: 80%;
height: 30px;
color: rgba(0, 0, 0, 0.65);
background-color: #fff;
border-color: #d9d9d9;
}`
]
@ViewChild('basicKey') basicKey: BasicKeyComponent;
@ViewChild('newType') newType: NewTypeComponent;
constructor(private overAllSer: OverAllService, private fb: FormBuilder,
private message: NzMessageService) {
}
ngOnInit() {
this.validateForm = {
hostid: this.hostId,
name: null,
interfaceid: null,
key_: null,
value_type: null,
type: null,
units: null,
history: null,
trends: null,
valuemapid: null,
delay: null,
condition_commonly: null, //故障
condition_high: null, //故障
faultCondition_commonly: null, //危险
faultCondition_high: null, //危险
delta: null,
formula: null
this.isCheck = true;
this.hostId = hostId;
this.validateForm = {
name: null,
interfaceid: null,
key_: null,
value_type: null,
type: null,
units: null,
history: null,
trends: null,
valuemapid: null,
delay: null,
condition_commonly: null, //故障
condition_high: null, //故障
faultCondition_commonly: null, //危险
faultCondition_high: null, //危险
delta: null,
formula: null,
applicationids: null
this.overAllSer.findDetailed(this.hostId).subscribe(
(res) => {
this.interfaceList = res.data[0].interfaces;
const data = {
hostid: this.hostId,
name: this.validateForm.name,
interfaceid: this.validateForm.interfaceid,
key_: this.validateForm.key_,
value_type: Number(this.validateForm.value_type),
type: Number(this.validateForm.type),
data_type: Number(this.validateForm.data_type),
units: this.validateForm.units,
history: this.validateForm.history + 'd',
trends: this.validateForm.trends + 'd',
valuemapid: this.validateForm.valuemapid,
delay: this.validateForm.delay,
condition: '', //故障
faultCondition: '', //危险
delta: Number(this.validateForm.delta),
formula: this.validateForm.formula,
applicationids: [this.validateForm.applicationids]
};
if (this.conditionType == 'commonly') { //常规
this.conditionList.forEach(res => {
data.condition += '{' + this.validateForm.name + ':' + this.validateForm.key_ + '.last()}' + res.equal + '' + res.value ;
data.faultCondition += '{' + this.validateForm.name + ':' + this.validateForm.key_ + '.last()}' + res.equal + '' + res.value;
});
} else { //高级
data.condition = this.validateForm.condition_high;
data.faultCondition = this.validateForm.faultCondition_high;
}
console.log(this.conditionList);
console.log(this.faultConditionList);
console.log(data);
this.overAllSer.create(data).subscribe(
this.isCheck = false;
}
this.message.info(res.errMsg);
},
}
handleCheckCancel(): void {
this.isCheck = false;
}
//键值查询
(res) => {
if (res.errCode == 10000) {
this.message.info('添加成功');