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 | 155 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 153 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..b6f9849 100644
--- a/src/app/routes/devices/version/version.component.ts
+++ b/src/app/routes/devices/version/version.component.ts
@@ -1,15 +1,166 @@
+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';
+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%'
+ },
+ createTime: {
+ text: '������������',
+ width: '18%',
+ type: {
+ name: Types.Date,
+ format: 'YYYY-MM-DD HH:mm:ss'
+ }
+ },
+ 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 ;
+ }
+ this.versionService.getPagingList(this.grid, this.queryMap.value).subscribe(
+ (res: PageBean) => {
+ if (res != null && res.data != null) {
+ this.grid.initData(res);
+ this.grid.refreshStatus();
+ }
+ }
+ );
+ }
+
+ edit() {
+ // this.modalHelper.static(VersionEditComponent, { user }).subscribe(() => {
+ // this.load(true);
+ // this.msgSrv.success('���������������������������');
+ // });
+ }
+// 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('���������������������������');
+ }
+ }
+ );
+ });
+ }
+
+ 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 );
+ }
+ });
+ }
+
+
+ dataChange(res: any) {
+
+ }
+
+ sort(field: string, value: any) {
+ // this.sortMap = {};
+ // this.sortMap[field] = value;
+ // this.q.sorter = value ? `${field}_${value}` : '';
+ // this.load(true);
+ }
+
+ reset(ls: any[]) {
+ for (const item of ls) item.value = false;
+ this.load(true);
}
}
--
Gitblit v1.8.0