165 lines
4.1 KiB
TypeScript
165 lines
4.1 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 IRunnerComplaint from '@/domain/iRunnerComplaint';
|
|
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<IRunnerComplaint>[] = [
|
|
{
|
|
title: t('runner.complaint.id'),
|
|
dataIndex: 'id',
|
|
hideInForm: true,
|
|
sorter: true,
|
|
align: 'center',
|
|
width: 80,
|
|
},
|
|
{
|
|
title: t('runner.complaint.complaint_no'),
|
|
dataIndex: 'complaint_no',
|
|
valueType: 'text',
|
|
align: 'center',
|
|
},
|
|
{
|
|
title: t('runner.complaint.user_id'),
|
|
dataIndex: 'user_id',
|
|
valueType: 'text',
|
|
align: 'center',
|
|
},
|
|
{
|
|
title: t('runner.complaint.worker_id'),
|
|
dataIndex: 'worker_id',
|
|
valueType: 'text',
|
|
align: 'center',
|
|
},
|
|
{
|
|
title: t('runner.complaint.order_id'),
|
|
dataIndex: 'order_id',
|
|
valueType: 'text',
|
|
align: 'center',
|
|
},
|
|
{
|
|
title: t('runner.complaint.type'),
|
|
dataIndex: 'type',
|
|
valueType: 'text',
|
|
align: 'center',
|
|
},
|
|
{
|
|
title: t('runner.complaint.content'),
|
|
dataIndex: 'content',
|
|
valueType: 'text',
|
|
align: 'center',
|
|
hideInSearch: true,
|
|
},
|
|
{
|
|
title: t('runner.complaint.images'),
|
|
dataIndex: 'images',
|
|
valueType: 'text',
|
|
align: 'center',
|
|
hideInSearch: true,
|
|
},
|
|
{
|
|
title: t('runner.complaint.status'),
|
|
dataIndex: 'status',
|
|
valueType: 'radioButton',
|
|
fieldProps: {
|
|
options: [
|
|
{ value: 0, label: t('runner.complaint.status.0') },
|
|
{ value: 1, label: t('runner.complaint.status.1') },
|
|
],
|
|
},
|
|
render: (value: number) => {
|
|
return value === 1
|
|
? <Tag color="success">{t('runner.complaint.status.1')}</Tag>
|
|
: <Tag color="warning">{t('runner.complaint.status.0')}</Tag>;
|
|
},
|
|
filters: [
|
|
{ text: t('runner.complaint.status.0'), value: 0 },
|
|
{ text: t('runner.complaint.status.1'), value: 1 },
|
|
],
|
|
align: 'center',
|
|
},
|
|
{
|
|
title: t('runner.complaint.result'),
|
|
dataIndex: 'result',
|
|
valueType: 'text',
|
|
align: 'center',
|
|
hideInSearch: true,
|
|
},
|
|
{
|
|
title: t('runner.complaint.result_remark'),
|
|
dataIndex: 'result_remark',
|
|
valueType: 'text',
|
|
align: 'center',
|
|
hideInSearch: true,
|
|
},
|
|
{
|
|
title: t('runner.complaint.handled_at'),
|
|
dataIndex: 'handled_at',
|
|
hideInForm: true,
|
|
hideInSearch: true,
|
|
align: 'center',
|
|
render: (value: string) => (value ? dayjs(value).fromNow() : '-'),
|
|
},
|
|
{
|
|
title: t('runner.complaint.created_at'),
|
|
hideInForm: true,
|
|
hideInSearch: true,
|
|
dataIndex: 'created_at',
|
|
align: 'center',
|
|
render: (value: string) => (value ? dayjs(value).fromNow() : '-'),
|
|
},
|
|
{
|
|
title: t('runner.complaint.updated_at'),
|
|
hideInForm: true,
|
|
hideInSearch: true,
|
|
dataIndex: 'updated_at',
|
|
align: 'center',
|
|
render: (value: string) => (value ? dayjs(value).fromNow() : '-'),
|
|
},
|
|
];
|
|
|
|
const tableProps: XinTableProps<IRunnerComplaint> = {
|
|
api: '/runner/complaint',
|
|
columns,
|
|
rowKey: 'id',
|
|
accessName: 'runner.complaint',
|
|
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.complaint.page.title')}</Title>
|
|
<Text type="secondary">{t('runner.complaint.page.description')}</Text>
|
|
</div>
|
|
<XinTable<IRunnerComplaint> {...tableProps} />
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default Table;
|