发送
@@ -51,8 +123,12 @@
- 设备上线
- 设备下线
+ 设备上线
+ 设备下线
@@ -74,7 +150,12 @@
-
+
获取
@@ -107,15 +188,44 @@
From b71fa84af3f67d0236ad94306836a528784288c9 Mon Sep 17 00:00:00 2001
From: alwayssuper <12851801+alwayssuper@user.noreply.gitee.com>
Date: Sun, 5 Jan 2025 22:57:10 +0800
Subject: [PATCH 3/5] =?UTF-8?q?feat=EF=BC=9Bsimulator?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/api/iot/device/device/index.ts | 15 ++
.../device/device/detail/DeviceDetailsLog.vue | 34 ++---
.../device/detail/DeviceDetailsSimulator.vue | 136 +++++++++++++-----
3 files changed, 135 insertions(+), 50 deletions(-)
diff --git a/src/api/iot/device/device/index.ts b/src/api/iot/device/device/index.ts
index ec80bfab..5377203b 100644
--- a/src/api/iot/device/device/index.ts
+++ b/src/api/iot/device/device/index.ts
@@ -63,6 +63,16 @@ export enum DeviceStatusEnum {
DISABLED = 3 // 已禁用
}
+// IoT 模拟设备数据
+export interface SimulatorDataVO {
+ productKey: string
+ deviceKey: string
+ type: string
+ subType: string
+ reportTime: string
+ content: string // 存储 JSON 字符串
+}
+
// 设备 API
export const DeviceApi = {
// 查询设备分页
@@ -136,5 +146,10 @@ export const DeviceApi = {
// 获取导入模板
importDeviceTemplate: async () => {
return await request.download({ url: `/iot/device/get-import-template` })
+ },
+
+ // 模拟设备
+ simulatorDevice: async (data: SimulatorDataVO) => {
+ return await request.post({ url: `/iot/device/data/simulator`, data })
}
}
diff --git a/src/views/iot/device/device/detail/DeviceDetailsLog.vue b/src/views/iot/device/device/detail/DeviceDetailsLog.vue
index 280092a7..d0a43a5c 100644
--- a/src/views/iot/device/device/detail/DeviceDetailsLog.vue
+++ b/src/views/iot/device/device/detail/DeviceDetailsLog.vue
@@ -90,23 +90,23 @@ const typeMap = {
/** 查询日志列表 */
const getLogList = async () => {
- if (!props.deviceId) return
- loading.value = true
- try {
- const res = await DeviceApi.getDeviceLogs(props.deviceId, queryParams)
- total.value = res.total
- logList.value = res.list.map((item: any) => {
- const log = {
- time: item.time,
- type: typeMap[item.type as keyof typeof typeMap] || item.type,
- name: getLogName(item),
- content: item.content
- }
- return log
- })
- } finally {
- loading.value = false
- }
+ // if (!props.deviceId) return
+ // loading.value = true
+ // try {
+ // const res = await DeviceApi.getDeviceLogs(props.deviceId, queryParams)
+ // total.value = res.total
+ // logList.value = res.list.map((item: any) => {
+ // const log = {
+ // time: item.time,
+ // type: typeMap[item.type as keyof typeof typeMap] || item.type,
+ // name: getLogName(item),
+ // content: item.content
+ // }
+ // return log
+ // })
+ // } finally {
+ // loading.value = false
+ // }
}
/** 获取日志名称 */
diff --git a/src/views/iot/device/device/detail/DeviceDetailsSimulator.vue b/src/views/iot/device/device/detail/DeviceDetailsSimulator.vue
index 972cb8eb..bc16d69f 100644
--- a/src/views/iot/device/device/detail/DeviceDetailsSimulator.vue
+++ b/src/views/iot/device/device/detail/DeviceDetailsSimulator.vue
@@ -11,11 +11,6 @@
-
-
-
-
-
@@ -87,6 +82,11 @@
+
+
+
+
+
发送
@@ -98,11 +98,6 @@
-
-
-
-
-
@@ -112,6 +107,11 @@
prop="specs"
:show-overflow-tooltip="true"
/>
+
+
+
+
+
发送
@@ -142,11 +142,6 @@
-
-
-
-
-
@@ -156,6 +151,11 @@
prop="specs"
:show-overflow-tooltip="true"
/>
+
+
+
+
+
获取
@@ -189,7 +189,7 @@