修复错误。
This commit is contained in:
parent
150c5a96f5
commit
cd772d5b04
@ -61,6 +61,7 @@ export const generateDynamicColumns = (data: DynamicDeviceData[]): ColumnConfig[
|
||||
title: fieldNameMapping[safeField] || safeField,
|
||||
minWidth: 150,
|
||||
showOverflow: true,
|
||||
slots: {}, // 添加空的slots属性,避免VXE表格报错
|
||||
};
|
||||
|
||||
// 应用字段类型配置,确保配置是安全的
|
||||
@ -75,6 +76,10 @@ export const generateDynamicColumns = (data: DynamicDeviceData[]): ColumnConfig[
|
||||
if (typeConfig.minWidth !== undefined) {
|
||||
columnConfig.minWidth = typeConfig.minWidth;
|
||||
}
|
||||
// 确保slots属性始终存在
|
||||
if (!columnConfig.slots) {
|
||||
columnConfig.slots = {};
|
||||
}
|
||||
}
|
||||
|
||||
return columnConfig;
|
||||
|
||||
@ -59,18 +59,19 @@ const dynamicColumns = ref<any[]>([]);
|
||||
|
||||
// 固定列定义(始终显示)- 基于 IoTDBTreeModelDeviceDataDto 类型
|
||||
const fixedColumns = [
|
||||
{ title: '序号', type: 'seq', width: 50, field: 'seq' },
|
||||
{ field: 'Timestamps', title: $t('abp.IoTDBBase.Timestamps'), minWidth: 150, showOverflow: true },
|
||||
{ field: 'SystemName', title: $t('abp.IoTDBBase.SystemName'), minWidth: 150, showOverflow: true },
|
||||
{ field: 'ProjectId', title: $t('abp.IoTDBBase.ProjectId'), minWidth: 150, showOverflow: true },
|
||||
{ field: 'DeviceType', title: $t('abp.IoTDBBase.DeviceType'), minWidth: 150, showOverflow: true },
|
||||
{ title: '序号', type: 'seq', width: 50, field: 'seq', slots: {} },
|
||||
{ field: 'Timestamps', title: $t('abp.IoTDBBase.Timestamps'), minWidth: 150, showOverflow: true, slots: {} },
|
||||
{ field: 'SystemName', title: $t('abp.IoTDBBase.SystemName'), minWidth: 150, showOverflow: true, slots: {} },
|
||||
{ field: 'ProjectId', title: $t('abp.IoTDBBase.ProjectId'), minWidth: 150, showOverflow: true, slots: {} },
|
||||
{ field: 'DeviceType', title: $t('abp.IoTDBBase.DeviceType'), minWidth: 150, showOverflow: true, slots: {} },
|
||||
{
|
||||
field: 'IoTDataType',
|
||||
title: $t('abp.IoTDBBase.IoTDataType'),
|
||||
minWidth: 150,
|
||||
showOverflow: true,
|
||||
slots: {},
|
||||
},
|
||||
{ field: 'DeviceId', title: $t('abp.IoTDBBase.DeviceId'), minWidth: 150, showOverflow: true },
|
||||
{ field: 'DeviceId', title: $t('abp.IoTDBBase.DeviceId'), minWidth: 150, showOverflow: true, slots: {} },
|
||||
];
|
||||
|
||||
// 合并固定列和动态列 - 使用计算属性确保响应式
|
||||
@ -81,7 +82,10 @@ const allColumns = computed(() => {
|
||||
if (dynamicColumns.value && Array.isArray(dynamicColumns.value)) {
|
||||
const validDynamicColumns = dynamicColumns.value.filter(col =>
|
||||
col && typeof col === 'object' && col.field && col.title
|
||||
);
|
||||
).map(col => ({
|
||||
...col,
|
||||
slots: col.slots || {} // 确保每个列都有slots属性
|
||||
}));
|
||||
columns.push(...validDynamicColumns);
|
||||
}
|
||||
|
||||
|
||||
@ -30,6 +30,7 @@ export interface ColumnConfig {
|
||||
width?: string | number;
|
||||
showOverflow?: boolean;
|
||||
formatter?: (value: any) => string;
|
||||
slots?: Record<string, any>; // 添加slots属性
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
@ -44,6 +45,7 @@ export interface FieldTypeConfig {
|
||||
formatter?: (value: any) => string;
|
||||
width?: string | number;
|
||||
minWidth?: string | number;
|
||||
slots?: Record<string, any>;
|
||||
[key: string]: any;
|
||||
};
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user