Commit b39dfd11 authored by “yiyousong”'s avatar “yiyousong”

perf: 优化部门搜索

parent 8de00861
......@@ -22,10 +22,10 @@
<!-- 部门管理 -->
<div class="department-list">
<a-spin :spinning="deptLoading">
<div v-if="department.length">
<div v-if="departList.length">
<div
:class="{ department_off: true, active: active === i }"
v-for="(v, i) in department"
v-for="(v, i) in departList"
:key="v.id"
@click="changeDept(v.id, i)"
>
......@@ -318,6 +318,7 @@ export default {
visibleWork: false,
visibleAdd: false,
department: [], // 部门列表
departList: [], // 部门列表
deptTotal: 0, // 部门总数
windowData: [], // 窗口列表数据
total: 0, // 窗口总数
......@@ -345,7 +346,8 @@ export default {
watch: {
deptSearchVal(newVal) {
if (newVal === "") {
this.getDeptListData();
this.departList = this.department;
// this.getDeptListData();
}
},
},
......@@ -374,17 +376,6 @@ export default {
},
created() {},
methods: {
// 去掉空children
delChildren(arr) {
return arr.map((v) => {
if (v.children && v.children.length > 0) {
this.delChildren(v.children);
} else {
delete v.children;
}
return v;
});
},
// 获取部门列表
async getDeptListData() {
this.deptLoading = true;
......@@ -392,35 +383,16 @@ export default {
siteId: this.siteId,
page: 1,
size: -1,
name: `%${this.deptSearchVal}%`,
});
this.deptLoading = false;
let { code, data } = res.data;
if (code === 1) {
this.department = data.data;
this.departList = data.data;
this.deptTotal = data.total;
}
},
// 获取站点业务数据
// async getBusinessData(obj = {}) {
// let res = await siteBusinessList({
// page: 1,
// size: -1,
// siteId: this.siteId,
// ...obj,
// });
// let { data } = res.data.data;
// this.business = data
// .map((v) => {
// if (v.children && v.children.length) {
// return v.children;
// } else {
// return v;
// }
// })
// .flat();
// this.business = this.delChildren(this.business);
// },
// 新增部门
showModalAdd() {
if (!this.siteId) {
......@@ -537,7 +509,10 @@ export default {
// 部门搜索
onSearch(val) {
if (val != "") {
this.getDeptListData();
this.departList = this.department.filter((v) => {
return v.name.includes(val);
});
// this.getDeptListData();
}
},
// 窗口搜索
......
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