修复分页异常问题

This commit is contained in:
ChenYi 2025-07-17 14:36:24 +08:00
parent 8b24e4219e
commit d699782bc9
2 changed files with 62 additions and 47 deletions

View File

@ -8,7 +8,7 @@ import { useRoute } from 'vue-router';
import { Page } from '@vben/common-ui';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { postMetersPage, postCTWingLogInfoPage } from '#/api-client';
import { postCTWingLogInfoPage, postMetersPage } from '#/api-client';
import DeviceSelect from '../deviceData/DeviceSelect.vue';
import { querySchema, tableSchema } from './schema';
@ -89,17 +89,21 @@ const formOptions: VbenFormProps = {
if (deviceId) {
// deviceOptions
let device = deviceOptions.value.length > 0 ? deviceOptions.value.find(d => d.id === deviceId) : null;
let device =
deviceOptions.value.length > 0
? deviceOptions.value.find((d) => d.id === deviceId)
: null;
// DeviceSelect
if (!device && gridApi?.formApi) {
try {
// DeviceSelect
const deviceSelectRef = gridApi.formApi.getFieldComponentRef('DeviceId');
const deviceSelectRef =
gridApi.formApi.getFieldComponentRef('DeviceId');
if (deviceSelectRef && deviceSelectRef.getSelectedDevice) {
device = deviceSelectRef.getSelectedDevice();
}
} catch (error) {
} catch {
//
}
}
@ -110,14 +114,15 @@ const formOptions: VbenFormProps = {
//
setTimeout(() => {
try {
const deviceSelectRef = gridApi.formApi.getFieldComponentRef('DeviceId');
const deviceSelectRef =
gridApi.formApi.getFieldComponentRef('DeviceId');
if (deviceSelectRef && deviceSelectRef.getSelectedDevice) {
const delayedDevice = deviceSelectRef.getSelectedDevice();
if (delayedDevice) {
selectedDeviceInfo.value = delayedDevice;
}
}
} catch (error) {
} catch {
//
}
}, 100);
@ -131,10 +136,10 @@ const formOptions: VbenFormProps = {
const relevantFields = new Set([
'DeviceId',
'DeviceType',
'IoTDataType',
'SystemName',
'StartCreationTime',
'EndCreationTime',
'IoTDataType',
'StartCreationTime',
'SystemName',
]);
const hasRelevantChange = changedFields.some((field) =>
relevantFields.has(field),
@ -173,8 +178,8 @@ const gridOptions: VxeGridProps<any> = {
proxyConfig: {
ajax: {
query: async ({ page }, formValues) => {
// formValuesAPI
const currentFormValues = formValues || (gridApi?.formApi ? await gridApi.formApi.getValues() : {}) || {};
// API
const currentFormValues = gridApi?.formApi ? await gridApi.formApi.getValues() : {};
//
let deviceId = currentFormValues.DeviceId || '';
@ -182,10 +187,14 @@ const gridOptions: VxeGridProps<any> = {
const deviceType = currentFormValues.DeviceType || '';
// 使
const deviceInfo = selectedDeviceInfo.value || (currentFormValues.DeviceId && deviceOptions.value.length > 0 ? getDeviceInfoById(currentFormValues.DeviceId) : null);
const deviceInfo =
selectedDeviceInfo.value ||
(currentFormValues.DeviceId && deviceOptions.value.length > 0
? getDeviceInfoById(currentFormValues.DeviceId)
: null);
if (deviceInfo) {
systemName = deviceInfo.systemName || '';
systemName = deviceInfo.businessSystemName || '';
// id
if (Number(deviceType) === 10) {
// 使 focusId
@ -195,7 +204,6 @@ const gridOptions: VxeGridProps<any> = {
deviceId = deviceInfo.meterId || deviceId;
}
}
//
const queryParams = {
pageIndex: page.currentPage,

View File

@ -88,17 +88,21 @@ const formOptions: VbenFormProps = {
if (deviceId) {
// deviceOptions
let device = deviceOptions.value.length > 0 ? deviceOptions.value.find(d => d.id === deviceId) : null;
let device =
deviceOptions.value.length > 0
? deviceOptions.value.find((d) => d.id === deviceId)
: null;
// DeviceSelect
if (!device && gridApi?.formApi) {
try {
// DeviceSelect
const deviceSelectRef = gridApi.formApi.getFieldComponentRef('DeviceId');
const deviceSelectRef =
gridApi.formApi.getFieldComponentRef('DeviceId');
if (deviceSelectRef && deviceSelectRef.getSelectedDevice) {
device = deviceSelectRef.getSelectedDevice();
}
} catch (error) {
} catch {
//
}
}
@ -109,14 +113,15 @@ const formOptions: VbenFormProps = {
//
setTimeout(() => {
try {
const deviceSelectRef = gridApi.formApi.getFieldComponentRef('DeviceId');
const deviceSelectRef =
gridApi.formApi.getFieldComponentRef('DeviceId');
if (deviceSelectRef && deviceSelectRef.getSelectedDevice) {
const delayedDevice = deviceSelectRef.getSelectedDevice();
if (delayedDevice) {
selectedDeviceInfo.value = delayedDevice;
}
}
} catch (error) {
} catch {
//
}
}, 100);
@ -130,10 +135,10 @@ const formOptions: VbenFormProps = {
const relevantFields = new Set([
'DeviceId',
'DeviceType',
'IoTDataType',
'SystemName',
'StartCreationTime',
'EndCreationTime',
'IoTDataType',
'StartCreationTime',
'SystemName',
]);
const hasRelevantChange = changedFields.some((field) =>
relevantFields.has(field),
@ -157,7 +162,6 @@ const gridOptions: VxeGridProps<any> = {
columns: tableSchema.value,
height: 'auto',
keepSource: true,
//
pager: true,
pagerConfig: {
currentPage: 1,
@ -172,8 +176,8 @@ const gridOptions: VxeGridProps<any> = {
proxyConfig: {
ajax: {
query: async ({ page }, formValues) => {
// formValuesAPI
const currentFormValues = formValues || (gridApi?.formApi ? await gridApi.formApi.getValues() : {}) || {};
// API
const currentFormValues = gridApi?.formApi ? await gridApi.formApi.getValues() : {};
//
let deviceId = currentFormValues.DeviceId || '';
@ -181,10 +185,14 @@ const gridOptions: VxeGridProps<any> = {
const deviceType = currentFormValues.DeviceType || '';
// 使
const deviceInfo = selectedDeviceInfo.value || (currentFormValues.DeviceId && deviceOptions.value.length > 0 ? getDeviceInfoById(currentFormValues.DeviceId) : null);
const deviceInfo =
selectedDeviceInfo.value ||
(currentFormValues.DeviceId && deviceOptions.value.length > 0
? getDeviceInfoById(currentFormValues.DeviceId)
: null);
if (deviceInfo) {
systemName = deviceInfo.systemName || '';
systemName = deviceInfo.businessSystemName || '';
// id
if (Number(deviceType) === 10) {
// 使 focusId
@ -251,7 +259,6 @@ watch(
},
);
//
onMounted(async () => {
await fetchDeviceOptions();