Skip to content

Commit 201f188

Browse files
committed
feat: s-table Page URI mode
1 parent e03abe6 commit 201f188

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

src/components/Table/index.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default {
1717
props: Object.assign({}, T.props, {
1818
rowKey: {
1919
type: [String, Function],
20-
default: 'id'
20+
default: 'key'
2121
},
2222
data: {
2323
type: Function,
@@ -40,7 +40,7 @@ export default {
4040
default: 'default'
4141
},
4242
/**
43-
* {
43+
* alert: {
4444
* show: true,
4545
* clear: Function
4646
* }
@@ -61,11 +61,25 @@ export default {
6161
showPagination: {
6262
type: String | Boolean,
6363
default: 'auto'
64+
},
65+
/**
66+
* enable page URI mode
67+
*
68+
* e.g:
69+
* /users/1
70+
* /users/2
71+
* /users/3?queryParam=test
72+
* ...
73+
*/
74+
pageURI: {
75+
type: Boolean,
76+
default: false
6477
}
6578
}),
6679
watch: {
6780
'localPagination.current' (val) {
68-
this.$router.push({
81+
this.pageURI && this.$router.push({
82+
...this.$route,
6983
name: this.$route.name,
7084
params: Object.assign({}, this.$route.params, {
7185
pageNo: val
@@ -89,8 +103,10 @@ export default {
89103
}
90104
},
91105
created () {
106+
const { pageNo } = this.$route.params
107+
const localPageNum = this.pageURI && (pageNo && parseInt(pageNo)) || this.pageNum
92108
this.localPagination = ['auto', true].includes(this.showPagination) && Object.assign({}, this.localPagination, {
93-
current: this.pageNum,
109+
current: localPageNum,
94110
pageSize: this.pageSize,
95111
showSizeChanger: this.showSizeChanger
96112
})

src/config/router.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export const asyncRouterMap = [
7777
meta: { title: '列表页', icon: 'table', permission: [ 'table' ] },
7878
children: [
7979
{
80-
path: '/list/table-list',
80+
path: '/list/table-list/:pageNo([1-9]\\d*)?',
8181
name: 'TableListWrapper',
8282
hideChildrenInMenu: true, // 强制显示 MenuItem 而不是 SubMenu
8383
component: () => import('@/views/list/TableList'),

0 commit comments

Comments
 (0)