修改分页定义
This commit is contained in:
@@ -23,8 +23,14 @@ interface Pageable {
|
|||||||
total: number;
|
total: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface ResPageable {
|
||||||
|
current: number;
|
||||||
|
size: number;
|
||||||
|
total: number;
|
||||||
|
}
|
||||||
|
|
||||||
interface PaginationProps {
|
interface PaginationProps {
|
||||||
pageable: Pageable;
|
pageable: ResPageable;
|
||||||
handleSizeChange: (size: number) => void;
|
handleSizeChange: (size: number) => void;
|
||||||
handleCurrentChange: (currentPage: number) => void;
|
handleCurrentChange: (currentPage: number) => void;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,7 +94,7 @@
|
|||||||
<slot name='pagination'>
|
<slot name='pagination'>
|
||||||
<Pagination
|
<Pagination
|
||||||
v-if='pagination'
|
v-if='pagination'
|
||||||
:pageable='pageable'
|
:pageable='resPageable'
|
||||||
:handle-size-change='handleSizeChange'
|
:handle-size-change='handleSizeChange'
|
||||||
:handle-current-change='handleCurrentChange'
|
:handle-current-change='handleCurrentChange'
|
||||||
/>
|
/>
|
||||||
@@ -173,6 +173,7 @@ const { selectionChange, selectedList, selectedListIds, isSelected } = useSelect
|
|||||||
const {
|
const {
|
||||||
tableData,
|
tableData,
|
||||||
pageable,
|
pageable,
|
||||||
|
resPageable,
|
||||||
searchParam,
|
searchParam,
|
||||||
searchInitParam,
|
searchInitParam,
|
||||||
getTableList,
|
getTableList,
|
||||||
@@ -190,7 +191,7 @@ const clearSelection = () => tableRef.value!.clearSelection()
|
|||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
dragSort()
|
dragSort()
|
||||||
props.requestAuto && getTableList()
|
props.requestAuto && getTableList()
|
||||||
props.data && (pageable.value.total = props.data.length)
|
props.data && (resPageable.value.total = props.data.length)
|
||||||
})
|
})
|
||||||
|
|
||||||
// 处理表格数据
|
// 处理表格数据
|
||||||
@@ -198,8 +199,8 @@ const processTableData = computed(() => {
|
|||||||
if (!props.data) return tableData.value
|
if (!props.data) return tableData.value
|
||||||
if (!props.pagination) return props.data
|
if (!props.pagination) return props.data
|
||||||
return props.data.slice(
|
return props.data.slice(
|
||||||
(pageable.value.pageNum - 1) * pageable.value.pageSize,
|
(resPageable.value.current - 1) * resPageable.value.size,
|
||||||
pageable.value.pageSize * pageable.value.pageNum,
|
resPageable.value.size * resPageable.value.current,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -4,9 +4,17 @@ export namespace Table {
|
|||||||
pageSize: number;
|
pageSize: number;
|
||||||
total: number;
|
total: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ResPageable {
|
||||||
|
current: number;
|
||||||
|
size: number;
|
||||||
|
total: number;
|
||||||
|
}
|
||||||
|
|
||||||
export interface StateProps {
|
export interface StateProps {
|
||||||
tableData: any[];
|
tableData: any[];
|
||||||
pageable: Pageable;
|
pageable: Pageable;
|
||||||
|
resPageable: ResPageable;
|
||||||
searchParam: {
|
searchParam: {
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -20,6 +20,15 @@ export const useTable = (
|
|||||||
tableData: [],
|
tableData: [],
|
||||||
// 分页数据
|
// 分页数据
|
||||||
pageable: {
|
pageable: {
|
||||||
|
// 当前页数
|
||||||
|
pageNum: 1,
|
||||||
|
// 每页显示条数
|
||||||
|
pageSize: 10,
|
||||||
|
// 总条数
|
||||||
|
total: 0,
|
||||||
|
},
|
||||||
|
// 响应分页
|
||||||
|
resPageable: {
|
||||||
// 当前页数
|
// 当前页数
|
||||||
current: 1,
|
current: 1,
|
||||||
// 每页显示条数
|
// 每页显示条数
|
||||||
@@ -71,9 +80,9 @@ export const useTable = (
|
|||||||
state.tableData = isPageable ? data.records : data;
|
state.tableData = isPageable ? data.records : data;
|
||||||
// 解构后台返回的分页数据 (如果有分页更新分页信息)
|
// 解构后台返回的分页数据 (如果有分页更新分页信息)
|
||||||
if (isPageable) {
|
if (isPageable) {
|
||||||
state.pageable.total = data.total;
|
state.resPageable.total = data.total;
|
||||||
state.pageable.current = data.current;
|
state.resPageable.current = data.current;
|
||||||
state.pageable.size = data.size;
|
state.resPageable.size = data.size;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
requestError && requestError(error);
|
requestError && requestError(error);
|
||||||
|
|||||||
@@ -2,7 +2,11 @@
|
|||||||
<el-dialog class='table-box' v-model='dialogVisible1' top='114px'
|
<el-dialog class='table-box' v-model='dialogVisible1' top='114px'
|
||||||
:style="{ height: height, maxHeight: height, overflow: 'hidden' }" :title='title1' :width='width' :modal='false'>
|
:style="{ height: height, maxHeight: height, overflow: 'hidden' }" :title='title1' :width='width' :modal='false'>
|
||||||
<div class="table-box">
|
<div class="table-box">
|
||||||
<ProTable :columns="columns" :data="data">
|
<ProTable
|
||||||
|
ref='proTable'
|
||||||
|
:columns="columns"
|
||||||
|
:data="data"
|
||||||
|
>
|
||||||
<template #tableHeader="scope">
|
<template #tableHeader="scope">
|
||||||
<el-button type="primary" :icon="CirclePlus" @click="openDrawer('新增')">新增</el-button>
|
<el-button type="primary" :icon="CirclePlus" @click="openDrawer('新增')">新增</el-button>
|
||||||
<el-button type="primary" :icon="Upload" plain @click="batchAdd">批量添加</el-button>
|
<el-button type="primary" :icon="Upload" plain @click="batchAdd">批量添加</el-button>
|
||||||
|
|||||||
Reference in New Issue
Block a user