Commit b3eae2ae authored by wangqinghua's avatar wangqinghua

commonService

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