From f0a666fb1d78f8f90fa6be40b28350a51df583c2 Mon Sep 17 00:00:00 2001 From: fhysy <1149505133@qq.com> Date: Fri, 29 Aug 2025 11:59:43 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E4=B8=8A=E4=B8=8B=E7=BA=BF=E6=A8=A1=E6=8B=9F=E3=80=81=E4=BA=A7?= =?UTF-8?q?=E5=93=81json=E5=AF=BC=E5=85=A5=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增设备上下线模拟接口和相关组件 - 实现设备状态模拟和高级模式下的 JSON 编辑 - 优化设备详情页面布局,添加设备图片显示 - 修复 websocket 取消订阅时的消息格式问题 --- apps/web-antd/package.json | 1 + apps/web-antd/src/api/device/device/index.ts | 9 + apps/web-antd/src/utils/websocket.ts | 2 +- .../detail/components/DeviceSimulation.vue | 6 +- .../components/simulation/EventSimulation.vue | 4 +- .../simulation/FunctionSimulation.vue | 2 +- .../simulation/OnlineOfflineSimulation.vue | 414 ++++++++++++++++++ .../src/views/device/device/detail/index.vue | 38 +- .../product/detail/components/EventDrawer.vue | 3 +- .../detail/components/FunctionDrawer.vue | 5 +- .../product/detail/components/ImportForm.vue | 329 ++++++++++++++ .../product/detail/components/Metadata.vue | 13 +- .../src/views/device/product/detail/index.vue | 13 +- 13 files changed, 820 insertions(+), 19 deletions(-) create mode 100644 apps/web-antd/src/views/device/device/detail/components/simulation/OnlineOfflineSimulation.vue create mode 100644 apps/web-antd/src/views/device/product/detail/components/ImportForm.vue diff --git a/apps/web-antd/package.json b/apps/web-antd/package.json index 110d9bc..c5fd098 100644 --- a/apps/web-antd/package.json +++ b/apps/web-antd/package.json @@ -52,6 +52,7 @@ "lodash-es": "^4.17.21", "monaco-editor": "^0.52.2", "pinia": "catalog:", + "qrcode.vue": "^3.6.0", "rxjs": "^7.8.2", "tinymce": "^7.3.0", "unplugin-vue-components": "^0.27.3", diff --git a/apps/web-antd/src/api/device/device/index.ts b/apps/web-antd/src/api/device/device/index.ts index d8271c9..1f3df1b 100644 --- a/apps/web-antd/src/api/device/device/index.ts +++ b/apps/web-antd/src/api/device/device/index.ts @@ -89,3 +89,12 @@ export function deviceOperateFunc(data: any) { export function deviceOperateEvent(data: any) { return requestClient.postWithMsg('/device/operate/mockEvent', data); } + +/** + * 上下线模拟 + * @param data + * @returns void + */ +export function deviceOperateStatus(data: any) { + return requestClient.postWithMsg('/device/operate/mockStatus', data); +} diff --git a/apps/web-antd/src/utils/websocket.ts b/apps/web-antd/src/utils/websocket.ts index 2517645..321712c 100644 --- a/apps/web-antd/src/utils/websocket.ts +++ b/apps/web-antd/src/utils/websocket.ts @@ -171,7 +171,7 @@ export const getWebSocket = ( } return () => { - const unsub = JSON.stringify({ id, type: 'unsub' }); + const unsub = JSON.stringify({ id, topic, type: 'unsub' }); const list = subs[id]; if (Array.isArray(list)) { const idx = list.indexOf(handle); diff --git a/apps/web-antd/src/views/device/device/detail/components/DeviceSimulation.vue b/apps/web-antd/src/views/device/device/detail/components/DeviceSimulation.vue index ef17eca..a1731f3 100644 --- a/apps/web-antd/src/views/device/device/detail/components/DeviceSimulation.vue +++ b/apps/web-antd/src/views/device/device/detail/components/DeviceSimulation.vue @@ -5,6 +5,7 @@ import { TabPane, Tabs } from 'ant-design-vue'; import EventSimulation from './simulation/EventSimulation.vue'; import FunctionSimulation from './simulation/FunctionSimulation.vue'; +import OnlineOfflineSimulation from './simulation/OnlineOfflineSimulation.vue'; import PropertySimulation from './simulation/PropertySimulation.vue'; interface Props { @@ -85,7 +86,10 @@ const eventList = computed(() => { /> -
上下线功能开发中...
+
diff --git a/apps/web-antd/src/views/device/device/detail/components/simulation/EventSimulation.vue b/apps/web-antd/src/views/device/device/detail/components/simulation/EventSimulation.vue index 40e1a27..e4351fe 100644 --- a/apps/web-antd/src/views/device/device/detail/components/simulation/EventSimulation.vue +++ b/apps/web-antd/src/views/device/device/detail/components/simulation/EventSimulation.vue @@ -395,7 +395,7 @@ onMounted(() => {
- 精简模式下参数只支持输入框的方式录入 + 精简模式下参数支持表单的方式录入
@@ -550,7 +550,7 @@ onMounted(() => {
- +
diff --git a/apps/web-antd/src/views/device/device/detail/components/simulation/FunctionSimulation.vue b/apps/web-antd/src/views/device/device/detail/components/simulation/FunctionSimulation.vue index 398f18c..4b0b3ea 100644 --- a/apps/web-antd/src/views/device/device/detail/components/simulation/FunctionSimulation.vue +++ b/apps/web-antd/src/views/device/device/detail/components/simulation/FunctionSimulation.vue @@ -574,7 +574,7 @@ onMounted(() => {
- 精简模式下参数只支持输入框的方式录入 + 精简模式下参数支持表单的方式录入
diff --git a/apps/web-antd/src/views/device/device/detail/components/simulation/OnlineOfflineSimulation.vue b/apps/web-antd/src/views/device/device/detail/components/simulation/OnlineOfflineSimulation.vue new file mode 100644 index 0000000..cd9fede --- /dev/null +++ b/apps/web-antd/src/views/device/device/detail/components/simulation/OnlineOfflineSimulation.vue @@ -0,0 +1,414 @@ + + + + + diff --git a/apps/web-antd/src/views/device/device/detail/index.vue b/apps/web-antd/src/views/device/device/detail/index.vue index b10f604..67da29d 100644 --- a/apps/web-antd/src/views/device/device/detail/index.vue +++ b/apps/web-antd/src/views/device/device/detail/index.vue @@ -1,11 +1,12 @@ + + + + diff --git a/apps/web-antd/src/views/device/product/detail/components/Metadata.vue b/apps/web-antd/src/views/device/product/detail/components/Metadata.vue index 4f39851..a992fb0 100644 --- a/apps/web-antd/src/views/device/product/detail/components/Metadata.vue +++ b/apps/web-antd/src/views/device/product/detail/components/Metadata.vue @@ -87,8 +87,6 @@ const handleViewTSL = () => { // 导入成功 const handleImportSuccess = () => { importVisible.value = false; - loadMetadata(); - message.success('导入成功'); }; // 关闭导入抽屉 @@ -298,6 +296,12 @@ const handleMetadataChange = (data: any) => { } }; +// 物模型数据变更 +const handleMetadataImport = (data: any) => { + console.log('data', data); + currentMetadata.value = data; +}; + // 监听路由变化,提示未保存 const handleBeforeRouteLeave = (next: any) => { if (metadataChanged.value) { @@ -424,7 +428,10 @@ onBeforeRouteLeave((to, from, next) => { width="600px" @close="handleImportClose" > - + diff --git a/apps/web-antd/src/views/device/product/detail/index.vue b/apps/web-antd/src/views/device/product/detail/index.vue index baf5081..b790c9a 100644 --- a/apps/web-antd/src/views/device/product/detail/index.vue +++ b/apps/web-antd/src/views/device/product/detail/index.vue @@ -5,7 +5,7 @@ import { useRoute, useRouter } from 'vue-router'; import { Page } from '@vben/common-ui'; import { ArrowLeftOutlined } from '@ant-design/icons-vue'; -import { message, Modal, Switch, TabPane, Tabs } from 'ant-design-vue'; +import { Image, message, Modal, Switch, TabPane, Tabs } from 'ant-design-vue'; import { productPushMetadataById, @@ -144,7 +144,12 @@ onUnmounted(() => {
- 设备数量:{{ deviceCount }} +
+ +
+
+ 设备数量:{{ deviceCount }} +
@@ -218,7 +223,9 @@ onUnmounted(() => { } .product-stats { - padding: 10px 0; + display: flex; + gap: 24px; + align-items: center; } .detail-tabs {