Skip to content

Commit e29fc36

Browse files
committed
添加Grid分页布局自定义
1 parent c687459 commit e29fc36

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

public/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32461,7 +32461,7 @@ var render = function() {
3246132461
[
3246232462
_c("el-pagination", {
3246332463
attrs: {
32464-
layout: "prev, pager, next, jumper,->,total, sizes",
32464+
layout: _vm.attrs.pageLayout,
3246532465
"hide-on-single-page": false,
3246632466
total: _vm.pageData.total,
3246732467
"page-size": _vm.pageData.pageSize,

resources/js/components/grid/Table.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@
167167
</div>
168168
<div class="table-page">
169169
<el-pagination
170-
layout="prev, pager, next, jumper,->,total, sizes"
170+
:layout="attrs.pageLayout"
171171
:hide-on-single-page="false"
172172
:total="pageData.total"
173173
:page-size="pageData.pageSize"

src/Grid.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
use SmallRuralDog\Admin\Layout\Content;
2525

2626

27-
class Grid extends Component implements \JsonSerializable
27+
class Grid extends Component
2828
{
2929
use HasGridAttributes, HasPageAttributes, HasDefaultSort, HasQuickSearch, HasFilter;
3030

@@ -380,6 +380,7 @@ public function jsonSerialize()
380380
$viewData['dataUrl'] = $this->dataUrl;
381381
$viewData['pageSizes'] = $this->pageSizes;
382382
$viewData['perPage'] = $this->perPage;
383+
$viewData['pageLayout'] = $this->pageLayout;
383384
$viewData['pageBackground'] = $this->pageBackground;
384385
$viewData['toolbars'] = $this->toolbars->builderData();
385386
$viewData['batchActions'] = $this->batchActions->builderActions();

src/Grid/Concerns/HasPageAttributes.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,23 @@ trait HasPageAttributes
99
protected $pageSizes = [10, 15, 20, 30, 50, 100];
1010
protected $perPage = 15;
1111

12+
protected $pageLayout = "total, sizes,->,prev, pager, next, jumper";
13+
1214
protected $pageBackground = true;
1315

16+
/**
17+
* 设置分页布局,子组件名用逗号分隔
18+
* prev, pager, next, jumper, ->, total
19+
* @param string $layout
20+
* @return $this
21+
*/
22+
public function pageLayout(string $layout)
23+
{
24+
$this->pageLayout = $layout;
25+
return $this;
26+
}
27+
28+
1429
/**
1530
* 每页显示个数选择器的选项设置
1631
* @param array $sizes

0 commit comments

Comments
 (0)