From f01d6b7e6bf8132524c1c2821fdcbbc5ca548369 Mon Sep 17 00:00:00 2001 From: fengxiang <110431245@qq.com> Date: Fri, 29 Dec 2017 16:57:22 +0800 Subject: [PATCH] 设备型号完成 --- src/app/routes/devices/version/version.component.ts | 162 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 160 insertions(+), 2 deletions(-) diff --git a/src/app/routes/devices/version/version.component.ts b/src/app/routes/devices/version/version.component.ts index 3297984..d8fcc2d 100644 --- a/src/app/routes/devices/version/version.component.ts +++ b/src/app/routes/devices/version/version.component.ts @@ -1,15 +1,173 @@ +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 { ToolsService } from '@core/services/tools.service'; import { Component, OnInit } from '@angular/core'; +import { NzMessageService, NzModalService } from 'ng-zorro-antd'; +import { ModalHelper } from '@delon/theme'; +import { HttpClient } from '@angular/common/http'; +import { environment } from '../../../../environments/environment'; +import { DateService } from '@core/services/date.service'; +import { VersionService } from 'app/routes/devices/version/version.service'; +import { Types } from '@core/enum/types.enum'; +import { Column, Grid, PageBean } from '@core/entity/grid'; +import { filter } from 'rxjs/operators/filter'; +export interface DeviceVersion { + createTime?: Column|any; + description?: Column|any; + id?: Column|any; + name?: Column|any; + version?: Column|any; +} @Component({ selector: 'app-version', templateUrl: './version.component.html', styles: [] }) export class VersionComponent implements OnInit { - - constructor() { } + private version: DeviceVersion; + grid: Grid<DeviceVersion> = new Grid(null); + queryMap = { text: '������������������������', value: ''}; + queryTextStream: Subject<string> = new Subject<string>(); + private initPage() { + this.version = { + name: { + text: '������', + width: '18%' + }, + version: { + text: '������', + width: '18%', + isSort: true + }, + createTime: { + text: '������������', + width: '18%', + type: { + name: Types.Date, + format: 'YYYY-MM-DD HH:mm:ss' + }, + isSort: true + }, + description: { + text: '������', + width: '18%' + } + }; + this.grid.title = '������������'; + this.grid.setColumns(this.version); + this.grid.pageSize = 10; + } + constructor( + private versionService: VersionService, + + private confirmServ: NzModalService, + public msgSrv: NzMessageService, + private modalHelper: ModalHelper, + ) {} ngOnInit() { + this.initPage(); + this.queryTextStream + .debounceTime(500) + .distinctUntilChanged() + .subscribe(queryText => { + this.load(); + }); + } + queryTextChanged($event) { + this.queryTextStream.next(this.queryMap.value); + } + load(reload: boolean = false) { + if (reload) { + this.grid.pageIndex = 1 ; + } + // ������������������ExpressionChangedAfterItHasBeenCheckedError + setTimeout(() => { + this.grid.loading = true; + }, 1); + this.versionService.getPagingList(this.grid, this.queryMap.value).subscribe( + (res: PageBean) => { + this.grid.loading = true; + if (res != null && res.data != null) { + this.grid.initData(res); + this.grid.refreshStatus(); + setTimeout(() => { + this.grid.loading = false; + }, 1); + } + } + ); + } + +// 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(); + ret.close(); + this.msgSrv.success('���������������������������'); + } + } + ); + }); + } + + delete(...id: number[]) { + this.versionService.delete( ...id ).subscribe( + ( res: any) => { + if (res.code === 1) { + this.load(); + 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) => { + const id = this.grid.data[index].id; + return Number.parseInt(id); + } + ); + this.delete( ...ids ); + } + }); + } + sort(field: string, value: string) { + // ������������field + this.grid.sorts = this.grid.sorts.filter( + (fn: string) => { + return fn !== field; + } + ); + // ������value������null������������������������������filed + if ( value != null ) { + this.grid.sorts.push(field); + } + this.load(); + } + + reset(ls: any[]) { + for (const item of ls) item.value = false; + this.load(true); } } -- Gitblit v1.8.0