Commit 1e59c9f8 authored by wangqinghua's avatar wangqinghua

workService

parent 74e36911
...@@ -84,6 +84,7 @@ import {ChildAssetsComponent} from './work/asset-part/child-assets/child-assets. ...@@ -84,6 +84,7 @@ import {ChildAssetsComponent} from './work/asset-part/child-assets/child-assets.
import {UploadComponent} from './work/modal/upload/upload.component'; import {UploadComponent} from './work/modal/upload/upload.component';
import {HandleDetailComponent} from './work/work-handle/handle-detail/handle-detail.component'; import {HandleDetailComponent} from './work/work-handle/handle-detail/handle-detail.component';
import {HandleEventComponent} from './work/work-handle/handle-event/handle-event.component'; import {HandleEventComponent} from './work/work-handle/handle-event/handle-event.component';
import {EventComponent} from './work/work-handle/Event/event.component';
@NgModule({ @NgModule({
imports: [ imports: [
...@@ -169,6 +170,7 @@ import {HandleEventComponent} from './work/work-handle/handle-event/handle-event ...@@ -169,6 +170,7 @@ import {HandleEventComponent} from './work/work-handle/handle-event/handle-event
HandleDetailComponent, HandleDetailComponent,
HandleComponent, HandleComponent,
HandleEventComponent, HandleEventComponent,
EventComponent,
], ],
providers:[ providers:[
OverAllService, OverAllService,
......
...@@ -151,7 +151,6 @@ ...@@ -151,7 +151,6 @@
</nz-upload> </nz-upload>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
</div> </div>
</form> </form>
</nz-modal> </nz-modal>
......
<!--新增事件-->
<!--添加资源-->
<nz-modal [nzWidth]="1080" [(nzVisible)]="isVisible" [nzTitle]="title" (nzOnCancel)="handleEditCancel()"
(nzOnOk)="handEditleOk()">
<form nz-form [formGroup]="validateForm">
<div nz-form class="ant-advanced-search-form form-select">
<div nz-row [nzGutter]="24">
<div nz-col [nzSpan]="12">
<nz-form-item nzFlex>
<nz-form-label [nzOffset]="4" [nzSpan]="6" nzRequired nzFor="title">事件标题</nz-form-label>
<nz-form-control [nzSpan]="14">
<input id="title" nz-input placeholder="事件标题" name="title" formControlName="title">
</nz-form-control>
</nz-form-item>
</div08
<div nz-col [nzSpan]="12">
<nz-form-item nzFlex>
<nz-form-label [nzOffset]="4" [nzSpan]="6" nzRequired nzFor="type">事件分类
</nz-form-label>
<nz-form-control [nzSpan]="14">
<nz-select name="type" nzPlaceHolder="选择事件分类" formControlName="type">
<!--<ng-container *ngFor="let item of hostTypeList">-->
<!--<nz-option [nzLabel]="item.name" [nzValue]="item.id"></nz-option>-->
<!--</ng-container>-->
</nz-select>
</nz-form-control>
</nz-form-item>
</div>
</div>
<div nz-row [nzGutter]="24">
<div nz-col [nzSpan]="12">
<nz-form-item nzFlex>
<nz-form-label [nzOffset]="4" [nzSpan]="6" nzRequired nzFor="requester">请求人</nz-form-label>
<nz-form-control [nzSpan]="14">
<input id="requester" nz-input placeholder="显示名" name="requester" formControlName="name">
</nz-form-control>
</nz-form-item>
</div>
<div nz-col [nzSpan]="12">
<nz-form-item nzFlex>
<nz-form-label [nzOffset]="4" [nzSpan]="6" nzRequired nzFor="requesterPhone">联系电话</nz-form-label>
<nz-form-control [nzSpan]="14">
<input id="requesterPhone" nz-input placeholder="显示名" name="requesterPhone" formControlName="name">
</nz-form-control>
</nz-form-item>
</div>
</div>
<nz-form-item>
<nz-form-label [nzSpan]="4" nzRequired>处理人</nz-form-label>
<nz-form-control [nzSpan]="14">
<button (click)="selectPerson()" nz-button><span>选择</span></button>
<ng-container *ngFor="let item of operatorsList;let i = index;">
<span>{{item.username}}</span><span (click)="deletePerson(i)">X</span>
</ng-container>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSpan]="4" nzRequired nzFor="description">详细描述</nz-form-label>
<nz-form-control [nzSpan]="14">
<textarea nz-input id="description" name="description" formControlName="description"
placeholder="发送信息" [nzAutosize]="{ minRows: 2, maxRows: 6 }"></textarea>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSpan]="7" nzRequired nzFor="group">附件</nz-form-label>
<nz-form-control [nzSpan]="12">
<nz-upload
[nzBeforeUpload]="beforeUpload"
[(nzFileList)]="fileList">
<button nz-button>
<i class="anticon anticon-upload"></i><span>上传</span>
</button>
</nz-upload>
</nz-form-control>
</nz-form-item>
</div>
</div>
</form>
</nz-modal>
<smart-select-person #smartSelectPerson (done)="getUser($event)"></smart-select-person>
import {Component, OnInit, ViewChild} from '@angular/core';
import {FormBuilder, FormControl, FormGroup, Validators} from '@angular/forms';
import {WorkService} from '../../work.service';
import {NzMessageService, UploadFile} from 'ng-zorro-antd';
import {SelectPersonComponent} from '../../../modal/select-person/select-person.component';
@Component({
selector: 'smart-event',
templateUrl: './event.component.html',
styles: []
})
export class EventComponent implements OnInit {
@ViewChild('smartSelectPerson') smartSelectPerson:SelectPersonComponent;
isVisible = false;
title;
eventId;
validateForm: FormGroup;
fileList: UploadFile[] = [];
operatorsList = []; //处理人列表
constructor(private workSer: WorkService, private message: NzMessageService,
private fb: FormBuilder) {
}
ngOnInit() {}
initForm() {
this.validateForm = this.fb.group(
{
title: [null, [Validators.required]],
description: [null],
type: [null],
requester: [null],
file: [null],
requesterPhone: [null],
operators: [null],
}
);
}
beforeUpload = (file: UploadFile): boolean => {
const isLt5M = file.size / 1024 < 5000;
if (!isLt5M) {
this.message.error('图标必须小于5M!');
} else {
this.fileList.push(file);
}
return false;
};
showAddModal(title) {
this.isVisible = true;
this.title = title;
}
showEditModal(title, id) {
this.isVisible = true;
this.title = title;
this.eventId = id;
}
handEditleOk() {
if (this.title == '新增事件') {
this.create();
}
if (this.title == '编辑事件') {
this.update();
}
}
//新增
create() {
let formData = new FormData();
this.fileList.forEach((file: any) => {
formData.append('file', file);
});
formData.append('json', JSON.stringify(this.validateForm.value));
this.workSer.create(formData).subscribe(
(res) => {
if (res.errCode == 10000) {
this.message.success('新增事件成功');
} else {
this.message.error(res.errMsg);
}
}
);
}
//编辑
update() {
let formData = new FormData();
this.fileList.forEach((file: any) => {
formData.append('file', file);
});
formData.append('json', JSON.stringify(this.validateForm.value));
formData.append('id', this.eventId);
this.workSer.update(formData).subscribe(
(res) => {
if (res.errCode == 10000) {
this.message.success('修改事件成功');
} else {
this.message.error(res.errMsg);
}
}
);
}
handleEditCancel() {
this.isVisible = false;
}
//选择处理人
selectPerson(){
// this.smartSelectPerson.showModal("选择处理人");
}
deletePerson(i){
this.operatorsList.splice(i,1);
}
getUser(e) {
const arr = [];
e.forEach(res => {
const data = {
username: res.name,
userId: res.id
};
arr.push(data);
});
this.operatorsList = arr;
}
}
<!--新增事件-->
<!--添加资源-->
<nz-modal [nzWidth]="1080" [(nzVisible)]="isVisible" [nzTitle]="title"
(nzOnCancel)="handleEditCancel()" (nzOnOk)="handEditleOk()">
<div nz-form class="ant-advanced-search-form form-select">
<div nz-row [nzGutter]="24">
<div nz-col [nzSpan]="12">
<nz-form-item nzFlex>
<nz-form-label [nzOffset]="4" [nzSpan]="6" nzRequired nzFor="equipmentTypeid">设备类型
</nz-form-label>
<nz-form-control [nzSpan]="14">
<nz-select name="equipmentTypeid" nzPlaceHolder="选择设备类型" [(ngModel)]="validateForm.hostExtend.equipmentTypeid" (ngModelChange)="getChildren($event)">
<ng-container *ngFor="let item of hostTypeList">
<nz-option [nzLabel]="item.name" [nzValue]="item.id"></nz-option>
</ng-container>
</nz-select>
</nz-form-control>
</nz-form-item>
</div>
</div>
<div nz-row [nzGutter]="24">
<div nz-col [nzSpan]="12">
<nz-form-item nzFlex>
<nz-form-label [nzOffset]="4" [nzSpan]="6" nzRequired nzFor="secondLevelType">二级类型
</nz-form-label>
<nz-form-control [nzSpan]="14">
<nz-select name="secondLevelType" nzPlaceHolder="选择二级类型" [(ngModel)]="validateForm.hostExtend.secondLevelTypeid">
<ng-container *ngFor="let item of hostTypeChildrenList">
<nz-option [nzLabel]="item.name" [nzValue]="item.id"></nz-option>
</ng-container>
</nz-select>
</nz-form-control>
</nz-form-item>
</div>
</div>
<div nz-row [nzGutter]="24">
<div nz-col [nzSpan]="12">
<nz-form-item nzFlex>
<nz-form-label [nzOffset]="4" [nzSpan]="6" nzRequired nzFor="name">显示名</nz-form-label>
<nz-form-control [nzSpan]="14">
<input id="name" nz-input placeholder="显示名" name="name" [(ngModel)]="validateForm.name">
</nz-form-control>
</nz-form-item>
</div>
</div>
<nz-form-item>
<nz-form-label [nzSpan]="4" nzRequired nzFor="host">IP地址</nz-form-label>
<nz-form-control [nzSpan]="14">
<input id="host" type="text" nz-input name="host" [(ngModel)]="validateForm.host">
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSpan]="4" nzRequired nzFor="groups">所在分组</nz-form-label>
<nz-form-control [nzSpan]="14">
<nz-checkbox-group [(ngModel)]="groupList" name="groupList"></nz-checkbox-group>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSpan]="4" nzFor="serviceid">关联业务</nz-form-label>
<nz-form-control [nzSpan]="14">
<nz-select name="serviceid" [(ngModel)]="validateForm.hostExtend.serviceid"
nzPlaceHolder="无关联业务">
<nz-option nzValue="" nzLabel="无"></nz-option>
</nz-select>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSpan]="4">添加接口</nz-form-label>
<nz-form-control [nzSpan]="20">
<ng-container *ngFor="let item of interfaceslist;let i = index;">
<div nz-row [nzGutter]="12">
<nz-form-control nz-col [nzSpan]="3">
<nz-select name="main" nzPlaceHolder="选择接口类型" [(ngModel)]="item.main"
(ngModelChange)="changeMain(i)">
<nz-option nzValue="1" nzLabel="默认"></nz-option>
<nz-option nzValue="0" nzLabel="不默认"></nz-option>
</nz-select>
</nz-form-control>
<nz-form-control nz-col [nzSpan]="4">
<input type="text" placeholder="IP地址" nz-input name="ip" [(ngModel)]="item.ip">
</nz-form-control>
<nz-form-control nz-col [nzSpan]="4">
<input type="text" placeholder="DNS名称" nz-input name="dns" [(ngModel)]="item.dns">
</nz-form-control>
<nz-form-control nz-col [nzSpan]="5">
<nz-select name="type" nzPlaceHolder="连接类型" [(ngModel)]="item.type"
(ngModelChange)="changePort(i)">
<nz-option nzValue="1" nzLabel="agent代理程序接口"></nz-option>
<nz-option nzValue="2" nzLabel="SNMP接口"></nz-option>
<nz-option nzValue="3" nzLabel="JMX接口"></nz-option>
<nz-option nzValue="4" nzLabel="IPMI接口"></nz-option>
</nz-select>
</nz-form-control>
<nz-form-control nz-col [nzSpan]="2">
<input type="text" placeholder="端口" nz-input name="port" [(ngModel)]="item.port">
</nz-form-control>
<nz-form-control nz-col [nzSpan]="4" *ngIf="item.type == 2">
<label nz-checkbox [(ngModel)]="item.bulk">使用大量请求</label>
</nz-form-control>
<nz-form-control nz-col [nzSpan]="2">
<span class="cursor" (click)="deleteInterfaces(i)">X</span>
</nz-form-control>
</div>
</ng-container>
<button nz-button (click)="addInterfaces()" nzType="default">添加</button>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSpan]="4" nzFor="test3">由agent代理程序检测</nz-form-label>
<nz-form-control [nzSpan]="14">
<nz-select name="test3" name="test3" nzPlaceHolder="无agen代理程序">
<nz-option nzValue="" nzLabel="无agen代理程序"></nz-option>
</nz-select>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSpan]="4" nzFor="templates">监控策略</nz-form-label>
<nz-form-control [nzSpan]="14">
<nz-select name="templates" style="width: 100%" [(ngModel)]="validateForm.templates"
[nzSize]="nzSize" nzMode="tags" nzPlaceHolder="选择监控策略">
<nz-option *ngFor="let option of tempList" [nzLabel]="option.name"
[nzValue]="option.templateid"></nz-option>
</nz-select>
</nz-form-control>
</nz-form-item>
</div>
</nz-modal>
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'smart-handle',
templateUrl: './handle.component.html',
styles: []
})
export class HandleComponent implements OnInit {
isVisible = false;
title;
eventId;
constructor() { }
ngOnInit() {
}
showAddModal(title){
this.isVisible = true;
this.title = title;
}
showEditModal(title,id){
this.isVisible = true;
this.title = title;
this.eventId = id;
}
}
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
nzPlaceHolder="结束时间"></nz-date-picker> nzPlaceHolder="结束时间"></nz-date-picker>
</div> </div>
<div nz-col nzSpan="3"> <div nz-col nzSpan="3">
<button nz-button nzType="default"><i class="anticon anticon-plus"></i>新增事件</button> <button (click)="showAddModal()" nz-button nzType="default"><i class="anticon anticon-plus"></i>新增事件</button>
</div> </div>
</div> </div>
...@@ -98,4 +98,6 @@ ...@@ -98,4 +98,6 @@
<!--事件转派--> <!--事件转派-->
<nz-modal> <nz-modal>
</nz-modal> </nz-modal>
\ No newline at end of file
<smart-event #smartEvent></smart-event>
\ No newline at end of file
import { Component, OnInit } from '@angular/core'; import {Component, OnInit, ViewChild} from '@angular/core';
import {pageSize} from '../../app.constants'; import {pageSize} from '../../app.constants';
import {WorkService} from '../work.service'; import {WorkService} from '../work.service';
import {NzMessageService} from 'ng-zorro-antd'; import {NzMessageService} from 'ng-zorro-antd';
import {Router} from '@angular/router'; import {Router} from '@angular/router';
import {EventComponent} from './Event/event.component';
@Component({ @Component({
selector: 'smart-work-handle', selector: 'smart-work-handle',
...@@ -10,6 +11,7 @@ import {Router} from '@angular/router'; ...@@ -10,6 +11,7 @@ import {Router} from '@angular/router';
styles: [] styles: []
}) })
export class WorkHandleComponent implements OnInit { export class WorkHandleComponent implements OnInit {
@ViewChild('smartEvent') smartEvent:EventComponent;
timeFormat = 'yyyy-MM-dd'; timeFormat = 'yyyy-MM-dd';
eventList; eventList;
...@@ -73,4 +75,9 @@ export class WorkHandleComponent implements OnInit { ...@@ -73,4 +75,9 @@ export class WorkHandleComponent implements OnInit {
}) })
} }
//新增事件
showAddModal(){
this.smartEvent.showAddModal('新增事件');
}
} }
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