bixi
Version:
企业级中后台前端解决方案
92 lines (79 loc) • 1.6 kB
text/typescript
import { OnInit } from '@angular/core';
export interface IPagination {
page: number;
pageSize: number;
total: number;
}
// // tslint:disable-next-line:interface-name
// export interface BixiPaginationListDirective {
// onReset?(): void;
// }
export const PAGE_SIZE_OPTIONS = [10, 25, 50, 75, 100];
export class BixiPaginationListBase implements OnInit {
pagination = {
page: 1,
pageSize: 10,
total: 0
};
loading = false;
ngOnInit() {
this.loading = true;
if (this.onReset) {
this.onReset();
}
this.onSearch();
}
/**
* 需要实现的查询方法
*/
onSearch(): void {
return;
}
onReset(): void {
return;
}
/**
* 重置分页,该方法会驱动一次查询
*/
onResetPaginationAndSearch() {
this.onResetPagination();
this.onSearch();
}
/**
* 重置分页/搜索,该方法会驱动一次查询
*/
onResetAndSearch() {
if (this.onReset) {
this.onReset();
}
this.onResetPaginationAndSearch();
}
/**
* 重置分页,该方法会驱动一次查询
*/
onResetPagination() {
this.pagination = {
page: 1,
pageSize: this.pagination.pageSize,
total: 0
};
}
/**
* 页数变化,该方法会驱动一次查询
*/
onPageChange(page: number = 1) {
this.pagination.page = page;
this.onSearch();
}
/**
* 分页条数变化,该方法会驱动一次查询
*/
onPageSizeChange(pageSize: number) {
this.pagination = {
page: 1,
pageSize,
total: 0
};
this.onSearch();
}
}