Commit b3eae2ae authored by wangqinghua's avatar wangqinghua

commonService

parent f378c4a2
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<nz-form-item> <nz-form-item>
<nz-form-label [nzSpan]="4" nzRequired nzFor="host1">选择设备</nz-form-label> <nz-form-label [nzSpan]="4" nzRequired nzFor="host1">选择设备</nz-form-label>
<nz-form-control [nzSpan]="14"> <nz-form-control [nzSpan]="14">
<div class="tree-div"> <div class="tree-div" style="height: 300px">
<nz-tree #nzTree <nz-tree #nzTree
[(ngModel)]="nodes" [(ngModel)]="nodes"
[nzCheckable]="true" [nzCheckable]="true"
......
...@@ -13,7 +13,7 @@ export class DeviceComponent implements OnInit { ...@@ -13,7 +13,7 @@ export class DeviceComponent implements OnInit {
@Output() done = new EventEmitter<any>(); @Output() done = new EventEmitter<any>();
isValiaible; isValiaible;
title = '添加设备'; title;
nodes; nodes;
nodeList; nodeList;
...@@ -30,7 +30,8 @@ export class DeviceComponent implements OnInit { ...@@ -30,7 +30,8 @@ export class DeviceComponent implements OnInit {
this.initForm(); this.initForm();
} }
showAddModal() { showAddModal(title) {
this.title = title;
this.isValiaible = true; this.isValiaible = true;
this.initForm(); this.initForm();
this.findTree(); this.findTree();
...@@ -45,7 +46,7 @@ export class DeviceComponent implements OnInit { ...@@ -45,7 +46,7 @@ export class DeviceComponent implements OnInit {
}; };
} }
//查询树 //查询树--- 分组
findTree() { findTree() {
const data = { const data = {
id: '', id: '',
...@@ -78,12 +79,17 @@ export class DeviceComponent implements OnInit { ...@@ -78,12 +79,17 @@ export class DeviceComponent implements OnInit {
//获取下级 //获取下级
mouseAction(name: string, event: NzFormatEmitEvent) { mouseAction(name: string, event: NzFormatEmitEvent) {
let type; let type;
setTimeout(_ => {
}, 1000);
if(event.node.level == 0){ if(event.node.level == 0){
type = "host"; //主机 type = "host"; //主机
} }
if(event.node.level == 1){ if(event.node.level == 1){
type = "item"; //监控项 type = "item"; //监控项
} }
if(this.title == "选择资源" && event.node.level == 1){
return false;
}
const index = <any>event.node.key - 1; const index = <any>event.node.key - 1;
const data = { const data = {
'id': event.node.origin.id, 'id': event.node.origin.id,
...@@ -96,6 +102,12 @@ export class DeviceComponent implements OnInit { ...@@ -96,6 +102,12 @@ export class DeviceComponent implements OnInit {
dataSet.forEach(res => { dataSet.forEach(res => {
res.title = res.name; res.title = res.name;
res.key = res.id; res.key = res.id;
if(this.title == "选择资源"){
res.isLeaf = true;
}
if(res.inventoryExtends == 1){
res.disabled = true;
}
}); });
event.node.addChildren(dataSet); event.node.addChildren(dataSet);
this.nodeList[index].children = dataSet; this.nodeList[index].children = dataSet;
...@@ -107,11 +119,13 @@ export class DeviceComponent implements OnInit { ...@@ -107,11 +119,13 @@ export class DeviceComponent implements OnInit {
} }
); );
setTimeout(_ => {
}, 1000);
} }
//选择树节点 //选择树节点
/**
* inventoryExtends 1:有资产 0:无资产
* @param {NzFormatEmitEvent} event
*/
selectCheckTree(event: NzFormatEmitEvent) { selectCheckTree(event: NzFormatEmitEvent) {
if (event.node.isChecked) { if (event.node.isChecked) {
if(event.node.level == 1){ if(event.node.level == 1){
...@@ -134,18 +148,33 @@ export class DeviceComponent implements OnInit { ...@@ -134,18 +148,33 @@ export class DeviceComponent implements OnInit {
} }
handEditleOk(){ handEditleOk(){
if(this.title == "添加设备"){
this.topology();
}
if(this.title == "选择资源"){
this.select();
}
}
topology(){
this.topologySer.findDefaultIcon(this.selectTreeList).subscribe( this.topologySer.findDefaultIcon(this.selectTreeList).subscribe(
(res)=>{ (res)=>{
if(res.data.length > 0){ if(res.data.length > 0){
this.done.emit(res.data); this.done.emit(res.data);
this.isValiaible = false; this.isValiaible = false;
}else{ }else{
this.message.warning("该项无默认图标") this.message.warning("该项无默认图标")
} }
} }
) )
} }
select(){
this.done.emit(this.selectTreeList);
this.isValiaible = false;
}
handleEditCancel(){ handleEditCancel(){
this.initForm(); this.initForm();
this.isValiaible = false; this.isValiaible = false;
......
...@@ -116,7 +116,7 @@ export class NeTopologyComponent implements OnInit, AfterViewInit { ...@@ -116,7 +116,7 @@ export class NeTopologyComponent implements OnInit, AfterViewInit {
this.message.warning("请选择需要编辑的拓扑图"); this.message.warning("请选择需要编辑的拓扑图");
return false; return false;
} }
this.smartDevice.showAddModal(); this.smartDevice.showAddModal("添加设备");
} }
//获取设备图片 //获取设备图片
......
...@@ -19,23 +19,23 @@ ...@@ -19,23 +19,23 @@
</div> </div>
</div> </div>
<div nz-row [nzGutter]="4" class="search-form"> <div nz-row [nzGutter]="4" class="search-form">
<div nz-col nzSpan="3"> <div nz-col nzSpan="5">
<nz-select style="width: 100%;" [(ngModel)]="obj.type" nzPlaceHolder="选择分类" (ngModelChange)="changeType($event)"> <nz-select style="width: 100%;" [(ngModel)]="obj.type" nzPlaceHolder="选择分类" (ngModelChange)="changeType()">
<ng-container *ngFor="let item of parentList"> <ng-container *ngFor="let item of parentList">
<nz-option [nzLabel]="item.name" [nzValue]="item.id"></nz-option> <nz-option [nzLabel]="item.name" [nzValue]="item.id"></nz-option>
</ng-container> </ng-container>
</nz-select> </nz-select>
</div> </div>
<div nz-col nzSpan="3"> <div nz-col nzSpan="3">
<button (click)="showUploadModal()" nz-button nzType="default"><i class="anticon anticon-plus"></i>导入资产</button> <button (click)="showUploadModal()" nz-button nzType="default"><i class="anticon anticon-upload"></i>导入资产</button>
</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 nz-button nzType="default"><i class="anticon anticon-download"></i>下载</button>
</div> </div>
<div nz-col nzSpan="6"> <div nz-col nzSpan="6">
<button (click)="showAddModal()" 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>
<button (click)="showPEditModal()" nz-button nzType="default"><i class="anticon anticon-plus"></i>编辑</button> <button (click)="showPEditModal()" nz-button nzType="default"><i class="anticon anticon-edit"></i>编辑</button>
<button nz-button nzType="default"><i class="anticon anticon-plus"></i>删除</button> <button (click)="deleteParentType()" nz-button nzType="default"><i class="anticon anticon-close-circle-o"></i>删除</button>
</div> </div>
</div> </div>
...@@ -76,13 +76,13 @@ ...@@ -76,13 +76,13 @@
<td class="handle text-center"> <td class="handle text-center">
<span (click)="goToChild(data)">明细</span> <span (click)="goToChild(data)">明细</span>
<span (click)="showEditModal(data)">编辑</span> <span (click)="showEditModal(data)">编辑</span>
<span (click)="deleteSend(data)">删除</span> <span (click)="deleteChildType(data)">删除</span>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</nz-table> </nz-table>
<!--新增分类--> <!--新增分类-->
<smart-type-asets #smartTypeAsets (done)="getList()"></smart-type-asets> <smart-type-asets #smartTypeAsets (done)="getTypeList()"></smart-type-asets>
<!--倒入资产--> <!--倒入资产-->
<smart-upload #smartUpload></smart-upload> <smart-upload #smartUpload></smart-upload>
\ No newline at end of file
...@@ -5,6 +5,7 @@ import {Router} from '@angular/router'; ...@@ -5,6 +5,7 @@ import {Router} from '@angular/router';
import {TypeAsetsComponent} from '../modal/type-asets/type-asets.component'; import {TypeAsetsComponent} from '../modal/type-asets/type-asets.component';
import {NzMessageService} from 'ng-zorro-antd'; import {NzMessageService} from 'ng-zorro-antd';
import {UploadComponent} from '../modal/upload/upload.component'; import {UploadComponent} from '../modal/upload/upload.component';
import {CommonService} from '../../shared/common/common.service';
@Component({ @Component({
selector: 'smart-asset-part', selector: 'smart-asset-part',
...@@ -34,13 +35,18 @@ export class AssetPartComponent implements OnInit { ...@@ -34,13 +35,18 @@ export class AssetPartComponent implements OnInit {
startTime:'', startTime:'',
endTime:'', endTime:'',
}; };
constructor(private workSer:WorkService,private router:Router, constructor(private workSer:WorkService,private router:Router,private commonSer:CommonService,
private messge:NzMessageService) { } private messge:NzMessageService) { }
ngOnInit() { ngOnInit() {
this.getList(); this.getList();
} }
getTypeList(){
this.getList();
this.changeType();
}
getList(){ getList(){
this.workSer.findByParentType().subscribe( this.workSer.findByParentType().subscribe(
(res)=>{ (res)=>{
...@@ -53,8 +59,8 @@ export class AssetPartComponent implements OnInit { ...@@ -53,8 +59,8 @@ export class AssetPartComponent implements OnInit {
) )
} }
changeType(e){ changeType(){
this.workSer.findByParentidCount(e).subscribe( this.workSer.findByParentidCount(this.obj.type).subscribe(
(res)=>{ (res)=>{
this.childrenList = res.data; this.childrenList = res.data;
} }
...@@ -81,14 +87,58 @@ export class AssetPartComponent implements OnInit { ...@@ -81,14 +87,58 @@ export class AssetPartComponent implements OnInit {
//编辑父级分类 //编辑父级分类
showPEditModal(){ showPEditModal(){
if(!this.obj.type){
this.messge.error("请选择需要编辑的分类");
return false;
}
this.smartTypeAsets.showEditModal("编辑分类",this.obj.type); this.smartTypeAsets.showEditModal("编辑分类",this.obj.type);
} }
//删除父分类
deleteParentType(){
const data = {
inventoryTypeIds:[]
};
data.inventoryTypeIds.push(this.obj.type);
this.commonSer.deleteThing("确定删除该父级分类",()=>{
this.workSer.deleteType(data).subscribe(
(res)=>{
if(res.errCode == 10000){
this.messge.success("删除成功");
this.getList();
}else{
this.messge.error(res.errMsg);
}
}
)
})
}
//编辑子级分类 //编辑子级分类
showCEditModal(id){ showCEditModal(id){
this.smartTypeAsets.showEditModal("编辑分类",id); this.smartTypeAsets.showEditModal("编辑分类",id);
} }
//删除子级分类
deleteChildType(item){
const data = {
inventoryTypeIds:[]
};
data.inventoryTypeIds.push(item.id);
this.commonSer.deleteThing("确定删除该子级分类",()=>{
this.workSer.deleteType(data).subscribe(
(res)=>{
if(res.errCode == 10000){
this.messge.success("删除成功");
this.changeType();
}else{
this.messge.error(res.errMsg);
}
}
)
})
}
//导入资产 //导入资产
showUploadModal(){ showUploadModal(){
this.smartUpload.showModal(); this.smartUpload.showModal();
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
</nz-form-label> </nz-form-label>
<nz-form-control [nzSpan]="14"> <nz-form-control [nzSpan]="14">
{{inventoryExtend?.name}} {{inventoryExtend?.name}}
<button (click)="linkThen()" nz-button nzType="primary">关联</button>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
</div> </div>
...@@ -206,7 +207,7 @@ ...@@ -206,7 +207,7 @@
</div> </div>
</nz-tab> </nz-tab>
<nz-tab #thirdTabs nzTitle="关联事件" > <nz-tab #thirdTabs nzTitle="关联事件" >
<nz-table #nzTable [nzData]="warnList" [nzFrontPagination]="false" [nzTotal]="totalNum" [nzPageIndex]="pageNum" [nzPageSize]="pageCount" (nzPageIndexChange)="change($event)" [nzLoading]="loading"> <nz-table #nzTable [nzData]="thingList" [nzFrontPagination]="false" [nzTotal]="totalNum" [nzPageIndex]="pageNum" [nzPageSize]="pageCount" (nzPageIndexChange)="change($event)" [nzLoading]="loading">
<thead> <thead>
<tr> <tr>
<th nzShowSort>时间</th> <th nzShowSort>时间</th>
...@@ -220,7 +221,7 @@ ...@@ -220,7 +221,7 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr *ngFor="let data of warnList"> <tr *ngFor="let data of thingList">
<td class="table-timeline"> <td class="table-timeline">
<nz-timeline-item>{{data.clock}}</nz-timeline-item> <nz-timeline-item>{{data.clock}}</nz-timeline-item>
</td> </td>
...@@ -236,10 +237,13 @@ ...@@ -236,10 +237,13 @@
<ng-container *ngIf="data.r_clock">已恢复</ng-container> <ng-container *ngIf="data.r_clock">已恢复</ng-container>
<ng-container *ngIf="!data.r_clock">告警中</ng-container> <ng-container *ngIf="!data.r_clock">告警中</ng-container>
</td> </td>
<td class="list-icon" (click)="showLog(data)"><i class="anticon anticon-profile"></i></td> <td class="list-icon"><i class="anticon anticon-profile"></i></td>
</tr> </tr>
</tbody> </tbody>
</nz-table> </nz-table>
</nz-tab> </nz-tab>
</nz-tabset> </nz-tabset>
\ No newline at end of file
<!--选择资源-->
<smart-device #smartDevice (done)="setLink($event)"></smart-device>
import { Component, OnInit } from '@angular/core'; import {Component, OnInit, ViewChild} from '@angular/core';
import {ActivatedRoute} from '@angular/router'; import {ActivatedRoute} from '@angular/router';
import {WorkService} from '../../work.service'; import {WorkService} from '../../work.service';
import {DeviceComponent} from '../../../netTopology/model/device/device.component';
import {UploadComponent} from '../../modal/upload/upload.component';
import {pageSize} from '../../../app.constants';
import {NzMessageService} from 'ng-zorro-antd';
@Component({ @Component({
selector: 'smart-assets-detail', selector: 'smart-assets-detail',
...@@ -8,10 +12,18 @@ import {WorkService} from '../../work.service'; ...@@ -8,10 +12,18 @@ import {WorkService} from '../../work.service';
styles: [] styles: []
}) })
export class AssetsDetailComponent implements OnInit { export class AssetsDetailComponent implements OnInit {
@ViewChild('smartDevice') smartDevice:DeviceComponent;
invertoryId; invertoryId;
inventoryExtend; inventoryExtend;
constructor(private routerInfo:ActivatedRoute,private workSer:WorkService) {
totalNum;
pageNum=1;
pageCount = pageSize;
loading = false;
thingList;
constructor(private routerInfo:ActivatedRoute,private workSer:WorkService,
private message:NzMessageService) {
this.routerInfo.queryParams.subscribe( this.routerInfo.queryParams.subscribe(
(res)=>{ (res)=>{
this.invertoryId = res.invertoryId; this.invertoryId = res.invertoryId;
...@@ -31,4 +43,32 @@ export class AssetsDetailComponent implements OnInit { ...@@ -31,4 +43,32 @@ export class AssetsDetailComponent implements OnInit {
) )
} }
// 打开添加关联modal
linkThen(){
this.smartDevice.showAddModal("选择资源");
}
//设置关联
setLink(e){
console.log(e);
const data = {
hostid:e.hostIds[0],
id:this.invertoryId
}
this.workSer.updateHostid(data).subscribe(
(res)=>{
if(res.errCode == 10000){
this.message.success("设置关联主机成功");
this.getDetail();
}else{
this.message.error(res.errMsg);
}
}
)
}
change(e){
}
} }
...@@ -26,10 +26,10 @@ ...@@ -26,10 +26,10 @@
<button (click)="showAddModal()" 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 nz-col nzSpan="3"> <div nz-col nzSpan="3">
<button nz-button nzType="default"><i class="anticon anticon-plus"></i>导入资产</button> <button nz-button nzType="default"><i class="anticon anticon-upload"></i>导入资产</button>
</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 nz-button nzType="default"><i class="anticon anticon-download"></i>下载模版</button>
</div> </div>
<div nz-col nzSpan="6"> <div nz-col nzSpan="6">
...@@ -81,4 +81,6 @@ ...@@ -81,4 +81,6 @@
</nz-table> </nz-table>
<!--新增资产--> <!--新增资产-->
<smart-assets #smartAssets (done)="getList()"></smart-assets> <smart-assets #smartAssets (done)="getList()"></smart-assets>
\ No newline at end of file <!--倒入资产-->
<smart-upload #smartUpload></smart-upload>
\ No newline at end of file
...@@ -4,6 +4,7 @@ import {ActivatedRoute, Router} from '@angular/router'; ...@@ -4,6 +4,7 @@ import {ActivatedRoute, Router} from '@angular/router';
import {CommonService} from '../../../shared/common/common.service'; import {CommonService} from '../../../shared/common/common.service';
import {NzMessageService} from 'ng-zorro-antd'; import {NzMessageService} from 'ng-zorro-antd';
import {AssetsComponent} from '../../modal/assets/assets.component'; import {AssetsComponent} from '../../modal/assets/assets.component';
import {UploadComponent} from '../../modal/upload/upload.component';
@Component({ @Component({
selector: 'smart-child-assets', selector: 'smart-child-assets',
...@@ -12,6 +13,7 @@ import {AssetsComponent} from '../../modal/assets/assets.component'; ...@@ -12,6 +13,7 @@ import {AssetsComponent} from '../../modal/assets/assets.component';
}) })
export class ChildAssetsComponent implements OnInit { export class ChildAssetsComponent implements OnInit {
@ViewChild('smartAssets') smartAssets:AssetsComponent; @ViewChild('smartAssets') smartAssets:AssetsComponent;
@ViewChild('smartUpload') smartUpload:UploadComponent;
childId; childId;
childrenList; childrenList;
...@@ -76,4 +78,9 @@ export class ChildAssetsComponent implements OnInit { ...@@ -76,4 +78,9 @@ export class ChildAssetsComponent implements OnInit {
}) })
} }
//导入资产
showUploadModal(){
this.smartUpload.showModal();
}
} }
...@@ -138,4 +138,9 @@ export class WorkService { ...@@ -138,4 +138,9 @@ export class WorkService {
selectByPrimaryKey(params): Observable<any>{ selectByPrimaryKey(params): Observable<any>{
return this.http.get(SERVER_API_URL + '/inventory/selectByPrimaryKey/' +params); return this.http.get(SERVER_API_URL + '/inventory/selectByPrimaryKey/' +params);
} }
//删除资产分类
deleteType(data): Observable<any>{
return this.http.post(SERVER_API_URL + '/inventory/deleteType' ,data);
}
} }
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