Compare commits

...

2 Commits

Author SHA1 Message Date
ChenYi
fffc4e8551 完善设备数据查询 2026-04-20 13:39:05 +08:00
ChenYi
b5c1948ec2 完善设备数据查看,过滤DataType 2026-04-20 09:37:34 +08:00
5 changed files with 51 additions and 10 deletions

View File

@ -247,6 +247,7 @@
"FormattedTimestamps": "Formatted Timestamps", "FormattedTimestamps": "Formatted Timestamps",
"DevicePath": "DevicePath", "DevicePath": "DevicePath",
"DeviceAddress": "MasterDeviceAddress", "DeviceAddress": "MasterDeviceAddress",
"DataType": "DataType",
"SubDevice": "SubDevice", "SubDevice": "SubDevice",
"CacheRefresh": "Cache Refresh", "CacheRefresh": "Cache Refresh",
"TelemetryLog": "Telemetry Log", "TelemetryLog": "Telemetry Log",

View File

@ -240,6 +240,7 @@
"FormattedTimestamps": "本地时间", "FormattedTimestamps": "本地时间",
"DevicePath": "设备路径", "DevicePath": "设备路径",
"DeviceAddress": "主设备地址", "DeviceAddress": "主设备地址",
"DataType": "测点数据类型",
"SubDevice": "从设备地址", "SubDevice": "从设备地址",
"CacheRefresh": "缓存刷新", "CacheRefresh": "缓存刷新",
"TelemetryLog": "遥测日志", "TelemetryLog": "遥测日志",

View File

