crud 新增 alwaysShowPagination 属性 (#1544)

This commit is contained in:
liaoxuezhi 2021-02-05 10:36:51 +08:00 committed by GitHub
parent a3952beb00
commit a6cdb9d33d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 6 deletions

View File

@ -1184,8 +1184,6 @@ crud 组件支持通过配置`headerToolbar`和`footerToolbar`属性,实现在
1. 批量操作按钮上配置 `disabledOn` 值为 `this.selectedItems.some(item => item.owner === this.amisUser.name)`
2. 给表格加上 `itemCheckableOn` 值为 `this.owner === this.amisUser.name` 表示只有 owner 是自己的才可以打勾。
### 数据统计
在`headerToolbar`或者`footerToolbar`数组中添加`statistics`字符串,可以实现简单的数据统计功能
@ -1742,3 +1740,4 @@ CRUD 中不限制有多少个单条操作、添加一个操作对应的添加一
| labelTpl | `string` | | 单条描述模板,`keepItemSelectionOnPageChange`设置为`true`后会把所有已选择条目列出来,此选项可以用来定制条目展示文案。 |
| headerToolbar | Array | `['bulkActions', 'pagination']` | 顶部工具栏配置 |
| footerToolbar | Array | `['statistics', 'pagination']` | 底部工具栏配置 |
| alwaysShowPagination | `boolean` | `false` | 是否总是显示分页 |

View File

@ -279,6 +279,11 @@ export interface CRUDCommonSchema extends BaseSchema {
*/
accordion?: boolean;
};
/**
* 1
*/
alwaysShowPagination?: boolean;
}
export type CRUDCardsSchema = CRUDCommonSchema & {
@ -1592,11 +1597,15 @@ export default class CRUD extends React.Component<CRUDProps, any> {
}
renderPagination() {
const {store, render, classnames: cx} = this.props;
const {store, render, classnames: cx, alwaysShowPagination} = this.props;
const {page, lastPage} = store;
if (store.mode !== 'simple' && store.lastPage < 2) {
if (
store.mode !== 'simple' &&
store.lastPage < 2 &&
!alwaysShowPagination
) {
return null;
}
@ -1620,9 +1629,14 @@ export default class CRUD extends React.Component<CRUDProps, any> {
}
renderStatistics() {
const {store, classnames: cx, translate: __} = this.props;
const {
store,
classnames: cx,
translate: __,
alwaysShowPagination
} = this.props;
if (store.lastPage <= 1) {
if (store.lastPage <= 1 && !alwaysShowPagination) {
return null;
}