2025-07-14 16:04:42 +08:00

80 lines
1.9 KiB
Vue

<script setup lang="ts">
import type { VbenFormProps } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';
import { useRoute } from 'vue-router';
import { Page } from '@vben/common-ui';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { postCTWingLogInfoPage } from '#/api-client';
import { querySchema, tableSchema } from './schema';
defineOptions({
name: 'CTWingLog',
});
const route = useRoute();
const { DeviceType, DeviceId, FocusAddress } = route.query;
const formOptions: VbenFormProps = {
schema: querySchema.value,
};
const gridOptions: VxeGridProps<any> = {
checkboxConfig: {
highlight: true,
labelField: 'name',
},
columns: tableSchema.value,
height: 'auto',
keepSource: true,
pagerConfig: {},
toolbarConfig: {
custom: true,
},
customConfig: {
storage: true,
},
proxyConfig: {
ajax: {
query: async ({ page }, formValues) => {
// 构建查询参数
const queryParams: any = {
pageIndex: page.currentPage,
pageSize: page.pageSize,
};
// 如果有表单值,添加到查询参数中
if (formValues) {
Object.assign(queryParams, formValues);
}
// 添加路由参数
if (DeviceType) queryParams.DeviceType = DeviceType;
if (DeviceId) queryParams.DeviceId = DeviceId;
if (FocusAddress) queryParams.FocusAddress = FocusAddress;
const { data } = await postCTWingLogInfoPage({
body: queryParams,
});
// 确保返回的数据包含totalCount字段
const result = {
items: data.items || [],
totalCount: data.totalCount || (data.items ? data.items.length : 0),
};
return result;
},
},
},
};
const [Grid] = useVbenVxeGrid({ formOptions, gridOptions });
</script>
<template>
<Page auto-content-height>
<Grid />
</Page>
</template>