设备管理完善

This commit is contained in:
ChenYi 2026-01-23 16:24:17 +08:00
parent dce95f9e7b
commit f61f46a69b
4 changed files with 100 additions and 3 deletions

View File

@ -204,6 +204,7 @@
"ioTPlatformName": "PlatformName", "ioTPlatformName": "PlatformName",
"ioTPlatformDeviceOpenInfo": "DeviceOpenInfo", "ioTPlatformDeviceOpenInfo": "DeviceOpenInfo",
"platformPassword": "Password", "platformPassword": "Password",
"firmwareVersion": "FirmwareVersion",
"ioTPlatformProductId": "ProductId", "ioTPlatformProductId": "ProductId",
"ioTPlatformProductName": "ProductName", "ioTPlatformProductName": "ProductName",
"ioTPlatformAccountId": "AccountId", "ioTPlatformAccountId": "AccountId",

View File

@ -197,6 +197,7 @@
"ioTPlatformName": "物联网平台类型", "ioTPlatformName": "物联网平台类型",
"ioTPlatformDeviceOpenInfo": "平台设备信息", "ioTPlatformDeviceOpenInfo": "平台设备信息",
"platformPassword": "设备密码", "platformPassword": "设备密码",
"firmwareVersion": "固件版本",
"ioTPlatformProductId": "产品Id", "ioTPlatformProductId": "产品Id",
"ioTPlatformProductName": "产品名称", "ioTPlatformProductName": "产品名称",
"ioTPlatformAccountId": "所属账号Id", "ioTPlatformAccountId": "所属账号Id",

View File

@ -349,10 +349,24 @@ const commandTableColumns = computed(() => [
if (record.accessMode === 'r') { if (record.accessMode === 'r') {
return h('span', { style: { color: '#999' } }, '只读属性,无法设置指令'); return h('span', { style: { color: '#999' } }, '只读属性,无法设置指令');
} }
const dataType = record.ioTPlatformRawFieldDataType;
const isNumeric = isNumericType(dataType);
return h(Input, { return h(Input, {
value: record.commandValue, value: record.commandValue,
placeholder: '请输入指令内容', placeholder: isNumeric ? '请输入数字' : '请输入指令内容',
type: 'text',
'onUpdate:value': (val: string) => { 'onUpdate:value': (val: string) => {
//
if (isNumeric && val !== '') {
//
//
const numericRegex = /^-?\d*\.?\d*$/;
if (!numericRegex.test(val)) {
return; //
}
}
record.commandValue = val; record.commandValue = val;
}, },
}); });
@ -452,12 +466,77 @@ interface ThingModelProperty {
loading?: boolean; // loading?: boolean; //
selected?: boolean; // selected?: boolean; //
accessMode?: string; // 访rw-r- accessMode?: string; // 访rw-r-
ioTPlatformRawFieldDataType?: string; // INT32, STRING
} }
const thingModelProperties = ref<ThingModelProperty[]>([]); const thingModelProperties = ref<ThingModelProperty[]>([]);
const thingModelLoading = ref(false); const thingModelLoading = ref(false);
// //
const filterKeyword = ref(''); const filterKeyword = ref('');
//
const isNumericType = (dataType: string | undefined): boolean => {
if (!dataType) return false;
const upperType = dataType.toUpperCase();
return (
upperType.includes('INT') ||
upperType.includes('FLOAT') ||
upperType.includes('DOUBLE') ||
upperType === 'NUMBER' ||
upperType === 'DECIMAL'
);
};
//
const convertValueByType = (
value: string,
dataType: string | undefined,
): any => {
if (!value || value.trim() === '') {
return value;
}
if (!dataType) {
return value;
}
const upperType = dataType.toUpperCase();
//
if (isNumericType(dataType)) {
//
const numValue = Number(value);
if (isNaN(numValue)) {
return value; //
}
//
if (upperType.includes('INT')) {
return Number.parseInt(value, 10);
} else if (
upperType.includes('FLOAT') ||
upperType.includes('DOUBLE') ||
upperType === 'DECIMAL'
) {
return Number.parseFloat(value);
}
return numValue;
}
//
if (upperType === 'BOOL' || upperType === 'BOOLEAN') {
if (value.toLowerCase() === 'true' || value === '1') {
return true;
}
if (value.toLowerCase() === 'false' || value === '0') {
return false;
}
return value; //
}
//
return value;
};
// //
const filteredThingModelProperties = computed(() => { const filteredThingModelProperties = computed(() => {
if (!filterKeyword.value.trim()) { if (!filterKeyword.value.trim()) {
@ -507,6 +586,7 @@ const fetchThingModelProperties = async (row: Record<string, any>) => {
loading: false, loading: false,
selected: false, selected: false,
accessMode: item.accessMode || '', // 访 accessMode: item.accessMode || '', // 访
ioTPlatformRawFieldDataType: item.ioTPlatformRawFieldDataType || '', //
})); }));
} catch (error) { } catch (error) {
console.error('获取平台物模型属性失败:', error); console.error('获取平台物模型属性失败:', error);
@ -547,7 +627,12 @@ const submitBatchCommand = async () => {
// //
const commandContent: Record<string, any> = {}; const commandContent: Record<string, any> = {};
selectedProperties.forEach((prop) => { selectedProperties.forEach((prop) => {
commandContent[prop.ioTPlatformRawFieldName] = prop.commandValue.trim(); //
const convertedValue = convertValueByType(
prop.commandValue.trim(),
prop.ioTPlatformRawFieldDataType,
);
commandContent[prop.ioTPlatformRawFieldName] = convertedValue;
}); });
try { try {
@ -1467,7 +1552,12 @@ const sendCommand = async (property: ThingModelProperty) => {
property.loading = true; property.loading = true;
try { try {
const commandContent: Record<string, any> = {}; const commandContent: Record<string, any> = {};
commandContent[property.ioTPlatformRawFieldName] = property.commandValue; //
const convertedValue = convertValueByType(
property.commandValue.trim(),
property.ioTPlatformRawFieldDataType,
);
commandContent[property.ioTPlatformRawFieldName] = convertedValue;
const result = await postAggregationDeviceDeviceCommandForApiAsync({ const result = await postAggregationDeviceDeviceCommandForApiAsync({
body: { body: {

View File

@ -185,6 +185,11 @@ export const tableSchema: any = computed((): VxeGridProps['columns'] => [
title: $t('abp.deviceInfos.platformPassword'), title: $t('abp.deviceInfos.platformPassword'),
minWidth: '150', minWidth: '150',
}, },
{
field: 'firmwareVersion',
title: $t('abp.deviceInfos.firmwareVersion'),
minWidth: '150',
},
{ {
field: 'ioTPlatformResponse', field: 'ioTPlatformResponse',
title: $t('abp.deviceInfos.ioTPlatformResponse'), title: $t('abp.deviceInfos.ioTPlatformResponse'),