mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-29 05:09:46 +01:00
完成搜索功能开发
This commit is contained in:
parent
f9472627f4
commit
f2197ed956
1 changed files with 28 additions and 11 deletions
|
|
@ -21,9 +21,9 @@
|
||||||
</div>
|
</div>
|
||||||
<div style="display: flex;align-items: center;gap: 8px;margin-top: 10px">
|
<div style="display: flex;align-items: center;gap: 8px;margin-top: 10px">
|
||||||
<div class="serach-box">
|
<div class="serach-box">
|
||||||
<el-input placeholder="输入名称搜索.." v-model="serach" style="border: none; background: transparent;" />
|
<el-input placeholder="输入名称搜索.." v-model="serach" style="border: none; background: transparent;" @keyup.enter.native="handleSearch" />
|
||||||
<img src="@/assets/home/search.png" alt=""
|
<img src="@/assets/home/search.png" alt=""
|
||||||
style="width: 12px;height: 12px;margin-right: 11px;cursor: pointer;" />
|
style="width: 12px;height: 12px;margin-right: 11px;cursor: pointer;" @click="handleSearch" />
|
||||||
</div>
|
</div>
|
||||||
<img src="@/assets/home/avatar.png" alt="" style="width: 21px;height: 21px;" />
|
<img src="@/assets/home/avatar.png" alt="" style="width: 21px;height: 21px;" />
|
||||||
<div class="user-info">
|
<div class="user-info">
|
||||||
|
|
@ -56,8 +56,8 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
style="display: flex;flex-wrap: wrap;margin-top: 15px;gap: 15px;justify-content: space-between;box-sizing: border-box;">
|
style="display: flex;flex-wrap: wrap;margin-top: 15px;gap: 15px;justify-content: flex-start;box-sizing: border-box;">
|
||||||
<div class="device-item" v-for="(item,index) in deviceList" :key="index">
|
<div class="device-item" v-for="(item,index) in filteredDeviceList" :key="index">
|
||||||
<div style="display: flex;justify-content: space-between;">
|
<div style="display: flex;justify-content: space-between;">
|
||||||
<div style="font-weight: 700;font-size: 18px;text-align: left;color: #3d4566;">
|
<div style="font-weight: 700;font-size: 18px;text-align: left;color: #3d4566;">
|
||||||
<!-- CC:ba:97:11:a6:ac-->
|
<!-- CC:ba:97:11:a6:ac-->
|
||||||
|
|
@ -229,7 +229,9 @@ export default {
|
||||||
name: 'home',
|
name: 'home',
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
serach: '',
|
serach: '', // 搜索框输入内容
|
||||||
|
deviceList: [], // 原始设备列表
|
||||||
|
filteredDeviceList: [], // 过滤后的设备列表
|
||||||
switchValue: false,
|
switchValue: false,
|
||||||
addDeviceDialogVisible: false,
|
addDeviceDialogVisible: false,
|
||||||
deviceCode: "",
|
deviceCode: "",
|
||||||
|
|
@ -250,8 +252,7 @@ export default {
|
||||||
}],
|
}],
|
||||||
userInfo: {
|
userInfo: {
|
||||||
mobile: '' // 初始化用户信息
|
mobile: '' // 初始化用户信息
|
||||||
},
|
}
|
||||||
deviceList:[]
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
@ -270,14 +271,30 @@ export default {
|
||||||
// 获取已绑设备
|
// 获取已绑设备
|
||||||
getList(){
|
getList(){
|
||||||
Api.user.getHomeList(({data})=>{
|
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() {
|
mounted() {
|
||||||
this.fetchUserInfo(); // 组件加载时获取用户信息
|
this.fetchUserInfo(); // 组件加载时获取用户信息
|
||||||
this.getList()
|
this.getList(); // 初始化设备列表
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue