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

perf: 优化部门搜索

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