|
|
@@ -1,7 +1,7 @@
|
|
|
import React, { useState } from 'react';
|
|
|
import {
|
|
|
- Button, Table, Space, Form, Input, Select,
|
|
|
- message, Modal, Card, Typography, Tag, Popconfirm
|
|
|
+ Button, Table, Space, Form, Input, Select, Modal, Card, Typography, Tag, Popconfirm,
|
|
|
+ App
|
|
|
} from 'antd';
|
|
|
import { useQuery } from '@tanstack/react-query';
|
|
|
import dayjs from 'dayjs';
|
|
|
@@ -19,6 +19,7 @@ const { Title } = Typography;
|
|
|
|
|
|
// 用户管理页面
|
|
|
export const UsersPage = () => {
|
|
|
+ const { message } = App.useApp();
|
|
|
const [searchParams, setSearchParams] = useState({
|
|
|
page: 1,
|
|
|
limit: 10,
|
|
|
@@ -155,6 +156,11 @@ export const UsersPage = () => {
|
|
|
dataIndex: 'email',
|
|
|
key: 'email',
|
|
|
},
|
|
|
+ {
|
|
|
+ title: '真实姓名',
|
|
|
+ dataIndex: 'name',
|
|
|
+ key: 'name',
|
|
|
+ },
|
|
|
{
|
|
|
title: '角色',
|
|
|
dataIndex: 'role',
|
|
|
@@ -196,9 +202,11 @@ export const UsersPage = () => {
|
|
|
|
|
|
return (
|
|
|
<div>
|
|
|
- <Title level={2}>用户管理</Title>
|
|
|
- <Card>
|
|
|
- <Form layout="inline" onFinish={handleSearch} style={{ marginBottom: 16 }}>
|
|
|
+ <div className="mb-6 flex justify-between items-center">
|
|
|
+ <Title level={2}>用户管理</Title>
|
|
|
+ </div>
|
|
|
+ <Card className="shadow-md transition-all duration-300 hover:shadow-lg">
|
|
|
+ <Form layout="inline" onFinish={handleSearch} style={{ marginBottom: 16, padding: '16px 0' }}>
|
|
|
<Form.Item name="search" label="搜索">
|
|
|
<Input placeholder="用户名/昵称/邮箱" allowClear />
|
|
|
</Form.Item>
|
|
|
@@ -226,6 +234,9 @@ export const UsersPage = () => {
|
|
|
showTotal: (total) => `共 ${total} 条记录`
|
|
|
}}
|
|
|
onChange={handleTableChange}
|
|
|
+ bordered
|
|
|
+ scroll={{ x: 'max-content' }}
|
|
|
+ rowClassName={(record, index) => index % 2 === 0 ? 'bg-white' : 'bg-gray-50'}
|
|
|
/>
|
|
|
</Card>
|
|
|
|
|
|
@@ -239,14 +250,20 @@ export const UsersPage = () => {
|
|
|
form.resetFields();
|
|
|
}}
|
|
|
width={600}
|
|
|
+ centered
|
|
|
+ destroyOnClose
|
|
|
+ maskClosable={false}
|
|
|
>
|
|
|
<Form
|
|
|
form={form}
|
|
|
layout="vertical"
|
|
|
+ labelCol={{ span: 5 }}
|
|
|
+ wrapperCol={{ span: 19 }}
|
|
|
>
|
|
|
<Form.Item
|
|
|
name="username"
|
|
|
label="用户名"
|
|
|
+ required
|
|
|
rules={[
|
|
|
{ required: true, message: '请输入用户名' },
|
|
|
{ min: 3, message: '用户名至少3个字符' }
|
|
|
@@ -258,7 +275,7 @@ export const UsersPage = () => {
|
|
|
<Form.Item
|
|
|
name="nickname"
|
|
|
label="昵称"
|
|
|
- rules={[{ required: true, message: '请输入昵称' }]}
|
|
|
+ rules={[{ required: false, message: '请输入昵称' }]}
|
|
|
>
|
|
|
<Input placeholder="请输入昵称" />
|
|
|
</Form.Item>
|
|
|
@@ -285,10 +302,19 @@ export const UsersPage = () => {
|
|
|
<Input placeholder="请输入手机号" />
|
|
|
</Form.Item>
|
|
|
|
|
|
+ <Form.Item
|
|
|
+ name="name"
|
|
|
+ label="真实姓名"
|
|
|
+ rules={[{ required: false, message: '请输入真实姓名' }]}
|
|
|
+ >
|
|
|
+ <Input placeholder="请输入真实姓名" />
|
|
|
+ </Form.Item>
|
|
|
+
|
|
|
{!editingUser && (
|
|
|
<Form.Item
|
|
|
name="password"
|
|
|
label="密码"
|
|
|
+ required
|
|
|
rules={[
|
|
|
{ required: true, message: '请输入密码' },
|
|
|
{ min: 6, message: '密码至少6个字符' }
|
|
|
@@ -301,6 +327,7 @@ export const UsersPage = () => {
|
|
|
<Form.Item
|
|
|
name="isDisabled"
|
|
|
label="状态"
|
|
|
+ required
|
|
|
rules={[{ required: true, message: '请选择状态' }]}
|
|
|
>
|
|
|
<Select placeholder="请选择状态">
|