|
@@ -3,6 +3,7 @@ import { Table, Button, Space, Input, Modal, Form ,Select} from 'antd';
|
|
|
import { App } from 'antd';
|
|
import { App } from 'antd';
|
|
|
import AreaTreeSelect from '@/client/admin/components/AreaTreeSelect';
|
|
import AreaTreeSelect from '@/client/admin/components/AreaTreeSelect';
|
|
|
import UserSelect from '@/client/admin/components/UserSelect';
|
|
import UserSelect from '@/client/admin/components/UserSelect';
|
|
|
|
|
+import AuditButtons from '@/client/admin/components/AuditButtons';
|
|
|
import { PlusOutlined, EditOutlined, DeleteOutlined, SearchOutlined } from '@ant-design/icons';
|
|
import { PlusOutlined, EditOutlined, DeleteOutlined, SearchOutlined } from '@ant-design/icons';
|
|
|
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
|
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
|
|
import { clientClient, areaClient } from '@/client/api';
|
|
import { clientClient, areaClient } from '@/client/api';
|
|
@@ -229,24 +230,6 @@ const Clients: React.FC = () => {
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- // 审核客户
|
|
|
|
|
- const auditClient = useMutation({
|
|
|
|
|
- mutationFn: async ({ id, auditStatus }: { id: number; auditStatus: number }) => {
|
|
|
|
|
- const res = await clientClient[':id'].$put({
|
|
|
|
|
- param: { id },
|
|
|
|
|
- json: { auditStatus } as any,
|
|
|
|
|
- });
|
|
|
|
|
- if (!res.ok) {
|
|
|
|
|
- throw new Error('审核操作失败');
|
|
|
|
|
- }
|
|
|
|
|
- return res.json();
|
|
|
|
|
- },
|
|
|
|
|
- onSuccess: () => {
|
|
|
|
|
- message.success('审核操作成功');
|
|
|
|
|
- queryClient.invalidateQueries({ queryKey: ['clients'] });
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
const handleDelete = async (id: number) => {
|
|
const handleDelete = async (id: number) => {
|
|
|
try {
|
|
try {
|
|
|
await deleteClient.mutateAsync(id);
|
|
await deleteClient.mutateAsync(id);
|
|
@@ -254,87 +237,42 @@ const Clients: React.FC = () => {
|
|
|
message.error('删除失败,请重试');
|
|
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 = [
|
|
const columns = [
|
|
|
- {
|
|
|
|
|
- title: '项目名称',
|
|
|
|
|
- dataIndex: 'companyName',
|
|
|
|
|
- key: 'companyName',
|
|
|
|
|
- width: 200,
|
|
|
|
|
- ellipsis: true,
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- title: '省份',
|
|
|
|
|
- dataIndex: 'areaId',
|
|
|
|
|
- key: 'province',
|
|
|
|
|
- width: 100,
|
|
|
|
|
- render: (areaId: number) => getAreaDisplay(areaId, 'province'),
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- title: '地区',
|
|
|
|
|
- dataIndex: 'areaId',
|
|
|
|
|
- key: 'region',
|
|
|
|
|
- width: 100,
|
|
|
|
|
- render: (areaId: number) => getAreaDisplay(areaId, 'region'),
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- title: '登记审核',
|
|
|
|
|
- dataIndex: 'auditStatus',
|
|
|
|
|
- key: 'auditStatus',
|
|
|
|
|
- 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 (
|
|
|
|
|
- <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>
|
|
|
|
|
- );
|
|
|
|
|
- },
|
|
|
|
|
- },
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ title: '项目名称',
|
|
|
|
|
+ dataIndex: 'companyName',
|
|
|
|
|
+ key: 'companyName',
|
|
|
|
|
+ width: 200,
|
|
|
|
|
+ ellipsis: true,
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ title: '省份',
|
|
|
|
|
+ dataIndex: 'areaId',
|
|
|
|
|
+ key: 'province',
|
|
|
|
|
+ width: 100,
|
|
|
|
|
+ render: (areaId: number) => getAreaDisplay(areaId, 'province'),
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ title: '地区',
|
|
|
|
|
+ dataIndex: 'areaId',
|
|
|
|
|
+ key: 'region',
|
|
|
|
|
+ width: 100,
|
|
|
|
|
+ render: (areaId: number) => getAreaDisplay(areaId, 'region'),
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ title: '登记审核',
|
|
|
|
|
+ dataIndex: 'auditStatus',
|
|
|
|
|
+ key: 'auditStatus',
|
|
|
|
|
+ width: 150,
|
|
|
|
|
+ render: (status: number, record: ClientItem) => (
|
|
|
|
|
+ <AuditButtons
|
|
|
|
|
+ recordId={record.id}
|
|
|
|
|
+ currentStatus={status}
|
|
|
|
|
+ />
|
|
|
|
|
+ ),
|
|
|
|
|
+ },
|
|
|
{
|
|
{
|
|
|
title: '主产品/合同估额',
|
|
title: '主产品/合同估额',
|
|
|
dataIndex: 'description',
|
|
dataIndex: 'description',
|