Newer
Older
import {ActivatedRoute, Router} from '@angular/router';
import {CommonService} from '../../../shared/common/common.service';
import {SystemService} from '../../../system/system.service';
import {OverAllService} from '../../overAll.service';
import {NzMessageService} from 'ng-zorro-antd';
import {pageSize} from '../../../app.constants';
import {CheckPrototypeComponent} from '../modal/check-prototype/check-prototype.component';
selector: 'smart-check-list',
templateUrl: './check-list.component.html',
styles: []
@ViewChild('smartCheckProtoType') smartCheckProtoType: CheckPrototypeComponent;
pageNum = 1;
pageCount = pageSize;
totalNum;
checkList;
selectList = [];
allChecked;
indeterminate;
constructor(private overAllSer: OverAllService, private routerInfo: ActivatedRoute, private router: Router,
private message: NzMessageService, private systemSer: SystemService,
private commonSer: CommonService) {
this.routerInfo.queryParams.subscribe(
(res) => {
this.discoveryids = res.discoveryids;
this.tempName = res.name;
this.hostId = res.hostId;
}
);
}
checkAll(value: boolean): void {
this.checkList.forEach(data => data.checked = value);
this.refreshStatus();
}
currentPageDataChange($event: Array<{ checked: boolean }>): void {
this.checkList = $event;
}
selectItem(item, e) {
if (e) {
this.selectList.push(item);
} else {
this.selectList.forEach((value, index) => {
if (value.id == item.id) {
this.selectList.splice(index, 1);
}
});
}
this.refreshStatus();
}
refreshStatus(): void {
const allChecked = this.checkList.every(value => value.checked === true);
const allUnChecked = this.checkList.every(value => !value.checked);
this.allChecked = allChecked;
this.indeterminate = (!allChecked) && (!allUnChecked);
}
ngOnInit() {
this.getList();
}
//翻页
change(e) {
this.pageNum = e;
this.getList();
}
pageNum: this.pageNum,
pageCount: this.pageCount,
discoveryids: [this.discoveryids]
};
this.overAllSer.findItemPrototype(data).subscribe(
(res) => {
this.checkList = res.data.data;
this.totalNum = res.data.totalNum;
showAddModal() {
this.smartCheckProtoType.showAddModal(this.hostId, this.discoveryids, '添加监控项原型');
showEditModal(data) {
this.smartCheckProtoType.showEditModal(this.hostId, this.discoveryids, data.itemid, '编辑监控项原型');
};
data.ids.push(item.itemid);
this.overAllSer.deleteItemPrototype(data).subscribe(
(res) => {
if (res.errCode == 10000) {
this.message.success('删除成功');
deleteBatchCheck() {
if (this.selectList.length == 0) {
this.message.warning('请选择需要删除的监控项原型');
this.commonSer.confirmThing('删除', '确定删除选择的监控项原型', () => {
const data = {
ids: this.selectList.map(e => {
return e.itemid;
})
};
this.overAllSer.deleteItemPrototype(data).subscribe(
(res) => {
if (res.errCode == 10000) {
this.message.success('删除成功');