Commit 7c0b7b85 authored by “yiyousong”'s avatar “yiyousong”

perf: 优化用户管理搜索

parent 421d923a
......@@ -8,10 +8,19 @@
</div>
<div class="search_btn">
<a-space>
<a-select
v-model="userform.type"
placeholder="请选择类型"
style="width: 150px"
>
<a-select-option :value="1">按用户名</a-select-option>
<a-select-option :value="2">按用户姓名</a-select-option>
<a-select-option :value="3">按电话</a-select-option>
</a-select>
<a-input
v-model="userform.searchVal"
style="width: 250px"
placeholder="请输入用户姓名/手机号搜索"
placeholder="请输入关键字搜索"
>
<a-icon slot="prefix" type="search" />
</a-input>
......@@ -172,6 +181,7 @@ export default {
sourceInfoForm: {},
userDict: {}, // 角色数据
userform: {
type: 1,
roleId: undefined,
searchVal: undefined,
},
......@@ -197,11 +207,14 @@ export default {
this.tableLoading = true;
let realName = "";
let mobile = "";
let loginName = "";
if (this.userform.searchVal) {
if (/^[\d]+$/.test(this.userform.searchVal)) {
mobile = "%" + this.userform.searchVal + "%";
} else {
if (this.userform.type == 1) {
loginName = "%" + this.userform.searchVal + "%";
} else if (this.userform.type == 2) {
realName = "%" + this.userform.searchVal + "%";
} else if (this.userform.type == 3) {
mobile = "%" + this.userform.searchVal + "%";
}
}
let res = await userList({
......@@ -210,24 +223,27 @@ export default {
roleId: this.userform.roleId,
realName,
mobile,
loginName,
});
let { dict, data, total } = res.data;
let { roleId } = dict;
if (!data.length && this.tablePagination.current > 1) {
this.tablePagination.current -= 1;
this.getUserList();
}
this.userDict = roleId;
let { loginName } = this.userData;
if (this.loginNames.includes(loginName)) {
this.tableSourceData = data;
this.tablePagination.total = total;
} else {
this.tableSourceData = data.filter((v) => {
return !this.loginNames.includes(v.loginName);
});
if (res.code == 1) {
let { dict, data, total } = res.data;
let { roleId } = dict;
if (!data.length && this.tablePagination.current > 1) {
this.tablePagination.current -= 1;
this.getUserList();
}
this.userDict = roleId;
let { loginName } = this.userData;
if (this.loginNames.includes(loginName)) {
this.tableSourceData = data;
this.tablePagination.total = total;
} else {
this.tableSourceData = data.filter((v) => {
return !this.loginNames.includes(v.loginName);
});
this.tablePagination.total = total - 3;
this.tablePagination.total = total - this.loginNames.length;
}
}
this.tableLoading = false;
},
......
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