From d7c33b454f5df8fca194461692d7c0c55b6b41e2 Mon Sep 17 00:00:00 2001 From: puhui999 Date: Wed, 25 Dec 2024 18:35:37 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=8A=9F=E8=83=BD=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E3=80=91IOT:=20ThingModel=20=E6=9C=8D=E5=8A=A1=E5=92=8C?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/iot/thingmodel/index.ts | 64 ++- src/utils/dict.ts | 2 +- src/views/iot/thingmodel/ThingModelEvent.vue | 39 ++ src/views/iot/thingmodel/ThingModelForm.vue | 57 +- ...elDataSpecs.vue => ThingModelProperty.vue} | 13 +- .../iot/thingmodel/ThingModelService.vue | 36 ++ .../dataSpecs/ThingModelNumberDataSpecs.vue | 8 +- .../dataSpecs/ThingModelStructDataSpecs.vue | 4 +- src/views/iot/utils/constants.ts | 531 ------------------ 9 files changed, 186 insertions(+), 568 deletions(-) create mode 100644 src/views/iot/thingmodel/ThingModelEvent.vue rename src/views/iot/thingmodel/{ThingModelDataSpecs.vue => ThingModelProperty.vue} (92%) create mode 100644 src/views/iot/thingmodel/ThingModelService.vue diff --git a/src/api/iot/thingmodel/index.ts b/src/api/iot/thingmodel/index.ts index 8e2b69ade..3c21ee806 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,18 +38,58 @@ export interface ThingModelService { [key: string]: any } -// IOT 产品功能(物模型)类型枚举类 -export enum ProductFunctionTypeEnum { - PROPERTY = 1, // 属性 - SERVICE = 2, // 服务 - EVENT = 3 // 事件 -} +// IOT 产品物模型类型枚举类 +export const ThingModelType = { + PROPERTY: 1, // 属性 + SERVICE: 2, // 服务 + EVENT: 3 // 事件 +} as const -// IOT 产品功能(物模型)访问模式枚举类 -export enum ProductFunctionAccessModeEnum { - READ_WRITE = 'rw', // 读写 - READ_ONLY = 'r' // 只读 -} +// 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 + +// IOT 产品物模型事件类型枚举 +export const ThingModelServiceEventType = { + INFO: { + label: '信息', + value: 'info' + }, + ALERT: { + label: '告警', + value: 'alert' + }, + ERROR: { + label: '故障', + value: 'error' + } +} as const + +// IOT 产品物模型参数是输入参数还是输出参数 +export const ThingModelParamDirection = { + INPUT: 'input', // 输入参数 + OUTPUT: 'output' // 输出参数 +} as const // IoT 产品物模型 API export const ThingModelApi = { diff --git a/src/utils/dict.ts b/src/utils/dict.ts index eae50a273..c18236318 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 000000000..7a49b2e71 --- /dev/null +++ b/src/views/iot/thingmodel/ThingModelEvent.vue @@ -0,0 +1,39 @@ + + + + + diff --git a/src/views/iot/thingmodel/ThingModelForm.vue b/src/views/iot/thingmodel/ThingModelForm.vue index f178cdf85..c821f5400 100644 --- a/src/views/iot/thingmodel/ThingModelForm.vue +++ b/src/views/iot/thingmodel/ThingModelForm.vue @@ -25,10 +25,17 @@ - + + + +