1
0
mirror of https://github.com/zclzone/vue-naive-admin.git synced 2025-12-26 19:20:21 +08:00

feat: crud组件handleSearch增加参数控制是否留在当前页

This commit is contained in:
zclzone
2024-06-20 14:02:45 +08:00
parent c98e489063
commit c2ff434b9d
3 changed files with 14 additions and 5 deletions

View File

@@ -117,6 +117,10 @@ async function handleQuery() {
})
tableData.value = data?.pageData || data
pagination.itemCount = data.total ?? data.length
if (pagination.itemCount && !tableData.value.length && pagination.page > 1) {
// 如果当前页数据为空且总条数不为0则返回上一页数据
onPageChange(pagination.page - 1)
}
}
catch (error) {
tableData.value = []
@@ -127,9 +131,14 @@ async function handleQuery() {
loading.value = false
}
}
function handleSearch() {
pagination.page = 1
handleQuery()
function handleSearch(keepCurrentPage = false) {
if (keepCurrentPage) {
handleQuery()
}
else {
onPageChange(1)
}
}
async function handleReset() {
const queryItems = { ...props.queryItems }