159 lines
4.4 KiB
TypeScript
159 lines
4.4 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 IRunnerDeposit from '@/domain/iRunnerDeposit';
|
|
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<IRunnerDeposit>[] = [
|
|
{
|
|
title: t('finance.deposit.id'),
|
|
dataIndex: 'id',
|
|
hideInForm: true,
|
|
sorter: true,
|
|
align: 'center',
|
|
width: 80,
|
|
},
|
|
{
|
|
title: t('finance.deposit.deposit_no'),
|
|
dataIndex: 'deposit_no',
|
|
valueType: 'text',
|
|
align: 'center',
|
|
},
|
|
{
|
|
title: t('finance.deposit.worker_id'),
|
|
dataIndex: 'worker_id',
|
|
valueType: 'text',
|
|
align: 'center',
|
|
},
|
|
{
|
|
title: t('finance.deposit.user_id'),
|
|
dataIndex: 'user_id',
|
|
valueType: 'text',
|
|
align: 'center',
|
|
},
|
|
{
|
|
title: t('finance.deposit.amount'),
|
|
dataIndex: 'amount',
|
|
valueType: 'text',
|
|
align: 'center',
|
|
},
|
|
{
|
|
title: t('finance.deposit.status'),
|
|
dataIndex: 'status',
|
|
valueType: 'radioButton',
|
|
fieldProps: {
|
|
options: [
|
|
{ value: 0, label: t('finance.deposit.status.0') },
|
|
{ value: 1, label: t('finance.deposit.status.1') },
|
|
{ value: 2, label: t('finance.deposit.status.2') },
|
|
{ value: 3, label: t('finance.deposit.status.3') },
|
|
],
|
|
},
|
|
render: (value: number) => {
|
|
if (value === 1) return <Tag color="success">{t('finance.deposit.status.1')}</Tag>;
|
|
if (value === 2) return <Tag color="warning">{t('finance.deposit.status.2')}</Tag>;
|
|
if (value === 3) return <Tag color="error">{t('finance.deposit.status.3')}</Tag>;
|
|
return <Tag color="default">{t('finance.deposit.status.0')}</Tag>;
|
|
},
|
|
filters: [
|
|
{ text: t('finance.deposit.status.0'), value: 0 },
|
|
{ text: t('finance.deposit.status.1'), value: 1 },
|
|
{ text: t('finance.deposit.status.2'), value: 2 },
|
|
{ text: t('finance.deposit.status.3'), value: 3 },
|
|
],
|
|
align: 'center',
|
|
},
|
|
{
|
|
title: t('finance.deposit.deduct_reason'),
|
|
dataIndex: 'deduct_reason',
|
|
valueType: 'text',
|
|
align: 'center',
|
|
hideInSearch: true,
|
|
},
|
|
{
|
|
title: t('finance.deposit.paid_at'),
|
|
dataIndex: 'paid_at',
|
|
hideInForm: true,
|
|
hideInSearch: true,
|
|
align: 'center',
|
|
render: (value: string) => (value ? dayjs(value).fromNow() : '-'),
|
|
},
|
|
{
|
|
title: t('finance.deposit.refund_at'),
|
|
dataIndex: 'refund_at',
|
|
hideInForm: true,
|
|
hideInSearch: true,
|
|
align: 'center',
|
|
render: (value: string) => (value ? dayjs(value).fromNow() : '-'),
|
|
},
|
|
{
|
|
title: t('finance.deposit.deducted_at'),
|
|
dataIndex: 'deducted_at',
|
|
hideInForm: true,
|
|
hideInSearch: true,
|
|
align: 'center',
|
|
render: (value: string) => (value ? dayjs(value).fromNow() : '-'),
|
|
},
|
|
{
|
|
title: t('finance.deposit.created_at'),
|
|
hideInForm: true,
|
|
hideInSearch: true,
|
|
dataIndex: 'created_at',
|
|
align: 'center',
|
|
render: (value: string) => (value ? dayjs(value).fromNow() : '-'),
|
|
},
|
|
{
|
|
title: t('finance.deposit.updated_at'),
|
|
hideInForm: true,
|
|
hideInSearch: true,
|
|
dataIndex: 'updated_at',
|
|
align: 'center',
|
|
render: (value: string) => (value ? dayjs(value).fromNow() : '-'),
|
|
},
|
|
];
|
|
|
|
const tableProps: XinTableProps<IRunnerDeposit> = {
|
|
api: '/runner/deposit',
|
|
columns,
|
|
rowKey: 'id',
|
|
accessName: 'runner.deposit',
|
|
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.deposit.page.title')}</Title>
|
|
<Text type="secondary">{t('finance.deposit.page.description')}</Text>
|
|
</div>
|
|
<XinTable<IRunnerDeposit> {...tableProps} />
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default Table;
|