From b8e2e1524169d0008accf22f2e796495ad45a378 Mon Sep 17 00:00:00 2001
From: xufenglei <xufenglei>
Date: Thu, 04 Jan 2018 16:06:40 +0800
Subject: [PATCH] 账户管理
---
src/app/core/entity/grid.ts | 48 ++++++++++++++++++++++++++++++++++--------------
1 files changed, 34 insertions(+), 14 deletions(-)
diff --git a/src/app/core/entity/grid.ts b/src/app/core/entity/grid.ts
index 65331b3..d380735 100644
--- a/src/app/core/entity/grid.ts
+++ b/src/app/core/entity/grid.ts
@@ -1,12 +1,19 @@
-import { Type } from '@angular/core';
+import { Column } from '@core/entity/grid';
import { Types } from '@core/enum/types.enum';
+
+export interface AreaNames {
+ provinceName?: string;
+ cityName?: string;
+ areaName?: string;
+}
export interface Column {
text?: string;
name?: string;
- value?: any;
width?: string;
- sort?: boolean;
+ sort?: string;
+ isSort?: boolean;
type?: DataType;
+ format?: Function;
}
export interface DataType {
name: Types;
@@ -18,31 +25,44 @@
pageSize?: number ; // ���������������
total?: number;
data?: any[];
- queryParams?: string;
+ queryParams?: string;
+ orderByClause?: string;
+ getOrderByClause ?(): string;
}
-export class Grid implements PageBean {
+export class Grid<T> implements PageBean {
+ getOrderByClause(): string {
+ const orderby = this.sorts.map( (fn) => {
+ return this.columns.find( (col: Column) => {
+ return fn === col.name;
+ } );
+ }).map( (col: Column) => {
+ const sort = col.sort.startsWith('asc') ? 'asc' : 'desc' ;
+ return col.name + '||' + sort;
+ }).join('|||');
+ return encodeURI(orderby);
+ }
title = '';
pageIndex = 0; // ������
pageSize = 10; // ������������������
- data: any[] = [];
+ data: T[] = [];
total = 0;
queryParams = '';
pages = 0; // ���������
- queryMap?: any = {};
size = 0; // ���������������������
sorts?: any[] = [];
+ loading = false;
indeterminate = false;
allChecked = false;
selectedIndexs?: number[] = []; // ������������������
columns?: Column[] = [];
-
+
checkAll(value: boolean) {
this.data.forEach(
- row => {row.checked = value;}
- )
+ row => {row['checked'] = value; }
+ );
this.refreshStatus();
}
- getData():any[]{
+ getData(): any [] {
return this.data;
}
initData(pageData: {data?: any[], total?: number}) {
@@ -57,11 +77,11 @@
}
refreshStatus() {
const data = this.data;
- const allChecked = data.every(value => value.checked);
- const allUnChecked = data.every(value => !value.checked);
+ const allChecked = data.every(value => value['checked']);
+ const allUnChecked = data.every(value => !value['checked']);
this.allChecked = allChecked;
this.indeterminate = (!allChecked) && (!allUnChecked);
- this.selectedIndexs = data.filter(value => value.checked).map(
+ this.selectedIndexs = data.filter(value => value['checked']).map(
row => {
return row['index'] != null ? row['index'] : 0;
}
--
Gitblit v1.8.0