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