| | |
| | | export interface Column { |
| | | text?: string; |
| | | name?: string; |
| | | value?: any; |
| | | width?: string; |
| | | sort?: boolean; |
| | | type?: DataType; |
| | |
| | | pageSize?: number ; // 一页多少条 |
| | | total?: number; |
| | | data?: any[]; |
| | | queryParams?: string; |
| | | queryParams?: string; |
| | | } |
| | | export class Grid implements PageBean { |
| | | export class Grid<T> implements PageBean { |
| | | title = ''; |
| | | pageIndex = 0; // 页码 |
| | | pageSize = 10; // 每页几行数据 |
| | | data: any[] = []; |
| | | data: T[] = []; |
| | | total = 0; |
| | | queryParams = ''; |
| | | pages = 0; // 总页数 |
| | |
| | | |
| | | checkAll(value: boolean) { |
| | | this.data.forEach( |
| | | row => {row.checked = value; } |
| | | row => {row['checked'] = value; } |
| | | ); |
| | | this.refreshStatus(); |
| | | } |
| | |
| | | } |
| | | 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; |
| | | } |