Commit 76a00edf authored by “yiyousong”'s avatar “yiyousong”

perf: 优化设备列表搜索

parent 5506d7b0
...@@ -25,10 +25,13 @@ ...@@ -25,10 +25,13 @@
v-model="type" v-model="type"
placeholder="请选择搜索类型" placeholder="请选择搜索类型"
> >
<el-option label="按设备名称" :value="1"> </el-option> <el-option
<el-option label="按mac地址" :value="2"> </el-option> v-for="(v, key) in typeList"
<el-option label="按设备IP" :value="3"> </el-option> :key="key"
<el-option label="按所属机构" :value="4"> </el-option> :label="v"
:value="key"
>
</el-option>
</el-select> </el-select>
<el-input <el-input
size="small" size="small"
...@@ -71,6 +74,8 @@ ...@@ -71,6 +74,8 @@
</el-table-column> </el-table-column>
<el-table-column align="center" prop="deviceMac" label="mac地址"> <el-table-column align="center" prop="deviceMac" label="mac地址">
</el-table-column> </el-table-column>
<el-table-column align="center" prop="ip" label="IP地址">
</el-table-column>
<el-table-column align="center" label="设备位置"> <el-table-column align="center" label="设备位置">
<template slot-scope="scope"> <template slot-scope="scope">
<span <span
...@@ -204,6 +209,12 @@ import { ...@@ -204,6 +209,12 @@ import {
delDevice, delDevice,
} from "@/api/device"; } from "@/api/device";
import local from "@/utils/local"; import local from "@/utils/local";
const typeList = {
deviceName: "按设备名称",
deviceMac: "按mac地址",
ip: "按IP地址",
belong: "按所属机构",
};
export default { export default {
components: { components: {
TableHeader, TableHeader,
...@@ -214,6 +225,7 @@ export default { ...@@ -214,6 +225,7 @@ export default {
}, },
data() { data() {
return { return {
typeList,
searchVal: "", searchVal: "",
siteId: local.getLocal("sampleSiteId") siteId: local.getLocal("sampleSiteId")
? local.getLocal("sampleSiteId") ? local.getLocal("sampleSiteId")
...@@ -227,7 +239,7 @@ export default { ...@@ -227,7 +239,7 @@ export default {
loading: false, loading: false,
matterDrawer: false, matterDrawer: false,
dict: {}, // 字典 dict: {}, // 字典
type: 1, type: "deviceName",
}; };
}, },
created() { created() {
...@@ -242,15 +254,8 @@ export default { ...@@ -242,15 +254,8 @@ export default {
page: this.current, page: this.current,
size: this.size, size: this.size,
}; };
if (this.type == 1) { let value = `%${this.searchVal}%`;
obj.deviceName = `%${this.searchVal}%`; obj[this.type] = value;
} else if (this.type == 2) {
obj.deviceMac = `%${this.searchVal}%`;
} else if (this.type == 3) {
obj.ip = `%${this.searchVal}%`;
} else if (this.type == 4) {
obj.belong = `%${this.searchVal}%`;
}
let res = await getDeviceList(obj); let res = await getDeviceList(obj);
this.loading = false; this.loading = false;
...@@ -278,7 +283,7 @@ export default { ...@@ -278,7 +283,7 @@ export default {
searchReset() { searchReset() {
this.searchVal = ""; this.searchVal = "";
this.current = 1; this.current = 1;
this.type = 1; this.type = "deviceName";
this.getDeviceList(); this.getDeviceList();
}, },
// 翻页 // 翻页
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment