fix: 修复CRUD直接传递Pagination组件时,丢失total属性 (#6081) (#6087)

This commit is contained in:
meerkat 2023-05-05 16:14:11 +08:00 committed by GitHub
parent 77614dd809
commit a9e36b3eaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 177 additions and 2 deletions

View File

@ -69,7 +69,23 @@ test('Renderer:crud basic interval headerToolbar footerToolbar', async () => {
interval: 1000,
perPage: 2,
headerToolbar: ['export-excel', 'statistics'],
footerToolbar: ['pagination', 'export-excel'],
footerToolbar: [
'pagination',
{
type: 'pagination',
total: '${count}',
layout: 'total,perPage,pager,go',
mode: 'normal',
activePage: 2,
perPage: 10,
maxButtons: 7,
showPerPage: true,
perPageAvailable: [10, 20, 50, 100],
showPageInput: true,
disabled: false
},
'export-excel'
],
columns: [
{
name: '__id',

View File

@ -2940,6 +2940,155 @@ exports[`Renderer:crud basic interval headerToolbar footerToolbar 1`] = `
</div>
</div>
</div>
<div
class="cxd-Crud-toolbar-item cxd-Crud-toolbar-item--right"
>
<div
class="cxd-Crud-pager"
>
<div
class="cxd-Pagination-wrap"
>
<div
class="cxd-Pagination-total cxd-Pagination-item"
>
共 144 条
</div>
<div
aria-expanded="false"
aria-haspopup="listbox"
aria-labelledby="downshift-0-label"
class="cxd-Select cxd-Pagination-perpage cxd-Pagination-item"
role="combobox"
tabindex="0"
>
<div
class="cxd-Select-valueWrap"
>
<div
class="cxd-Select-placeholder"
>
请选择
</div>
</div>
<span
class="cxd-Select-arrow"
>
<icon-mock
classname="icon icon-right-arrow-bold"
icon="right-arrow-bold"
/>
</span>
</div>
<ul
class="cxd-Pagination cxd-Pagination--sm cxd-Pagination-item"
>
<li
class="cxd-Pagination-prev is-disabled"
>
<span>
<icon-mock
classname="icon icon-left-arrow"
icon="left-arrow"
/>
</span>
</li>
<li
class="cxd-Pagination-pager-item is-active"
>
<a
role="button"
>
1
</a>
</li>
<li
class="cxd-Pagination-pager-item"
>
<a
role="button"
>
2
</a>
</li>
<li
class="cxd-Pagination-pager-item"
>
<a
role="button"
>
3
</a>
</li>
<li
class="cxd-Pagination-pager-item"
>
<a
role="button"
>
4
</a>
</li>
<li
class="cxd-Pagination-pager-item"
>
<a
role="button"
>
5
</a>
</li>
<li
class="ellipsis"
>
<a
role="button"
>
...
</a>
</li>
<li
class="cxd-Pagination-pager-item"
>
<a
role="button"
>
72
</a>
</li>
<li
class="cxd-Pagination-next"
>
<span>
<icon-mock
classname="icon icon-right-arrow"
icon="right-arrow"
/>
</span>
</li>
</ul>
<div
class="cxd-Pagination-inputGroup cxd-Pagination-item"
>
<span
class="cxd-Pagination-inputGroup-left"
>
跳转至
</span>
<input
class="cxd-Pagination-inputGroup-input"
type="text"
value=""
/>
<span
class="cxd-Pagination-inputGroup-right"
>
GO
</span>
</div>
</div>
</div>
</div>
<div
class="cxd-Crud-toolbar-item cxd-Crud-toolbar-item--left"
>

View File

@ -1795,7 +1795,12 @@ export default class CRUD extends React.Component<CRUDProps, any> {
const extraProps: Pick<
PaginationProps,
'showPageInput' | 'maxButtons' | 'layout' | 'popOverContainerSelector'
| 'showPageInput'
| 'maxButtons'
| 'layout'
| 'popOverContainerSelector'
| 'total'
| 'perPageAvailable'
> = {};
/** 优先级showPageInput显性配置 > (lastPage > 9) */
@ -1809,6 +1814,11 @@ export default class CRUD extends React.Component<CRUDProps, any> {
extraProps.popOverContainerSelector = (
toolbar as Schema
).popOverContainerSelector;
extraProps.perPageAvailable = (toolbar as Schema).perPageAvailable;
extraProps.total = resolveVariableAndFilter(
(toolbar as Schema).total,
store.data
);
} else {
extraProps.showPageInput = lastPage > 9;
}