Commit bdaebc34 authored by wangqinghua's avatar wangqinghua

directive

parent f98e9779
......@@ -107,6 +107,8 @@ import {LogAnalysisComponent} from './business/log-analysis/log-analysis.compone
import {BConfigComponent} from './business/b-config/b-config.component';
import {BusinessService} from './business/business.service';
import {BusinessComponent} from './business/modal/business/business.component';
import {DisableControlDirective} from './shared/common/disable-control.directive';
import {SelectTriggerComponent} from './modal/select-trigger/select-trigger.component';
@NgModule({
imports: [
......@@ -170,6 +172,7 @@ import {BusinessComponent} from './business/modal/business/business.component';
IconComponent,
ToUtilPipe,
ToRepeatPipe,
DisableControlDirective,
LookPlanComponent,
PlanModalComponent,
SelectPersonComponent,
......@@ -216,6 +219,7 @@ import {BusinessComponent} from './business/modal/business/business.component';
LogAnalysisComponent,
BConfigComponent,
BusinessComponent,
SelectTriggerComponent,
],
providers:[
OverAllService,
......
......@@ -12,7 +12,7 @@
</nz-breadcrumb-item>
</nz-breadcrumb>
</div>
<div nz-col nzSpan="2" class="text-right">
<div nz-col nzSpan="12" class="text-right">
<button (click)="ngOnInit()" nz-button nzType="primary"><i class="anticon anticon-sync"></i></button>
<smart-full-screen></smart-full-screen>
</div>
......@@ -20,19 +20,94 @@
<div nz-row class="search-form tag-form">
<div nz-col nzSpan="12">
<nz-select style="width: 200px;" nzPlaceHolder="选择业务" [(ngModel)]="selectedValue"
(ngModelChange)="select()">
<nz-select style="width: 200px;" nzPlaceHolder="选择业务">
<nz-option nzLabel="按设备类型展开" nzValue="type"></nz-option>
<nz-option nzLabel="按资源分组展开" nzValue="group"></nz-option>
</nz-select>
</div>
<div nz-col nzSpan="12" class="text-right">
<button nz-button nzType="default" (click)="showAddModal()"><i class="anticon anticon-plus-circle-o"></i>添加</button>
<button (click)="openBatchHost(1,'停止')" nz-button nzType="default"><i class="anticon anticon-pause-circle-o"></i>编辑</button>
<button (click)="batchDeleteConfirm()" nz-button nzType="default"><i class="anticon anticon-close-circle-o"></i>删除资源</button>
<button nz-button nzType="default"><i class="anticon anticon-pause-circle-o"></i>编辑</button>
<button nz-button nzType="default"><i class="anticon anticon-close-circle-o"></i>删除资源</button>
</div>
</div>
<nz-table #nzTable [nzData]="dataSet" nzSingleSort [nzLoading]="isLoading" [nzShowPagination]="false">
<thead>
<tr>
<th [nzChecked]="allChecked"></th>
<th>名称</th>
<th>状态</th>
<th>关联网站</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<ng-template ngFor let-data [ngForOf]="nzTable.data">
<ng-template ngFor let-item [ngForOf]="expandDataCache[data.host]">
<tr *ngIf="(item.parent&&item.parent.expand)||!(item.parent)">
<!--父级-->
<ng-container *ngIf="!item.level">
<td></td>
<td [nzIndentSize]="item.level*20" nzShowExpand [nzExpand]='item.expand'
(nzExpandChange)="getChildren(item)">
<span>{{item.name}}</span>
</td>
</ng-container>
<!--子集-->
<ng-container *ngIf="item.level">
<td nzShowCheckbox [nzIndeterminate]="indeterminate"
(nzCheckedChange)="selectChecked($event,item)" [(nzChecked)]="item.checked"></td>
<td class="cursor main-color" [nzIndentSize]="item.level*20">
<span (click)="goDetail(item)">{{item.name}}</span>
</td>
</ng-container>
<td class="round-tag tag-form">
<ng-container *ngIf="item.status == 0">
<nz-tag class="tag-green" [nzColor]="color.green"></nz-tag>
</ng-container>
<ng-container *ngIf="item.status == 2 || item.status == 3">
<nz-tag class="tag-yellow" [nzColor]="color.yellow"></nz-tag>
</ng-container>
<ng-container *ngIf="item.status == 4 || item.status == 5">
<nz-tag class="tag-red" [nzColor]="color.red"></nz-tag>
</ng-container>
</td>
<td class="cursor">
<span (click)="goTOInventory(item?.inventory?.id)">{{item?.inventory?.name}}</span>
</td>
<td class="handle main-color">
<ng-container *ngIf="!item.level">
<span (click)="showBasicEditModal(item)">添加资源</span>
<span (click)="updateGroup(item)">编辑</span>
<span (click)="showDeleteGroupConfirm(item)">删除</span>
</ng-container>
<ng-container *ngIf="item.level">
<span (click)="showBasicCheckModal(item.hostid,item.host)">添加监测点</span>
<span (click)="editBasicModal(item)">编辑</span>
<span (click)="showDeleteConfirm(item)">删除</span>
<nz-dropdown [nzTrigger]="'click'" class="table-dropdown">
<a nz-dropdown>更多 <i class="anticon anticon-down main-color"></i>
</a>
<ul nz-menu nzSelectable>
<li *ngIf="!item.monitorTask" (click)="showTempStop(item)" nz-menu-item><a>临时暂停</a></li>
<li (click)="openHost(item)" nz-menu-item><a>
<ng-container *ngIf="item.status == 1">开启</ng-container>
<ng-container *ngIf="item.status == 0">停止</ng-container>
监控
</a></li>
<li nz-menu-item (click)="goDetail(item)"><a>查看监测点</a></li>
<li (click)="showAlarm(item)" nz-menu-item><a>添加告警</a></li>
</ul>
</nz-dropdown>
</ng-container>
</td>
</tr>
</ng-template>
</ng-template>
</tbody>
</nz-table>
<!--业务-->
<smart-business #smartBusiness></smart-business>
\ No newline at end of file
import {Component, OnInit, Output, ViewChild} from '@angular/core';
import {BusinessComponent} from '../modal/business/business.component';
import {BusinessService} from '../business.service';
import {TreeNodeInterface} from '../../overAll/basic/basic.component';
import {NzMessageService} from 'ng-zorro-antd';
import {color} from '../../app.constants';
@Component({
selector: 'smart-b-config',
......@@ -9,10 +13,91 @@ import {BusinessComponent} from '../modal/business/business.component';
export class BConfigComponent implements OnInit {
@ViewChild('smartBusiness') smartBusiness: BusinessComponent;
constructor() {
sid; //节点id
color = color;
isLoading = false; //加载中
dataSet; //数据list
expandDataCache = {};
constructor(private busineSer:BusinessService,private message:NzMessageService) {
}
collapse(array: TreeNodeInterface[], data: TreeNodeInterface, $event: boolean): void {
if ($event === false) {
if (data.children) {
data.children.forEach(d => {
const target = array.find(a => a.host === d.host);
target.expand = false;
this.collapse(array, target, false);
});
} else {
return;
}
}
}
convertTreeToList(root: any, groupId: string, index): TreeNodeInterface[] {
const stack = [];
const array = [];
const hashMap = {};
if (root.host == index) {
stack.push({...root, level: 0, expand: true});
} else {
stack.push({...root, level: 0, expand: false});
}
while (stack.length !== 0) {
const node = stack.pop();
this.visitNode(node, hashMap, array);
if (node.list) {
for (let i = node.list.length - 1; i >= 0; i--) {
stack.push({...node.list[i], level: node.level + 1, expand: true, parent: node, gId: groupId, checked: false});
}
}
}
return array;
}
visitNode(node: TreeNodeInterface, hashMap: object, array: TreeNodeInterface[]): void {
if (!hashMap[node.host]) {
hashMap[node.host] = true;
array.push(node);
}
}
toTree(index) {
this.dataSet.forEach(item => {
this.expandDataCache[item.host] = this.convertTreeToList(item, item.id, index);
});
}
ngOnInit() {
this.getList();
}
//查询业务树
getList(){
this.isLoading = true;
const data = {
"sid":this.sid,
};
this.busineSer.findChild(data).subscribe(
(res)=>{
this.isLoading = false;
if(res.errCode == 10000){
this.dataSet = res.data;
this.dataSet.forEach((e,index)=>{
e.service = index;
e.checked = false;
})
this.toTree(null);
}else{
this.message.error(res.errMsg);
}
}
)
}
//添加业务
......
......@@ -89,7 +89,7 @@ export class BusinessComponent implements OnInit {
this.add.emit();
this.initForm();
} else {
this.message.info(res.errMsg);
this.message.error(res.errMsg);
}
this.isOkLoading = false;
}
......
......@@ -36,12 +36,14 @@
<div nz-row class="layui-layout layui-layout-admin header-bar">
<div nz-col nzSpan="12" class="layui-header ">
<nz-select style="width: 200px;" nzPlaceHolder="选择背景色" [(ngModel)]="backgroundColor" (ngModelChange)="changeColor()">
<nz-option nzLabel="白色" nzValue="#ffffff"></nz-option>
<nz-option nzLabel="淡绿" nzValue="#cadf91"></nz-option>
<nz-option nzLabel="棕色" nzValue="#cbb492"></nz-option>
<nz-option nzLabel="浅灰" nzValue="#c3c7c9"></nz-option>
</nz-select>
<ng-container *ngIf="editType == '只读模式'">
<nz-select style="width: 200px;" nzPlaceHolder="选择背景色" [(ngModel)]="backgroundColor" (ngModelChange)="changeColor()">
<nz-option nzLabel="白色" nzValue="#ffffff"></nz-option>
<nz-option nzLabel="淡绿" nzValue="#cadf91"></nz-option>
<nz-option nzLabel="棕色" nzValue="#cbb492"></nz-option>
<nz-option nzLabel="浅灰" nzValue="#c3c7c9"></nz-option>
</nz-select>
</ng-container>
<ng-container *ngIf="editType == '编辑模式'">
<span (click)="addDevice()">添加设备</span>
<!--<span (click)="addCheck()">添加监测点</span>-->
......
......@@ -45,7 +45,6 @@ import {DisableControlDirective} from './common/disable-control.directive';
NgbActiveModal,
CommonService,
UtilService,
DisableControlDirective,
],
entryComponents: [JhiLoginModalComponent],
exports: [
......
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