Commit b4d7a00b authored by wangqinghua's avatar wangqinghua

business

parent 90972e43
...@@ -46,10 +46,32 @@ ...@@ -46,10 +46,32 @@
<ng-template ngFor let-item [ngForOf]="expandDataCache[data.serviceid]"> <ng-template ngFor let-item [ngForOf]="expandDataCache[data.serviceid]">
<tr *ngIf="(item.parent&&item.parent.expand)||!(item.parent)"> <tr *ngIf="(item.parent&&item.parent.expand)||!(item.parent)">
<td [nzIndentSize]="item.level*20" [nzShowExpand]="!!item.children" [(nzExpand)]="item.expand" (nzExpandChange)="getChildren(item)"> <td [nzIndentSize]="item.level*20" [nzShowExpand]="!!item.children" [(nzExpand)]="item.expand" (nzExpandChange)="getChildren(item)">
{{item.name}} <span (click)="showEditModal(item)" class="main-color cursor">{{item.name}}</span>
</td>
<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 class="main-color cursor" (click)="contract(item)">关联</span>
</td>
<td class="handle main-color">
<span (click)="showAddModal()">添加子节点</span>
<ng-container *ngIf="item.level == 0">
<span (click)="showBasicEditModal(item)">配置告警推送</span>
</ng-container>
<ng-container *ngIf="item.level > 0">
<span (click)="editBasicModal(item)">编辑</span>
<span (click)="showDeleteConfirm(item)">移除</span>
</ng-container>
</td> </td>
<td>{{item.age}}</td>
<td>{{item.address}}</td>
</tr> </tr>
</ng-template> </ng-template>
</ng-template> </ng-template>
......
...@@ -4,6 +4,7 @@ import { BusinessService } from '../business.service'; ...@@ -4,6 +4,7 @@ import { BusinessService } from '../business.service';
import {TreeNodeInterface} from '../../overAll/basic/basic.component'; import {TreeNodeInterface} from '../../overAll/basic/basic.component';
import {NzMessageService} from 'ng-zorro-antd'; import {NzMessageService} from 'ng-zorro-antd';
import {color} from '../../app.constants'; import {color} from '../../app.constants';
import {CommonService} from '../../shared/common/common.service';
@Component({ @Component({
selector: 'smart-b-config', selector: 'smart-b-config',
...@@ -19,7 +20,8 @@ export class BConfigComponent implements OnInit { ...@@ -19,7 +20,8 @@ export class BConfigComponent implements OnInit {
isLoading = false; //加载中 isLoading = false; //加载中
constructor(private busineSer:BusinessService,private message:NzMessageService) { constructor(private busineSer:BusinessService,private message:NzMessageService,
private commonSer:CommonService) {
} }
dataSet: any[]; dataSet: any[];
...@@ -54,12 +56,10 @@ export class BConfigComponent implements OnInit { ...@@ -54,12 +56,10 @@ export class BConfigComponent implements OnInit {
} }
} }
} }
// console.log(array);
return array; return array;
} }
visitNode(node: TreeNodeInterface, hashMap: object, array: TreeNodeInterface[]): void { visitNode(node: TreeNodeInterface, hashMap: object, array: TreeNodeInterface[]): void {
console.log(hashMap);
if (!hashMap[ node.serviceid ]) { if (!hashMap[ node.serviceid ]) {
hashMap[ node.serviceid ] = true; hashMap[ node.serviceid ] = true;
array.push(node); array.push(node);
...@@ -70,7 +70,6 @@ export class BConfigComponent implements OnInit { ...@@ -70,7 +70,6 @@ export class BConfigComponent implements OnInit {
this.dataSet.forEach((item,i) => { this.dataSet.forEach((item,i) => {
this.expandDataCache[item.serviceid] = this.convertTreeToList(item); this.expandDataCache[item.serviceid] = this.convertTreeToList(item);
}); });
console.log(this.expandDataCache);
} }
ngOnInit() { ngOnInit() {
...@@ -100,7 +99,7 @@ export class BConfigComponent implements OnInit { ...@@ -100,7 +99,7 @@ export class BConfigComponent implements OnInit {
) )
} }
// //获取下级
getChildren(item){ getChildren(item){
this.isLoading = true; this.isLoading = true;
const data = { const data = {
...@@ -109,6 +108,7 @@ export class BConfigComponent implements OnInit { ...@@ -109,6 +108,7 @@ export class BConfigComponent implements OnInit {
this.busineSer.findChild(data).subscribe( this.busineSer.findChild(data).subscribe(
(res)=>{ (res)=>{
if (res.data) { if (res.data) {
res.data.forEach(e=>e.children = []);
this.dataSet.forEach(e=>{ this.dataSet.forEach(e=>{
if(e.serviceid == item.serviceid){ if(e.serviceid == item.serviceid){
e.children = res.data; e.children = res.data;
...@@ -123,6 +123,31 @@ export class BConfigComponent implements OnInit { ...@@ -123,6 +123,31 @@ export class BConfigComponent implements OnInit {
) )
} }
//删除单个资源
showDeleteConfirm(item) {
this.commonSer.confirmThing("删除","确定删除该服务",()=>{
const data = {
serviceids:[]
};
data.serviceids.push(item.serviceid);
this.busineSer.deleteService(data).subscribe(
(res)=>{
if (res.errCode == 10000) {
this.message.success('删除成功');
this.getList();
} else {
this.message.error(res.errMsg);
}
}
)
})
}
//关联网站
contract(item){
}
//添加业务 //添加业务
showAddModal() { showAddModal() {
this.smartBusiness.showModal('添加业务'); this.smartBusiness.showModal('添加业务');
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
<nz-option nzValue="2" nzLabel="问题,都有问题"></nz-option> <nz-option nzValue="2" nzLabel="问题,都有问题"></nz-option>
<nz-option nzValue="0" nzLabel="不计算"></nz-option> <nz-option nzValue="0" nzLabel="不计算"></nz-option>
</nz-select> </nz-select>
<nz-form-explain *ngIf="validateForm.get('algorithm').dirty && validateForm.get('parentid').errors">请选择用于计算服务状态的算法!</nz-form-explain> <nz-form-explain *ngIf="validateForm.get('algorithm').dirty && validateForm.get('parentid').errors">请选择上层服务!</nz-form-explain>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
<nz-form-item> <nz-form-item>
...@@ -40,8 +40,8 @@ ...@@ -40,8 +40,8 @@
<nz-form-item> <nz-form-item>
<nz-form-label [nzSpan]="7" nzRequired nzFor="sortorder">排序(0->999)</nz-form-label> <nz-form-label [nzSpan]="7" nzRequired nzFor="sortorder">排序(0->999)</nz-form-label>
<nz-form-control [nzSpan]="12"> <nz-form-control [nzSpan]="12">
<input type="text" nz-input formControlName="sortorder" placeholder="组名称"> <input type="text" nz-input formControlName="sortorder" placeholder="排序(0->999)">
<nz-form-explain *ngIf="validateForm.get('sortorder').dirty && validateForm.get('sortorder').errors">请输入分组名称</nz-form-explain> <nz-form-explain *ngIf="validateForm.get('sortorder').dirty && validateForm.get('sortorder').errors">最大值为999</nz-form-explain>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
</form> </form>
......
...@@ -47,10 +47,15 @@ export class BusinessComponent implements OnInit { ...@@ -47,10 +47,15 @@ export class BusinessComponent implements OnInit {
name: ['', [Validators.required]], name: ['', [Validators.required]],
algorithm: [''], algorithm: [''],
showsla: ['99.9000'], showsla: ['99.9000'],
sortorder: ['1'], sortorder: ['1',[Validators.maxLength(3)]],
parentid: ['1'], parentid: ['1'],
}); });
// this.validateForm.get('showsla').disable(); this.validateForm.get('showsla').disable();
}
//获取服务列表
getServiceList(){
} }
showModal(title): void { showModal(title): void {
...@@ -59,6 +64,9 @@ export class BusinessComponent implements OnInit { ...@@ -59,6 +64,9 @@ export class BusinessComponent implements OnInit {
} }
showEditModal(title,item){ showEditModal(title,item){
item.algorithm += "";
item.showsla += "";
item.sortorder += "";
this.title = title; this.title = title;
this.serviceId = item.serviceid; this.serviceId = item.serviceid;
this.isVisiable = true; this.isVisiable = true;
...@@ -84,10 +92,10 @@ export class BusinessComponent implements OnInit { ...@@ -84,10 +92,10 @@ export class BusinessComponent implements OnInit {
create() { create() {
const data = { const data = {
algorithm:0, algorithm:Number(this.validateForm.value.algorithm),
name:'新增', name:this.validateForm.value.name,
sortorder:0, sortorder:Number(this.validateForm.value.sortorder),
showsla:0, showsla:this.checked?this.validateForm.value.showsla:0,
parentid:7 parentid:7
} }
this.busineSer.createService(data).subscribe( this.busineSer.createService(data).subscribe(
...@@ -107,11 +115,13 @@ export class BusinessComponent implements OnInit { ...@@ -107,11 +115,13 @@ export class BusinessComponent implements OnInit {
update() { update() {
const data = { const data = {
groupid:this.groupid, algorithm:Number(this.validateForm.value.algorithm),
groupDescribe:this.validateForm.value.groupDescribe, name:this.validateForm.value.name,
name:this.validateForm.value.name sortorder:Number(this.validateForm.value.sortorder),
}; showsla:this.checked?this.validateForm.value.showsla:0,
parentid:7,
serviceid:this.serviceId
}
this.busineSer.updateService(data).subscribe( this.busineSer.updateService(data).subscribe(
(res) => { (res) => {
if (res.errCode == 10000) { if (res.errCode == 10000) {
......
...@@ -15,6 +15,7 @@ import {PauseComponent} from '../../modal/pause/pause.component'; ...@@ -15,6 +15,7 @@ import {PauseComponent} from '../../modal/pause/pause.component';
import {AlarmModalComponent} from '../../modal/alarm-modal/alarm-modal.component'; import {AlarmModalComponent} from '../../modal/alarm-modal/alarm-modal.component';
import {color} from '../../app.constants'; import {color} from '../../app.constants';
import {JhiMainComponent} from '../../layouts'; import {JhiMainComponent} from '../../layouts';
import {CommonService} from '../../shared/common/common.service';
export interface TreeNodeInterface { export interface TreeNodeInterface {
host: any; host: any;
...@@ -75,6 +76,7 @@ export class BasicComponent implements OnInit { ...@@ -75,6 +76,7 @@ export class BasicComponent implements OnInit {
searchData; searchData;
constructor(private fb: FormBuilder, private overAllSer: OverAllService, private router: Router, constructor(private fb: FormBuilder, private overAllSer: OverAllService, private router: Router,
private commonSer:CommonService,
private modalService: NzModalService, private message: NzMessageService, private main: JhiMainComponent) { private modalService: NzModalService, private message: NzMessageService, private main: JhiMainComponent) {
} }
...@@ -282,12 +284,7 @@ export class BasicComponent implements OnInit { ...@@ -282,12 +284,7 @@ export class BasicComponent implements OnInit {
//删除单个资源 //删除单个资源
showDeleteConfirm(item) { showDeleteConfirm(item) {
this.modalService.confirm({ this.commonSer.confirmThing("删除","确认删除该资源吗?",()=>{
nzTitle: '删除',
nzContent: '<b style="color: red;">确认删除该资源吗?</b>',
nzOkText: '确定',
nzOkType: 'danger',
nzOnOk: () => {
const data = { const data = {
hostids: [] hostids: []
}; };
...@@ -302,10 +299,7 @@ export class BasicComponent implements OnInit { ...@@ -302,10 +299,7 @@ export class BasicComponent implements OnInit {
} }
} }
); );
}, })
nzCancelText: '取消',
nzOnCancel: () => console.log('Cancel')
});
} }
//批量删除资源 //批量删除资源
...@@ -314,12 +308,8 @@ export class BasicComponent implements OnInit { ...@@ -314,12 +308,8 @@ export class BasicComponent implements OnInit {
this.message.info('请选择需要删除的设备'); this.message.info('请选择需要删除的设备');
return false; return false;
} }
this.modalService.confirm({
nzTitle: '删除', this.commonSer.confirmThing("删除","确认要删除所选设备吗?",()=>{
nzContent: '<b style="color: red;">确认要删除所选设备吗?</b>',
nzOkText: '确定',
nzOkType: 'danger',
nzOnOk: () => {
const data = { const data = {
hostids: this.batchDelList hostids: this.batchDelList
}; };
...@@ -330,13 +320,10 @@ export class BasicComponent implements OnInit { ...@@ -330,13 +320,10 @@ export class BasicComponent implements OnInit {
this.batchDelList = []; this.batchDelList = [];
this.select(); this.select();
} else { } else {
this.message.info(res.errMsg); this.message.error(res.errMsg);
} }
} }
); );
},
nzCancelText: '取消',
nzOnCancel: () => console.log('Cancel')
}); });
} }
......
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