动态模型调整
This commit is contained in:
parent
40e26fbfe6
commit
1d90754602
@ -27,6 +27,16 @@ export const fieldTypeConfig: FieldTypeConfig = {
|
|||||||
// 可以根据需要添加更多类型配置
|
// 可以根据需要添加更多类型配置
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 固定字段列表 - 这些字段已经在固定列中定义,不需要在动态列中重复生成
|
||||||
|
const FIXED_FIELDS = [
|
||||||
|
'SystemName',
|
||||||
|
'ProjectId',
|
||||||
|
'DeviceType',
|
||||||
|
'IoTDataType',
|
||||||
|
'DeviceId',
|
||||||
|
'Timestamps'
|
||||||
|
];
|
||||||
|
|
||||||
// 动态生成表格列
|
// 动态生成表格列
|
||||||
export const generateDynamicColumns = (data: DynamicDeviceData[]): ColumnConfig[] => {
|
export const generateDynamicColumns = (data: DynamicDeviceData[]): ColumnConfig[] => {
|
||||||
if (!data || data.length === 0) return [];
|
if (!data || data.length === 0) return [];
|
||||||
@ -36,8 +46,8 @@ export const generateDynamicColumns = (data: DynamicDeviceData[]): ColumnConfig[
|
|||||||
if (!firstRow) return [];
|
if (!firstRow) return [];
|
||||||
const fields = Object.keys(firstRow);
|
const fields = Object.keys(firstRow);
|
||||||
|
|
||||||
// 过滤掉不需要显示的字段
|
// 过滤掉不需要显示的字段和固定字段
|
||||||
const excludeFields = ['id', 'key', '__typename'];
|
const excludeFields = ['id', 'key', '__typename', ...FIXED_FIELDS];
|
||||||
|
|
||||||
return fields
|
return fields
|
||||||
.filter(field => !excludeFields.includes(field))
|
.filter(field => !excludeFields.includes(field))
|
||||||
|
|||||||
@ -24,10 +24,15 @@ const { DeviceType, DeviceId, FocusAddress } = route.query;
|
|||||||
// 动态列定义
|
// 动态列定义
|
||||||
const dynamicColumns = ref<any[]>([]);
|
const dynamicColumns = ref<any[]>([]);
|
||||||
|
|
||||||
// 固定列定义(始终显示)
|
// 固定列定义(始终显示)- 基于 IoTDBTreeModelDeviceDataDto 类型
|
||||||
const fixedColumns = [
|
const fixedColumns = [
|
||||||
{ title: '序号', type: 'seq', width: 50 },
|
{ title: '序号', type: 'seq', width: 50 },
|
||||||
// 可以在这里添加其他固定列
|
{ field: 'SystemName', title: '系统名称', minWidth: 150 },
|
||||||
|
{ field: 'ProjectId', title: '项目ID', minWidth: 150 },
|
||||||
|
{ field: 'DeviceType', title: '设备类型', minWidth: 150 },
|
||||||
|
{ field: 'IoTDataType', title: 'IoT数据类型', minWidth: 150 },
|
||||||
|
{ field: 'DeviceId', title: '设备ID', minWidth: 150 },
|
||||||
|
{ field: 'Timestamps', title: '时间戳', minWidth: 150 },
|
||||||
];
|
];
|
||||||
|
|
||||||
// 合并固定列和动态列 - 使用计算属性确保响应式
|
// 合并固定列和动态列 - 使用计算属性确保响应式
|
||||||
@ -39,11 +44,8 @@ const allColumns = computed(() => [
|
|||||||
// 初始化默认列(防止表格空白)
|
// 初始化默认列(防止表格空白)
|
||||||
const initDefaultColumns = () => {
|
const initDefaultColumns = () => {
|
||||||
if (dynamicColumns.value.length === 0) {
|
if (dynamicColumns.value.length === 0) {
|
||||||
dynamicColumns.value = [
|
// 不再需要在这里设置默认列,因为固定列已经包含了基本字段
|
||||||
{ field: 'SystemName', title: '系统名称', minWidth: 150 },
|
dynamicColumns.value = [];
|
||||||
{ field: 'DeviceType', title: '设备类型', minWidth: 150 },
|
|
||||||
{ field: 'DeviceId', title: '设备ID', minWidth: 150 },
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user