From 55da782025f5728051fea9fff49f9e6b6f602a1e Mon Sep 17 00:00:00 2001 From: fengxiang <110431245@qq.com> Date: Thu, 28 Dec 2017 17:31:15 +0800 Subject: [PATCH] 设备信息模块 --- src/app/routes/devices/version/version.component.ts | 97 ++++++++++++++++++++++++++++++++---------------- 1 files changed, 64 insertions(+), 33 deletions(-) diff --git a/src/app/routes/devices/version/version.component.ts b/src/app/routes/devices/version/version.component.ts index 72fddc4..b6f9849 100644 --- a/src/app/routes/devices/version/version.component.ts +++ b/src/app/routes/devices/version/version.component.ts @@ -1,8 +1,10 @@ +import { DataType } from './../../../core/entity/grid'; +import { AddOrEditComponent } from './add-or-edit/add-or-edit.component'; +import { Version } from '@angular/compiler/src/util'; import { Subject } from 'rxjs/Subject'; -import '../../../rxjs-operators'; import { ToolsService } from '@core/services/tools.service'; import { Component, OnInit } from '@angular/core'; -import { NzMessageService } from 'ng-zorro-antd'; +import { NzMessageService, NzModalService } from 'ng-zorro-antd'; import { ModalHelper } from '@delon/theme'; import { HttpClient } from '@angular/common/http'; import { environment } from '../../../../environments/environment'; @@ -11,12 +13,12 @@ import { Types } from '@core/enum/types.enum'; import { Column, Grid, PageBean } from '@core/entity/grid'; -interface DeviceVersion { - createTime: Column; - description: Column; - id?: Column; - name: Column; - version: Column; +export interface DeviceVersion { + createTime?: Column|any; + description?: Column|any; + id?: Column|any; + name?: Column|any; + version?: Column|any; } @Component({ selector: 'app-version', @@ -24,23 +26,23 @@ styles: [] }) export class VersionComponent implements OnInit { - - grid: Grid = new Grid(null); + private version: DeviceVersion; + grid: Grid<DeviceVersion> = new Grid(null); queryMap = { text: '������������������������', value: ''}; queryTextStream: Subject<string> = new Subject<string>(); private initPage() { - const columns: DeviceVersion = { + this.version = { name: { text: '������', - width: '22%' + width: '18%' }, version: { text: '������', - width: '22%' + width: '18%' }, createTime: { text: '������������', - width: '22%', + width: '18%', type: { name: Types.Date, format: 'YYYY-MM-DD HH:mm:ss' @@ -48,20 +50,20 @@ }, description: { text: '������', - width: '22%' + width: '18%' } }; this.grid.title = '������������'; - this.grid.setColumns(columns); + this.grid.setColumns(this.version); this.grid.pageSize = 10; } constructor( - public http: HttpClient, private versionService: VersionService, - public dateSrv: DateService, + + private confirmServ: NzModalService, public msgSrv: NzMessageService, private modalHelper: ModalHelper, - private toolsService: ToolsService) {} + ) {} ngOnInit() { this.initPage(); @@ -95,24 +97,53 @@ // this.msgSrv.success('���������������������������'); // }); } - - add() { - // const user = {}; - // this.modalHelper.static(VersionEditComponent, { user }).subscribe(() => { - // this.load(true); - // this.msgSrv.success('���������������������������'); - // }); - } - - delete(user) { - this.http.delete(environment.SERVER_BASH_URL + '/user/operate_user/' + user.id).subscribe((res: any) => { - this.msgSrv.success('���������������������������'); - this.load(true); +// rowData���null��������������� + addOrModify(data) { + if ( data == null) { + data = {}; + } + const cols = this.version; + this.modalHelper.static(AddOrEditComponent, { cols , data }).subscribe( + ( ret: { data: any, close: Function} ) => { + this.versionService.save(ret.data).subscribe( + ( res: any) => { + if (res.code === 1) { + this.load(true); + ret.close(); + this.msgSrv.success('���������������������������'); + } + } + ); }); } - remove() { + delete(...id: number[]) { + this.versionService.delete( ...id ).subscribe( + ( res: any) => { + if (res.code === 1) { + this.load(true); + this.msgSrv.success('���������������������������'); + } + } + ); + } + deleteSelected() { + this.confirmServ.confirm({ + title: '������������', + content: '������������������������������������������������', + okText: '������', + cancelText: '������' + }).on('onOk', () => { + if (this.grid.selectedIndexs != null && this.grid.selectedIndexs.length > 0) { + const ids = this.grid.selectedIndexs.map( + (index: number) => { + return Number.parseInt(this.grid.data[index].id); + } + ); + this.delete( ...ids ); + } + }); } -- Gitblit v1.8.0