修复分页

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, // 使 columns: fixedColumns, // 使
height: 'auto', height: 'auto',
keepSource: true, keepSource: true,
//
pager: true,
pagerConfig: { pagerConfig: {
currentPage: 1, currentPage: 1,
pageSize: 20, pageSize: 20,
// //
onChange: (currentPage: number, pageSize: number) => { onChange: (currentPage: number, pageSize: number) => {
console.log('分页变化:', { currentPage, pageSize });
// pageSize // pageSize
if (pageSize !== gridOptions.pagerConfig.pageSize) { if (pageSize !== gridOptions.pagerConfig.pageSize) {
// pageSize // pageSize
gridOptions.pagerConfig.pageSize = pageSize; gridOptions.pagerConfig.pageSize = pageSize;
gridOptions.pagerConfig.currentPage = 1; gridOptions.pagerConfig.currentPage = 1;
} }
//
if (gridApi) {
console.log('触发数据重新加载');
gridApi.reload();
}
}, },
}, },
toolbarConfig: { toolbarConfig: {
@ -253,6 +261,16 @@ const gridOptions: VxeGridProps<any> = {
} }
} }
try { 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({ const { data } = await postTreeModelDeviceDataInfoPage({
body: { body: {
pageIndex: page.currentPage, pageIndex: page.currentPage,
@ -285,6 +303,9 @@ const gridOptions: VxeGridProps<any> = {
gridOptions: { gridOptions: {
...gridOptions, ...gridOptions,
columns: allColumns.value, columns: allColumns.value,
//
pager: true,
pagerConfig: gridOptions.pagerConfig,
}, },
}); });
} }
@ -321,9 +342,26 @@ const [Grid, gridApi] = useVbenVxeGrid({ formOptions, gridOptions });
watch( watch(
() => gridApi?.pagerApi?.pageSize, () => gridApi?.pagerApi?.pageSize,
(newSize, oldSize) => { (newSize, oldSize) => {
console.log('页面大小变化:', { newSize, oldSize });
if (newSize !== oldSize && oldSize) { if (newSize !== oldSize && oldSize) {
// //
gridApi.pagerApi.currentPage = 1; 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: {
...gridOptions, ...gridOptions,
columns: allColumns.value, columns: allColumns.value,
//
pager: true,
pagerConfig: gridOptions.pagerConfig,
}, },
}); });
} }