refactor(user): 优化用户管理模块提升体验与代码质量

- 删除系统用户管理模块中重复且冗余的 Extra 组件及相关引用
- 修复用户列表数据请求时搜索条件被覆盖的问题,保留默认筛选参数
- 清理未使用的 userType 和 handleTabs 相关代码,减少死代码
- 修改密码重置操作的明文展示方式,改为使用弹窗提示,提升安全性
- 在用户及管理员列表中新增状态列,显示用户状态(正常/冻结)
- 修改表格行点击事件为打开用户详情界面,移除无提示双击编辑操作
- 在用户列表页面新增高级筛选条件(角色、注册来源、类型)
- 添加搜索和重置按钮,绑定高级筛选参数,提高筛选灵活性
This commit is contained in:
2026-07-11 19:02:29 +08:00
parent 548a178a55
commit 05c8f765da
6 changed files with 143 additions and 121 deletions

View File

@@ -1,8 +1,50 @@
<template>
<a-page-header :title="getPageTitle()" @back="() => $router.go(-1)">
<template #extra>
<Extra />
</template>
<!-- 高级筛选 -->
<a-form layout="inline" class="ele-form-inline" style="margin-bottom: 16px">
<a-form-item label="角色">
<a-select
v-model:value="searchWhere.roleId"
placeholder="全部角色"
allow-clear
style="width: 160px"
>
<a-select-option
v-for="item in roles"
:key="item.value"
:value="item.value"
>{{ item.text }}</a-select-option
>
</a-select>
</a-form-item>
<a-form-item label="注册来源">
<a-select
v-model:value="searchWhere.platform"
placeholder="全部来源"
allow-clear
style="width: 140px"
>
<a-select-option value="MP-WEIXIN">微信小程序</a-select-option>
<a-select-option value="H5">H5</a-select-option>
<a-select-option value="WEB">Web</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="类型">
<a-select
v-model:value="searchWhere.isAdmin"
placeholder="全部"
allow-clear
style="width: 120px"
>
<a-select-option :value="1">管理员</a-select-option>
<a-select-option :value="2">普通用户</a-select-option>
</a-select>
</a-form-item>
<a-form-item>
<a-button type="primary" @click="reload()">搜索</a-button>
<a-button style="margin-left: 8px" @click="resetSearch">重置</a-button>
</a-form-item>
</a-form>
<a-card :bordered="false">
<!-- 表格 -->
<ele-pro-table
@@ -95,6 +137,11 @@
{{ item.roleName }}
</a-tag>
</template>
<template v-if="column.key === 'status'">
<a-tag v-if="record.status === 0" color="green">正常</a-tag>
<a-tag v-else-if="record.status === 1" color="red">冻结</a-tag>
<span v-else>-</span>
</template>
<template v-if="column.key === 'platform'">
<WechatOutlined v-if="record.platform === 'MP-WEIXIN'" />
<Html5Outlined v-if="record.platform === 'H5'" />
@@ -191,7 +238,6 @@
import { Organization } from '@/api/system/organization/model';
import { hasRole } from '@/utils/permission';
import { getPageTitle } from '@/utils/common';
import Extra from './components/Extra.vue';
import { useUserStore } from '@/store/modules/user';
// 加载状态
@@ -212,8 +258,19 @@
const showInfo = ref(false);
// 是否显示用户导入弹窗
const showImport = ref(false);
const userType = ref<number>();
const searchText = ref('');
// 高级筛选条件
const searchWhere = reactive({
roleId: undefined,
platform: undefined,
isAdmin: undefined
});
const resetSearch = () => {
searchWhere.roleId = undefined;
searchWhere.platform = undefined;
searchWhere.isAdmin = undefined;
reload();
};
const userStore = useUserStore();
// 当前用户信息
const loginUser = computed(() => userStore.info ?? {});
@@ -393,6 +450,13 @@
key: 'roles',
align: 'center'
},
{
title: '状态',
dataIndex: 'status',
key: 'status',
align: 'center',
width: 90
},
{
title: '管理员',
key: 'isAdmin',
@@ -426,17 +490,15 @@
});
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit,
where,
orders,
filters
}) => {
where = {};
where.roleId = filters.roles;
where.keywords = searchText.value;
return pageUsers({ page, limit, ...where, ...orders });
const datasource: DatasourceFunction = ({ page, limit, where, orders }) => {
const params = {
...where,
keywords: searchText.value,
roleId: searchWhere.roleId,
platform: searchWhere.platform,
isAdmin: searchWhere.isAdmin || undefined
};
return pageUsers({ page, limit, ...params, ...orders });
};
/* 搜索 */
@@ -462,11 +524,6 @@
showImport.value = true;
};
const handleTabs = (e) => {
userType.value = Number(e.target.value);
reload();
};
/* 删除单个 */
const remove = (row: User) => {
const hide = messageLoading('请求中..', 0);
@@ -520,9 +577,12 @@
const hide = message.loading('请求中..', 0);
const password = uuid(8);
updateUserPassword(row.userId, password)
.then((msg) => {
.then(() => {
hide();
message.success(msg + ',新密码:' + password);
Modal.success({
title: '密码重置成功',
content: `新密码:${password}(请妥善保管并及时通知用户)`
});
})
.catch((e) => {
hide();
@@ -647,13 +707,9 @@
/* 自定义行属性 */
const customRow = (record: User) => {
return {
// 行点击事件
// 行点击查看用户详情
onClick: () => {
// console.log(record);
},
// 行双击事件
onDblclick: () => {
openEdit(record);
openInfo(record);
}
};
};