mirror of
https://github.com/zclzone/vue-naive-admin.git
synced 2025-04-30 22:29:01 +08:00
feat: crud组件handleSearch增加参数控制是否留在当前页
This commit is contained in:
parent
c98e489063
commit
c2ff434b9d
@ -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 }
|
||||
|
@ -100,7 +100,7 @@ export function useCrud({ name, initForm = {}, doCreate, doDelete, doUpdate, ref
|
||||
const data = await doDelete(id)
|
||||
$message.success('删除成功')
|
||||
d.loading = false
|
||||
refresh(data)
|
||||
refresh(data, true)
|
||||
}
|
||||
catch (error) {
|
||||
d.loading = false
|
||||
|
@ -120,7 +120,7 @@ const { modalRef, modalFormRef, modalAction, modalForm, handleAdd, handleDelete,
|
||||
doDelete: api.delete,
|
||||
doUpdate: api.update,
|
||||
initForm: { enable: true },
|
||||
refresh: () => $table.value?.handleSearch(),
|
||||
refresh: (_, keepCurrentPage) => $table.value?.handleSearch(keepCurrentPage),
|
||||
})
|
||||
|
||||
const columns = [
|
||||
|
Loading…
x
Reference in New Issue
Block a user