Files
gofly-platform-services/zlt-web/react-web-next/src/pages/search/User/index.tsx
T

51 lines
2.5 KiB
TypeScript
Raw Normal View History

import React, { useRef, useState } from 'react';
import { PageContainer, ProFormSelect, ProFormText, ProTable } from '@ant-design/pro-components';
import type { ProColumns, ActionType } from '@ant-design/pro-components';
import { systemApi } from '@/services/system';
import { ActionBar, SearchBarPlus } from '@/components/ui';
const UserSearchPage: React.FC = () => {
const [params, setParams] = useState<Record<string, any>>({});
const actionRef = useRef<ActionType>();
const columns: ProColumns<any>[] = [
{ dataIndex: 'index', valueType: 'indexBorder', width: 48 },
{ title: '用户ID', dataIndex: 'id', width: 100 },
{ title: '账号', dataIndex: 'username', render: (_, r) => <span dangerouslySetInnerHTML={{ __html: r.username || '' }} /> },
{ title: '用户昵称', dataIndex: 'nickname', render: (_, r) => <span dangerouslySetInnerHTML={{ __html: r.nickname || '' }} /> },
{ title: '手机号', dataIndex: 'mobile', render: (_, r) => <span dangerouslySetInnerHTML={{ __html: r.mobile || '' }} /> },
{ title: '性别', dataIndex: 'sex', render: (_, r) => <span dangerouslySetInnerHTML={{ __html: r.sex || '' }} /> },
{ title: '类型', dataIndex: 'type', render: (_, r) => <span dangerouslySetInnerHTML={{ __html: r.type || '' }} /> },
{ title: '创建时间', dataIndex: 'createTime', valueType: 'dateTime', width: 180 },
];
return (
<PageContainer header={{ title: '用户检索' }}>
<SearchBarPlus defaultCollapsed split onTenantChanged={() => actionRef.current?.reload?.()} onFinish={async (values) => {
const { searchKey, searchValue } = values as any;
let queryStr = '';
if (searchKey && searchValue) queryStr = searchKey === 'none' ? searchValue : `${searchKey}:${searchValue}`;
setParams({ ...params, queryStr });
}}>
<ProFormSelect name="searchKey" label="检索" valueEnum={{ none: '全文检索', id: 'ID', username: '账号', nickname: '用户昵称', mobile: '手机号', sex: '性别', type: '用户类型' }} />
<ProFormText name="searchValue" placeholder="请输入关键字" />
</SearchBarPlus>
<ActionBar />
<ProTable<any>
actionRef={actionRef}
rowKey="id"
headerTitle="用户检索"
request={(p) => systemApi.searchUsers({ ...p, ...params })}
columns={columns}
search={false}
pagination={{ showSizeChanger: true, showQuickJumper: true }}
/>
</PageContainer>
);
};
export default UserSearchPage;