From 93a0789e34280c3607a80c5ebfdb3da5894b5e97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E6=B5=A9=E6=B5=A9?= <1036606149@qq.com> Date: Sun, 22 Sep 2024 15:42:20 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=96=B0=E5=A2=9E=E3=80=91=20IOT=20?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E7=AE=A1=E7=90=86=EF=BC=8C=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/iot/device/index.ts | 1 + src/router/modules/remaining.ts | 11 ++ .../iot/device/detail/DeviceDetailsHeader.vue | 114 ++++++++++++ .../iot/device/detail/DeviceDetailsInfo.vue | 175 ++++++++++++++++++ src/views/iot/device/detail/index.vue | 66 +++++++ src/views/iot/device/index.vue | 38 ++-- 6 files changed, 387 insertions(+), 18 deletions(-) create mode 100644 src/views/iot/device/detail/DeviceDetailsHeader.vue create mode 100644 src/views/iot/device/detail/DeviceDetailsInfo.vue create mode 100644 src/views/iot/device/detail/index.vue diff --git a/src/api/iot/device/index.ts b/src/api/iot/device/index.ts index 39a2e5a8..2a1951de 100644 --- a/src/api/iot/device/index.ts +++ b/src/api/iot/device/index.ts @@ -15,6 +15,7 @@ export interface DeviceVO { lastOnlineTime: Date // 最后上线时间 lastOfflineTime: Date // 最后离线时间 activeTime: Date // 设备激活时间 + createTime: Date // 创建时间 ip: string // 设备的 IP 地址 firmwareVersion: string // 设备的固件版本 deviceSecret: string // 设备密钥,用于设备认证,需安全存储 diff --git a/src/router/modules/remaining.ts b/src/router/modules/remaining.ts index 4595d563..cba8359c 100644 --- a/src/router/modules/remaining.ts +++ b/src/router/modules/remaining.ts @@ -622,6 +622,17 @@ const remainingRouter: AppRouteRecordRaw[] = [ activeMenu: '/iot/product' }, component: () => import('@/views/iot/product/detail/index.vue') + }, + { + path: 'device/detail/:id', + name: 'IoTDeviceDetail', + meta: { + title: '设备详情', + noCache: true, + hidden: true, + activeMenu: '/iot/device' + }, + component: () => import('@/views/iot/device/detail/index.vue') } ] } diff --git a/src/views/iot/device/detail/DeviceDetailsHeader.vue b/src/views/iot/device/detail/DeviceDetailsHeader.vue new file mode 100644 index 00000000..cc585f4a --- /dev/null +++ b/src/views/iot/device/detail/DeviceDetailsHeader.vue @@ -0,0 +1,114 @@ + + + + + + + {{ device.deviceName }} + + + + + + + 编辑 + + + + + + + + {{ product.name }} + + + {{ product.productKey }} + 复制 + + + + + + + diff --git a/src/views/iot/device/detail/DeviceDetailsInfo.vue b/src/views/iot/device/detail/DeviceDetailsInfo.vue new file mode 100644 index 00000000..2acbaabb --- /dev/null +++ b/src/views/iot/device/detail/DeviceDetailsInfo.vue @@ -0,0 +1,175 @@ + + + + + {{ product.name }} + {{ product.productKey }} + 复制 + + + + + {{ device.deviceName }} + 复制 + + {{ device.nickname }} + {{ + formatDate(device.createTime) + }} + {{ + formatDate(device.activeTime) + }} + {{ + formatDate(device.lastOnlineTime) + }} + + + + {{ + formatDate(device.lastOfflineTime) + }} + + 查看 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 关闭 + + + + + diff --git a/src/views/iot/device/detail/index.vue b/src/views/iot/device/detail/index.vue new file mode 100644 index 00000000..2db16bbc --- /dev/null +++ b/src/views/iot/device/detail/index.vue @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + diff --git a/src/views/iot/device/index.vue b/src/views/iot/device/index.vue index bb733250..566c78a6 100644 --- a/src/views/iot/device/index.vue +++ b/src/views/iot/device/index.vue @@ -96,7 +96,11 @@ - + + + {{ scope.row.deviceName }} + + @@ -122,6 +126,14 @@ /> + + 查看 + import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' import { dateFormatter } from '@/utils/formatTime' -import download from '@/utils/download' -import { DeviceApi, DeviceUpdateStatusVO, DeviceVO } from '@/api/iot/device' +import { DeviceApi, DeviceVO } from '@/api/iot/device' import DeviceForm from './DeviceForm.vue' import { ProductApi } from '@/api/iot/product' @@ -223,6 +234,12 @@ const openForm = (type: string, id?: number) => { formRef.value.open(type, id) } +/** 打开详情 */ +const { currentRoute, push } = useRouter() +const openDetail = (id: number) => { + push({ name: 'IoTDeviceDetail', params: { id } }) +} + /** 删除按钮操作 */ const handleDelete = async (id: number) => { try { @@ -235,21 +252,6 @@ const handleDelete = async (id: number) => { await getList() } catch {} } - -/** 导出按钮操作 */ -const handleExport = async () => { - try { - // 导出的二次确认 - await message.exportConfirm() - // 发起导出 - exportLoading.value = true - const data = await DeviceApi.exportDevice(queryParams) - download.excel(data, '设备.xls') - } catch { - } finally { - exportLoading.value = false - } -} /** 查询字典下拉列表 */ const products = ref() const getProducts = async () => {