From f2197ed95650baf4970ddaff93fd6c57c1962f1d Mon Sep 17 00:00:00 2001 From: CGD <3030332422@qq.com> Date: Mon, 10 Mar 2025 11:20:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=90=9C=E7=B4=A2=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/manager-web/src/views/home.vue | 39 +++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/main/manager-web/src/views/home.vue b/main/manager-web/src/views/home.vue index 12ab76894..58a5d53b2 100644 --- a/main/manager-web/src/views/home.vue +++ b/main/manager-web/src/views/home.vue @@ -21,9 +21,9 @@
- + + style="width: 12px;height: 12px;margin-right: 11px;cursor: pointer;" @click="handleSearch" />
@@ -56,8 +56,8 @@
-
+ style="display: flex;flex-wrap: wrap;margin-top: 15px;gap: 15px;justify-content: flex-start;box-sizing: border-box;"> +
@@ -229,7 +229,9 @@ export default { name: 'home', data() { return { - serach: '', + serach: '', // 搜索框输入内容 + deviceList: [], // 原始设备列表 + filteredDeviceList: [], // 过滤后的设备列表 switchValue: false, addDeviceDialogVisible: false, deviceCode: "", @@ -250,8 +252,7 @@ export default { }], userInfo: { mobile: '' // 初始化用户信息 - }, - deviceList:[] + } }; }, methods: { @@ -270,14 +271,30 @@ export default { // 获取已绑设备 getList(){ Api.user.getHomeList(({data})=>{ - console.log(data.data) - this.deviceList = data.data + this.deviceList = data.data; // 保存原始设备列表 + this.filteredDeviceList = data.data; // 初始化过滤后的设备列表 }) - } + }, + // 处理搜索 + handleSearch() { + if (this.serach.trim() === '') { + // 如果搜索框为空,显示全部设备 + this.filteredDeviceList = this.deviceList; + } else { + // 过滤设备列表 + this.filteredDeviceList = this.deviceList.filter(device => { + return ( + device.list[0]?.mac_address?.includes(this.serach) || // 匹配MAC地址 + device.list[0]?.device_type?.includes(this.serach) || // 匹配设备型号 + device.list[0]?.app_version?.includes(this.serach) // 匹配APP版本 + ); + }); + } + }, }, mounted() { this.fetchUserInfo(); // 组件加载时获取用户信息 - this.getList() + this.getList(); // 初始化设备列表 } }