完善设备数列展示

This commit is contained in:
ChenYi 2025-09-18 13:45:54 +08:00
parent ed9ef19805
commit 572cad895a
2 changed files with 40 additions and 34 deletions

View File

@ -13,22 +13,22 @@ export const fieldNameMapping: FieldMapping = {
IoTDataType: 'IoT数据类型',
DeviceType: '设备类型',
DeviceAddress: '设备ID',
Timestamps: '时间戳',
// Timestamps: '时间戳', // 已隐藏使用TimestampStr替代
// 可以根据需要添加更多映射
};
// 字段类型配置
export const fieldTypeConfig: FieldTypeConfig = {
Timestamps: {
formatter: (value: string) => {
if (!value) return '';
try {
return new Date(value).toLocaleString();
} catch {
return value;
}
},
},
// Timestamps: { // 已隐藏使用TimestampStr替代
// formatter: (value: string) => {
// if (!value) return '';
// try {
// return new Date(value).toLocaleString();
// } catch {
// return value;
// }
// },
// },
// 可以根据需要添加更多类型配置
};
@ -40,6 +40,7 @@ const FIXED_FIELDS = [
'DeviceAddress',
'TimestampStr',
'FormattedTimestamps',
'Timestamps', // 添加Timestamps到固定字段列表确保它被隐藏
'DeviceAddress',
];

View File

@ -8,8 +8,10 @@ import { useRoute } from 'vue-router';
import { Page } from '@vben/common-ui';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { postDeviceInfoPage } from '#/api-client';
import { postTreeModelDeviceDataInfoPage } from '#/api-client';
import {
postDeviceInfoPage,
postTreeModelDeviceDataInfoPage,
} from '#/api-client';
import { $t } from '#/locales';
import { generateDynamicColumns } from './dynamicColumns';
@ -44,10 +46,16 @@ const fetchDeviceOptions = async () => {
//
const getDeviceInfoByAddress = (deviceAddress: string) => {
if (!deviceAddress || !deviceOptions.value || deviceOptions.value.length === 0) {
if (
!deviceAddress ||
!deviceOptions.value ||
deviceOptions.value.length === 0
) {
return null;
}
return deviceOptions.value.find((device) => device.deviceAddress === deviceAddress);
return deviceOptions.value.find(
(device) => device.deviceAddress === deviceAddress,
);
};
// yyyy-MM-dd HH:mm:ss
@ -77,7 +85,7 @@ const dynamicColumns = ref<any[]>([]);
const fixedColumns = [
{ title: '序号', type: 'seq', width: 50, field: 'seq', slots: {} },
{
field: 'Timestamps',
field: 'TimestampStr',
title: $t('abp.IoTDBBase.Timestamps'),
minWidth: 150,
showOverflow: true,
@ -486,7 +494,7 @@ const initializeGrid = async () => {
//
watch(
() => [IoTDataType, DeviceAddress],
() => [IoTDataType, DeviceAddress],
async (newValues, oldValues) => {
//
if (isInitializing.value || !isGridInitialized.value) {
@ -494,10 +502,9 @@ watch(
}
//
const hasChanged = oldValues && (
newValues[0] !== oldValues[0] ||
newValues[1] !== oldValues[1]
);
const hasChanged =
oldValues &&
(newValues[0] !== oldValues[0] || newValues[1] !== oldValues[1]);
if (hasChanged && newValues.some(Boolean) && gridApi) {
//
@ -509,8 +516,6 @@ watch(
{ immediate: false }, // false
);
//
onMounted(async () => {
// VXE