feat(user): 优化用户审核功能及新增店名显示
- 在用户模型中新增 storeName 字段以支持店名信息 - 用户列表页增加“店名”列,支持表格内显示及提示完整信息 - 审核弹窗新增单条审核时的关键信息展示,包括店名、姓名及所在地区 - 优化审核弹窗逻辑,批量审核时不展示单条用户信息 - 精简待审核用户专用页,固定只显示审核状态为“待审核”的用户 - 待审核页删除高级筛选功能,仅保留关键字搜索 - 保留待审核页的角色、注册来源、审核状态列展示,满足显示需求 - 调整用户列表页操作项样式,统一使用 a-space 包装,提升界面一致性
This commit is contained in:
46
.workbuddy/memory/2026-07-12.md
Normal file
46
.workbuddy/memory/2026-07-12.md
Normal file
@@ -0,0 +1,46 @@
|
||||
# 2026-07-12 工作日志
|
||||
|
||||
## 用户审核弹窗与列表增加店名/姓名/地区信息
|
||||
|
||||
针对用户管理 `system/user` 的审核功能做信息补全:
|
||||
|
||||
### 1. 新增字段
|
||||
- `src/api/system/user/model/index.ts`:在 `User` 接口增加 `storeName?: string`(店名)。
|
||||
|
||||
### 2. 用户列表增加「店名」列
|
||||
- `src/views/system/user/index.vue`:
|
||||
- 列配置在「昵称」后新增 `storeName` 列(`title: '店名'`,`align: 'center'`,`ellipsis: true`)。
|
||||
- `bodyCell` 渲染分支:空值显示 `-`,保留 `title` 提示完整店名。
|
||||
|
||||
### 3. 审核弹窗展示用户关键信息
|
||||
- 新增响应式变量 `currentAuditUser`。
|
||||
- `openAudit(row)` 时把当前行记录赋给 `currentAuditUser`;`openBatchAudit` 时清空(批量审核不展示单条信息)。
|
||||
- 审核弹窗顶部增加信息区(仅单条审核时展示):
|
||||
- **店名**:`currentAuditUser.storeName || '-'`
|
||||
- **姓名**:`currentAuditUser.realName || currentAuditUser.nickname || '-'`(真实姓名优先,无则取昵称)
|
||||
- **所在地区**:`province + city + region` 拼接,空则显示 `-`
|
||||
|
||||
### 验证
|
||||
- `vue-tsc --noEmit` 类型检查:本次改动文件无新增错误(列出的报错均为项目既有错误:`$router`、`getPageTitle`、`loginUser`/`updateIsAdmin` 未使用、导出数组隐式 any 等,与本次无关)。
|
||||
- 落地核对:模型 `storeName` 1 处、页面列配置 1 处、`bodyCell` 渲染 1 处、`currentAuditUser` 变量 7 处、弹窗信息区字段各 1 处。
|
||||
|
||||
## 待审核用户专用页 `/system/user/pending` 精简
|
||||
|
||||
`src/views/system/user/pending/index.vue` 已存在(基于 user 列表的副本)。按用户要求改造:
|
||||
|
||||
### 1. 只显示待审核用户
|
||||
- `datasource` 改为固定 `auditStatus: 0`,不再读取筛选条件。
|
||||
|
||||
### 2. 删除高级筛选区(角色/注册来源/类型/审核状态 4个下拉 + 搜索/重置按钮)
|
||||
- 模板删除整个 `<a-form>` 高级筛选区。
|
||||
- 脚本删除 `searchWhere` reactive、`resetSearch`、`roles` 变量、`filters()` 调用。
|
||||
- 删除已无用的 `listRoles` import。
|
||||
- 顶部关键词搜索框(`a-input-search`)保留。
|
||||
|
||||
### 注意点(待用户确认)
|
||||
- 列表的「角色」列、「注册来源」列、「审核状态」列均**保留**(用户要求删除的是筛选"功能",非列表展示列)。其中「审核状态」列在待审核页全会显示"待审核",若用户也想删列表列需再告知。
|
||||
- 工具栏「新建/修改/重置密码/批量审核/批量删除/导入/导出」按钮保留未动。
|
||||
|
||||
### 验证
|
||||
- `vue-tsc --noEmit`:本页面无新增类型错误(残留报错均为项目既有问题)。
|
||||
- 落地核对:高级筛选残留 0、searchWhere/resetSearch/roles/filters/listRoles 残留 0、datasource 固定 auditStatus:0 = 1。
|
||||
@@ -135,6 +135,8 @@ export interface User {
|
||||
auditRemark?: string;
|
||||
// 审核时间
|
||||
auditTime?: string;
|
||||
// 店名
|
||||
storeName?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -40,18 +40,6 @@
|
||||
<a-select-option :value="2">普通用户</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
<a-form-item label="审核状态">
|
||||
<a-select
|
||||
v-model:value="searchWhere.auditStatus"
|
||||
placeholder="全部"
|
||||
allow-clear
|
||||
style="width: 140px"
|
||||
>
|
||||
<a-select-option :value="0">待审核</a-select-option>
|
||||
<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>
|
||||
@@ -96,17 +84,6 @@
|
||||
:disabled="selection.length === 0"
|
||||
>重置密码
|
||||
</a-button>
|
||||
<a-button
|
||||
type="primary"
|
||||
class="ele-btn-icon"
|
||||
@click="openBatchAudit"
|
||||
:disabled="selection.length === 0"
|
||||
>
|
||||
<template #icon>
|
||||
<CheckCircleOutlined />
|
||||
</template>
|
||||
<span>批量审核</span>
|
||||
</a-button>
|
||||
<a-button
|
||||
danger
|
||||
type="primary"
|
||||
@@ -151,6 +128,9 @@
|
||||
<template v-if="column.key === 'nickname'">
|
||||
<span>{{ record.nickname }}</span>
|
||||
</template>
|
||||
<template v-if="column.key === 'storeName'">
|
||||
<span :title="record.storeName">{{ record.storeName || '-' }}</span>
|
||||
</template>
|
||||
<template v-if="column.key === 'mobile'">
|
||||
<span v-if="hasRole('superAdmin')">{{ record.phone }}</span>
|
||||
<span v-else>{{ record.mobile }}</span>
|
||||
@@ -195,13 +175,10 @@
|
||||
<!-- />-->
|
||||
</template>
|
||||
<template v-if="column.key === 'action'">
|
||||
<div>
|
||||
<a-space>
|
||||
<a @click="openEdit(record)">修改</a>
|
||||
<a-divider type="vertical" v-if="record.auditStatus === 0" />
|
||||
<a v-if="record.auditStatus === 0" @click.stop="openAudit(record)">审核</a>
|
||||
<a-divider type="vertical" v-if="record.auditStatus === 0" />
|
||||
<a-divider type="vertical" />
|
||||
<!-- <a @click="resetPsw(record)">重置</a>-->
|
||||
<!-- <a-divider type="vertical" />-->
|
||||
<a-popconfirm
|
||||
placement="topRight"
|
||||
title="确定要删除此用户吗?"
|
||||
@@ -209,7 +186,7 @@
|
||||
>
|
||||
<a class="ele-text-danger">删除</a>
|
||||
</a-popconfirm>
|
||||
</div>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
@@ -232,6 +209,22 @@
|
||||
@ok="submitAudit"
|
||||
>
|
||||
<a-form :model="auditForm" layout="vertical">
|
||||
<div
|
||||
v-if="!batchAudit && currentAuditUser"
|
||||
class="audit-user-info"
|
||||
style="margin-bottom: 16px; padding: 12px; background: #f5f5f5; border-radius: 4px;"
|
||||
>
|
||||
<p style="margin-bottom: 8px;">
|
||||
<strong>店名:</strong>{{ currentAuditUser.storeName || '-' }}
|
||||
</p>
|
||||
<p style="margin-bottom: 8px;">
|
||||
<strong>姓名:</strong>{{ currentAuditUser.realName || currentAuditUser.nickname || '-' }}
|
||||
</p>
|
||||
<p style="margin-bottom: 0;">
|
||||
<strong>所在地区:</strong>
|
||||
{{ [currentAuditUser.province, currentAuditUser.city, currentAuditUser.region].filter(Boolean).join(' ') || '-' }}
|
||||
</p>
|
||||
</div>
|
||||
<a-form-item label="审核结果">
|
||||
<a-radio-group v-model:value="auditForm.status">
|
||||
<a-radio :value="1">通过</a-radio>
|
||||
@@ -317,6 +310,8 @@
|
||||
const showAudit = ref(false);
|
||||
// 是否批量审核
|
||||
const batchAudit = ref(false);
|
||||
// 当前审核用户(单条审核时显示详情)
|
||||
const currentAuditUser = ref<User | null>(null);
|
||||
// 审核弹窗标题
|
||||
const auditTitle = ref('审核用户');
|
||||
// 审核表单
|
||||
@@ -479,26 +474,26 @@
|
||||
key: 'birthday',
|
||||
hideInTable: true
|
||||
},
|
||||
{
|
||||
title: '省份',
|
||||
dataIndex: 'province',
|
||||
key: 'province',
|
||||
hideInTable: true
|
||||
},
|
||||
{
|
||||
title: '城市',
|
||||
dataIndex: 'city',
|
||||
key: 'city',
|
||||
hideInTable: true,
|
||||
showSorterTooltip: false
|
||||
},
|
||||
{
|
||||
title: '地区',
|
||||
dataIndex: 'region',
|
||||
key: 'region',
|
||||
hideInTable: true,
|
||||
showSorterTooltip: false
|
||||
},
|
||||
// {
|
||||
// title: '省份',
|
||||
// dataIndex: 'province',
|
||||
// key: 'province',
|
||||
// hideInTable: true
|
||||
// },
|
||||
// {
|
||||
// title: '城市',
|
||||
// dataIndex: 'city',
|
||||
// key: 'city',
|
||||
// hideInTable: true,
|
||||
// showSorterTooltip: false
|
||||
// },
|
||||
// {
|
||||
// title: '地区',
|
||||
// dataIndex: 'region',
|
||||
// key: 'region',
|
||||
// hideInTable: true,
|
||||
// showSorterTooltip: false
|
||||
// },
|
||||
{
|
||||
title: '邮箱认证',
|
||||
dataIndex: 'emailVerified',
|
||||
@@ -526,13 +521,6 @@
|
||||
align: 'center',
|
||||
width: 90
|
||||
},
|
||||
{
|
||||
title: '审核状态',
|
||||
dataIndex: 'auditStatus',
|
||||
key: 'auditStatus',
|
||||
align: 'center',
|
||||
width: 100
|
||||
},
|
||||
{
|
||||
title: '管理员',
|
||||
key: 'isAdmin',
|
||||
@@ -684,6 +672,7 @@
|
||||
/* 打开单条审核弹窗 */
|
||||
const openAudit = (row: User) => {
|
||||
batchAudit.value = false;
|
||||
currentAuditUser.value = row;
|
||||
auditForm.userId = row.userId;
|
||||
auditForm.status = 1;
|
||||
auditForm.remark = '';
|
||||
@@ -698,6 +687,7 @@
|
||||
return;
|
||||
}
|
||||
batchAudit.value = true;
|
||||
currentAuditUser.value = null;
|
||||
auditForm.userId = undefined;
|
||||
auditForm.status = 1;
|
||||
auditForm.remark = '';
|
||||
@@ -830,7 +820,11 @@
|
||||
const customRow = (record: User) => {
|
||||
return {
|
||||
// 行点击查看用户详情
|
||||
onClick: () => {
|
||||
// onClick: () => {
|
||||
// openInfo(record);
|
||||
// },
|
||||
// 行双击事件
|
||||
onDblclick: () => {
|
||||
openInfo(record);
|
||||
}
|
||||
};
|
||||
|
||||
681
src/views/system/user/pending/index.vue
Normal file
681
src/views/system/user/pending/index.vue
Normal file
@@ -0,0 +1,681 @@
|
||||
<template>
|
||||
<a-page-header :title="getPageTitle()" @back="() => $router.go(-1)">
|
||||
<a-card :bordered="false">
|
||||
<!-- 表格 -->
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="userId"
|
||||
:columns="columns"
|
||||
:datasource="datasource"
|
||||
v-model:selection="selection"
|
||||
:scroll="{ x: 1300 }"
|
||||
:where="defaultWhere"
|
||||
cache-key="proSystemUserTable"
|
||||
>
|
||||
<template #toolbar>
|
||||
<a-space>
|
||||
<a-button
|
||||
type="primary"
|
||||
class="ele-btn-icon"
|
||||
@click="openBatchAudit"
|
||||
:disabled="selection.length === 0"
|
||||
>
|
||||
<template #icon>
|
||||
<CheckCircleOutlined />
|
||||
</template>
|
||||
<span>批量审核</span>
|
||||
</a-button>
|
||||
<a-button
|
||||
danger
|
||||
type="primary"
|
||||
class="ele-btn-icon"
|
||||
:disabled="selection.length === 0"
|
||||
@click="removeBatch"
|
||||
>
|
||||
<template #icon>
|
||||
<delete-outlined />
|
||||
</template>
|
||||
<span>批量删除</span>
|
||||
</a-button>
|
||||
<a-input-search
|
||||
allow-clear
|
||||
v-model:value="searchText"
|
||||
placeholder="请输入关键词"
|
||||
@search="handleSearch"
|
||||
@pressEnter="handleSearch"
|
||||
/>
|
||||
</a-space>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'avatar'">
|
||||
<a-avatar
|
||||
:size="30"
|
||||
:src="`${record.avatar}`"
|
||||
style="margin-right: 4px"
|
||||
>
|
||||
<template #icon>
|
||||
<UserOutlined />
|
||||
</template>
|
||||
</a-avatar>
|
||||
</template>
|
||||
<template v-if="column.key === 'nickname'">
|
||||
<span>{{ record.nickname }}</span>
|
||||
</template>
|
||||
<template v-if="column.key === 'storeName'">
|
||||
<span :title="record.storeName">{{ record.storeName || '-' }}</span>
|
||||
</template>
|
||||
<template v-if="column.key === 'mobile'">
|
||||
<span v-if="hasRole('superAdmin')">{{ record.phone }}</span>
|
||||
<span v-else>{{ record.mobile }}</span>
|
||||
</template>
|
||||
<template v-if="column.key === 'roles'">
|
||||
<a-tag v-for="item in record.roles" :key="item.roleId" color="blue">
|
||||
{{ 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 === 'auditStatus'">
|
||||
<a-tag v-if="record.auditStatus === 0" color="orange">待审核</a-tag>
|
||||
<a-tag v-else-if="record.auditStatus === 1" color="green">通过</a-tag>
|
||||
<a-tag v-else-if="record.auditStatus === 2" 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'" />
|
||||
<ChromeOutlined v-if="record.platform === 'WEB'" />
|
||||
</template>
|
||||
<template v-if="column.key === 'balance'">
|
||||
<span class="ele-text-success">
|
||||
¥{{ formatNumber(record.balance) }}
|
||||
</span>
|
||||
</template>
|
||||
<template v-if="column.key === 'expendMoney'">
|
||||
<span class="ele-text-warning">
|
||||
¥{{ formatNumber(record.expendMoney) }}
|
||||
</span>
|
||||
</template>
|
||||
<template v-if="column.key === 'isAdmin'">
|
||||
<a-tag v-if="record.isAdmin">是</a-tag>
|
||||
<a-tag v-else>否</a-tag>
|
||||
<!-- <a-switch-->
|
||||
<!-- :checked="record.isAdmin == 1"-->
|
||||
<!-- @change="updateIsAdmin(record)"-->
|
||||
<!-- />-->
|
||||
</template>
|
||||
<template v-if="column.key === 'action'">
|
||||
<a-space>
|
||||
<a @click="openEdit(record)">修改</a>
|
||||
<a-divider type="vertical" v-if="record.auditStatus === 0" />
|
||||
<a v-if="record.auditStatus === 0" @click.stop="openAudit(record)">审核</a>
|
||||
<a-divider type="vertical" />
|
||||
<!-- <a @click="resetPsw(record)">重置</a>-->
|
||||
<a-popconfirm
|
||||
placement="topRight"
|
||||
title="确定要删除此用户吗?"
|
||||
@confirm="remove(record)"
|
||||
>
|
||||
<a class="ele-text-danger">删除</a>
|
||||
</a-popconfirm>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
</a-card>
|
||||
<!-- 编辑弹窗 -->
|
||||
<user-edit
|
||||
v-model:visible="showEdit"
|
||||
:data="current"
|
||||
:organization-list="data"
|
||||
@done="reload"
|
||||
/>
|
||||
<!-- 导入弹窗 -->
|
||||
<user-import v-model:visible="showImport" @done="reload" />
|
||||
<!-- 用户详情 -->
|
||||
<user-info v-model:visible="showInfo" :data="current" @done="reload" />
|
||||
<!-- 审核弹窗 -->
|
||||
<a-modal
|
||||
v-model:visible="showAudit"
|
||||
:title="auditTitle"
|
||||
@ok="submitAudit"
|
||||
>
|
||||
<a-form :model="auditForm" layout="vertical">
|
||||
<div
|
||||
v-if="!batchAudit && currentAuditUser"
|
||||
class="audit-user-info"
|
||||
style="margin-bottom: 16px; padding: 12px; background: #f5f5f5; border-radius: 4px;"
|
||||
>
|
||||
<p style="margin-bottom: 8px;">
|
||||
<strong>店名:</strong>{{ currentAuditUser.storeName || '-' }}
|
||||
</p>
|
||||
<p style="margin-bottom: 8px;">
|
||||
<strong>姓名:</strong>{{ currentAuditUser.realName || currentAuditUser.nickname || '-' }}
|
||||
</p>
|
||||
<p style="margin-bottom: 0;">
|
||||
<strong>所在地区:</strong>
|
||||
{{ [currentAuditUser.province, currentAuditUser.city, currentAuditUser.region].filter(Boolean).join(' ') || '-' }}
|
||||
</p>
|
||||
</div>
|
||||
<a-form-item label="审核结果">
|
||||
<a-radio-group v-model:value="auditForm.status">
|
||||
<a-radio :value="1">通过</a-radio>
|
||||
<a-radio :value="2">拒绝</a-radio>
|
||||
</a-radio-group>
|
||||
</a-form-item>
|
||||
<a-form-item label="审核备注">
|
||||
<a-textarea
|
||||
v-model:value="auditForm.remark"
|
||||
:rows="3"
|
||||
placeholder="请输入审核备注(拒绝时建议填写)"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-modal>
|
||||
</a-page-header>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { createVNode, ref, computed, reactive } from 'vue';
|
||||
import { message, Modal } from 'ant-design-vue/es';
|
||||
import {
|
||||
PlusOutlined,
|
||||
DeleteOutlined,
|
||||
UploadOutlined,
|
||||
EditOutlined,
|
||||
UserOutlined,
|
||||
Html5Outlined,
|
||||
ChromeOutlined,
|
||||
WechatOutlined,
|
||||
ExclamationCircleOutlined,
|
||||
CheckCircleOutlined
|
||||
} from '@ant-design/icons-vue';
|
||||
import type { EleProTable } from 'ele-admin-pro/es';
|
||||
import type {
|
||||
DatasourceFunction,
|
||||
ColumnItem
|
||||
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import { messageLoading, formatNumber } from 'ele-admin-pro/es';
|
||||
import UserEdit from '../components/user-edit.vue';
|
||||
import UserImport from '../components/user-import.vue';
|
||||
import UserInfo from '../components/user-info.vue';
|
||||
import { toDateString } from 'ele-admin-pro';
|
||||
import {
|
||||
pageUsers,
|
||||
removeUser,
|
||||
removeUsers,
|
||||
updateUserPassword,
|
||||
updateUser,
|
||||
listUsers,
|
||||
auditUser
|
||||
} from '@/api/system/user';
|
||||
import type { User, UserParam } from '@/api/system/user/model';
|
||||
import { toTreeData, uuid } from 'ele-admin-pro';
|
||||
import { utils, writeFile } from 'xlsx';
|
||||
import dayjs from 'dayjs';
|
||||
import { listOrganizations } from '@/api/system/organization';
|
||||
import { Organization } from '@/api/system/organization/model';
|
||||
import { hasRole } from '@/utils/permission';
|
||||
import { getPageTitle } from '@/utils/common';
|
||||
import { useUserStore } from '@/store/modules/user';
|
||||
|
||||
// 加载状态
|
||||
const loading = ref(true);
|
||||
// 树形数据
|
||||
const data = ref<Organization[]>([]);
|
||||
// 树展开的key
|
||||
const expandedRowKeys = ref<number[]>([]);
|
||||
// 树选中的key
|
||||
const selectedRowKeys = ref<number[]>([]);
|
||||
// 表格选中数据
|
||||
const selection = ref<User[]>([]);
|
||||
// 当前编辑数据
|
||||
const current = ref<User | null>(null);
|
||||
// 是否显示编辑弹窗
|
||||
const showEdit = ref(false);
|
||||
// 是否显示用户详情
|
||||
const showInfo = ref(false);
|
||||
// 是否显示用户导入弹窗
|
||||
const showImport = ref(false);
|
||||
// 是否显示审核弹窗
|
||||
const showAudit = ref(false);
|
||||
// 是否批量审核
|
||||
const batchAudit = ref(false);
|
||||
// 当前审核用户(单条审核时显示详情)
|
||||
const currentAuditUser = ref<User | null>(null);
|
||||
// 审核弹窗标题
|
||||
const auditTitle = ref('审核用户');
|
||||
// 审核表单
|
||||
const auditForm = reactive({
|
||||
userId: undefined as number | undefined,
|
||||
status: 1,
|
||||
remark: ''
|
||||
});
|
||||
const searchText = ref('');
|
||||
const userStore = useUserStore();
|
||||
// 当前用户信息
|
||||
const loginUser = computed(() => userStore.info ?? {});
|
||||
// 加载机构
|
||||
listOrganizations()
|
||||
.then((list) => {
|
||||
loading.value = false;
|
||||
const eks: number[] = [];
|
||||
list.forEach((d) => {
|
||||
d.key = d.organizationId;
|
||||
d.value = d.organizationId;
|
||||
d.title = d.organizationName;
|
||||
if (typeof d.key === 'number') {
|
||||
eks.push(d.key);
|
||||
}
|
||||
});
|
||||
expandedRowKeys.value = eks;
|
||||
data.value = toTreeData({
|
||||
data: list,
|
||||
idField: 'organizationId',
|
||||
parentIdField: 'parentId'
|
||||
});
|
||||
if (list.length) {
|
||||
if (typeof list[0].key === 'number') {
|
||||
selectedRowKeys.value = [list[0].key];
|
||||
}
|
||||
// current.value = list[0];
|
||||
} else {
|
||||
selectedRowKeys.value = [];
|
||||
// current.value = null;
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
// 表格列配置
|
||||
const columns = ref<ColumnItem[]>([
|
||||
{
|
||||
title: 'ID',
|
||||
dataIndex: 'userId',
|
||||
width: 90,
|
||||
showSorterTooltip: false
|
||||
},
|
||||
{
|
||||
title: '店名',
|
||||
key: 'shopName',
|
||||
dataIndex: 'shopName',
|
||||
width: 180
|
||||
},
|
||||
{
|
||||
title: '手机号码',
|
||||
dataIndex: 'mobile',
|
||||
key: 'mobile',
|
||||
showSorterTooltip: false
|
||||
},
|
||||
{
|
||||
title: '真实姓名',
|
||||
dataIndex: 'realName',
|
||||
showSorterTooltip: false
|
||||
},
|
||||
{
|
||||
title: '省份',
|
||||
dataIndex: 'province',
|
||||
key: 'province',
|
||||
},
|
||||
{
|
||||
title: '城市',
|
||||
dataIndex: 'city',
|
||||
key: 'city',
|
||||
showSorterTooltip: false
|
||||
},
|
||||
{
|
||||
title: '地区',
|
||||
dataIndex: 'region',
|
||||
key: 'region',
|
||||
showSorterTooltip: false
|
||||
},
|
||||
{
|
||||
title: '邮箱',
|
||||
dataIndex: 'email',
|
||||
align: 'center',
|
||||
hideInTable: true,
|
||||
showSorterTooltip: false
|
||||
},
|
||||
{
|
||||
title: '证件号码',
|
||||
dataIndex: 'idCard',
|
||||
align: 'center',
|
||||
hideInTable: true
|
||||
},
|
||||
{
|
||||
title: '出生日期',
|
||||
dataIndex: 'birthday',
|
||||
key: 'birthday',
|
||||
hideInTable: true
|
||||
},
|
||||
{
|
||||
title: '邮箱认证',
|
||||
dataIndex: 'emailVerified',
|
||||
hideInTable: true,
|
||||
showSorterTooltip: false,
|
||||
customRender: ({ text }) => ['未认证', '已认证'][text]
|
||||
},
|
||||
{
|
||||
title: '实名认证',
|
||||
dataIndex: 'certification',
|
||||
sorter: true,
|
||||
hideInTable: true,
|
||||
customRender: ({ text }) => ['未认证', '已认证'][text]
|
||||
},
|
||||
{
|
||||
title: '审核状态',
|
||||
dataIndex: 'auditStatus',
|
||||
key: 'auditStatus',
|
||||
align: 'center',
|
||||
width: 100
|
||||
},
|
||||
{
|
||||
title: '注册时间',
|
||||
dataIndex: 'createTime',
|
||||
sorter: true,
|
||||
showSorterTooltip: false,
|
||||
ellipsis: true,
|
||||
customRender: ({ text }) => toDateString(text, 'yyyy-MM-dd HH:mm:ss')
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 160,
|
||||
fixed: 'right',
|
||||
align: 'center'
|
||||
}
|
||||
]);
|
||||
|
||||
// 默认搜索条件
|
||||
const defaultWhere = reactive({
|
||||
username: '',
|
||||
nickname: ''
|
||||
});
|
||||
|
||||
// 表格数据源
|
||||
const datasource: DatasourceFunction = ({ page, limit, where, orders }) => {
|
||||
const params = {
|
||||
...where,
|
||||
keywords: searchText.value,
|
||||
auditStatus: 0
|
||||
};
|
||||
return pageUsers({ page, limit, ...params, ...orders });
|
||||
};
|
||||
|
||||
/* 搜索 */
|
||||
const reload = (where?: UserParam) => {
|
||||
selection.value = [];
|
||||
tableRef?.value?.reload({ where });
|
||||
};
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (row?: User) => {
|
||||
current.value = row ?? null;
|
||||
showEdit.value = true;
|
||||
};
|
||||
|
||||
/* 打开用户详情弹窗 */
|
||||
const openInfo = (row?: User) => {
|
||||
current.value = row ?? null;
|
||||
showInfo.value = true;
|
||||
};
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openImport = () => {
|
||||
showImport.value = true;
|
||||
};
|
||||
|
||||
/* 删除单个 */
|
||||
const remove = (row: User) => {
|
||||
const hide = messageLoading('请求中..', 0);
|
||||
removeUser(row.userId)
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
/* 批量删除 */
|
||||
const removeBatch = () => {
|
||||
if (!selection.value.length) {
|
||||
message.error('请至少选择一条数据');
|
||||
return;
|
||||
}
|
||||
Modal.confirm({
|
||||
title: '提示',
|
||||
content: '确定要删除选中的用户吗?',
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
maskClosable: true,
|
||||
onOk: () => {
|
||||
const hide = messageLoading('请求中..', 0);
|
||||
removeUsers(selection.value.map((d) => d.userId))
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* 重置用户密码 */
|
||||
const resetPsw = (row: User) => {
|
||||
Modal.confirm({
|
||||
title: '提示',
|
||||
content: '确定要重置此用户的密码吗?',
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
maskClosable: true,
|
||||
onOk: () => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
const password = uuid(8);
|
||||
updateUserPassword(row.userId, password)
|
||||
.then(() => {
|
||||
hide();
|
||||
Modal.success({
|
||||
title: '密码重置成功',
|
||||
content: `新密码:${password}(请妥善保管并及时通知用户)`
|
||||
});
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* 修改用户状态 */
|
||||
const updateIsAdmin = (row: User) => {
|
||||
row.isAdmin = !row.isAdmin;
|
||||
updateUser(row)
|
||||
.then((msg) => {
|
||||
message.success(msg);
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
/* 打开单条审核弹窗 */
|
||||
const openAudit = (row: User) => {
|
||||
batchAudit.value = false;
|
||||
currentAuditUser.value = row;
|
||||
auditForm.userId = row.userId;
|
||||
auditForm.status = 1;
|
||||
auditForm.remark = '';
|
||||
auditTitle.value = `审核用户 - ${row.nickname || row.username}`;
|
||||
showAudit.value = true;
|
||||
};
|
||||
|
||||
/* 打开批量审核弹窗 */
|
||||
const openBatchAudit = () => {
|
||||
if (!selection.value.length) {
|
||||
message.error('请至少选择一条数据');
|
||||
return;
|
||||
}
|
||||
batchAudit.value = true;
|
||||
currentAuditUser.value = null;
|
||||
auditForm.userId = undefined;
|
||||
auditForm.status = 1;
|
||||
auditForm.remark = '';
|
||||
auditTitle.value = `批量审核(已选 ${selection.value.length} 条)`;
|
||||
showAudit.value = true;
|
||||
};
|
||||
|
||||
/* 提交审核 */
|
||||
const submitAudit = () => {
|
||||
const hide = message.loading('提交中..', 0);
|
||||
const doOne = (userId: number) =>
|
||||
auditUser(userId, { status: auditForm.status, remark: auditForm.remark });
|
||||
const tasks = batchAudit.value
|
||||
? selection.value.map((d) => doOne(d.userId as number))
|
||||
: [doOne(auditForm.userId as number)];
|
||||
Promise.all(tasks)
|
||||
.then(() => {
|
||||
hide();
|
||||
message.success('审核完成');
|
||||
showAudit.value = false;
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
/* 搜索处理 */
|
||||
const handleSearch = () => {
|
||||
reload();
|
||||
};
|
||||
|
||||
/* 导出功能 */
|
||||
const handleExport = async () => {
|
||||
if (loading.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
loading.value = true;
|
||||
message.loading('正在准备导出数据...', 0);
|
||||
|
||||
try {
|
||||
const array: (string | number)[][] = [
|
||||
[
|
||||
'用户ID',
|
||||
'头像',
|
||||
'手机号码',
|
||||
'真实姓名',
|
||||
'昵称',
|
||||
'性别',
|
||||
'邮箱',
|
||||
'可用余额',
|
||||
'可用积分',
|
||||
'注册来源',
|
||||
'注册时间'
|
||||
]
|
||||
];
|
||||
|
||||
// 构建查询参数
|
||||
const queryParams = {
|
||||
keywords: searchText.value
|
||||
};
|
||||
|
||||
// 按搜索结果导出
|
||||
const list = await listUsers(queryParams);
|
||||
|
||||
if (!list || list.length === 0) {
|
||||
message.warning('没有数据可以导出');
|
||||
loading.value = false;
|
||||
return;
|
||||
}
|
||||
|
||||
list.forEach((user: User) => {
|
||||
array.push([
|
||||
`${user.userId || ''}`,
|
||||
`${user.avatar ? '有头像' : '无头像'}`,
|
||||
`${user.phone || ''}`,
|
||||
`${user.realName || ''}`,
|
||||
`${user.nickname || ''}`,
|
||||
`${user.sex === '1' ? '男' : user.sex === '2' ? '女' : ''}`,
|
||||
`${user.email || ''}`,
|
||||
`${user.balance || '0'}`,
|
||||
`${user.points || '0'}`,
|
||||
`${user.platform || ''}`,
|
||||
`${user.createTime || ''}`
|
||||
]);
|
||||
});
|
||||
|
||||
const sheetName = `导出用户列表${dayjs(new Date()).format('YYYYMMDD')}`;
|
||||
const workbook = {
|
||||
SheetNames: [sheetName],
|
||||
Sheets: {}
|
||||
};
|
||||
const sheet = utils.aoa_to_sheet(array);
|
||||
workbook.Sheets[sheetName] = sheet;
|
||||
|
||||
// 设置列宽
|
||||
sheet['!cols'] = [
|
||||
{ wch: 10 }, // 用户ID
|
||||
{ wch: 10 }, // 头像
|
||||
{ wch: 15 }, // 手机号码
|
||||
{ wch: 15 }, // 真实姓名
|
||||
{ wch: 15 }, // 昵称
|
||||
{ wch: 8 }, // 性别
|
||||
{ wch: 20 }, // 邮箱
|
||||
{ wch: 12 }, // 可用余额
|
||||
{ wch: 12 }, // 可用积分
|
||||
{ wch: 12 }, // 注册来源
|
||||
{ wch: 20 } // 注册时间
|
||||
];
|
||||
|
||||
message.destroy();
|
||||
message.loading('正在生成Excel文件...', 0);
|
||||
|
||||
setTimeout(() => {
|
||||
writeFile(workbook, `${sheetName}.xlsx`);
|
||||
loading.value = false;
|
||||
message.destroy();
|
||||
message.success(`成功导出 ${list.length} 条记录`);
|
||||
}, 1000);
|
||||
} catch (error: any) {
|
||||
loading.value = false;
|
||||
message.destroy();
|
||||
message.error(error.message || '导出失败,请重试');
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'SystemUser'
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.user-box {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
.user-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: start;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user