Files
xin-school/web/pages/finance/withdrawal/index.tsx
T
2026-06-17 10:35:13 +08:00

159 lines
4.2 KiB
TypeScript

import { Tag, Typography } from 'antd';
import React from 'react';
import XinTable from '@/components/XinTable';
import type { XinTableColumn, XinTableProps } from '@/components/XinTable/typings';
import type IRunnerWithdrawal from '@/domain/iRunnerWithdrawal';
import { useTranslation } from 'react-i18next';
import dayjs from 'dayjs';
import relativeTime from 'dayjs/plugin/relativeTime';
const { Title, Text } = Typography;
dayjs.extend(relativeTime);
const Table: React.FC = () => {
const { t } = useTranslation();
const columns: XinTableColumn<IRunnerWithdrawal>[] = [
{
title: t('finance.withdrawal.id'),
dataIndex: 'id',
hideInForm: true,
sorter: true,
align: 'center',
width: 80,
},
{
title: t('finance.withdrawal.withdraw_no'),
dataIndex: 'withdraw_no',
valueType: 'text',
align: 'center',
},
{
title: t('finance.withdrawal.user_id'),
dataIndex: 'user_id',
valueType: 'text',
align: 'center',
},
{
title: t('finance.withdrawal.worker_id'),
dataIndex: 'worker_id',
valueType: 'text',
align: 'center',
},
{
title: t('finance.withdrawal.amount'),
dataIndex: 'amount',
valueType: 'text',
align: 'center',
},
{
title: t('finance.withdrawal.fee'),
dataIndex: 'fee',
valueType: 'text',
align: 'center',
},
{
title: t('finance.withdrawal.channel'),
dataIndex: 'channel',
valueType: 'text',
align: 'center',
},
{
title: t('finance.withdrawal.account_info'),
dataIndex: 'account_info',
valueType: 'text',
align: 'center',
hideInSearch: true,
},
{
title: t('finance.withdrawal.status'),
dataIndex: 'status',
valueType: 'radioButton',
fieldProps: {
options: [
{ value: 0, label: t('finance.withdrawal.status.0') },
{ value: 1, label: t('finance.withdrawal.status.1') },
{ value: 2, label: t('finance.withdrawal.status.2') },
],
},
render: (value: number) => {
if (value === 1) return <Tag color="success">{t('finance.withdrawal.status.1')}</Tag>;
if (value === 2) return <Tag color="error">{t('finance.withdrawal.status.2')}</Tag>;
return <Tag color="processing">{t('finance.withdrawal.status.0')}</Tag>;
},
filters: [
{ text: t('finance.withdrawal.status.0'), value: 0 },
{ text: t('finance.withdrawal.status.1'), value: 1 },
{ text: t('finance.withdrawal.status.2'), value: 2 },
],
align: 'center',
},
{
title: t('finance.withdrawal.remark'),
dataIndex: 'remark',
valueType: 'text',
align: 'center',
hideInSearch: true,
},
{
title: t('finance.withdrawal.processed_at'),
dataIndex: 'processed_at',
hideInForm: true,
hideInSearch: true,
align: 'center',
render: (value: string) => (value ? dayjs(value).fromNow() : '-'),
},
{
title: t('finance.withdrawal.created_at'),
hideInForm: true,
hideInSearch: true,
dataIndex: 'created_at',
align: 'center',
render: (value: string) => (value ? dayjs(value).fromNow() : '-'),
},
{
title: t('finance.withdrawal.updated_at'),
hideInForm: true,
hideInSearch: true,
dataIndex: 'updated_at',
align: 'center',
render: (value: string) => (value ? dayjs(value).fromNow() : '-'),
},
];
const tableProps: XinTableProps<IRunnerWithdrawal> = {
api: '/runner/withdrawal',
columns,
rowKey: 'id',
accessName: 'runner.withdrawal',
formProps: {
grid: true,
colProps: { span: 12 },
rowProps: { gutter: [30, 0] },
layout: 'vertical',
},
modalProps: {
width: 800,
},
cardProps: {
variant: 'borderless',
},
pagination: {
size: 'small',
style: { marginBottom: 0 },
},
};
return (
<>
<div className="mb-5">
<Title level={3}>{t('finance.withdrawal.page.title')}</Title>
<Text type="secondary">{t('finance.withdrawal.page.description')}</Text>
</div>
<XinTable<IRunnerWithdrawal> {...tableProps} />
</>
);
};
export default Table;