Newer
Older
import {AfterViewChecked, AfterViewInit, Component, ElementRef, OnInit, ViewChild} from '@angular/core';
import {NzMessageService, NzModalService, UploadFile} from 'ng-zorro-antd';
import {TopologyComponent} from '../model/topology/topology.component';
import {CheckComponent} from '../model/check/check.component';
import {DeviceComponent} from '../model/device/device.component';
import {SelectGroupComponent} from '../../modal/select-group/select-group.component';
@Component({
selector: 'smart-ne-topology',
templateUrl: './ne-topology.component.html',
`
.layui-side-scroll {
width: initial;
}
.layui-layout-right {
position: absolute;
top: 10px;
left: 20px;
color: #ca0814;
font-size: 20px;
}
position: absolute;
top: 10px;
right: 20px;
color: #666666;
font-size: 20px;
}
vertical-align: middle;
color: red;
font-size: 15px;
margin-left: 12px;
cursor: pointer;
}
@ViewChild('smartTopology') smartTopology: TopologyComponent;
@ViewChild('smartCheck') smartCheck: CheckComponent;
@ViewChild('smartSelectGroup') smartSelectGroup: SelectGroupComponent;
constructor(private topologySer: TopologyService, private message: NzMessageService,
//一级分类
getTypeList(){
this.topologySer.findTreeWithWeb().subscribe(
(res)=>{
if(res.errCode == 10000){
this.options = res.data;
layui.use('form', function() {
let form = layui.form;
form.render("select");
});
}else{
this.message.error(res.errMSg);
}
}
)
}
ngAfterViewInit() {
layui.use('element', () => {
let element = layui.element;
element.init();
});
addCheck() {
if (!this.topoId) {
this.message.warning('请选择需要编辑的拓扑图');
addDevice() {
if (!this.topoId) {
this.message.warning('请选择需要编辑的拓扑图');
(res) => {
if (res.errCode == 10000) {
this.dataSet = res.data;
} else {
};
this.topologySer.update(data).subscribe(
(res) => {
if (res.errCode == 10000) {
editor.loadTopologyByJson(JSON.parse(json.topology), 'img/backimg.png');
this.checkJson = json.check;
return e.id;
})
};
this.topologySer.findElementStatus(data).subscribe(
return false;
}
this.modalSer.confirm({
nzTitle: '删除',
nzContent: '<b style="color: red;">确认删除该拓扑图吗?</b>',
nzOkText: '确定',
nzOkType: 'danger',
nzOnOk: () => {
this.topologySer.delete(this.topoId).subscribe(
(res) => {
if (res.errCode == 10000) {
this.topoId = null;
}
}
);
},
nzCancelText: '取消',
nzOnCancel: () => console.log('Cancel')
console.log(event);
this.checkJson.push(JSON.parse(event));
}
//load
loadCanvas() {
// 节点树中每个节点的拖放动作定义给拓扑图编辑器
let nodes = $('[topo-div-type=\'topo-node\']');
let nodeLength = nodes.length;
for (let i = 0; i < nodeLength; i++) {
let text = $(nodes[i]).find('span').eq(0).text();
editor.drag(nodes[i], document.getElementById('topology-canvas'), text);
}
editor.loadTopology('', 'img/backimg.png');
showAddImg() {
if (!this.topoId) {
this.message.warning('请选择需要编辑的拓扑图');
this.isVisible = true;
}
beforeUpload = (file: UploadFile): boolean => {
handleOk() {
if (this.fileList.length == 0) {
this.message.warning('请选择图片');
this.fileList.forEach((file: any) => {
formData.append('file', file);