@ -1225,19 +1225,31 @@ const [ServiceCallModal, serviceCallModalApi] = useVbenModal({
const serviceCallModalState = serviceCallModalApi.useStore(); const serviceCallModalState = serviceCallModalApi.useStore();
/** 服务入参:部分字段需为数值(如 Quantity,避免以字符串提交 */ /** 服务入参:部分字段需为数值,避免以字符串提交 */
function coerceServiceCallParamValue( function coerceServiceCallParamValue(
fieldName: string, fieldName: string,
raw: string, raw: string,
ctx: { isOperateBreakerService: boolean },
): { ok: true; value: unknown } | { ok: false; message: string } { ): { ok: true; value: unknown } | { ok: false; message: string } {
const key = fieldName.trim(); const key = fieldName.trim().toLowerCase();
if (key.toLowerCase() === 'quantity') { if (key === 'quantity') {
const n = Number(raw); const n = Number(raw);
if (Number.isNaN(n)) { if (Number.isNaN(n)) {
return { ok: false, message: '数量Quantity需填写有效数字' }; return { ok: false, message: '数量Quantity需填写有效数字' };
} }
return { ok: true, value: n }; return { ok: true, value: n };
} }
// OperateType
if (ctx.isOperateBreakerService && key === 'operatetype') {
const n = Number(raw);
if (Number.isNaN(n)) {
return {
ok: false,
message: '操作类型OperateType需为有效数字',
};
}
return { ok: true, value: n };
}
return { ok: true, value: raw }; return { ok: true, value: raw };
} }
@ -1261,10 +1273,13 @@ async function submitDeviceServiceCall() {
return; return;
} }
const serviceParams: Record<string, unknown> = {}; const serviceParams: Record<string, unknown> = {};
const coerceCtx = {
isOperateBreakerService: isOperateBreakerServiceItem(item),
};
for (const f of serviceParamFields.value) { for (const f of serviceParamFields.value) {
const v = (serviceCallFormValues.value[f.name] ?? '').trim(); const v = (serviceCallFormValues.value[f.name] ?? '').trim();
if (v !== '') { if (v !== '') {
const coerced = coerceServiceCallParamValue(f.name, v); const coerced = coerceServiceCallParamValue(f.name, v, coerceCtx);
if (!coerced.ok) { if (!coerced.ok) {
Message.warning(coerced.message); Message.warning(coerced.message);
return; return;

View File

@ -17,6 +17,7 @@ export const fieldNameMapping: FieldMapping = {
// ProjectId: '项目ID', // ProjectId: '项目ID',
// ProjectName: '项目名称', // ProjectName: '项目名称',
IoTDataType: 'IoT数据类型', IoTDataType: 'IoT数据类型',
DataType: '测点数据类型',
DeviceType: '设备类型', DeviceType: '设备类型',
DeviceAddress: '设备ID', DeviceAddress: '设备ID',
// Timestamps: '时间戳', // 已隐藏使用TimestampStr替代 // Timestamps: '时间戳', // 已隐藏使用TimestampStr替代
@ -43,6 +44,7 @@ const FIXED_FIELDS = [
// 'DataBaseName', // 'DataBaseName',
'DeviceType', 'DeviceType',
'IoTDataType', 'IoTDataType',
'DataType',
'SubDevice', 'SubDevice',
'TimestampStr', 'TimestampStr',
'FormattedTimestamps', 'FormattedTimestamps',

View File

@ -81,7 +81,7 @@ const { IoTDataType, DeviceAddress } = route.query;
// //
const dynamicColumns = ref<any[]>([]); const dynamicColumns = ref<any[]>([]);
// Sub_Device // Sub_DeviceDataType DeviceType=
const showSubDeviceColumn = ref(false); const showSubDeviceColumn = ref(false);
// - IoTDBTreeModelDeviceDataDto // - IoTDBTreeModelDeviceDataDto
@ -133,22 +133,31 @@ const subDeviceColumn = {
slots: {}, slots: {},
}; };
// DataType Sub_Device
const dataTypeColumn = {
field: 'DataType',
title: $t('abp.IoTDBBase.DataType'),
minWidth: 150,
showOverflow: true,
slots: {},
};
// - 使 // - 使
const allColumns = computed(() => { const allColumns = computed(() => {
// //
if (!isGridInitialized.value) { if (!isGridInitialized.value) {
const baseColumns = [...fixedBaseColumns]; const baseColumns = [...fixedBaseColumns];
if (showSubDeviceColumn.value) { if (showSubDeviceColumn.value) {
baseColumns.push(subDeviceColumn); baseColumns.push(subDeviceColumn, dataTypeColumn);
} }
return baseColumns; return baseColumns;
} }
const columns = [...fixedBaseColumns]; const columns = [...fixedBaseColumns];
// DeviceType Sub_Device // DeviceType Sub_DeviceDataType
if (showSubDeviceColumn.value) { if (showSubDeviceColumn.value) {
columns.push(subDeviceColumn); columns.push(subDeviceColumn, dataTypeColumn);
} }
// //
@ -172,7 +181,7 @@ const initDefaultColumns = () => {
dynamicColumns.value = []; dynamicColumns.value = [];
} }
// Sub_Device // DeviceType
showSubDeviceColumn.value = false; showSubDeviceColumn.value = false;
}; };
@ -184,6 +193,18 @@ const isInitializing = ref(false);
// //
initDefaultColumns(); initDefaultColumns();
// DeviceType Sub_DeviceDataType
const syncSubDeviceColumnsVisibilityFromForm = async () => {
try {
if (!gridApi?.formApi) return;
const v = await gridApi.formApi.getValues();
const deviceType = v.DeviceType;
showSubDeviceColumn.value = deviceType === 3 || deviceType === '3';
} catch {
//
}
};
const formOptions: VbenFormProps = { const formOptions: VbenFormProps = {
schema: querySchema.value, schema: querySchema.value,
initialValues: { initialValues: {
@ -200,7 +221,7 @@ const formOptions: VbenFormProps = {
return; return;
} }
// DeviceType Sub_Device // DeviceType Sub_DeviceDataType
if (changedFields.includes('DeviceType')) { if (changedFields.includes('DeviceType')) {
// DeviceTypeEnum: =0, =1, =2, =3 // DeviceTypeEnum: =0, =1, =2, =3
const deviceType = values.DeviceType; const deviceType = values.DeviceType;
@ -474,6 +495,7 @@ const initializeGrid = async () => {
isGridInitialized.value = true; isGridInitialized.value = true;
// //
await syncSubDeviceColumnsVisibilityFromForm();
if (gridApi && gridApi.setState) { if (gridApi && gridApi.setState) {
await nextTick(); await nextTick();
gridApi.setState({ gridApi.setState({