75 lines
2.1 KiB
TypeScript
75 lines
2.1 KiB
TypeScript
import { Check, X } from 'lucide-react';
|
|
import { Button, Tag, type TableColumn } from '@/components/ui';
|
|
import type { AuditItem, AuditStatus } from '@/mock';
|
|
|
|
const riskToneMap = {
|
|
low: 'success',
|
|
medium: 'warning',
|
|
high: 'danger',
|
|
} as const;
|
|
|
|
const riskLabelMap = {
|
|
low: '低风险',
|
|
medium: '中风险',
|
|
high: '高风险',
|
|
};
|
|
|
|
const auditStatusLabelMap: Record<AuditStatus, string> = {
|
|
pending: '待审核',
|
|
approved: '已通过',
|
|
rejected: '已驳回',
|
|
};
|
|
|
|
export function createAuditColumns(
|
|
onUpdateStatus: (id: string, status: AuditStatus) => void,
|
|
): Array<TableColumn<AuditItem>> {
|
|
return [
|
|
{ key: 'id', title: '审核编号', render: (record) => record.id },
|
|
{ key: 'customer', title: '客户', render: (record) => record.customer },
|
|
{ key: 'type', title: '类型', render: (record) => <Tag tone="accent">{record.type}</Tag> },
|
|
{ key: 'content', title: '内容', render: (record) => record.content },
|
|
{ key: 'submittedAt', title: '提交时间', render: (record) => record.submittedAt },
|
|
{
|
|
key: 'risk',
|
|
title: '风险',
|
|
render: (record) => <Tag tone={riskToneMap[record.risk]}>{riskLabelMap[record.risk]}</Tag>,
|
|
},
|
|
{
|
|
key: 'status',
|
|
title: '状态',
|
|
render: (record) => (
|
|
<Tag tone={record.status === 'approved' ? 'success' : record.status === 'rejected' ? 'danger' : 'info'}>
|
|
{auditStatusLabelMap[record.status]}
|
|
</Tag>
|
|
),
|
|
},
|
|
{
|
|
key: 'actions',
|
|
title: '操作',
|
|
align: 'right',
|
|
render: (record) => (
|
|
<div className="table-actions">
|
|
<Button
|
|
disabled={record.status !== 'pending'}
|
|
icon={<Check size={15} />}
|
|
onClick={() => onUpdateStatus(record.id, 'approved')}
|
|
size="sm"
|
|
variant="secondary"
|
|
>
|
|
通过
|
|
</Button>
|
|
<Button
|
|
disabled={record.status !== 'pending'}
|
|
icon={<X size={15} />}
|
|
onClick={() => onUpdateStatus(record.id, 'rejected')}
|
|
size="sm"
|
|
variant="ghost"
|
|
>
|
|
驳回
|
|
</Button>
|
|
</div>
|
|
),
|
|
},
|
|
];
|
|
}
|