Compare commits
No commits in common. "59ab5facd538323182cbda2e1f6410431f35a1c6" and "caf28b0ad79f0e9e96d275f04eaf5a41446931f9" have entirely different histories.
59ab5facd5
...
caf28b0ad7
@ -244,8 +244,7 @@
|
||||
"Timestamps": "Timestamps",
|
||||
"FormattedTimestamps": "Formatted Timestamps",
|
||||
"DevicePath": "DevicePath",
|
||||
"DeviceAddress": "MasterDeviceAddress",
|
||||
"SubDevice": "SubDevice",
|
||||
"DeviceAddress": "Device Address",
|
||||
"CacheRefresh": "Cache Refresh",
|
||||
"TelemetryLog": "Telemetry Log",
|
||||
"PlatformLog": "Platform Log",
|
||||
|
||||
@ -237,8 +237,7 @@
|
||||
"Timestamps": "UTC时标(纳秒)",
|
||||
"FormattedTimestamps": "本地时间",
|
||||
"DevicePath": "设备路径",
|
||||
"DeviceAddress": "主设备地址",
|
||||
"SubDevice": "从设备地址",
|
||||
"DeviceAddress": "设备地址",
|
||||
"CacheRefresh": "缓存刷新",
|
||||
"TelemetryLog": "遥测日志",
|
||||
"PlatformLog": "平台日志",
|
||||
|
||||
@ -1,9 +1,3 @@
|
||||
/*
|
||||
* @Description: 文件内容描述
|
||||
* @Author: 陈益
|
||||
* @Date: 2025-09-18 10:20:19
|
||||
* @LastEditors: 陈益
|
||||
*/
|
||||
import type {
|
||||
ColumnConfig,
|
||||
DynamicDeviceData,
|
||||
@ -43,7 +37,7 @@ const FIXED_FIELDS = [
|
||||
// 'DataBaseName',
|
||||
'DeviceType',
|
||||
'IoTDataType',
|
||||
'SubDevice',
|
||||
'DeviceAddress',
|
||||
'TimestampStr',
|
||||
'FormattedTimestamps',
|
||||
'Timestamps', // 添加Timestamps到固定字段列表,确保它被隐藏
|
||||
|
||||
@ -81,11 +81,8 @@ const { IoTDataType, DeviceAddress } = route.query;
|
||||
// 动态列定义
|
||||
const dynamicColumns = ref<any[]>([]);
|
||||
|
||||
// 是否显示 Sub_Device 列
|
||||
const showSubDeviceColumn = ref(false);
|
||||
|
||||
// 固定列定义(基础列,始终显示)- 基于 IoTDBTreeModelDeviceDataDto 类型
|
||||
const fixedBaseColumns = [
|
||||
// 固定列定义(始终显示)- 基于 IoTDBTreeModelDeviceDataDto 类型
|
||||
const fixedColumns = [
|
||||
{ title: '序号', type: 'seq', width: 50, field: 'seq', slots: {} },
|
||||
{
|
||||
field: 'TimestampStr',
|
||||
@ -124,32 +121,14 @@ const fixedBaseColumns = [
|
||||
},
|
||||
];
|
||||
|
||||
// Sub_Device 固定列定义
|
||||
const subDeviceColumn = {
|
||||
field: 'SubDevice',
|
||||
title: $t('abp.IoTDBBase.SubDevice'),
|
||||
minWidth: 150,
|
||||
showOverflow: true,
|
||||
slots: {},
|
||||
};
|
||||
|
||||
// 合并固定列和动态列 - 使用计算属性确保响应式
|
||||
const allColumns = computed(() => {
|
||||
// 如果表格未初始化,只返回固定列
|
||||
if (!isGridInitialized.value) {
|
||||
const baseColumns = [...fixedBaseColumns];
|
||||
if (showSubDeviceColumn.value) {
|
||||
baseColumns.push(subDeviceColumn);
|
||||
}
|
||||
return baseColumns;
|
||||
return [...fixedColumns];
|
||||
}
|
||||
|
||||
const columns = [...fixedBaseColumns];
|
||||
|
||||
// 根据 DeviceType 控制 Sub_Device 列是否显示
|
||||
if (showSubDeviceColumn.value) {
|
||||
columns.push(subDeviceColumn);
|
||||
}
|
||||
const columns = [...fixedColumns];
|
||||
|
||||
// 安全地添加动态列
|
||||
if (dynamicColumns.value && Array.isArray(dynamicColumns.value)) {
|
||||
@ -171,9 +150,6 @@ const initDefaultColumns = () => {
|
||||
if (!Array.isArray(dynamicColumns.value)) {
|
||||
dynamicColumns.value = [];
|
||||
}
|
||||
|
||||
// 默认不显示 Sub_Device 列,后续由表单值控制
|
||||
showSubDeviceColumn.value = false;
|
||||
};
|
||||
|
||||
// 表格是否已初始化
|
||||
@ -200,21 +176,13 @@ const formOptions: VbenFormProps = {
|
||||
return;
|
||||
}
|
||||
|
||||
// 根据 DeviceType 控制 Sub_Device 列是否显示
|
||||
if (changedFields.includes('DeviceType')) {
|
||||
// DeviceTypeEnum: 未知=0, 网关设备=1, 直连设备=2, 子设备=3
|
||||
const deviceType = values.DeviceType;
|
||||
showSubDeviceColumn.value =
|
||||
deviceType === 3 || deviceType === '3';
|
||||
}
|
||||
|
||||
// 当任何相关字段发生变化时,刷新表格数据
|
||||
const relevantFields = new Set([
|
||||
'DeviceAddress',
|
||||
'DeviceType',
|
||||
'EndCreationTime',
|
||||
'IoTDataType',
|
||||
'StartCreationTime',
|
||||
'DeviceType',
|
||||
]);
|
||||
const hasRelevantChange = changedFields.some((field) =>
|
||||
relevantFields.has(field),
|
||||
@ -284,7 +252,7 @@ const gridOptions: VxeGridProps<any> = {
|
||||
highlight: true,
|
||||
labelField: 'name',
|
||||
},
|
||||
columns: fixedBaseColumns, // 初始化时只使用基础固定列
|
||||
columns: fixedColumns, // 初始化时只使用固定列
|
||||
height: 'auto',
|
||||
keepSource: true,
|
||||
// 确保分页功能正常工作
|
||||
|
||||
@ -6,11 +6,10 @@ export interface BaseDeviceData {
|
||||
IoTDataType?: string;
|
||||
DeviceType?: string;
|
||||
DeviceId?: string;
|
||||
SubDevice?: string;
|
||||
Timestamps?: string;
|
||||
[key: string]: any; // 允许任意额外字段
|
||||
}
|
||||
|
||||
|
||||
// 动态设备数据类型
|
||||
export interface DynamicDeviceData extends BaseDeviceData {
|
||||
[key: string]: any; // 允许任意字段
|
||||
@ -18,7 +17,7 @@ export interface DynamicDeviceData extends BaseDeviceData {
|
||||
|
||||
// 分页响应类型
|
||||
export interface DynamicPageResponse<T = DynamicDeviceData> {
|
||||
items?: null | T[];
|
||||
items?: T[] | null;
|
||||
totalCount?: number;
|
||||
[key: string]: any; // 允许任意额外字段
|
||||
}
|
||||
@ -27,8 +26,8 @@ export interface DynamicPageResponse<T = DynamicDeviceData> {
|
||||
export interface ColumnConfig {
|
||||
field: string;
|
||||
title: string;
|
||||
minWidth?: number | string;
|
||||
width?: number | string;
|
||||
minWidth?: string | number;
|
||||
width?: string | number;
|
||||
showOverflow?: boolean;
|
||||
formatter?: (value: any) => string;
|
||||
slots?: Record<string, any>; // 添加slots属性
|
||||
@ -43,10 +42,10 @@ export interface FieldMapping {
|
||||
// 字段类型配置类型
|
||||
export interface FieldTypeConfig {
|
||||
[key: string]: {
|
||||
[key: string]: any;
|
||||
formatter?: (value: any) => string;
|
||||
minWidth?: number | string;
|
||||
width?: string | number;
|
||||
minWidth?: string | number;
|
||||
slots?: Record<string, any>;
|
||||
width?: number | string;
|
||||
[key: string]: any;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,12 +107,6 @@ export const tableSchema: any = computed((): VxeGridProps['columns'] => [
|
||||
minWidth: '120',
|
||||
slots: {},
|
||||
},
|
||||
{
|
||||
field: 'subDevice',
|
||||
title: $t('abp.IoTDBBase.SubDevice'),
|
||||
minWidth: '120',
|
||||
slots: {},
|
||||
},
|
||||
{
|
||||
field: 'messageType',
|
||||
title: $t('abp.OneNETLog.MessageType'),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user