Files
2026-06-17 10:35:13 +08:00

125 lines
3.0 KiB
TypeScript

import { Typography } from 'antd';
import React from 'react';
import XinTable from '@/components/XinTable';
import type { XinTableColumn, XinTableProps } from '@/components/XinTable/typings';
import type IRunnerCreditLog from '@/domain/iRunnerCreditLog';
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<IRunnerCreditLog>[] = [
{
title: t('runner.credit_log.id'),
dataIndex: 'id',
hideInForm: true,
sorter: true,
align: 'center',
width: 80,
},
{
title: t('runner.credit_log.worker_id'),
dataIndex: 'worker_id',
valueType: 'text',
align: 'center',
},
{
title: t('runner.credit_log.score'),
dataIndex: 'score',
valueType: 'text',
align: 'center',
hideInSearch: true,
},
{
title: t('runner.credit_log.score_after'),
dataIndex: 'score_after',
valueType: 'text',
align: 'center',
hideInSearch: true,
},
{
title: t('runner.credit_log.type'),
dataIndex: 'type',
valueType: 'text',
align: 'center',
},
{
title: t('runner.credit_log.description'),
dataIndex: 'description',
valueType: 'text',
align: 'center',
hideInSearch: true,
},
{
title: t('runner.credit_log.related_type'),
dataIndex: 'related_type',
valueType: 'text',
align: 'center',
},
{
title: t('runner.credit_log.related_id'),
dataIndex: 'related_id',
valueType: 'text',
align: 'center',
},
{
title: t('runner.credit_log.created_at'),
hideInForm: true,
hideInSearch: true,
dataIndex: 'created_at',
align: 'center',
render: (value: string) => (value ? dayjs(value).fromNow() : '-'),
},
{
title: t('runner.credit_log.updated_at'),
hideInForm: true,
hideInSearch: true,
dataIndex: 'updated_at',
align: 'center',
render: (value: string) => (value ? dayjs(value).fromNow() : '-'),
},
];
const tableProps: XinTableProps<IRunnerCreditLog> = {
api: '/runner/credit-log',
columns,
rowKey: 'id',
accessName: 'runner.credit_log',
addShow: false,
editShow: false,
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('runner.credit_log.page.title')}</Title>
<Text type="secondary">{t('runner.credit_log.page.description')}</Text>
</div>
<XinTable<IRunnerCreditLog> {...tableProps} />
</>
);
};
export default Table;