Commit 25f53b00 authored by wangqinghua's avatar wangqinghua

update

parent 3b7b3b38
<!--添加资源-->
<nz-modal [nzWidth]="780" [(nzVisible)]="isVisible" [nzTitle]="title" (nzOnCancel)="handleEditCancel()" (nzOnOk)="handEditleOk()">
<nz-modal [nzWidth]="780" [(nzVisible)]="isVisible" [nzTitle]="title" (nzOnCancel)="handleEditCancel()" (nzOnOk)="handEditleOk()" [nzOkLoading]="isOkLoading">
<nz-table #basicTable [nzData]="dataSet" nzPageSize="5">
<thead>
<tr>
......
......@@ -13,6 +13,7 @@ export class SelectRoleComponent implements OnInit {
title;
selectList = [];
isVisible = false;
isOkLoading = false;
allChecked = false;
checkedNumber = 0;
disabledButton = true;
......
......@@ -443,4 +443,14 @@ export class OverAllService {
deleteTri(data): Observable<any> {
return this.http.post(SERVER_API_URL + '/trigger/delete', data);
}
//下载xml模板
exportTemplates(data): Observable<any> {
return this.http.post(SERVER_API_URL + '/templates/export', data);
}
//上传xml模板
importTemplates(data): Observable<any> {
return this.http.post(SERVER_API_URL + '/templates/import', data);
}
}
......@@ -26,6 +26,8 @@
<div nz-col nzSpan="12">
<input style="width: 250px" (keyup.enter)="search()" type="text" nz-input [(ngModel)]="searchName" placeholder="输入资源名称">
<button (click)="search()" nz-button nzType="default"><i class="anticon anticon-search" style="color: #6097b7"></i>搜索</button>
<button (click)="download()" [nzLoading]="isDownload" nz-button nzType="default"><i class="anticon anticon-download"></i>下载模版</button>
<button (click)="showUploadModal()" nz-button nzType="default"><i class="anticon anticon-upload"></i>导入文件</button>
</div>
<div nz-col nzSpan="12" class="text-right">
<button nz-button nzType="default" (click)="showGroupModal()">
......@@ -148,4 +150,6 @@
<!--自动发现-->
<smart-discovery #smartDiscovery (done)="handleOk($event)"></smart-discovery>
<!--监控策略-->
<smart-strategy #smartStrategy (done)="handleOk($event)"></smart-strategy>
\ No newline at end of file
<smart-strategy #smartStrategy (done)="handleOk($event)"></smart-strategy>
<!--导入文件-->
<smart-upload #smartUpload></smart-upload>
\ No newline at end of file
......@@ -13,6 +13,9 @@ import {TreeNodeInterface} from '../basic/basic.component';
import {Router} from '@angular/router';
import {DiscoveryComponent} from '../../modal/discovery/discovery.component';
import {StrategyComponent} from '../../modal/strategy/strategy.component';
import {WorkService} from '../../work/work.service';
import {CommonService} from '../../shared/common/common.service';
import {UploadComponent} from '../../work/modal/upload/upload.component';
@Component({
selector: 'smart-template',
......@@ -28,8 +31,10 @@ export class TemplateComponent implements OnInit {
@ViewChild('smartAlarmModal') smartAlarmModal: AlarmModalComponent;
@ViewChild('smartDiscovery') smartDiscovery: DiscoveryComponent;
@ViewChild('smartStrategy') smartStrategy: StrategyComponent;
@ViewChild('smartUpload') smartUpload:UploadComponent;
color = color;
isDownload = false;
//表格信息
isLoading = false;
......@@ -64,8 +69,9 @@ export class TemplateComponent implements OnInit {
isClone = false;
constructor(private fb: FormBuilder, private overAllSer: OverAllService, private router: Router,
private modalService: NzModalService, private message: NzMessageService, private main: JhiMainComponent) {
constructor(private fb: FormBuilder, private overAllSer: OverAllService, private router: Router,private workSer:WorkService,
private modalService: NzModalService, private message: NzMessageService, private main: JhiMainComponent,
private commonSer:CommonService) {
}
dataSet: any[];
......@@ -347,86 +353,90 @@ export class TemplateComponent implements OnInit {
this.message.info('请选择需要删除的设备');
return false;
}
this.modalService.confirm({
nzTitle: '删除',
nzContent: '<b style="color: red;">确认要删除所选模版吗?</b>',
nzOkText: '确定',
nzOkType: 'danger',
nzOnOk: () => {
const data = {
templateids: this.batchDelList
};
this.overAllSer.deleteTemplates(data).subscribe(
(res) => {
if (res.errCode == 10000) {
this.message.success('删除成功');
this.batchDelList = [];
this.getTemplateGroup();
} else {
this.message.error(res.errMsg);
}
this.commonSer.confirmThing('删除','确认要删除所选模版吗?',()=>{
const data = {
templateids: this.batchDelList
};
this.overAllSer.deleteTemplates(data).subscribe(
(res) => {
if (res.errCode == 10000) {
this.message.success('删除成功');
this.batchDelList = [];
this.getTemplateGroup();
} else {
this.message.error(res.errMsg);
}
);
},
nzCancelText: '取消',
nzOnCancel: () => console.log('Cancel')
});
}
);
})
}
//删除单个模版
showDeleteConfirm(item) {
this.modalService.confirm({
nzTitle: '删除',
nzContent: '<b style="color: red;">确认删除该模版吗?</b>',
nzOkText: '确定',
nzOkType: 'danger',
nzOnOk: () => {
const data = {
templateids: []
};
data.templateids.push(item.templateid);
this.overAllSer.deleteTemplates(data).subscribe(
(res) => {
if (res.errCode == 10000) {
this.message.info('删除成功');
this.getTemplateGroup();
} else {
this.message.info(res.errMsg);
}
this.commonSer.confirmThing('删除','确认删除该模版吗?',()=>{
const data = {
templateids: []
};
data.templateids.push(item.templateid);
this.overAllSer.deleteTemplates(data).subscribe(
(res) => {
if (res.errCode == 10000) {
this.message.info('删除成功');
this.getTemplateGroup();
} else {
this.message.info(res.errMsg);
}
);
},
nzCancelText: '取消',
nzOnCancel: () => console.log('Cancel')
}
);
});
}
//删除单个模版
//克隆单个模版
cloneTemp(item) {
this.modalService.confirm({
nzTitle: '克隆',
nzContent: '<b style="color: red;">确认克隆该模版吗?</b>',
nzOkText: '确定',
nzOkType: 'danger',
nzOnOk: () => {
this.isClone = true;
const data = {
templateid: Number(item.templateid)
};
this.overAllSer.cloneTemplates(data).subscribe(
(res) => {
if (res.errCode == 10000) {
this.message.info('克隆成功');
this.getTemplateGroup();
} else {
this.message.info(res.errMsg);
}
this.isClone = false;
this.commonSer.confirmThing('克隆','确认克隆该模版吗?',()=>{
this.isClone = true;
const data = {
templateid: Number(item.templateid)
};
this.overAllSer.cloneTemplates(data).subscribe(
(res) => {
if (res.errCode == 10000) {
this.message.info('克隆成功');
this.getTemplateGroup();
} else {
this.message.info(res.errMsg);
}
);
},
nzCancelText: '取消',
nzOnCancel: () => console.log('Cancel')
this.isClone = false;
}
);
});
}
//导入资产
showUploadModal(){
this.smartUpload.showModal("上传XML模版");
}
//下载模版
download(){
this.isDownload = true;
const data = {
ids:this.batchDelList
};
this.overAllSer.exportTemplates(data).subscribe(
(res)=>{
if(res.errCode == 10000){
this.workSer.downloadTemplate('templateExport',res.data).subscribe(
(data)=>{
this.isDownload = false;
this.commonSer.downloadXMLFile('XML模版',data)
}
)
}else{
this.isDownload = false;
this.message.error(res.errMsg);
}
}
)
}
}
......@@ -96,6 +96,17 @@ export class CommonService implements OnInit {
document.body.removeChild(link);
}
downloadXMLFile(title,data: Response) {
const blob = new Blob([data], {type:"application/octet-stream"});
const url= window.URL.createObjectURL(blob);
let link = document.createElement("a");
link.setAttribute("href", url);
link.setAttribute("download", title);
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
/**
* 部分区域全屏
* @param element 全屏区域
......
<nz-modal [(nzVisible)]="isVisible" nzTitle="{{title}}" (nzOnCancel)="handleCancel()" (nzOnOk)="handleOk()" [nzOkLoading]="isOkLoading">
<nz-modal [(nzVisible)]="isVisible" [nzTitle]="title" (nzOnCancel)="handleCancel()" (nzOnOk)="handleOk()" [nzOkLoading]="isOkLoading">
<form [formGroup]="validateForm" nz-form >
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="groupName">部门名称</nz-form-label>
......
......@@ -27,7 +27,6 @@ export class GroupModalComponent implements OnInit {
}
initForm(){
this.isOkLoading = false;
this.validateForm = this.fb.group({
name:[null,[Validators.required,Validators.maxLength(15)]],
parentId:[null],
......@@ -86,15 +85,12 @@ export class GroupModalComponent implements OnInit {
}else{
this.message.error(res.errMsg);
}
this.isOkLoading = false;
}
)
}
update(){
if(this.validateForm.value.parentId == this.orgId){
this.message.error("不能将当前部门作为上级部门");
return false;
}
this.validateForm.addControl("id",new FormControl(this.orgId));
this.systemSer.updateOrganization(this.validateForm.value).subscribe(
(res)=>{
......@@ -106,6 +102,7 @@ export class GroupModalComponent implements OnInit {
}else{
this.message.error(res.errMsg);
}
this.isOkLoading = false;
}
)
}
......
<nz-modal [nzWidth]="780" [(nzVisible)]="isVisible" nzTitle="{{title}}" (nzOnCancel)="handleCancel()" (nzOnOk)="handleOk()">
<nz-modal [nzWidth]="780" [(nzVisible)]="isVisible" [nzTitle]="title" (nzOnCancel)="handleCancel()" (nzOnOk)="handleOk()" [nzOkLoading]="isOkLoading">
<form [formGroup]="validateForm" nz-form>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="name">用户登录名</nz-form-label>
......
......@@ -19,6 +19,7 @@ export class UserComponent implements OnInit {
title;
isVisible = false;
isOkLoading = false;
groupList:any[];
validateForm:FormGroup;
userId;
......@@ -82,6 +83,7 @@ export class UserComponent implements OnInit {
if(this.validateForm.invalid){
return false;
}
this.isOkLoading = true;
if(this.title == "新增用户"){
this.create();
}
......@@ -101,6 +103,7 @@ export class UserComponent implements OnInit {
}else{
this.message.error(res.errMsg);
}
this.isOkLoading = false;
}
)
}
......@@ -117,6 +120,7 @@ export class UserComponent implements OnInit {
}else{
this.message.error(res.errMsg);
}
this.isOkLoading = false;
}
)
}
......
<!--添加图片-->
<nz-modal [(nzVisible)]="isVisible" [nzTitle]="title" (nzOnCancel)="handleCancel()" (nzOnOk)="handleOk()">
<nz-modal [(nzVisible)]="isVisible" [nzTitle]="title" (nzOnCancel)="handleCancel()" (nzOnOk)="handleOk()" [nzOkLoading]="isOkLoading">
<form nz-form>
<nz-form-item>
<nz-form-label [nzSpan]="7" nzRequired nzFor="group">选择文件</nz-form-label>
......
......@@ -2,6 +2,7 @@ import {Component, EventEmitter, OnInit, Output} from '@angular/core';
import {NzMessageService, UploadFile} from 'ng-zorro-antd';
import {WorkService} from '../../work.service';
import {SystemService} from '../../../system/system.service';
import {OverAllService} from '../../../overAll/overAll.service';
@Component({
selector: 'smart-upload',
......@@ -13,10 +14,11 @@ export class UploadComponent implements OnInit {
title;
isVisible = false;
isOkLoading = false;
fileList: UploadFile[] = [];
constructor(private message: NzMessageService, private workSer: WorkService,
private systemSer: SystemService) {
private systemSer: SystemService,private overAllSer:OverAllService) {
}
ngOnInit() {
......@@ -28,7 +30,7 @@ export class UploadComponent implements OnInit {
}
beforeUpload = (file: UploadFile): boolean => {
const isExcel = file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
const isExcel = file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' || 'application/octet-stream';
if (!isExcel) {
this.message.error('请上传excel文件!');
} else {
......@@ -47,6 +49,7 @@ export class UploadComponent implements OnInit {
this.message.warning('请选择文件');
return false;
}
this.isOkLoading = true;
if (this.title == '上传资产文件') {
this.assetsUpload();
}
......@@ -56,6 +59,9 @@ export class UploadComponent implements OnInit {
if (this.title == '上传组织文件') {
this.orgUpload();
}
if(this.title == '上传XML模版'){
this.xmlpload();
}
}
//上传资产文件
......@@ -73,6 +79,7 @@ export class UploadComponent implements OnInit {
} else {
this.message.error(res.errMsg);
}
this.isOkLoading = false;
}
);
}
......@@ -93,6 +100,7 @@ export class UploadComponent implements OnInit {
} else {
this.message.error(res.errMsg);
}
this.isOkLoading = false;
}
);
}
......@@ -113,6 +121,27 @@ export class UploadComponent implements OnInit {
} else {
this.message.error(res.errMsg);
}
this.isOkLoading = false;
}
);
}
//上传XML文件
xmlpload() {
const formData = new FormData();
this.fileList.forEach((file: any) => {
formData.append('file', file);
});
this.overAllSer.importTemplates(formData).subscribe(
(res) => {
if (res.errCode == 10000) {
this.isVisible = false;
this.fileList = [];
this.message.success('上传成功');
} else {
this.message.error(res.errMsg);
}
this.isOkLoading = false;
}
);
}
......
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