修复分页
This commit is contained in:
parent
3d4b568a3b
commit
8d2752f919
@ -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,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user