diff --git a/src/api/iot/device/index.ts b/src/api/iot/device/index.ts index 24d48789..903874b7 100644 --- a/src/api/iot/device/index.ts +++ b/src/api/iot/device/index.ts @@ -1,16 +1,16 @@ import request from '@/config/axios' -// 设备 VO +// IoT 设备 VO export interface DeviceVO { id: number // 设备 ID,主键,自增 - deviceKey: string // 设备唯一标识符,全局唯一,用于识别设备 - deviceName: string // 设备名称,在产品内唯一,用于标识设备 - productId: number // 产品 ID,关联 iot_product 表的 id - productKey: string // 产品 Key,关联 iot_product 表的 product_key - deviceType: number // 设备类型:0 - 直连设备,1 - 网关子设备,2 - 网关设备 - nickname: string // 设备备注名称,供用户自定义备注 - gatewayId: number // 网关设备 ID,子设备需要关联的网关设备 ID - status: number // 设备状态:0 - 未激活,1 - 在线,2 - 离线,3 - 已禁用 + deviceKey: string // 设备唯一标识符 + deviceName: string // 设备名称 + productId: number // 产品编号 + productKey: string // 产品标识 + deviceType: number // 设备类型 + nickname: string // 设备备注名称 + gatewayId: number // 网关设备 ID + status: number // 设备状态 statusLastUpdateTime: Date // 设备状态最后更新时间 lastOnlineTime: Date // 最后上线时间 lastOfflineTime: Date // 最后离线时间 @@ -22,17 +22,17 @@ export interface DeviceVO { mqttClientId: string // MQTT 客户端 ID mqttUsername: string // MQTT 用户名 mqttPassword: string // MQTT 密码 - authType: string // 认证类型(如一机一密、动态注册) - latitude: number // 设备位置的纬度,范围 -90.000000 ~ 90.000000 - longitude: number // 设备位置的经度,范围 -180.000000 ~ 180.000000 - areaId: number // 地区编码,符合国家地区编码标准,关联地区表 + authType: string // 认证类型 + latitude: number // 设备位置的纬度 + longitude: number // 设备位置的经度 + areaId: number // 地区编码 address: string // 设备详细地址 serialNumber: string // 设备序列号 } export interface DeviceUpdateStatusVO { id: number // 设备 ID,主键,自增 - status: number // 设备状态:0 - 未激活,1 - 在线,2 - 离线,3 - 已禁用 + status: number // 设备状态 } // 设备 API diff --git a/src/api/iot/product/index.ts b/src/api/iot/product/index.ts index 2a8d430f..1ffa490d 100644 --- a/src/api/iot/product/index.ts +++ b/src/api/iot/product/index.ts @@ -1,50 +1,51 @@ import request from '@/config/axios' -// iot 产品 VO +// IoT 产品 VO export interface ProductVO { + id: number // 产品编号 name: string // 产品名称 - id: number // 产品ID productKey: string // 产品标识 - protocolId: number // 协议编号(脚本解析 id) + protocolId: number // 协议编号 categoryId: number // 产品所属品类标识符 description: string // 产品描述 - validateType: number // 数据校验级别, 0: 强校验, 1: 弱校验, 2: 免校验 - status: number // 产品状态, 0: DEVELOPMENT_STATUS, 1: RELEASE_STATUS - deviceType: number // 设备类型, 0: 直连设备, 1: 网关子设备, 2: 网关设备 - netType: number // 联网方式, 0: Wi-Fi, 1: Cellular, 2: Ethernet, 3: 其他 - protocolType: number // 接入网关协议, 0: modbus, 1: opc-ua, 2: customize, 3: ble, 4: zigbee - dataFormat: number // 数据格式, 0: 透传模式, 1: Alink JSON + validateType: number // 数据校验级别 + status: number // 产品状态 + deviceType: number // 设备类型 + netType: number // 联网方式 + protocolType: number // 接入网关协议 + dataFormat: number // 数据格式 deviceCount: number // 设备数量 + createTime: Date // 创建时间 } -// iot 产品 API +// IoT 产品 API export const ProductApi = { - // 查询iot 产品分页 + // 查询产品分页 getProductPage: async (params: any) => { return await request.get({ url: `/iot/product/page`, params }) }, - // 查询iot 产品详情 + // 查询产品详情 getProduct: async (id: number) => { return await request.get({ url: `/iot/product/get?id=` + id }) }, - // 新增iot 产品 + // 新增产品 createProduct: async (data: ProductVO) => { return await request.post({ url: `/iot/product/create`, data }) }, - // 修改iot 产品 + // 修改产品 updateProduct: async (data: ProductVO) => { return await request.put({ url: `/iot/product/update`, data }) }, - // 删除iot 产品 + // 删除产品 deleteProduct: async (id: number) => { return await request.delete({ url: `/iot/product/delete?id=` + id }) }, - // 导出iot 产品 Excel + // 导出产品 Excel exportProduct: async (params) => { return await request.download({ url: `/iot/product/export-excel`, params }) }, @@ -54,7 +55,7 @@ export const ProductApi = { return await request.put({ url: `/iot/product/update-status?id=` + id + `&status=` + status }) }, - // 查询产品(精简)列表 + // 查询产品(精简)列表 getSimpleProductList() { return request.get({ url: '/iot/product/list-all-simple' }) } diff --git a/src/api/iot/thinkmodelfunction/index.ts b/src/api/iot/thinkmodelfunction/index.ts index 29f06a78..bd2e2d0f 100644 --- a/src/api/iot/thinkmodelfunction/index.ts +++ b/src/api/iot/thinkmodelfunction/index.ts @@ -6,21 +6,21 @@ export interface ThinkModelFunctionVO { identifier: string // 功能标识 name: string // 功能名称 description: string // 功能描述 - productId: number // 产品ID(关联 IotProductDO 的 id) - productKey: string // 产品Key(关联 IotProductDO 的 productKey) - type: number // 功能类型(1 - 属性,2 - 服务,3 - 事件) - property: string // 属性(存储 ThingModelProperty 的 JSON 数据) - event: string // 事件(存储 ThingModelEvent 的 JSON 数据) - service: string // 服务(存储服务的 JSON 数据) + productId: number // 产品编号 + productKey: string // 产品标识 + type: number // 功能类型 + property: string // 属性 + event: string // 事件 + service: string // 服务 } // IoT 产品物模型 API export const ThinkModelFunctionApi = { - // 查询IoT 产品物模型分页 + // 查询产品物模型分页 getThinkModelFunctionPage: async (params: any) => { return await request.get({ url: `/iot/think-model-function/page`, params }) }, - // 获得IoT 产品物模型 + // 获得产品物模型 getThinkModelFunctionListByProductId: async (params: any) => { return await request.get({ url: `/iot/think-model-function/list-by-product-id`, @@ -28,27 +28,27 @@ export const ThinkModelFunctionApi = { }) }, - // 查询IoT 产品物模型详情 + // 查询产品物模型详情 getThinkModelFunction: async (id: number) => { return await request.get({ url: `/iot/think-model-function/get?id=` + id }) }, - // 新增IoT 产品物模型 + // 新增产品物模型 createThinkModelFunction: async (data: ThinkModelFunctionVO) => { return await request.post({ url: `/iot/think-model-function/create`, data }) }, - // 修改IoT 产品物模型 + // 修改产品物模型 updateThinkModelFunction: async (data: ThinkModelFunctionVO) => { return await request.put({ url: `/iot/think-model-function/update`, data }) }, - // 删除IoT 产品物模型 + // 删除产品物模型 deleteThinkModelFunction: async (id: number) => { return await request.delete({ url: `/iot/think-model-function/delete?id=` + id }) }, - // 导出IoT 产品物模型 Excel + // 导出产品物模型 Excel exportThinkModelFunction: async (params) => { return await request.download({ url: `/iot/think-model-function/export-excel`, params }) } diff --git a/src/views/iot/device/DeviceForm.vue b/src/views/iot/device/DeviceForm.vue index f926b6d4..cb026012 100644 --- a/src/views/iot/device/DeviceForm.vue +++ b/src/views/iot/device/DeviceForm.vue @@ -57,8 +57,7 @@ const formData = ref({ id: undefined, productId: undefined, deviceName: undefined, - nickname: undefined, - serialNumber: undefined + nickname: undefined }) const formRules = reactive({ productId: [{ required: true, message: '产品不能为空', trigger: 'blur' }], @@ -66,7 +65,7 @@ const formRules = reactive({ { pattern: /^[a-zA-Z0-9_.\-:@]{4,32}$/, message: - '支持英文字母、数字、下划线(_)、中划线(-)、点号(.)、半角冒号(:)和特殊字符@,长度限制为4~32个字符', + '支持英文字母、数字、下划线(_)、中划线(-)、点号(.)、半角冒号(:)和特殊字符@,长度限制为 4~32 个字符', trigger: 'blur' } ], @@ -79,7 +78,7 @@ const formRules = reactive({ } const length = value.replace(/[\u4e00-\u9fa5\u3040-\u30ff]/g, 'aa').length if (length < 4 || length > 64) { - callback(new Error('备注名称长度限制为4~64个字符,中文及日文算2个字符')) + callback(new Error('备注名称长度限制为 4~64 个字符,中文及日文算 2 个字符')) } else if (!/^[\u4e00-\u9fa5\u3040-\u30ff_a-zA-Z0-9]+$/.test(value)) { callback(new Error('备注名称只能包含中文、英文字母、日文、数字和下划线(_)')) } else { diff --git a/src/views/iot/device/detail/DeviceDetailsHeader.vue b/src/views/iot/device/detail/DeviceDetailsHeader.vue index 4360cab1..62960529 100644 --- a/src/views/iot/device/detail/DeviceDetailsHeader.vue +++ b/src/views/iot/device/detail/DeviceDetailsHeader.vue @@ -59,6 +59,7 @@ const emit = defineEmits(['refresh']) * @param text 需要复制的文本 */ const copyToClipboard = (text: string) => { + // TODO @haohao:可以考虑用 await 异步转同步哈 navigator.clipboard.writeText(text).then(() => { message.success('复制成功') }) diff --git a/src/views/iot/device/detail/DeviceDetailsInfo.vue b/src/views/iot/device/detail/DeviceDetailsInfo.vue index 77084625..59b9d254 100644 --- a/src/views/iot/device/detail/DeviceDetailsInfo.vue +++ b/src/views/iot/device/detail/DeviceDetailsInfo.vue @@ -3,33 +3,33 @@ {{ product.name }} - {{ product.productKey }} + + {{ product.productKey }} 复制 - {{ device.deviceName }} + + {{ device.deviceName }} 复制 {{ device.nickname }} - {{ - formatDate(device.createTime) - }} - {{ - formatDate(device.activeTime) - }} - {{ - formatDate(device.lastOnlineTime) - }} + + {{ formatDate(device.createTime) }} + + + {{ formatDate(device.activeTime) }} + + + {{ formatDate(device.lastOnlineTime) }} + - {{ - formatDate(device.lastOfflineTime) - }} + + {{ formatDate(device.lastOfflineTime) }} + 查看 @@ -53,7 +53,6 @@ - -