修改分页
This commit is contained in:
parent
8d2752f919
commit
edc6241d7d
@ -202,21 +202,6 @@ const gridOptions: VxeGridProps<any> = {
|
||||
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: {
|
||||
custom: true,
|
||||
@ -229,7 +214,11 @@ const gridOptions: VxeGridProps<any> = {
|
||||
showHeaderOverflow: true,
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }, formValues) => {
|
||||
query: async ({ page, sorts, filters }, formValues) => {
|
||||
// 确保page参数存在
|
||||
if (!page) {
|
||||
return { items: [], totalCount: 0 };
|
||||
}
|
||||
// 处理DeviceType和IoTDataType,确保传递数字类型
|
||||
const deviceTypeValue = formValues.DeviceType || DeviceType;
|
||||
const deviceTypeNumber = deviceTypeValue
|
||||
@ -261,16 +250,6 @@ 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,
|
||||
@ -342,12 +321,10 @@ 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();
|
||||
}
|
||||
},
|
||||
@ -357,10 +334,8 @@ watch(
|
||||
watch(
|
||||
() => gridApi?.pagerApi?.currentPage,
|
||||
(newPage, oldPage) => {
|
||||
console.log('当前页变化:', { newPage, oldPage });
|
||||
if (newPage !== oldPage && oldPage) {
|
||||
// 触发数据重新加载
|
||||
console.log('当前页变化,触发重新加载');
|
||||
gridApi.reload();
|
||||
}
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user