修复分页

This commit is contained in:
ChenYi 2025-07-16 17:34:58 +08:00
parent 3d4b568a3b
commit 8d2752f919

View File

@ -197,17 +197,25 @@ const gridOptions: VxeGridProps<any> = {
columns: fixedColumns, // 使
height: 'auto',
keepSource: true,
//
pager: true,
pagerConfig: {
currentPage: 1,
pageSize: 20,
//
onChange: (currentPage: number, pageSize: number) => {
console.log('分页变化:', { currentPage, pageSize });
// pageSize
if (pageSize !== gridOptions.pagerConfig.pageSize) {
// pageSize
gridOptions.pagerConfig.pageSize = pageSize;
gridOptions.pagerConfig.currentPage = 1;
}
//
if (gridApi) {
console.log('触发数据重新加载');
gridApi.reload();
}
},
},
toolbarConfig: {
@ -253,6 +261,16 @@ const gridOptions: VxeGridProps<any> = {
}
}
try {
console.log('API调用参数:', {
pageIndex: page.currentPage,
pageSize: page.pageSize,
DeviceType: deviceTypeNumber,
DeviceId: finalDeviceId,
FocusAddress: finalFocusAddress,
SystemName: formValues.SystemName || SystemName,
IoTDataType: ioTDataTypeValue,
});
const { data } = await postTreeModelDeviceDataInfoPage({
body: {
pageIndex: page.currentPage,
@ -285,6 +303,9 @@ const gridOptions: VxeGridProps<any> = {
gridOptions: {
...gridOptions,
columns: allColumns.value,
//
pager: true,
pagerConfig: gridOptions.pagerConfig,
},
});
}
@ -321,9 +342,26 @@ const [Grid, gridApi] = useVbenVxeGrid({ formOptions, gridOptions });
watch(
() => gridApi?.pagerApi?.pageSize,
(newSize, oldSize) => {
console.log('页面大小变化:', { newSize, oldSize });
if (newSize !== oldSize && oldSize) {
//
gridApi.pagerApi.currentPage = 1;
//
console.log('页面大小变化,触发重新加载');
gridApi.reload();
}
},
);
//
watch(
() => gridApi?.pagerApi?.currentPage,
(newPage, oldPage) => {
console.log('当前页变化:', { newPage, oldPage });
if (newPage !== oldPage && oldPage) {
//
console.log('当前页变化,触发重新加载');
gridApi.reload();
}
},
);
@ -344,6 +382,9 @@ const initializeGrid = async () => {
gridOptions: {
...gridOptions,
columns: allColumns.value,
//
pager: true,
pagerConfig: gridOptions.pagerConfig,
},
});
}