From ea1df9d55f2f0f57b9a843bea8780e2b4e341279 Mon Sep 17 00:00:00 2001 From: Kven <2955163637@qq.com> Date: Fri, 28 Feb 2025 20:47:07 +0800 Subject: [PATCH] =?UTF-8?q?feat(iot):=20=E6=96=B0=E5=A2=9E=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E5=9C=B0=E5=9B=BE=E5=8A=9F=E8=83=BD=E5=B9=B6=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E8=AE=BE=E5=A4=87=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增设备地图页面,实现设备在地图上的展示和信息弹出 - 扩展设备接口,增加经纬度和图标字段 - 优化设备编辑页面,将产品名称改为所属产品下拉选择- 更新产品属性页面,调整属性类型为读写类型 - 添加高德地图相关依赖和类型定义 --- package.json | 3 + src/api/device.ts | 3 + src/env.d.ts | 2 + src/router/routes/modules/iot.ts | 12 ++ .../iot/device/components/device-edit.vue | 22 ++-- src/views/iot/device/index.vue | 3 +- src/views/iot/deviceMap/index.vue | 117 ++++++++++++++++++ .../iot/product/components/product-tsl.vue | 16 ++- .../notice/components/message-edit.vue | 2 +- 9 files changed, 161 insertions(+), 19 deletions(-) create mode 100644 src/views/iot/deviceMap/index.vue diff --git a/package.json b/package.json index c8c25a3..bc65987 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,8 @@ ] }, "dependencies": { + "@amap/amap-jsapi-loader": "^1.0.1", + "@amap/amap-jsapi-types": "^0.0.15", "@arco-design/web-vue": "^2.44.7", "@vueuse/core": "^9.3.0", "@wangeditor/editor-for-vue": "^5.1.12", @@ -58,6 +60,7 @@ "@arco-plugins/vite-vue": "^1.4.5", "@commitlint/cli": "^17.1.2", "@commitlint/config-conventional": "^17.1.0", + "@types/amap-js-api": "^1.4.16", "@types/file-saver": "^2.0.7", "@types/lodash": "^4.14.186", "@types/mockjs": "^1.0.7", diff --git a/src/api/device.ts b/src/api/device.ts index eab5ef1..ec478bf 100644 --- a/src/api/device.ts +++ b/src/api/device.ts @@ -10,6 +10,9 @@ export interface DeviceRecord { status?: string; isOnline?: boolean; pageable?: string; + longitude?: number; + latitude?: number; + icon?: string; } export interface DeviceCreateRecord { diff --git a/src/env.d.ts b/src/env.d.ts index 6b7fc7d..2a0a3eb 100644 --- a/src/env.d.ts +++ b/src/env.d.ts @@ -9,3 +9,5 @@ declare module '*.vue' { interface ImportMetaEnv { readonly VITE_API_BASE_URL: string; } + + diff --git a/src/router/routes/modules/iot.ts b/src/router/routes/modules/iot.ts index 70d8e4d..b89025e 100644 --- a/src/router/routes/modules/iot.ts +++ b/src/router/routes/modules/iot.ts @@ -98,6 +98,18 @@ const IOT: AppRouteRecordRaw = { permissions: ['iot:tsl'], }, }, + { + path: 'deviceMap', + name: 'DeviceMap', + component: () => import('@/views/iot/deviceMap/index.vue'), + meta: { + locale: '设备地图', + title: '设备地图', + requiresAuth: true, + showInMenu: true, + permissions: ['iot:device'], + }, + }, ], }; diff --git a/src/views/iot/device/components/device-edit.vue b/src/views/iot/device/components/device-edit.vue index f613e82..97a3956 100644 --- a/src/views/iot/device/components/device-edit.vue +++ b/src/views/iot/device/components/device-edit.vue @@ -34,22 +34,22 @@ > - {{ - item.name - }} + {{ + item.name + }} @@ -238,17 +238,15 @@ const loading = ref(false); // 搜索 - const handleSearch = (value: any) => { + const handleSearch = (value: string) => { if (value) { loading.value = true; options.value = []; window.setTimeout(async () => { const res = await queryDeviceByName({ name: value, - page: 1, - size: 10, }); - options.value = res.data.records.map((item: any) => { + options.value = res.data.map((item: any) => { return { id: item.id, name: item.name, @@ -298,8 +296,6 @@ if (!valid) { // 新增 formData.value.extendParams = paramsData.value; - const productId = await queryDeviceByName(formData.value.productName); - formData.value.productId = productId.data.records[0].id; if (props.isCreate) { // formData.value.username = formData.value.email; diff --git a/src/views/iot/device/index.vue b/src/views/iot/device/index.vue index f1a65b2..69dc9ba 100644 --- a/src/views/iot/device/index.vue +++ b/src/views/iot/device/index.vue @@ -331,7 +331,7 @@ }; // 搜索 - const handleSearch = (value: any) => { + const handleSearch = (value: string) => { if (value) { loading.value = true; options.value = []; @@ -392,6 +392,7 @@ }; onMounted(() => { search(); + handleSearch(''); }); watch(() => columns.value, deepClone, { deep: true, immediate: true }); diff --git a/src/views/iot/deviceMap/index.vue b/src/views/iot/deviceMap/index.vue new file mode 100644 index 0000000..e949ae3 --- /dev/null +++ b/src/views/iot/deviceMap/index.vue @@ -0,0 +1,117 @@ + + + + + + + + + + + ID: {{ selectedDevice.id }} + 名称: {{ selectedDevice.name }} + 状态: {{ selectedDevice.state }} + 在线状态: {{ selectedDevice.online ? '是' : '否' }} + + + + + + + + \ No newline at end of file diff --git a/src/views/iot/product/components/product-tsl.vue b/src/views/iot/product/components/product-tsl.vue index a669d2b..1329412 100644 --- a/src/views/iot/product/components/product-tsl.vue +++ b/src/views/iot/product/components/product-tsl.vue @@ -37,6 +37,9 @@ 删除 + + {{ record.ioType === 'READ_WRITE' ? '读写' : '只读' }} + @@ -105,11 +108,11 @@ :model="propertyAddData" :style="{ width: '800px', height: '420px' }" > - + - 读写 - 只读 + 读写 + 只读 @@ -439,6 +442,11 @@ dataIndex: 'identifier', slotName: 'identifier', }, + { + title: '类型', + dataIndex: 'ioType', + slotName: 'ioType', + }, { title: '备注', dataIndex: 'remark', diff --git a/src/views/notification/notice/components/message-edit.vue b/src/views/notification/notice/components/message-edit.vue index 8e8654a..946f3ef 100644 --- a/src/views/notification/notice/components/message-edit.vue +++ b/src/views/notification/notice/components/message-edit.vue @@ -136,7 +136,7 @@ - + 发送用户
ID: {{ selectedDevice.id }}
名称: {{ selectedDevice.name }}
状态: {{ selectedDevice.state }}
在线状态: {{ selectedDevice.online ? '是' : '否' }}