update
1.修改列表分页问题
This commit is contained in:
@@ -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;
|
||||
}
|
||||
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)) {
|
||||
return props.afterFetch({ result, setPage: setPage, setDataSource: setDataSource });
|
||||
dataSource.value = props.afterFetch({ result, setPage: setPage, setDataSource: setDataSource });
|
||||
} else {
|
||||
dataSource.value = result?.records;
|
||||
}
|
||||
paginationProp.value = { ...paginationProp.value, ...result };
|
||||
}
|
||||
} finally {
|
||||
tableLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user