1.修改列表分页问题
This commit is contained in:
2024-05-17 13:25:28 +08:00
parent 13faaa92a6
commit ce2b8f5837
@@ -1,6 +1,7 @@
<template>
<a-table
class="ant-table-striped"
:loading="tableLoading"
:dataSource="dataSource"
:columns="columns"
:scroll="{ y: '56vh' }"
@@ -38,6 +39,7 @@
//分页相关
const current = ref(1);
const pageSize = ref(10);
const tableLoading = ref(false);
const total = ref(0);
const deptId = ref();
const paginationProp = ref({
@@ -69,17 +71,19 @@
const dataSource = ref([]);
async function getRecords() {
if (!props.api) {
setDataSource([{ name: '张三', department: '公司机关', sex: '男' }]);
return;
}
const { code, result } = await props.api({ ...props.apiParams, pageSize: pageSize.value, pageNo: current.value });
if (code == 200) {
if (props.afterFetch && isFunction(props.afterFetch)) {
return props.afterFetch({ result, setPage: setPage, setDataSource: setDataSource });
} else {
dataSource.value = result?.records;
try {
tableLoading.value = true;
const { code, result } = await props.api({ ...props.apiParams, pageSize: pageSize.value, pageNo: current.value });
if (code == 200) {
if (props.afterFetch && isFunction(props.afterFetch)) {
dataSource.value = props.afterFetch({ result, setPage: setPage, setDataSource: setDataSource });
} else {
dataSource.value = result?.records;
}
paginationProp.value = { ...paginationProp.value, ...result };
}
} finally {
tableLoading.value = false;
}
}