diff --git a/src/utils/index.ts b/src/utils/index.ts index 059571e7..74c6548d 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,4 +1,4 @@ -import { toNumber } from 'lodash-es' +import {toNumber} from 'lodash-es' /** * @@ -118,7 +118,7 @@ export function toAnyString() { /** * 生成指定长度的随机字符串 - * + * * @param length 字符串长度 */ export function generateRandomStr(length: number): string { @@ -459,7 +459,7 @@ export function jsonParse(str: string) { try { return JSON.parse(str) } catch (e) { - console.error(`str[${str}] 不是一个 JSON 字符串`) + // console.error(`str[${str}] 不是一个 JSON 字符串`) return '' } } diff --git a/src/views/iot/device/device/detail/DeviceDetailsSimulator.vue b/src/views/iot/device/device/detail/DeviceDetailsSimulator.vue index ecf704af..0ce918aa 100644 --- a/src/views/iot/device/device/detail/DeviceDetailsSimulator.vue +++ b/src/views/iot/device/device/detail/DeviceDetailsSimulator.vue @@ -7,7 +7,7 @@ - + @@ -29,70 +29,11 @@ - + @@ -100,7 +41,7 @@
- 发送 + 发送
@@ -151,7 +92,7 @@ - + @@ -201,18 +142,13 @@ - diff --git a/src/views/iot/thingmodel/components/index.ts b/src/views/iot/thingmodel/components/index.ts new file mode 100644 index 00000000..66c692ba --- /dev/null +++ b/src/views/iot/thingmodel/components/index.ts @@ -0,0 +1,3 @@ +import DataDefinition from './DataDefinition.vue' + +export { DataDefinition } diff --git a/src/views/iot/thingmodel/config.ts b/src/views/iot/thingmodel/config.ts index 3343020b..5d075def 100644 --- a/src/views/iot/thingmodel/config.ts +++ b/src/views/iot/thingmodel/config.ts @@ -1,4 +1,4 @@ -import { isEmpty } from '@/utils/is' +import {isEmpty} from '@/utils/is' /** dataSpecs 数值型数据结构 */ export interface DataSpecsNumberDataVO { @@ -21,7 +21,7 @@ export interface DataSpecsEnumOrBoolDataVO { } /** 属性值的数据类型 */ -// TODO @puhui999:这个枚举类,要不放到 dict 里? +// TODO @puhui999:这个枚举类,要不放到 dict 里? 这个全是当常量来使用的不好放 dict 里 🤣 export const DataSpecsDataType = { INT: 'int', FLOAT: 'float', @@ -37,15 +37,15 @@ export const DataSpecsDataType = { /** 物体模型数据类型配置项 */ // TODO @puhui999:搞到字典里;label 只使用()部分,就是整数型、单精度浮点型等,这种哈。这样,拼接 value(label) 就可以渲染出来,通用性更强 export const dataTypeOptions = [ - { value: DataSpecsDataType.INT, label: 'int32 (整数型)' }, - { value: DataSpecsDataType.FLOAT, label: 'float (单精度浮点型)' }, - { value: DataSpecsDataType.DOUBLE, label: 'double (双精度浮点型)' }, - { value: DataSpecsDataType.ENUM, label: 'enum(枚举型)' }, - { value: DataSpecsDataType.BOOL, label: 'bool (布尔型)' }, - { value: DataSpecsDataType.TEXT, label: 'text (文本型)' }, - { value: DataSpecsDataType.DATE, label: 'date (时间型)' }, - { value: DataSpecsDataType.STRUCT, label: 'struct (结构体)' }, - { value: DataSpecsDataType.ARRAY, label: 'array (数组)' } + { value: DataSpecsDataType.INT, label: '整数型' }, + { value: DataSpecsDataType.FLOAT, label: '单精度浮点型' }, + { value: DataSpecsDataType.DOUBLE, label: '双精度浮点型' }, + { value: DataSpecsDataType.ENUM, label: '枚举型' }, + { value: DataSpecsDataType.BOOL, label: '布尔型' }, + { value: DataSpecsDataType.TEXT, label: '文本型' }, + { value: DataSpecsDataType.DATE, label: '时间型' }, + { value: DataSpecsDataType.STRUCT, label: '结构体' }, + { value: DataSpecsDataType.ARRAY, label: '数组' } ] /** 获得物体模型数据类型配置项名称 */ @@ -53,7 +53,8 @@ export const getDataTypeOptionsLabel = (value: string) => { if (isEmpty(value)) { return value } - return dataTypeOptions.find((option) => option.value === value)?.label + const dataType = dataTypeOptions.find((option) => option.value === value) + return dataType && `${dataType.value}(${dataType.label})` } // IOT 产品物模型类型枚举类 diff --git a/src/views/iot/thingmodel/dataSpecs/ThingModelArrayDataSpecs.vue b/src/views/iot/thingmodel/dataSpecs/ThingModelArrayDataSpecs.vue index faeb3d44..04a975a1 100644 --- a/src/views/iot/thingmodel/dataSpecs/ThingModelArrayDataSpecs.vue +++ b/src/views/iot/thingmodel/dataSpecs/ThingModelArrayDataSpecs.vue @@ -4,15 +4,15 @@ diff --git a/src/views/iot/thingmodel/dataSpecs/ThingModelStructDataSpecs.vue b/src/views/iot/thingmodel/dataSpecs/ThingModelStructDataSpecs.vue index eeff830a..fb2258c1 100644 --- a/src/views/iot/thingmodel/dataSpecs/ThingModelStructDataSpecs.vue +++ b/src/views/iot/thingmodel/dataSpecs/ThingModelStructDataSpecs.vue @@ -5,7 +5,6 @@ :rules="[{ required: true, validator: validateList, trigger: 'change' }]" label="JSON 对象" > -
{ } callback() } + +/** 组件初始化 */ +onMounted(async () => { + await nextTick() + // 预防 dataSpecsList 空指针 + isEmpty(dataSpecsList.value) && (dataSpecsList.value = []) +})