修改代码

This commit is contained in:
ChenYi 2025-07-17 10:27:56 +08:00
parent 6019490b00
commit 8609e3198a

View File

@ -2,16 +2,16 @@
import type { VbenFormProps } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';
import { ref, watch } from 'vue';
import { useRoute } from 'vue-router';
import { ref, nextTick, watch } from 'vue';
import { Page } from '@vben/common-ui';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { postCTWingLogInfoPage } from '#/api-client';
import { querySchema, tableSchema } from './schema';
import DeviceSelect from '../deviceData/DeviceSelect.vue';
import { querySchema, tableSchema } from './schema';
defineOptions({
name: 'CTWingLog',
@ -32,7 +32,7 @@ const formatDate = (date: any) => {
if (typeof date === 'string') return date;
if (date.toISOString) return date.format('YYYY-MM-DD HH:mm:ss');
return '';
};
};
const formOptions: VbenFormProps = {
schema: querySchema.value,
};
@ -46,10 +46,17 @@ const gridOptions: VxeGridProps<any> = {
height: 'auto',
keepSource: true,
pagerConfig: {
currentPage:1,
currentPage: 1,
pageSize: 10,
pageSizes: [10, 20, 100],
layouts: ['PrevPage', 'JumpNumber', 'NextPage', 'FullJump', 'Sizes', 'Total'],
layouts: [
'PrevPage',
'JumpNumber',
'NextPage',
'FullJump',
'Sizes',
'Total',
],
},
toolbarConfig: {
custom: true,
@ -63,23 +70,20 @@ const gridOptions: VxeGridProps<any> = {
//
let deviceId = '';
let systemName = '';
let deviceType = formValues?.DeviceType || '';
const deviceType = formValues?.DeviceType || '';
const finalFocusAddress = formValues.FocusAddress || '';
if (deviceSelectRef.value) {
const deviceInfo = deviceSelectRef.value.getSelectedDeviceInfo();
if (deviceInfo) {
finalFocusAddress = deviceInfo.focusAddress || '';
systemName = deviceInfo.systemName || '';
// 10focusIdmeterId
if (Number(deviceType) === 10) {
deviceId = deviceInfo.focusId || '';
} else {
deviceId = deviceInfo.meterId || '';
}
deviceId =
Number(deviceType) === 10
? deviceInfo.focusId || ''
: deviceInfo.meterId || '';
}
}
// deviceInfo退DeviceId
if (!deviceId) {
deviceId = formValues?.DeviceId || '';
}
//
const queryParams: any = {
pageIndex: page.currentPage,
@ -91,6 +95,7 @@ const gridOptions: VxeGridProps<any> = {
SystemName: systemName || formValues?.SystemName || '',
StartCreationTime: formatDate(formValues?.StartCreationTime),
EndCreationTime: formatDate(formValues?.EndCreationTime),
FocusAddress: finalFocusAddress,
};
if (DeviceType) queryParams.DeviceType = DeviceType;
if (DeviceId) queryParams.DeviceId = DeviceId;
@ -147,12 +152,9 @@ watch(
<template>
<Page auto-content-height>
<Grid>
<template #DeviceId="{ model, field }"> <DeviceSelect
ref="deviceSelectRef"
v-model:value="model[field]"
:placeholder="$t('common.pleaseSelect') + $t('abp.log.deviceInfo')"
allow-clear
/>
<template #DeviceId="{ model, field }">
<DeviceSelect ref="deviceSelectRef" v-model:value="model[field]"
:placeholder="$t('common.pleaseSelect') + $t('abp.log.deviceInfo')" allow-clear />
</template>
</Grid>
</Page>