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