From f17404615ea7ad34a4238c417c3f977c14a4062f Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 14 Jun 2025 11:10:47 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E3=80=90IoT=20=E7=89=A9=E8=81=94?= =?UTF-8?q?=E7=BD=91=E3=80=91=E5=AE=8C=E5=96=84=E8=AE=BE=E5=A4=87=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E7=9A=84=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/iot/device/device/index.ts | 4 +- src/api/iot/plugin/index.ts | 51 ------ src/router/modules/remaining.ts | 11 -- .../device/device/detail/DeviceDetailsLog.vue | 166 ----------------- .../device/detail/DeviceDetailsMessage.vue | 169 ++++++++++++++++++ .../device/detail/DeviceDetailsSimulator.vue | 4 +- src/views/iot/device/device/detail/index.vue | 11 +- src/views/iot/utils/constants.ts | 36 ++++ 8 files changed, 214 insertions(+), 238 deletions(-) delete mode 100644 src/api/iot/plugin/index.ts delete mode 100644 src/views/iot/device/device/detail/DeviceDetailsLog.vue create mode 100644 src/views/iot/device/device/detail/DeviceDetailsMessage.vue diff --git a/src/api/iot/device/device/index.ts b/src/api/iot/device/device/index.ts index 026525e4e..7a0ef6def 100644 --- a/src/api/iot/device/device/index.ts +++ b/src/api/iot/device/device/index.ts @@ -157,8 +157,8 @@ export const DeviceApi = { }, // 查询设备日志分页 - getDeviceLogPage: async (params: any) => { - return await request.get({ url: `/iot/device/log/page`, params }) + getDeviceMessagePage: async (params: any) => { + return await request.get({ url: `/iot/device/message/page`, params }) }, // 获取设备 MQTT 连接参数 diff --git a/src/api/iot/plugin/index.ts b/src/api/iot/plugin/index.ts deleted file mode 100644 index f68b5f941..000000000 --- a/src/api/iot/plugin/index.ts +++ /dev/null @@ -1,51 +0,0 @@ -import request from '@/config/axios' - -// IoT 插件配置 VO -export interface PluginConfigVO { - id: number // 主键ID - pluginKey: string // 插件标识 - name: string // 插件名称 - description: string // 描述 - deployType: number // 部署方式 - fileName: string // 插件包文件名 - version: string // 插件版本 - type: number // 插件类型 - protocol: string // 设备插件协议类型 - status: number // 状态 - configSchema: string // 插件配置项描述信息 - config: string // 插件配置信息 - script: string // 插件脚本 -} - -// IoT 插件配置 API -export const PluginConfigApi = { - // 查询插件配置分页 - getPluginConfigPage: async (params: any) => { - return await request.get({ url: `/iot/plugin-config/page`, params }) - }, - - // 查询插件配置详情 - getPluginConfig: async (id: number) => { - return await request.get({ url: `/iot/plugin-config/get?id=` + id }) - }, - - // 新增插件配置 - createPluginConfig: async (data: PluginConfigVO) => { - return await request.post({ url: `/iot/plugin-config/create`, data }) - }, - - // 修改插件配置 - updatePluginConfig: async (data: PluginConfigVO) => { - return await request.put({ url: `/iot/plugin-config/update`, data }) - }, - - // 删除插件配置 - deletePluginConfig: async (id: number) => { - return await request.delete({ url: `/iot/plugin-config/delete?id=` + id }) - }, - - // 修改插件状态 - updatePluginStatus: async (data: any) => { - return await request.put({ url: `/iot/plugin-config/update-status`, data }) - } -} diff --git a/src/router/modules/remaining.ts b/src/router/modules/remaining.ts index b8828b538..39bbe0ae5 100644 --- a/src/router/modules/remaining.ts +++ b/src/router/modules/remaining.ts @@ -733,17 +733,6 @@ const remainingRouter: AppRouteRecordRaw[] = [ activeMenu: '/iot/device/device' }, component: () => import('@/views/iot/device/device/detail/index.vue') - }, - { - path: 'plugin/detail/:id', - name: 'IoTPluginDetail', - meta: { - title: '插件详情', - noCache: true, - hidden: true, - activeMenu: '/iot/plugin' - }, - component: () => import('@/views/iot/plugin/detail/index.vue') } ] } diff --git a/src/views/iot/device/device/detail/DeviceDetailsLog.vue b/src/views/iot/device/device/detail/DeviceDetailsLog.vue deleted file mode 100644 index 8bbad4008..000000000 --- a/src/views/iot/device/device/detail/DeviceDetailsLog.vue +++ /dev/null @@ -1,166 +0,0 @@ - - - - diff --git a/src/views/iot/device/device/detail/DeviceDetailsMessage.vue b/src/views/iot/device/device/detail/DeviceDetailsMessage.vue new file mode 100644 index 000000000..6abf6d627 --- /dev/null +++ b/src/views/iot/device/device/detail/DeviceDetailsMessage.vue @@ -0,0 +1,169 @@ + + + + diff --git a/src/views/iot/device/device/detail/DeviceDetailsSimulator.vue b/src/views/iot/device/device/detail/DeviceDetailsSimulator.vue index 0ce918aa0..c37405c6b 100644 --- a/src/views/iot/device/device/detail/DeviceDetailsSimulator.vue +++ b/src/views/iot/device/device/detail/DeviceDetailsSimulator.vue @@ -134,7 +134,7 @@ - + @@ -146,7 +146,7 @@ import { ProductVO } from '@/api/iot/product/product' import { SimulatorData, ThingModelApi } from '@/api/iot/thingmodel' import { DeviceApi, DeviceStateEnum, DeviceVO } from '@/api/iot/device/device' -import DeviceDetailsLog from './DeviceDetailsLog.vue' +import DeviceDetailsMessage from './DeviceDetailsMessage.vue' import { getDataTypeOptionsLabel } from '@/views/iot/thingmodel/config' import { DataDefinition } from '@/views/iot/thingmodel/components' diff --git a/src/views/iot/device/device/detail/index.vue b/src/views/iot/device/device/detail/index.vue index a2bd3dec3..50408ffbe 100644 --- a/src/views/iot/device/device/detail/index.vue +++ b/src/views/iot/device/device/detail/index.vue @@ -10,14 +10,12 @@ - - - - + + { /** 初始化 */ const { delView } = useTagsViewStore() // 视图操作 -const { currentRoute } = useRouter() // 路由 +const router = useRouter() // 路由 +const { currentRoute } = router onMounted(async () => { if (!id) { message.warning('参数错误,产品不能为空!') diff --git a/src/views/iot/utils/constants.ts b/src/views/iot/utils/constants.ts index 29a9ef983..b31319f82 100644 --- a/src/views/iot/utils/constants.ts +++ b/src/views/iot/utils/constants.ts @@ -2,3 +2,39 @@ export const IOT_PROVIDE_KEY = { PRODUCT: 'IOT_PRODUCT' } + +/** + * IoT 设备消息的方法枚举 + */ +export const IotDeviceMessageMethodEnum = { + // ========== 设备状态 ========== + STATE_ONLINE: { + method: 'thing.state.online', + name: '设备上线', + upstream: true + }, + STATE_OFFLINE: { + method: 'thing.state.offline', + name: '设备下线', + upstream: true + }, + + // ========== 设备属性 ========== + PROPERTY_POST: { + method: 'thing.property.post', + name: '属性上报', + upstream: true + }, + PROPERTY_SET: { + method: 'thing.property.set', + name: '属性设置', + upstream: false + }, + + // ========== 设备事件 ========== + EVENT_POST: { + method: 'thing.event.post', + name: '事件上报', + upstream: true + } +}