动态模型调整

This commit is contained in:
ChenYi 2025-07-10 13:50:05 +08:00
parent 40e26fbfe6
commit 1d90754602
2 changed files with 21 additions and 9 deletions

View File

@ -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))

View File

@ -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 },
];
} }
}; };