diff --git a/src/api/iot/thingmodel/index.ts b/src/api/iot/thingmodel/index.ts index 8e2b69ad..9cb795ac 100644 --- a/src/api/iot/thingmodel/index.ts +++ b/src/api/iot/thingmodel/index.ts @@ -11,7 +11,7 @@ export interface ThingModelData { productId?: number // 产品编号 productKey?: string // 产品标识 dataType: string // 数据类型,与 dataSpecs 的 dataType 保持一致 - type: ProductFunctionTypeEnum // 功能类型 + type: number // 功能类型 property: ThingModelProperty // 属性 event?: ThingModelEvent // 事件 service?: ThingModelService // 服务 @@ -38,19 +38,6 @@ export interface ThingModelService { [key: string]: any } -// IOT 产品功能(物模型)类型枚举类 -export enum ProductFunctionTypeEnum { - PROPERTY = 1, // 属性 - SERVICE = 2, // 服务 - EVENT = 3 // 事件 -} - -// IOT 产品功能(物模型)访问模式枚举类 -export enum ProductFunctionAccessModeEnum { - READ_WRITE = 'rw', // 读写 - READ_ONLY = 'r' // 只读 -} - // IoT 产品物模型 API export const ThingModelApi = { // 查询产品物模型分页 diff --git a/src/utils/dict.ts b/src/utils/dict.ts index eae50a27..c1823631 100644 --- a/src/utils/dict.ts +++ b/src/utils/dict.ts @@ -238,7 +238,7 @@ export enum DICT_TYPE { IOT_DEVICE_STATUS = 'iot_device_status', // IOT 设备状态 IOT_PRODUCT_THING_MODEL_TYPE = 'iot_product_thing_model_type', // IOT 产品功能类型 IOT_DATA_TYPE = 'iot_data_type', // IOT 数据类型 - IOT_UNIT_TYPE = 'iot_unit_type', // IOT 单位类型 + IOT_PRODUCT_THING_MODEL_UNIT = 'iot_product_thing_model_unit', // IOT 物模型单位 IOT_RW_TYPE = 'iot_rw_type', // IOT 读写类型 IOT_PLUGIN_DEPLOY_TYPE = 'iot_plugin_deploy_type', // IOT 插件部署类型 IOT_PLUGIN_STATUS = 'iot_plugin_status', // IOT 插件状态 diff --git a/src/views/iot/thingmodel/ThingModelEvent.vue b/src/views/iot/thingmodel/ThingModelEvent.vue new file mode 100644 index 00000000..827e59dc --- /dev/null +++ b/src/views/iot/thingmodel/ThingModelEvent.vue @@ -0,0 +1,47 @@ + + + + + diff --git a/src/views/iot/thingmodel/ThingModelForm.vue b/src/views/iot/thingmodel/ThingModelForm.vue index 173dab34..c2260149 100644 --- a/src/views/iot/thingmodel/ThingModelForm.vue +++ b/src/views/iot/thingmodel/ThingModelForm.vue @@ -25,10 +25,26 @@ - + + + + + + + + + diff --git a/src/views/iot/thingmodel/config.ts b/src/views/iot/thingmodel/config.ts index 8dc00ee4..d9b43dc7 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 { @@ -48,9 +48,69 @@ export const dataTypeOptions = [ /** 获得物体模型数据类型配置项名称 */ export const getDataTypeOptionsLabel = (value: string) => { + if (isEmpty(value)) { + return value + } return dataTypeOptions.find((option) => option.value === value)?.label } +// IOT 产品物模型类型枚举类 +export const ThingModelType = { + PROPERTY: 1, // 属性 + SERVICE: 2, // 服务 + EVENT: 3 // 事件 +} as const + +// IOT 产品物模型访问模式枚举类 +export const ThingModelAccessMode = { + READ_WRITE: { + label: '读写', + value: 'rw' + }, + READ_ONLY: { + label: '只读', + value: 'r' + } +} as const + +// IOT 产品物模型服务调用方式枚举 +export const ThingModelServiceCallType = { + ASYNC: { + label: '异步调用', + value: 'async' + }, + SYNC: { + label: '同步调用', + value: 'sync' + } +} as const +export const getCallTypeByValue = (value: string): string | undefined => + Object.values(ThingModelServiceCallType).find((type) => type.value === value)?.label + +// IOT 产品物模型事件类型枚举 +export const ThingModelEventType = { + INFO: { + label: '信息', + value: 'info' + }, + ALERT: { + label: '告警', + value: 'alert' + }, + ERROR: { + label: '故障', + value: 'error' + } +} as const +export const getEventTypeByValue = (value: string): string | undefined => + Object.values(ThingModelEventType).find((type) => type.value === value)?.label + +// IOT 产品物模型参数是输入参数还是输出参数 +export const ThingModelParamDirection = { + INPUT: 'input', // 输入参数 + OUTPUT: 'output' // 输出参数 +} as const + /** 公共校验规则 */ export const ThingModelFormRules = { name: [ diff --git a/src/views/iot/thingmodel/dataSpecs/ThingModelNumberDataSpecs.vue b/src/views/iot/thingmodel/dataSpecs/ThingModelNumberDataSpecs.vue index bd60d6a4..2340c556 100644 --- a/src/views/iot/thingmodel/dataSpecs/ThingModelNumberDataSpecs.vue +++ b/src/views/iot/thingmodel/dataSpecs/ThingModelNumberDataSpecs.vue @@ -47,10 +47,10 @@ @change="unitChange" > @@ -58,8 +58,8 @@