From 1e95c39a868df7ed52b62d9895edb1e2badc2324 Mon Sep 17 00:00:00 2001
From: Kven <2955163637@qq.com>
Date: Wed, 12 Mar 2025 20:30:58 +0800
Subject: [PATCH] =?UTF-8?q?feat(iot):=20=E6=B7=BB=E5=8A=A0=E8=AE=BE?=
=?UTF-8?q?=E5=A4=87=E4=BA=8B=E4=BB=B6=E8=AE=B0=E5=BD=95=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 在设备详情页面新增事件记录标签页
- 实现事件记录的数据加载和展示
- 优化设备地图组件样式
- 更新产品编辑页面的预览图和图标上传逻辑
-调整产品 TSL 页面的样式和功能
- 新增事件日志查询接口
---
src/api/log.ts | 1 +
src/api/tsl.ts | 10 ++
src/router/routes/modules/iot.ts | 2 +-
.../iot/device/components/device-detail.vue | 78 +++++++++---
.../iot/device/components/device-map.vue | 2 +-
.../iot/product/components/product-edit.vue | 113 +++++-------------
.../iot/product/components/product-tsl.vue | 76 +++++++++++-
7 files changed, 173 insertions(+), 109 deletions(-)
diff --git a/src/api/log.ts b/src/api/log.ts
index 8dce0b0..242d066 100644
--- a/src/api/log.ts
+++ b/src/api/log.ts
@@ -29,3 +29,4 @@ export function deleteLogs(ids: number[]) {
data: ids,
});
}
+
diff --git a/src/api/tsl.ts b/src/api/tsl.ts
index 8abecc7..01f25e0 100644
--- a/src/api/tsl.ts
+++ b/src/api/tsl.ts
@@ -24,6 +24,7 @@ export interface eventRecord extends Record {
level?: string;
identifier?: string;
productId?: number;
+ clientId?: number;
}
export function queryServeList(data: ServeRecord) {
@@ -50,6 +51,15 @@ export function queryEventList(data: eventRecord) {
});
}
+// 事件记录
+export function queryEventLog(data: eventRecord) {
+ return axios({
+ url: '/api/rest/tsl/event/log',
+ method: 'get',
+ params: data,
+ });
+}
+
export function createServe(data: any) {
return axios.post(`/api/rest/tsl/serve`, data);
}
diff --git a/src/router/routes/modules/iot.ts b/src/router/routes/modules/iot.ts
index b89025e..ab3d9bd 100644
--- a/src/router/routes/modules/iot.ts
+++ b/src/router/routes/modules/iot.ts
@@ -44,7 +44,7 @@ const IOT: AppRouteRecordRaw = {
locale: '设备管理(卡片)',
title: '设备管理(卡片)',
requiresAuth: true,
- permissions: ['iot:device'],
+ permissions: ['iot:deviceCard'],
},
},
{
diff --git a/src/views/iot/device/components/device-detail.vue b/src/views/iot/device/components/device-detail.vue
index 8bfb9b7..bb10245 100644
--- a/src/views/iot/device/components/device-detail.vue
+++ b/src/views/iot/device/components/device-detail.vue
@@ -100,15 +100,25 @@
-
- 查看详情
+
+ 详情
+
+
+
+
+
+
+
+
+
+ 详情
-
+
@@ -157,7 +167,7 @@
import { onMounted, ref } from 'vue';
import { Message } from '@arco-design/web-vue';
import { queryDeviceDetail, queryDeviceRecord, sendCommand } from '@/api/device';
- import { queryServeDetail, queryServeList } from '@/api/tsl';
+ import { queryEventLog, queryServeDetail, queryServeList } from '@/api/tsl';
import useVisible from '@/hooks/visible';
import dynamicForm from './dynamic-form.vue';
import DeviceMap from './device-map.vue';
@@ -221,6 +231,18 @@
slotName: 'operations',
},
];
+ const deviceEventColumns = [
+ {
+ title: ' 事件名称',
+ dataIndex: 'name',
+ slotName: 'name',
+ },
+ {
+ title: '操作',
+ dataIndex: 'operations',
+ slotName: 'operations',
+ },
+ ];;
const activeKey = ref('1');
const detailVisible = ref(false);
@@ -243,24 +265,44 @@
}
);
const deviceReportData = ref([]);
+ const deviceEventData = ref([]);
+
const deviceServerData = ref([]);
const fields = ref([]);
const fetchData = async (Id: number) => {
- const res = await queryDeviceDetail(Id);
- renderData.value = res.data;
- const res1 = await queryDeviceRecord({
- clientId: renderData.value.clientId,
- size: 10,
- current: 1,
- });
- deviceReportData.value = res1.data.records;
- const res2 = await queryServeList({
- productId: renderData.value.productId,
- size: 10,
- current: 1,
- })
- deviceServerData.value = res2.data.records;
+ try {
+ const [detailRes, recordRes, serveRes, eventRes] = await Promise.all([
+ queryDeviceDetail(Id),
+ queryDeviceRecord({
+ clientId: renderData.value.clientId,
+ size: 10,
+ current: 1,
+ }),
+ queryServeList({
+ productId: renderData.value.productId,
+ size: 10,
+ current: 1,
+ }),
+ queryEventLog({
+ clientId: renderData.value.clientId,
+ size: 10,
+ current: 1,
+ }),
+ ]);
+
+ renderData.value = detailRes.data;
+ deviceReportData.value = recordRes.data.records;
+ deviceServerData.value = serveRes.data.records;
+ deviceEventData.value = eventRes.data.records;
+ } catch (error) {
+ console.error('Failed to fetch data:', error);
+ Message.error({
+ content: '数据加载失败',
+ duration: 5 * 1000,
+ });
+ }
};
+
const handleMenuClick = (e: any) => {
activeKey.value = e;
};
diff --git a/src/views/iot/device/components/device-map.vue b/src/views/iot/device/components/device-map.vue
index d10a853..c4c7056 100644
--- a/src/views/iot/device/components/device-map.vue
+++ b/src/views/iot/device/components/device-map.vue
@@ -1,7 +1,7 @@
-
+
diff --git a/src/views/iot/product/components/product-edit.vue b/src/views/iot/product/components/product-edit.vue
index 331f6c6..4833232 100644
--- a/src/views/iot/product/components/product-edit.vue
+++ b/src/views/iot/product/components/product-edit.vue
@@ -82,12 +82,12 @@
label="预览图"
>
@@ -97,11 +97,10 @@
>
@@ -153,81 +152,11 @@
>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-