修复错误。

This commit is contained in:
ChenYi 2025-07-16 17:05:52 +08:00
parent 150c5a96f5
commit cd772d5b04
3 changed files with 18 additions and 7 deletions

View File

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

View File

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

View File

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