| | |
| | | import { Type } from '@angular/core'; |
| | | import { Column } from '@core/entity/grid'; |
| | | import { Types } from '@core/enum/types.enum'; |
| | | export interface Column { |
| | | text?: string; |
| | | name?: string; |
| | | width?: string; |
| | | sort?: boolean; |
| | | sort?: string; |
| | | isSort?: boolean; |
| | | type?: DataType; |
| | | } |
| | | export interface DataType { |
| | |
| | | total?: number; |
| | | data?: any[]; |
| | | queryParams?: string; |
| | | orderByClause?: string; |
| | | getOrderByClause ?(): string; |
| | | } |
| | | 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; // 每页几行数据 |
| | |
| | | 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; } |