完善设备数据查看,过滤DataType
This commit is contained in:
parent
8fd4aba658
commit
b5c1948ec2
@ -247,6 +247,7 @@
|
||||
"FormattedTimestamps": "Formatted Timestamps",
|
||||
"DevicePath": "DevicePath",
|
||||
"DeviceAddress": "MasterDeviceAddress",
|
||||
"DataType": "DataType",
|
||||
"SubDevice": "SubDevice",
|
||||
"CacheRefresh": "Cache Refresh",
|
||||
"TelemetryLog": "Telemetry Log",
|
||||
|
||||
@ -240,6 +240,7 @@
|
||||
"FormattedTimestamps": "本地时间",
|
||||
"DevicePath": "设备路径",
|
||||
"DeviceAddress": "主设备地址",
|
||||
"DataType": "测点数据类型",
|
||||
"SubDevice": "从设备地址",
|
||||
"CacheRefresh": "缓存刷新",
|
||||
"TelemetryLog": "遥测日志",
|
||||
|
||||
@ -17,6 +17,7 @@ export const fieldNameMapping: FieldMapping = {
|
||||
// ProjectId: '项目ID',
|
||||
// ProjectName: '项目名称',
|
||||
IoTDataType: 'IoT数据类型',
|
||||
DataType: '测点数据类型',
|
||||
DeviceType: '设备类型',
|
||||
DeviceAddress: '设备ID',
|
||||
// Timestamps: '时间戳', // 已隐藏,使用TimestampStr替代
|
||||
@ -43,6 +44,7 @@ const FIXED_FIELDS = [
|
||||
// 'DataBaseName',
|
||||
'DeviceType',
|
||||
'IoTDataType',
|
||||
'DataType',
|
||||
'SubDevice',
|
||||
'TimestampStr',
|
||||
'FormattedTimestamps',
|
||||
|
||||
@ -81,7 +81,7 @@ const { IoTDataType, DeviceAddress } = route.query;
|
||||
// 动态列定义
|
||||
const dynamicColumns = ref<any[]>([]);
|
||||
|
||||
// 是否显示 Sub_Device 列
|
||||
// 是否显示子设备场景下的固定列(Sub_Device、DataType;与 DeviceType=子设备 联动)
|
||||
const showSubDeviceColumn = ref(false);
|
||||
|
||||
// 固定列定义(基础列,始终显示)- 基于 IoTDBTreeModelDeviceDataDto 类型
|
||||
@ -133,22 +133,31 @@ const subDeviceColumn = {
|
||||
slots: {},
|
||||
};
|
||||
|
||||
// DataType 固定列定义(与 Sub_Device 相同显示条件)
|
||||
const dataTypeColumn = {
|
||||
field: 'DataType',
|
||||
title: $t('abp.IoTDBBase.DataType'),
|
||||
minWidth: 150,
|
||||
showOverflow: true,
|
||||
slots: {},
|
||||
};
|
||||
|
||||
// 合并固定列和动态列 - 使用计算属性确保响应式
|
||||
const allColumns = computed(() => {
|
||||
// 如果表格未初始化,只返回固定列
|
||||
if (!isGridInitialized.value) {
|
||||
const baseColumns = [...fixedBaseColumns];
|
||||
if (showSubDeviceColumn.value) {
|
||||
baseColumns.push(subDeviceColumn);
|
||||
baseColumns.push(subDeviceColumn, dataTypeColumn);
|
||||
}
|
||||
return baseColumns;
|
||||
}
|
||||
|
||||
const columns = [...fixedBaseColumns];
|
||||
|
||||
// 根据 DeviceType 控制 Sub_Device 列是否显示
|
||||
// 根据 DeviceType 控制 Sub_Device、DataType 列是否显示
|
||||
if (showSubDeviceColumn.value) {
|
||||
columns.push(subDeviceColumn);
|
||||
columns.push(subDeviceColumn, dataTypeColumn);
|
||||
}
|
||||
|
||||
// 安全地添加动态列
|
||||
@ -172,7 +181,7 @@ const initDefaultColumns = () => {
|
||||
dynamicColumns.value = [];
|
||||
}
|
||||
|
||||
// 默认不显示 Sub_Device 列,后续由表单值控制
|
||||
// 默认不显示子设备相关固定列,后续由表单 DeviceType 控制
|
||||
showSubDeviceColumn.value = false;
|
||||
};
|
||||
|
||||
@ -184,6 +193,18 @@ const isInitializing = ref(false);
|
||||
// 初始化默认列
|
||||
initDefaultColumns();
|
||||
|
||||
// 根据当前表单 DeviceType 同步子设备相关列(Sub_Device、DataType)显示状态
|
||||
const syncSubDeviceColumnsVisibilityFromForm = async () => {
|
||||
try {
|
||||
if (!gridApi?.formApi) return;
|
||||
const v = await gridApi.formApi.getValues();
|
||||
const deviceType = v.DeviceType;
|
||||
showSubDeviceColumn.value = deviceType === 3 || deviceType === '3';
|
||||
} catch {
|
||||
// 静默处理
|
||||
}
|
||||
};
|
||||
|
||||
const formOptions: VbenFormProps = {
|
||||
schema: querySchema.value,
|
||||
initialValues: {
|
||||
@ -200,7 +221,7 @@ const formOptions: VbenFormProps = {
|
||||
return;
|
||||
}
|
||||
|
||||
// 根据 DeviceType 控制 Sub_Device 列是否显示
|
||||
// 根据 DeviceType 控制 Sub_Device、DataType 列是否显示
|
||||
if (changedFields.includes('DeviceType')) {
|
||||
// DeviceTypeEnum: 未知=0, 网关设备=1, 直连设备=2, 子设备=3
|
||||
const deviceType = values.DeviceType;
|
||||
@ -474,6 +495,7 @@ const initializeGrid = async () => {
|
||||
isGridInitialized.value = true;
|
||||
|
||||
// 更新表格列定义
|
||||
await syncSubDeviceColumnsVisibilityFromForm();
|
||||
if (gridApi && gridApi.setState) {
|
||||
await nextTick();
|
||||
gridApi.setState({
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user