feat: 1:优化token查询页 2:用户管理页面新增修改密码功能 3:调整景区与二维码关系
This commit is contained in:
@@ -1,10 +1,11 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { QueryFilter } from '@ant-design/pro-components';
|
import { QueryFilter } from '@ant-design/pro-components';
|
||||||
|
import { Button } from 'antd';
|
||||||
import TenantSelector from '@/components/ui/TenantSelector';
|
import TenantSelector from '@/components/ui/TenantSelector';
|
||||||
import { tenantApi } from '@/services/tenant';
|
import { tenantApi } from '@/services/tenant';
|
||||||
|
|
||||||
export interface SearchBarPlusProps {
|
export interface SearchBarPlusProps {
|
||||||
// QueryFilter 透传属性(常用)
|
// QueryFilter 常用属性
|
||||||
defaultCollapsed?: boolean;
|
defaultCollapsed?: boolean;
|
||||||
split?: boolean;
|
split?: boolean;
|
||||||
span?: number | { xs?: number; sm?: number; md?: number; lg?: number; xl?: number; xxl?: number };
|
span?: number | { xs?: number; sm?: number; md?: number; lg?: number; xl?: number; xxl?: number };
|
||||||
@@ -14,12 +15,14 @@ export interface SearchBarPlusProps {
|
|||||||
children?: React.ReactNode;
|
children?: React.ReactNode;
|
||||||
// 是否显示租户筛选(默认显示)
|
// 是否显示租户筛选(默认显示)
|
||||||
showTenant?: boolean;
|
showTenant?: boolean;
|
||||||
// 租户变化回调:用于触发表格 reload 等
|
// 租户变化回调:用于触发表格 reload
|
||||||
onTenantChanged?: (tenantId: string, includeChildren: boolean) => void;
|
onTenantChanged?: (tenantId: string, includeChildren: boolean) => void;
|
||||||
// 租户筛选放置位置:start 放在最前,end 放在最后(默认 start)
|
// 租户筛选放置位置:start 放在最前,end 放在最后(默认 start)
|
||||||
tenantPosition?: 'start' | 'end';
|
tenantPosition?: 'start' | 'end';
|
||||||
// 是否调用后端“切换查询租户”接口(默认不调用,避免跨页面副作用)
|
// 是否调用后端“切换查询租户”接口(默认不调用,避免跨页面副作用)
|
||||||
useSwitchTenant?: boolean;
|
useSwitchTenant?: boolean;
|
||||||
|
// 是否隐藏重置按钮(默认 false)
|
||||||
|
hideReset?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SearchBarPlus: React.FC<SearchBarPlusProps> = ({
|
const SearchBarPlus: React.FC<SearchBarPlusProps> = ({
|
||||||
@@ -33,6 +36,7 @@ const SearchBarPlus: React.FC<SearchBarPlusProps> = ({
|
|||||||
onTenantChanged,
|
onTenantChanged,
|
||||||
tenantPosition = 'start',
|
tenantPosition = 'start',
|
||||||
useSwitchTenant = false,
|
useSwitchTenant = false,
|
||||||
|
hideReset = false,
|
||||||
}) => {
|
}) => {
|
||||||
const handleFinish = async (values: Record<string, any>) => {
|
const handleFinish = async (values: Record<string, any>) => {
|
||||||
try {
|
try {
|
||||||
@@ -52,6 +56,17 @@ const SearchBarPlus: React.FC<SearchBarPlusProps> = ({
|
|||||||
span={span as any}
|
span={span as any}
|
||||||
form={form}
|
form={form}
|
||||||
onFinish={handleFinish}
|
onFinish={handleFinish}
|
||||||
|
submitter={
|
||||||
|
hideReset
|
||||||
|
? {
|
||||||
|
render: (props: any) => [
|
||||||
|
<Button key="submit" type="primary" onClick={() => props?.form?.submit?.()}>
|
||||||
|
查询
|
||||||
|
</Button>,
|
||||||
|
],
|
||||||
|
}
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
>
|
>
|
||||||
{showTenant && tenantPosition === 'start' ? <TenantSelector /> : null}
|
{showTenant && tenantPosition === 'start' ? <TenantSelector /> : null}
|
||||||
{children}
|
{children}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { ActionBar, GlassCard, GradientButton, SearchBarPlus } from '@/component
|
|||||||
import { PlusOutlined } from '@ant-design/icons';
|
import { PlusOutlined } from '@ant-design/icons';
|
||||||
import { ordersApi } from '@/services/orders';
|
import { ordersApi } from '@/services/orders';
|
||||||
import TourismForm, { TourismItem } from './components/TourismForm';
|
import TourismForm, { TourismItem } from './components/TourismForm';
|
||||||
|
import QrcodeListModal from './components/QrcodeListModal';
|
||||||
import { tenantApi } from '@/services/tenant';
|
import { tenantApi } from '@/services/tenant';
|
||||||
|
|
||||||
const TourismPage: React.FC = () => {
|
const TourismPage: React.FC = () => {
|
||||||
@@ -12,6 +13,8 @@ const TourismPage: React.FC = () => {
|
|||||||
const [editOpen, setEditOpen] = useState(false);
|
const [editOpen, setEditOpen] = useState(false);
|
||||||
const [current, setCurrent] = useState<TourismItem | undefined>(undefined);
|
const [current, setCurrent] = useState<TourismItem | undefined>(undefined);
|
||||||
const [params, setParams] = useState<Record<string, any>>({});
|
const [params, setParams] = useState<Record<string, any>>({});
|
||||||
|
const [qrcodeOpen, setQrcodeOpen] = useState(false);
|
||||||
|
const [qrcodeTourism, setQrcodeTourism] = useState<TourismItem | undefined>(undefined);
|
||||||
|
|
||||||
// 首次进入时,默认按“当前租户 + 包含下级租户”查询,避免全量数据
|
// 首次进入时,默认按“当前租户 + 包含下级租户”查询,避免全量数据
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -54,6 +57,7 @@ const TourismPage: React.FC = () => {
|
|||||||
key: 'action',
|
key: 'action',
|
||||||
render: (_: any, record: TourismItem) => (
|
render: (_: any, record: TourismItem) => (
|
||||||
<Space>
|
<Space>
|
||||||
|
<a onClick={() => { setQrcodeTourism(record); setQrcodeOpen(true); }}>打卡点</a>
|
||||||
<a onClick={() => { setCurrent(record); setEditOpen(true); }}>编辑</a>
|
<a onClick={() => { setCurrent(record); setEditOpen(true); }}>编辑</a>
|
||||||
<Popconfirm
|
<Popconfirm
|
||||||
title={`确认删除项目[${record.tourismName}]?`}
|
title={`确认删除项目[${record.tourismName}]?`}
|
||||||
@@ -144,6 +148,15 @@ const TourismPage: React.FC = () => {
|
|||||||
} finally { hide(); }
|
} finally { hide(); }
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
{qrcodeOpen && qrcodeTourism?.id ? (
|
||||||
|
<QrcodeListModal
|
||||||
|
open={qrcodeOpen}
|
||||||
|
onOpenChange={setQrcodeOpen}
|
||||||
|
tourismId={qrcodeTourism.id as number}
|
||||||
|
tourismName={qrcodeTourism.tourismName}
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
</PageContainer>
|
</PageContainer>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,30 +1,14 @@
|
|||||||
import React, { useEffect, useRef, useState } from 'react';
|
import React, { useRef } from 'react';
|
||||||
import { PageContainer, ProFormSelect, ProFormText, ProTable } from '@ant-design/pro-components';
|
import { PageContainer, ProTable } from '@ant-design/pro-components';
|
||||||
import type { ActionType } from '@ant-design/pro-components';
|
import type { ActionType, ProColumns } from '@ant-design/pro-components';
|
||||||
import { Popconfirm, Form, message } from 'antd';
|
import { Popconfirm, message, Button } from 'antd';
|
||||||
import { roleApi } from '@/services/role';
|
|
||||||
import { tokenApi, TokenItem } from '@/services/token';
|
import { tokenApi, TokenItem } from '@/services/token';
|
||||||
import { GlassCard, SearchBarPlus } from '@/components/ui';
|
import { GlassCard } from '@/components/ui';
|
||||||
|
|
||||||
const TokenPage: React.FC = () => {
|
const TokenPage: React.FC = () => {
|
||||||
const [apps, setApps] = useState<any[]>([]);
|
|
||||||
const [params, setParams] = useState<{ tenantId?: string; username?: string }>({});
|
|
||||||
const [form] = Form.useForm();
|
|
||||||
const actionRef = useRef<ActionType>();
|
const actionRef = useRef<ActionType>();
|
||||||
|
|
||||||
useEffect(() => {
|
const columns: ProColumns<TokenItem>[] = [
|
||||||
(async () => {
|
|
||||||
const appData = (await roleApi.apps()) || [];
|
|
||||||
setApps(appData);
|
|
||||||
if (appData.length > 0) {
|
|
||||||
const tenantId = appData[0].clientId;
|
|
||||||
setParams({ tenantId });
|
|
||||||
form.setFieldsValue({ tenantId });
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const columns = [
|
|
||||||
{ dataIndex: 'index', valueType: 'indexBorder' },
|
{ dataIndex: 'index', valueType: 'indexBorder' },
|
||||||
{ title: 'Token', dataIndex: 'tokenValue', width: 200 },
|
{ title: 'Token', dataIndex: 'tokenValue', width: 200 },
|
||||||
{ title: '过期时间', dataIndex: 'expiration', valueType: 'dateTime' },
|
{ title: '过期时间', dataIndex: 'expiration', valueType: 'dateTime' },
|
||||||
@@ -33,7 +17,8 @@ const TokenPage: React.FC = () => {
|
|||||||
{ title: '所属应用', dataIndex: 'clientId' },
|
{ title: '所属应用', dataIndex: 'clientId' },
|
||||||
{ title: '账号类型', dataIndex: 'accountType' },
|
{ title: '账号类型', dataIndex: 'accountType' },
|
||||||
{
|
{
|
||||||
title: '操作', key: 'action',
|
title: '操作',
|
||||||
|
key: 'action',
|
||||||
render: (_: any, entity: TokenItem) => (
|
render: (_: any, entity: TokenItem) => (
|
||||||
<Popconfirm
|
<Popconfirm
|
||||||
title={`确认删除 Token?`}
|
title={`确认删除 Token?`}
|
||||||
@@ -45,40 +30,31 @@ const TokenPage: React.FC = () => {
|
|||||||
actionRef.current?.reload();
|
actionRef.current?.reload();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
message.error('删除失败');
|
message.error('删除失败');
|
||||||
} finally { hide(); }
|
} finally {
|
||||||
|
hide();
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<a>删除</a>
|
<a>删除</a>
|
||||||
</Popconfirm>
|
</Popconfirm>
|
||||||
)
|
),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PageContainer header={{ title: 'Token 管理' }}>
|
<PageContainer header={{ title: 'Token 管理' }}>
|
||||||
<SearchBarPlus
|
|
||||||
defaultCollapsed
|
|
||||||
split
|
|
||||||
span={6}
|
|
||||||
onTenantChanged={() => actionRef.current?.reload?.()}
|
|
||||||
onFinish={async (values) => setParams(values)}
|
|
||||||
>
|
|
||||||
<ProFormSelect
|
|
||||||
name="tenantId"
|
|
||||||
label="所属应用"
|
|
||||||
fieldProps={{ allowClear: false }}
|
|
||||||
options={apps.map((item) => ({ label: item.clientId, value: item.clientId }))}
|
|
||||||
/>
|
|
||||||
<ProFormText name="username" label="搜索" placeholder="请输入用户名" />
|
|
||||||
</SearchBarPlus>
|
|
||||||
|
|
||||||
<GlassCard>
|
<GlassCard>
|
||||||
<ProTable<TokenItem>
|
<ProTable<TokenItem>
|
||||||
rowKey="tokenValue"
|
rowKey="tokenValue"
|
||||||
headerTitle="Token 列表"
|
headerTitle="Token 列表"
|
||||||
actionRef={actionRef}
|
actionRef={actionRef}
|
||||||
request={async (p) => tokenApi.page({ ...p, ...params } as any)}
|
request={async (p) => tokenApi.page({ ...p } as any)}
|
||||||
columns={columns as any}
|
columns={columns as any}
|
||||||
|
toolBarRender={() => [
|
||||||
|
<Button key="refresh" type="primary" onClick={() => actionRef.current?.reload?.()}>
|
||||||
|
查询
|
||||||
|
</Button>,
|
||||||
|
]}
|
||||||
search={false}
|
search={false}
|
||||||
pagination={{ showSizeChanger: true, showQuickJumper: true }}
|
pagination={{ showSizeChanger: true, showQuickJumper: true }}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -11,12 +11,13 @@ export interface UserTableRef {
|
|||||||
export interface UserTableProps {
|
export interface UserTableProps {
|
||||||
onEdit: (record: UserItem) => void;
|
onEdit: (record: UserItem) => void;
|
||||||
onResetPassword: (record: UserItem) => void;
|
onResetPassword: (record: UserItem) => void;
|
||||||
|
onChangePassword: (record: UserItem) => void;
|
||||||
onDelete: (record: UserItem) => void;
|
onDelete: (record: UserItem) => void;
|
||||||
// 额外查询参数(由外部查询条件统一注入)
|
// 额外查询参数(由外部查询条件统一注入)
|
||||||
extraParams?: Record<string, any>;
|
extraParams?: Record<string, any>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const UserTable = forwardRef<UserTableRef, UserTableProps>(({ onEdit, onResetPassword, onDelete, extraParams }, ref) => {
|
const UserTable = forwardRef<UserTableRef, UserTableProps>(({ onEdit, onResetPassword, onChangePassword, onDelete, extraParams }, ref) => {
|
||||||
const actionRef = useRef<ActionType>();
|
const actionRef = useRef<ActionType>();
|
||||||
|
|
||||||
useImperativeHandle(ref, () => ({
|
useImperativeHandle(ref, () => ({
|
||||||
@@ -35,7 +36,7 @@ const UserTable = forwardRef<UserTableRef, UserTableProps>(({ onEdit, onResetPas
|
|||||||
{ title: '用户名', dataIndex: 'username' },
|
{ title: '用户名', dataIndex: 'username' },
|
||||||
{ title: '用户昵称', dataIndex: 'nickname' },
|
{ title: '用户昵称', dataIndex: 'nickname' },
|
||||||
{ title: '手机号', dataIndex: 'mobile' },
|
{ title: '手机号', dataIndex: 'mobile' },
|
||||||
{ title: '性别', dataIndex: 'sex', valueType: 'select', valueEnum: { 0: { text: '男' }, 1: { text: '女' } }, width: 80 },
|
{ title: '性别', dataIndex: 'sex', valueType: 'select', valueEnum: { 0: { text: '女' }, 1: { text: '男' } }, width: 80 },
|
||||||
{ title: '创建时间', dataIndex: 'createTime', valueType: 'dateTime', search: false },
|
{ title: '创建时间', dataIndex: 'createTime', valueType: 'dateTime', search: false },
|
||||||
{
|
{
|
||||||
title: '状态', dataIndex: 'enabled', search: false,
|
title: '状态', dataIndex: 'enabled', search: false,
|
||||||
@@ -44,10 +45,11 @@ const UserTable = forwardRef<UserTableRef, UserTableProps>(({ onEdit, onResetPas
|
|||||||
)
|
)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '操作', valueType: 'option', width: 220,
|
title: '操作', valueType: 'option', width: 280,
|
||||||
render: (_, entity) => (
|
render: (_, entity) => (
|
||||||
<Space>
|
<Space>
|
||||||
<a onClick={() => onEdit(entity)}>编辑</a>
|
<a onClick={() => onEdit(entity)}>编辑</a>
|
||||||
|
<a onClick={() => onChangePassword(entity)}>修改密码</a>
|
||||||
<a onClick={() => onResetPassword(entity)}>重置密码</a>
|
<a onClick={() => onResetPassword(entity)}>重置密码</a>
|
||||||
<Popconfirm title={`确认删除用户[${entity.username}]?`} onConfirm={() => onDelete(entity)}>
|
<Popconfirm title={`确认删除用户[${entity.username}]?`} onConfirm={() => onDelete(entity)}>
|
||||||
<a style={{ color: '#1677ff' }}>删除</a>
|
<a style={{ color: '#1677ff' }}>删除</a>
|
||||||
@@ -71,7 +73,7 @@ const UserTable = forwardRef<UserTableRef, UserTableProps>(({ onEdit, onResetPas
|
|||||||
const { data, total } = await systemApi.users({ ...(safeP as any), ...(safeExtra as any) } as any);
|
const { data, total } = await systemApi.users({ ...(safeP as any), ...(safeExtra as any) } as any);
|
||||||
return { data, total, success: true };
|
return { data, total, success: true };
|
||||||
}}
|
}}
|
||||||
pagination={{ pageSize: 10 }}
|
pagination={{ pageSize: 20 }}
|
||||||
// 统一关闭 ProTable 自带搜索,由 SearchBarPlus 统一驱动
|
// 统一关闭 ProTable 自带搜索,由 SearchBarPlus 统一驱动
|
||||||
search={false}
|
search={false}
|
||||||
toolBarRender={false}
|
toolBarRender={false}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { systemApi, UserItem } from '@/services/system';
|
|||||||
import UserTable, { UserTableRef } from './components/UserTable';
|
import UserTable, { UserTableRef } from './components/UserTable';
|
||||||
import Toolbar from './components/Toolbar';
|
import Toolbar from './components/Toolbar';
|
||||||
import UserForm from './components/UserForm';
|
import UserForm from './components/UserForm';
|
||||||
|
import ChangePasswordModal from './components/ChangePasswordModal';
|
||||||
|
|
||||||
const UsersPage: React.FC = () => {
|
const UsersPage: React.FC = () => {
|
||||||
const tableRef = useRef<UserTableRef>(null);
|
const tableRef = useRef<UserTableRef>(null);
|
||||||
@@ -15,18 +16,27 @@ const UsersPage: React.FC = () => {
|
|||||||
const [createVisible, setCreateVisible] = useState(false);
|
const [createVisible, setCreateVisible] = useState(false);
|
||||||
const [editVisible, setEditVisible] = useState(false);
|
const [editVisible, setEditVisible] = useState(false);
|
||||||
const [currentRow, setCurrentRow] = useState<UserItem | undefined>(undefined);
|
const [currentRow, setCurrentRow] = useState<UserItem | undefined>(undefined);
|
||||||
|
const [pwdVisible, setPwdVisible] = useState(false);
|
||||||
|
const [pwdUser, setPwdUser] = useState<UserItem | undefined>(undefined);
|
||||||
|
|
||||||
const addUser = async (values: UserItem & { company?: string; type?: string }) => {
|
const addUser = async (values: UserItem & { company?: string; type?: string }) => {
|
||||||
const hide = message.loading('正在添加');
|
const hide = message.loading('正在添加');
|
||||||
try {
|
try {
|
||||||
await systemApi.saveOrUpdateUser({ ...(values as any), roleId: (values as any)?.roleIds ? (values as any).roleIds.join(',') : (values as any)?.roleId } as any);
|
const res: any = await systemApi.saveOrUpdateUserRaw({
|
||||||
|
...(values as any),
|
||||||
|
roleId: (values as any)?.roleIds ? (values as any).roleIds.join(',') : (values as any)?.roleId,
|
||||||
|
} as any);
|
||||||
|
const code = res?.resp_code ?? res?.code;
|
||||||
|
if (typeof code === 'number' && code !== 0) {
|
||||||
|
throw new Error(res?.resp_msg || res?.message || '添加用户失败');
|
||||||
|
}
|
||||||
hide();
|
hide();
|
||||||
message.success('添加用户成功');
|
message.success('添加用户成功');
|
||||||
tableRef.current?.reload();
|
tableRef.current?.reload();
|
||||||
return true;
|
return true;
|
||||||
} catch (e) {
|
} catch (e: any) {
|
||||||
hide();
|
hide();
|
||||||
message.error('添加用户失败');
|
message.error(e?.message || '添加用户失败');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -34,14 +44,22 @@ const UsersPage: React.FC = () => {
|
|||||||
const editUser = async (values: UserItem & { company?: string; type?: string }) => {
|
const editUser = async (values: UserItem & { company?: string; type?: string }) => {
|
||||||
const hide = message.loading('正在更新');
|
const hide = message.loading('正在更新');
|
||||||
try {
|
try {
|
||||||
await systemApi.saveOrUpdateUser({ ...(currentRow as any), ...(values as any), roleId: (values as any)?.roleIds ? (values as any).roleIds.join(',') : (values as any)?.roleId } as any);
|
const res: any = await systemApi.saveOrUpdateUserRaw({
|
||||||
|
...(currentRow as any),
|
||||||
|
...(values as any),
|
||||||
|
roleId: (values as any)?.roleIds ? (values as any).roleIds.join(',') : (values as any)?.roleId,
|
||||||
|
} as any);
|
||||||
|
const code = res?.resp_code ?? res?.code;
|
||||||
|
if (typeof code === 'number' && code !== 0) {
|
||||||
|
throw new Error(res?.resp_msg || res?.message || '修改用户失败');
|
||||||
|
}
|
||||||
hide();
|
hide();
|
||||||
message.success('修改用户成功');
|
message.success('修改用户成功');
|
||||||
tableRef.current?.reload();
|
tableRef.current?.reload();
|
||||||
return true;
|
return true;
|
||||||
} catch (e) {
|
} catch (e: any) {
|
||||||
hide();
|
hide();
|
||||||
message.error('修改用户失败');
|
message.error(e?.message || '修改用户失败');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -58,6 +76,28 @@ const UsersPage: React.FC = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const openChangePwd = (record: UserItem) => {
|
||||||
|
setPwdUser(record);
|
||||||
|
setPwdVisible(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
const submitChangePwd = async (values: { newPassword: string; confirmPassword: string }) => {
|
||||||
|
const hide = message.loading('正在修改密码');
|
||||||
|
try {
|
||||||
|
await systemApi.changePassword(pwdUser!.id!, values.newPassword);
|
||||||
|
hide();
|
||||||
|
message.success('修改密码成功');
|
||||||
|
setPwdVisible(false);
|
||||||
|
setPwdUser(undefined);
|
||||||
|
tableRef.current?.reload();
|
||||||
|
return true;
|
||||||
|
} catch (e) {
|
||||||
|
hide();
|
||||||
|
message.error('修改密码失败');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const delUser = async (record: UserItem) => {
|
const delUser = async (record: UserItem) => {
|
||||||
const hide = message.loading('正在删除');
|
const hide = message.loading('正在删除');
|
||||||
try {
|
try {
|
||||||
@@ -83,6 +123,7 @@ const UsersPage: React.FC = () => {
|
|||||||
defaultCollapsed={false}
|
defaultCollapsed={false}
|
||||||
split
|
split
|
||||||
span={6}
|
span={6}
|
||||||
|
hideReset
|
||||||
showTenant={!isAppType}
|
showTenant={!isAppType}
|
||||||
onTenantChanged={(tenantId, includeChildren) => {
|
onTenantChanged={(tenantId, includeChildren) => {
|
||||||
// 租户切换时,直接更新查询参数,ProTable 会因 params 变更自动请求
|
// 租户切换时,直接更新查询参数,ProTable 会因 params 变更自动请求
|
||||||
@@ -106,6 +147,7 @@ const UsersPage: React.FC = () => {
|
|||||||
<UserTable
|
<UserTable
|
||||||
ref={tableRef}
|
ref={tableRef}
|
||||||
onEdit={(r) => { setCurrentRow(r); setEditVisible(true); }}
|
onEdit={(r) => { setCurrentRow(r); setEditVisible(true); }}
|
||||||
|
onChangePassword={(r) => openChangePwd(r)}
|
||||||
onResetPassword={(r) => resetPwd(r)}
|
onResetPassword={(r) => resetPwd(r)}
|
||||||
onDelete={(r) => delUser(r)}
|
onDelete={(r) => delUser(r)}
|
||||||
// 通过 __refresh 强制区分每次点击
|
// 通过 __refresh 强制区分每次点击
|
||||||
@@ -113,11 +155,14 @@ const UsersPage: React.FC = () => {
|
|||||||
/>
|
/>
|
||||||
</GlassCard>
|
</GlassCard>
|
||||||
|
|
||||||
{/* 新建(仅系统用户) */}
|
{/* 新建(仅系统用户)*/}
|
||||||
<UserForm title="新建用户" visible={createVisible} onVisibleChange={setCreateVisible} onFinish={addUser} showCompany={!isAppType ? true : false} />
|
<UserForm title="新建用户" visible={createVisible} onVisibleChange={setCreateVisible} onFinish={addUser} showCompany={!isAppType ? true : false} />
|
||||||
|
|
||||||
{/* 编辑 */}
|
{/* 编辑 */}
|
||||||
<UserForm title="修改用户" visible={editVisible} onVisibleChange={setEditVisible} onFinish={editUser} initialValues={currentRow} showCompany={!isAppType ? true : false} />
|
<UserForm title="修改用户" visible={editVisible} onVisibleChange={setEditVisible} onFinish={editUser} initialValues={currentRow} showCompany={!isAppType ? true : false} />
|
||||||
|
|
||||||
|
{/* 修改密码 */}
|
||||||
|
<ChangePasswordModal visible={pwdVisible} user={pwdUser} onVisibleChange={setPwdVisible} onFinish={submitChangePwd} />
|
||||||
</PageContainer>
|
</PageContainer>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -49,6 +49,13 @@ export const ordersApi = {
|
|||||||
return (res as any).data || res;
|
return (res as any).data || res;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// 按景区ID查询二维码列表
|
||||||
|
qrcodeListByTourism: async (params: { current?: number; pageSize?: number; tourismId: number; [k: string]: any }) => {
|
||||||
|
const { current, pageSize, ...rest } = params || {};
|
||||||
|
const res = await request('/api-order/qrcode', { method: 'GET', params: { page: current, limit: pageSize, ...rest } });
|
||||||
|
return { data: (res as any).data, total: (res as any).count };
|
||||||
|
},
|
||||||
|
|
||||||
// 旅游景区
|
// 旅游景区
|
||||||
tourism: async (params: { current?: number; pageSize?: number; [k: string]: any }) => {
|
tourism: async (params: { current?: number; pageSize?: number; [k: string]: any }) => {
|
||||||
const { current, pageSize, ...rest } = params || {};
|
const { current, pageSize, ...rest } = params || {};
|
||||||
|
|||||||
@@ -40,6 +40,11 @@ export const systemApi = {
|
|||||||
const res = await request('/api-user/users/saveOrUpdate', { method: 'POST', data });
|
const res = await request('/api-user/users/saveOrUpdate', { method: 'POST', data });
|
||||||
return (res as any).data || res;
|
return (res as any).data || res;
|
||||||
},
|
},
|
||||||
|
// 原样返回后端包装,便于上层拿到 resp_code/resp_msg 做精确提示
|
||||||
|
saveOrUpdateUserRaw: async (data: Partial<UserItem>) => {
|
||||||
|
const res = await request('/api-user/users/saveOrUpdate', { method: 'POST', data });
|
||||||
|
return res as any;
|
||||||
|
},
|
||||||
|
|
||||||
// 启用/禁用
|
// 启用/禁用
|
||||||
updateEnabled: async (id: number, enabled: boolean) => {
|
updateEnabled: async (id: number, enabled: boolean) => {
|
||||||
@@ -52,6 +57,15 @@ export const systemApi = {
|
|||||||
const res = await request(`/api-user/users/${id}/password`, { method: 'PUT' });
|
const res = await request(`/api-user/users/${id}/password`, { method: 'PUT' });
|
||||||
return (res as any).data || res;
|
return (res as any).data || res;
|
||||||
},
|
},
|
||||||
|
// 修改密码(支持管理员为指定用户设置自定义密码,或用户自助修改)
|
||||||
|
// 后端签名:PUT /users/password,Body: { id, oldPassword?, newPassword }
|
||||||
|
changePassword: async (id: number, newPassword: string, oldPassword?: string) => {
|
||||||
|
const res = await request('/api-user/users/password', {
|
||||||
|
method: 'PUT',
|
||||||
|
data: { id, newPassword, oldPassword },
|
||||||
|
});
|
||||||
|
return (res as any).data || res;
|
||||||
|
},
|
||||||
|
|
||||||
// 删除用户
|
// 删除用户
|
||||||
deleteUser: async (id: number) => {
|
deleteUser: async (id: number) => {
|
||||||
|
|||||||
@@ -10,9 +10,12 @@ export interface TokenItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const tokenApi = {
|
export const tokenApi = {
|
||||||
page: async (params: { current?: number; pageSize?: number; tenantId: string; username?: string }) => {
|
page: async (params: { current?: number; pageSize?: number; tenantId?: string; username?: string }) => {
|
||||||
if (!params?.tenantId) return { data: [], total: 0 };
|
const p2 = { tenantId: 'webApp', ...params };
|
||||||
const res = await request('/api-uaa/tokens', { method: 'GET', params: { page: params.current, limit: params.pageSize, ...params } });
|
const res = await request('/api-uaa/tokens', {
|
||||||
|
method: 'GET',
|
||||||
|
params: { page: p2.current, limit: p2.pageSize, ...p2 },
|
||||||
|
});
|
||||||
const data = (res as any).data;
|
const data = (res as any).data;
|
||||||
const total = (res as any).count ?? data?.length ?? 0;
|
const total = (res as any).count ?? data?.length ?? 0;
|
||||||
return { data, total } as { data: TokenItem[]; total: number };
|
return { data, total } as { data: TokenItem[]; total: number };
|
||||||
|
|||||||
Reference in New Issue
Block a user