diff --git a/src/api/iot/thinkmodelfunction/index.ts b/src/api/iot/thinkmodelfunction/index.ts index 1fce8137..9c01cfa9 100644 --- a/src/api/iot/thinkmodelfunction/index.ts +++ b/src/api/iot/thinkmodelfunction/index.ts @@ -1,17 +1,41 @@ import request from '@/config/axios' -// IoT 产品物模型 VO -export interface ThinkModelFunctionVO { - id: number // 物模型功能编号 - identifier: string // 功能标识 - name: string // 功能名称 - description: string // 功能描述 - productId: number // 产品编号 - productKey: string // 产品标识 - type: number // 功能类型 - property: string // 属性 - event: string // 事件 - service: string // 服务 +/** + * IoT 产品物模型 + */ +export interface ThingModelData { + id?: number // 物模型功能编号 + identifier?: string // 功能标识 + name?: string // 功能名称 + description?: string // 功能描述 + productId?: number // 产品编号 + productKey?: string // 产品标识 + dataType: string // 数据类型,与 dataSpecs 的 dataType 保持一致 + type: ProductFunctionTypeEnum // 功能类型 + property: ThingModelProperty // 属性 + event?: ThingModelEvent // 事件 + service?: ThingModelService // 服务 +} + +/** + * ThingModelProperty 类型 + */ +export interface ThingModelProperty { + [key: string]: any +} + +/** + * ThingModelEvent 类型 + */ +export interface ThingModelEvent { + [key: string]: any +} + +/** + * ThingModelService 类型 + */ +export interface ThingModelService { + [key: string]: any } // IOT 产品功能(物模型)类型枚举类 @@ -30,39 +54,35 @@ export enum ProductFunctionAccessModeEnum { // IoT 产品物模型 API export const ThinkModelFunctionApi = { // 查询产品物模型分页 - getThinkModelFunctionPage: async (params: any) => { - return await request.get({ url: `/iot/think-model-function/page`, params }) + getProductThingModelPage: async (params: any) => { + return await request.get({ url: `/iot/product-thing-model/page`, params }) }, + // 获得产品物模型 - getThinkModelFunctionListByProductId: async (params: any) => { + getProductThingModelListByProductId: async (params: any) => { return await request.get({ - url: `/iot/think-model-function/list-by-product-id`, + url: `/iot/product-thing-model/list-by-product-id`, params }) }, // 查询产品物模型详情 - getThinkModelFunction: async (id: number) => { - return await request.get({ url: `/iot/think-model-function/get?id=` + id }) + getProductThingModel: async (id: number) => { + return await request.get({ url: `/iot/product-thing-model/get?id=` + id }) }, // 新增产品物模型 - createThinkModelFunction: async (data: ThinkModelFunctionVO) => { - return await request.post({ url: `/iot/think-model-function/create`, data }) + createProductThingModel: async (data: ThingModelData) => { + return await request.post({ url: `/iot/product-thing-model/create`, data }) }, // 修改产品物模型 - updateThinkModelFunction: async (data: ThinkModelFunctionVO) => { - return await request.put({ url: `/iot/think-model-function/update`, data }) + updateProductThingModel: async (data: ThingModelData) => { + return await request.put({ url: `/iot/product-thing-model/update`, data }) }, // 删除产品物模型 - deleteThinkModelFunction: async (id: number) => { - return await request.delete({ url: `/iot/think-model-function/delete?id=` + id }) - }, - - // 导出产品物模型 Excel - exportThinkModelFunction: async (params) => { - return await request.download({ url: `/iot/think-model-function/export-excel`, params }) + deleteProductThingModel: async (id: number) => { + return await request.delete({ url: `/iot/product-thing-model/delete?id=` + id }) } } diff --git a/src/views/iot/product/product/detail/ThingModel/ThingModelDataSpecs.vue b/src/views/iot/product/product/detail/ThingModel/ThingModelDataSpecs.vue new file mode 100644 index 00000000..38819105 --- /dev/null +++ b/src/views/iot/product/product/detail/ThingModel/ThingModelDataSpecs.vue @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + {{ item.value }} + - + + + + + + + + 字节 + + + + + + + + + + + + 读写 + 只读 + + + + + + + + + + diff --git a/src/views/iot/product/product/detail/ThingModel/ThingModelForm.vue b/src/views/iot/product/product/detail/ThingModel/ThingModelForm.vue new file mode 100644 index 00000000..f3d55d49 --- /dev/null +++ b/src/views/iot/product/product/detail/ThingModel/ThingModelForm.vue @@ -0,0 +1,171 @@ + + + + + + 属性 + 服务 + 事件 + + + + + + + + + + + + + + 确 定 + 取 消 + + + + + diff --git a/src/views/iot/product/product/detail/ThingModel/config.ts b/src/views/iot/product/product/detail/ThingModel/config.ts new file mode 100644 index 00000000..eb651960 --- /dev/null +++ b/src/views/iot/product/product/detail/ThingModel/config.ts @@ -0,0 +1,50 @@ +/** dataSpecs 数值型数据结构 */ +export interface DataSpecsNumberDataVO { + dataType: 'int' | 'float' | 'double' // 数据类型,取值为 INT、FLOAT 或 DOUBLE + max: string // 最大值,必须与 dataType 设置一致,且为 STRING 类型 + min: string // 最小值,必须与 dataType 设置一致,且为 STRING 类型 + step: string // 步长,必须与 dataType 设置一致,且为 STRING 类型 + precise?: string // 精度,当 dataType 为 FLOAT 或 DOUBLE 时可选 + defaultValue?: string // 默认值,可选 + unit: string // 单位的符号 + unitName: string // 单位的名称 +} + +/** dataSpecs 枚举型数据结构 */ +export interface DataSpecsEnumOrBoolDataVO { + dataType: 'enum' | 'bool' + defaultValue?: string // 默认值,可选 + name: string // 枚举项的名称 + value: number | undefined // 枚举值 +} + +/** 属性值的数据类型 */ +export const DataSpecsDataType = { + INT: 'int', + FLOAT: 'float', + DOUBLE: 'double', + ENUM: 'enum', + BOOL: 'bool', + TEXT: 'text', + DATE: 'date', + STRUCT: 'struct', + ARRAY: 'array' +} as const + +/** 物体模型数据类型配置项 */ +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 (数组)' } +] + +/** 获得物体模型数据类型配置项名称 */ +export const getDataTypeOptionsLabel = (value: string) => { + return dataTypeOptions.find((option) => option.value === value)?.label +} diff --git a/src/views/iot/product/product/detail/ThingModel/dataSpecs/ThingModelArrayTypeDataSpecs.vue b/src/views/iot/product/product/detail/ThingModel/dataSpecs/ThingModelArrayTypeDataSpecs.vue new file mode 100644 index 00000000..3b309d68 --- /dev/null +++ b/src/views/iot/product/product/detail/ThingModel/dataSpecs/ThingModelArrayTypeDataSpecs.vue @@ -0,0 +1,34 @@ + + + + + + {{ item.label }} + + + + + + + + + + + + diff --git a/src/views/iot/product/product/detail/ThingModel/dataSpecs/ThingModelEnumTypeDataSpecs.vue b/src/views/iot/product/product/detail/ThingModel/dataSpecs/ThingModelEnumTypeDataSpecs.vue new file mode 100644 index 00000000..0c67358a --- /dev/null +++ b/src/views/iot/product/product/detail/ThingModel/dataSpecs/ThingModelEnumTypeDataSpecs.vue @@ -0,0 +1,56 @@ + + + + + 参数值 + 参数描述 + + + + ~ + + 删除 + + +添加枚举项 + + + + + + + diff --git a/src/views/iot/product/product/detail/ThingModel/dataSpecs/ThingModelNumberTypeDataSpecs.vue b/src/views/iot/product/product/detail/ThingModel/dataSpecs/ThingModelNumberTypeDataSpecs.vue new file mode 100644 index 00000000..3920a0f5 --- /dev/null +++ b/src/views/iot/product/product/detail/ThingModel/dataSpecs/ThingModelNumberTypeDataSpecs.vue @@ -0,0 +1,49 @@ + + + + + ~ + + + + + + + + + + + + + + + + diff --git a/src/views/iot/product/product/detail/ThingModel/dataSpecs/index.ts b/src/views/iot/product/product/detail/ThingModel/dataSpecs/index.ts new file mode 100644 index 00000000..f2e1daaf --- /dev/null +++ b/src/views/iot/product/product/detail/ThingModel/dataSpecs/index.ts @@ -0,0 +1,5 @@ +import ThingModelEnumTypeDataSpecs from './ThingModelEnumTypeDataSpecs.vue' +import ThingModelNumberTypeDataSpecs from './ThingModelNumberTypeDataSpecs.vue' +import ThingModelArrayTypeDataSpecs from './ThingModelArrayTypeDataSpecs.vue' + +export { ThingModelEnumTypeDataSpecs, ThingModelNumberTypeDataSpecs, ThingModelArrayTypeDataSpecs } diff --git a/src/views/iot/product/product/detail/ThinkModelFunction.vue b/src/views/iot/product/product/detail/ThingModel/index.vue similarity index 58% rename from src/views/iot/product/product/detail/ThinkModelFunction.vue rename to src/views/iot/product/product/detail/ThingModel/index.vue index 4f10ad06..41cbb39d 100644 --- a/src/views/iot/product/product/detail/ThinkModelFunction.vue +++ b/src/views/iot/product/product/detail/ThingModel/index.vue @@ -2,18 +2,18 @@ - 搜索 - 重置 + + + 搜索 + + + + 重置 + - 添加功能 + + 添加功能 - - + + - - - - - + + + + + {{ dataTypeOptionsLabel(row.property.dataType) ?? '-' }} + + + + + + {{ row.property.dataSpecs ?? row.property.dataSpecsList }} + + + 编辑 删除 @@ -72,29 +88,31 @@ - + - diff --git a/src/views/iot/product/product/detail/index.vue b/src/views/iot/product/product/detail/index.vue index a2512dc0..e30b1636 100644 --- a/src/views/iot/product/product/detail/index.vue +++ b/src/views/iot/product/product/detail/index.vue @@ -8,8 +8,8 @@ - - + + @@ -22,9 +22,10 @@ import { DeviceApi } from '@/api/iot/device/device' import ProductDetailsHeader from './ProductDetailsHeader.vue' import ProductDetailsInfo from './ProductDetailsInfo.vue' import ProductTopic from './ProductTopic.vue' -import ThinkModelFunction from './ThinkModelFunction.vue' +import IoTProductThingModel from './ThingModel/index.vue' import { useTagsViewStore } from '@/store/modules/tagsView' import { useRouter } from 'vue-router' +import { IOT_PROVIDE_KEY } from '@/views/iot/utils/constants' defineOptions({ name: 'IoTProductDetail' }) @@ -38,6 +39,8 @@ const loading = ref(true) // 加载中 const product = ref({} as ProductVO) // 详情 const activeTab = ref('info') // 默认为 info 标签页 +provide(IOT_PROVIDE_KEY.PRODUCT, product) // 提供产品信息给产品信息详情页的所有子组件 + /** 获取详情 */ const getProductData = async (id: number) => { loading.value = true diff --git a/src/views/iot/product/product/index.vue b/src/views/iot/product/product/index.vue index 1e48a594..db61ccfe 100644 --- a/src/views/iot/product/product/index.vue +++ b/src/views/iot/product/product/index.vue @@ -2,49 +2,57 @@ - 搜索 - 重置 - - 新增 + + + 搜索 + + + + 重置 - 导出 + + 新增 + + + + 导出 @@ -64,8 +72,8 @@ - - + + @@ -103,41 +111,41 @@ - + 编辑 - + 详情 - + 物模型 @@ -148,68 +156,68 @@ - - - - - + + + + + - + - - + - - + 查看 编辑 删除 @@ -219,9 +227,9 @@ @@ -230,7 +238,7 @@ -