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