Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
74d225cc
authored
Mar 11, 2023
by
YunaiV
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
重构:在 config 列表,完整引入分页
parent
0506c4e5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
59 deletions
+27
-59
src/components/Pagination/index.vue
+25
-57
src/views/infra/config/index.vue
+2
-2
No files found.
src/components/Pagination/index.vue
View file @
74d225cc
<!-- 基于 ruoyi-vue3 的 Pagination 重构,核心是简化无用的属性,并使用 ts 重写 -->
<
template
>
<
template
>
<
div
:class=
"
{ hidden }" class="pagination-container">
<
el-pagination
<el-pagination
v-show=
"total > 0"
:background=
"background
"
class=
"float-right mt-15px mb-15px
"
v-model:current-page=
"currentPag
e"
:background=
"tru
e"
v-model:page-size=
"pageSize
"
layout=
"total, sizes, prev, pager, next, jumper
"
:layout=
"layout
"
:page-sizes=
"[10, 20, 30, 50]
"
:page-sizes=
"pageSizes
"
v-model:current-page=
"currentPage
"
:pager-count=
"pagerCount
"
v-model:page-size=
"pageSize
"
:total=
"total
"
:pager-count=
"pagerCount
"
@
size-change=
"handleSizeChange
"
:total=
"total
"
@
current-change=
"handleCurrent
Change"
@
size-change=
"handleSize
Change"
/>
@
current-change=
"handleCurrentChange"
</div
>
/
>
</
template
>
</
template
>
<
script
setup
>
<
script
setup
>
// TODO 芋艿:ts 重写
// TODO 芋艿:scrollTo 接入
// import { scrollTo } from '@/utils/scroll-to'
import
{
computed
}
from
'vue'
import
{
computed
}
from
'vue'
const
props
=
defineProps
({
const
props
=
defineProps
({
// 总条目数
total
:
{
total
:
{
required
:
true
,
required
:
true
,
type
:
Number
type
:
Number
},
},
// 当前页数:pageNo
page
:
{
page
:
{
type
:
Number
,
type
:
Number
,
default
:
1
default
:
1
},
},
// 每页显示条目个数:pageSize
limit
:
{
limit
:
{
type
:
Number
,
type
:
Number
,
default
:
20
default
:
20
},
},
pageSizes
:
{
// 设置最大页码按钮数。 页码按钮的数量,当总页数超过该值时会折叠
type
:
Array
,
default
()
{
return
[
10
,
20
,
30
,
50
]
}
},
// 移动端页码按钮的数量端默认值 5
// 移动端页码按钮的数量端默认值 5
pagerCount
:
{
pagerCount
:
{
type
:
Number
,
type
:
Number
,
default
:
document
.
body
.
clientWidth
<
992
?
5
:
7
default
:
document
.
body
.
clientWidth
<
992
?
5
:
7
},
layout
:
{
type
:
String
,
default
:
'total, sizes, prev, pager, next, jumper'
},
background
:
{
type
:
Boolean
,
default
:
true
},
autoScroll
:
{
type
:
Boolean
,
default
:
true
},
hidden
:
{
type
:
Boolean
,
default
:
false
}
}
})
})
...
@@ -68,6 +47,7 @@ const currentPage = computed({
...
@@ -68,6 +47,7 @@ const currentPage = computed({
return
props
.
page
return
props
.
page
},
},
set
(
val
)
{
set
(
val
)
{
// 触发 update:page 事件,更新 limit 属性,从而更新 pageNo
emit
(
'update:page'
,
val
)
emit
(
'update:page'
,
val
)
}
}
})
})
...
@@ -76,32 +56,20 @@ const pageSize = computed({
...
@@ -76,32 +56,20 @@ const pageSize = computed({
return
props
.
limit
return
props
.
limit
},
},
set
(
val
)
{
set
(
val
)
{
// 触发 update:limit 事件,更新 limit 属性,从而更新 pageSize
emit
(
'update:limit'
,
val
)
emit
(
'update:limit'
,
val
)
}
}
})
})
function
handleSizeChange
(
val
)
{
const
handleSizeChange
=
(
val
)
=>
{
// 如果修改后超过最大页面,强制跳转到第 1 页
if
(
currentPage
.
value
*
val
>
props
.
total
)
{
if
(
currentPage
.
value
*
val
>
props
.
total
)
{
currentPage
.
value
=
1
currentPage
.
value
=
1
}
}
// 触发 pagination 事件,重新加载列表
emit
(
'pagination'
,
{
page
:
currentPage
.
value
,
limit
:
val
})
emit
(
'pagination'
,
{
page
:
currentPage
.
value
,
limit
:
val
})
if
(
props
.
autoScroll
)
{
// scrollTo(0, 800)
}
}
}
function
handleCurrentChange
(
val
)
{
const
handleCurrentChange
=
(
val
)
=>
{
// 触发 pagination 事件,重新加载列表
emit
(
'pagination'
,
{
page
:
val
,
limit
:
pageSize
.
value
})
emit
(
'pagination'
,
{
page
:
val
,
limit
:
pageSize
.
value
})
if
(
props
.
autoScroll
)
{
// scrollTo(0, 800)
}
}
}
</
script
>
</
script
>
<
style
scoped
>
.pagination-container
{
background
:
#fff
;
padding
:
32px
16px
;
}
.pagination-container.hidden
{
display
:
none
;
}
</
style
>
src/views/infra/config/index.vue
View file @
74d225cc
...
@@ -36,7 +36,7 @@
...
@@ -36,7 +36,7 @@
range-separator=
"-"
range-separator=
"-"
start-placeholder=
"开始日期"
start-placeholder=
"开始日期"
end-placeholder=
"结束日期"
end-placeholder=
"结束日期"
:default-time=
"[new Date(
0, 0, 0, 0, 0, 0), new Date(0, 0, 0, 23, 59, 59
)]"
:default-time=
"[new Date(
'1 00:00:00'), new Date('1 23:59:59'
)]"
/>
/>
</el-form-item>
</el-form-item>
<el-form-item>
<el-form-item>
...
@@ -103,8 +103,8 @@
...
@@ -103,8 +103,8 @@
</
template
>
</
template
>
</el-table-column>
</el-table-column>
</el-table>
</el-table>
<!-- 分页 -->
<Pagination
<Pagination
v-show=
"total > 0"
:total=
"total"
:total=
"total"
v-model:page=
"queryParams.pageNo"
v-model:page=
"queryParams.pageNo"
v-model:limit=
"queryParams.pageSize"
v-model:limit=
"queryParams.pageSize"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment