From 1d9d8a19f9d29a749d8b005e30824e93fa5fb9a3 Mon Sep 17 00:00:00 2001 From: tikkhun Date: Sat, 29 Nov 2025 10:07:45 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E7=94=A8=E6=88=B7=E7=AE=A1=E7=90=86):=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=94=A8=E6=88=B7=E7=BC=96=E8=BE=91=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=92=8C=E7=8A=B6=E6=80=81=E5=88=87=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增用户编辑表单和接口调用 - 添加用户启用/禁用功能及状态标签显示 - 优化用户列表查询参数处理 - 统一站点名称字段为name --- src/pages/Organiza/User/index.tsx | 134 ++++++++++++++++++++++++++---- src/pages/Site/List/index.tsx | 4 +- 2 files changed, 118 insertions(+), 20 deletions(-) diff --git a/src/pages/Organiza/User/index.tsx b/src/pages/Organiza/User/index.tsx index 16c3684..1e97f3f 100644 --- a/src/pages/Organiza/User/index.tsx +++ b/src/pages/Organiza/User/index.tsx @@ -1,6 +1,8 @@ import { usercontrollerAdduser, usercontrollerListusers, + usercontrollerToggleactive, + usercontrollerUpdateuser, } from '@/servers/api/user'; import { PlusOutlined } from '@ant-design/icons'; import { @@ -9,34 +11,35 @@ import { PageContainer, ProColumns, ProForm, + ProFormSwitch, ProFormText, + ProFormTextArea, ProTable, } from '@ant-design/pro-components'; -import { App, Button } from 'antd'; +import { App, Button, Tag } from 'antd'; import { useRef } from 'react'; const ListPage: React.FC = () => { const actionRef = useRef(); + const { message } = App.useApp(); const columns: ProColumns[] = [ { title: '用户名', dataIndex: 'username', }, - { - title: '激活', - dataIndex: 'isActive', - valueEnum: { - true: { - text: '是', - }, - false: { - text: '否', - }, - }, - }, + { title: '超管', dataIndex: 'isSuper', + valueType: 'select', + valueEnum: { + true: { text: '是' }, + false: { text: '否' }, + }, + }, + { + title: '激活', + dataIndex: 'isActive', valueEnum: { true: { text: '是', @@ -45,6 +48,39 @@ const ListPage: React.FC = () => { text: '否', }, }, + render: (_, record: any) => ( + + {record?.isActive ? '启用中' : '已禁用'} + + ), + }, + { + title: '备注', + dataIndex: 'remark', + ellipsis: true, + }, + { + title: '操作', + dataIndex: 'option', + valueType: 'option', + render: (_, record: any) => ( + <> + + + + ), }, ]; return ( @@ -53,15 +89,23 @@ const ListPage: React.FC = () => { headerTitle="查询表格" actionRef={actionRef} rowKey="id" + request={async (params) => { - const { data, success } = await usercontrollerListusers(params); - + const { current = 1, pageSize = 10, username, isActive, isSuper, remark } = params as any; + console.log(`params`,params) + const qp: any = { current, pageSize }; + if (username) qp.username = username; + if (typeof isActive !== 'undefined' && isActive !== '') qp.isActive = String(isActive); + if (typeof isSuper !== 'undefined' && isSuper !== '') qp.isSuper = String(isSuper); + if (remark) qp.remark = remark; + const { data, success } = await usercontrollerListusers({ params: qp }); return { total: data?.total || 0, data: data?.items || [], success, }; }} + columns={columns} toolBarRender={() => []} /> @@ -101,6 +145,58 @@ const CreateForm: React.FC<{ message.error(error.message); } }} + > + + + + + + + + + ); +}; + +const EditForm: React.FC<{ + tableRef: React.MutableRefObject; + record: any; +}> = ({ tableRef, record }) => { + const { message } = App.useApp(); + return ( + 编辑} + initialValues={{ + username: record.username, + isSuper: record.isSuper, + isAdmin: record.isAdmin, + remark: record.remark, + }} + onFinish={async (values: any) => { + try { + // 中文注释:更新用户,密码可选填 + const { success, message: err } = await usercontrollerUpdateuser({ id: record.id }, values); + if (!success) throw new Error(err); + tableRef.current?.reload(); + message.success('更新成功'); + return true; + } catch (error: any) { + message.error(error.message); + return false; + } + }} > + + + ); diff --git a/src/pages/Site/List/index.tsx b/src/pages/Site/List/index.tsx index 0451707..7a7f870 100644 --- a/src/pages/Site/List/index.tsx +++ b/src/pages/Site/List/index.tsx @@ -73,7 +73,7 @@ const SiteList: React.FC = () => { sorter: true, hideInSearch: true, }, - { title: '站点名称', dataIndex: 'siteName', width: 220 }, + { title: '名称', dataIndex: 'name', width: 220 }, { title: 'API 地址', dataIndex: 'apiUrl', width: 280, hideInSearch: true }, { title: 'SKU 前缀', @@ -260,7 +260,7 @@ const SiteList: React.FC = () => { > {/* 站点名称,必填 */}