|
|
@@ -77,15 +77,19 @@ const Clients: React.FC = () => {
|
|
|
|
|
|
// 获取客户列表数据
|
|
|
const { data: clientsData, isLoading: clientsLoading, error: clientsError } = useQuery({
|
|
|
- queryKey: ['clients', pagination.current, pagination.pageSize, searchText],
|
|
|
+ queryKey: ['clients', pagination.current, pagination.pageSize, searchText, auditStatusFilter],
|
|
|
queryFn: async () => {
|
|
|
- const res = await clientClient.$get({
|
|
|
- query: {
|
|
|
- page: pagination.current,
|
|
|
- pageSize: pagination.pageSize,
|
|
|
- keyword: searchText
|
|
|
- }
|
|
|
- });
|
|
|
+ const query: any = {
|
|
|
+ page: pagination.current,
|
|
|
+ pageSize: pagination.pageSize,
|
|
|
+ keyword: searchText
|
|
|
+ };
|
|
|
+
|
|
|
+ if (auditStatusFilter !== undefined) {
|
|
|
+ query.auditStatus = auditStatusFilter;
|
|
|
+ }
|
|
|
+
|
|
|
+ const res = await clientClient.$get({ query });
|
|
|
if (!res.ok) {
|
|
|
throw new Error('获取客户列表失败');
|
|
|
}
|
|
|
@@ -250,6 +254,23 @@ const Clients: React.FC = () => {
|
|
|
message.error('删除失败,请重试');
|
|
|
}
|
|
|
};
|
|
|
+
|
|
|
+ const handleAudit = (id: number, auditStatus: number) => {
|
|
|
+ const actionText = auditStatus === 1 ? '通过审核' : '拒绝审核';
|
|
|
+ Modal.confirm({
|
|
|
+ title: '确认审核',
|
|
|
+ content: `确定要${actionText}该客户吗?`,
|
|
|
+ okText: '确定',
|
|
|
+ cancelText: '取消',
|
|
|
+ onOk: async () => {
|
|
|
+ try {
|
|
|
+ await auditClient.mutateAsync({ id, auditStatus });
|
|
|
+ } catch (error) {
|
|
|
+ message.error('审核操作失败,请重试');
|
|
|
+ }
|
|
|
+ },
|
|
|
+ });
|
|
|
+ };
|
|
|
|
|
|
// 表格列定义
|
|
|
const columns = [
|
|
|
@@ -278,15 +299,40 @@ const Clients: React.FC = () => {
|
|
|
title: '登记审核',
|
|
|
dataIndex: 'auditStatus',
|
|
|
key: 'auditStatus',
|
|
|
- width: 100,
|
|
|
- render: (status: number) => {
|
|
|
+ width: 150,
|
|
|
+ render: (status: number, record: ClientItem) => {
|
|
|
const statusMap = {
|
|
|
0: { text: '待审核', color: 'orange' },
|
|
|
1: { text: '已审核', color: 'green' },
|
|
|
2: { text: '已拒绝', color: 'red' }
|
|
|
};
|
|
|
const config = statusMap[status as keyof typeof statusMap] || { text: '-', color: 'default' };
|
|
|
- return <span style={{ color: config.color }}>{config.text}</span>;
|
|
|
+
|
|
|
+ return (
|
|
|
+ <div className="flex items-center space-x-2">
|
|
|
+ <span style={{ color: config.color }}>{config.text}</span>
|
|
|
+ {status === 0 && (
|
|
|
+ <Space size="small">
|
|
|
+ <Button
|
|
|
+ size="small"
|
|
|
+ type="primary"
|
|
|
+ onClick={() => handleAudit(record.id, 1)}
|
|
|
+ loading={auditClient.isPending}
|
|
|
+ >
|
|
|
+ 通过
|
|
|
+ </Button>
|
|
|
+ <Button
|
|
|
+ size="small"
|
|
|
+ danger
|
|
|
+ onClick={() => handleAudit(record.id, 2)}
|
|
|
+ loading={auditClient.isPending}
|
|
|
+ >
|
|
|
+ 拒绝
|
|
|
+ </Button>
|
|
|
+ </Space>
|
|
|
+ )}
|
|
|
+ </div>
|
|
|
+ );
|
|
|
},
|
|
|
},
|
|
|
{
|
|
|
@@ -412,6 +458,17 @@ const Clients: React.FC = () => {
|
|
|
className="max-w-md"
|
|
|
allowClear
|
|
|
/>
|
|
|
+ <Select
|
|
|
+ placeholder="审核状态"
|
|
|
+ value={auditStatusFilter}
|
|
|
+ onChange={setAuditStatusFilter}
|
|
|
+ style={{ width: 120 }}
|
|
|
+ allowClear
|
|
|
+ >
|
|
|
+ <Select.Option value={0}>待审核</Select.Option>
|
|
|
+ <Select.Option value={1}>已审核</Select.Option>
|
|
|
+ <Select.Option value={2}>已拒绝</Select.Option>
|
|
|
+ </Select>
|
|
|
<Button
|
|
|
type="primary"
|
|
|
onClick={handleSearch}
|
|
|
@@ -421,6 +478,7 @@ const Clients: React.FC = () => {
|
|
|
</Button>
|
|
|
<Button onClick={() => {
|
|
|
setSearchText('');
|
|
|
+ setAuditStatusFilter(undefined);
|
|
|
setPagination({ ...pagination, current: 1 });
|
|
|
}}>
|
|
|
重置
|