import { Tag, Typography } from 'antd'; import React from 'react'; import XinTable from '@/components/XinTable'; import type { XinTableColumn, XinTableProps } from '@/components/XinTable/typings'; import type ITaskOrder from '@/domain/iTaskOrder'; 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[] = [ { title: t('task.order_errand.id'), dataIndex: 'id', hideInForm: true, sorter: true, align: 'center', width: 80, }, { title: t('task.order_errand.order_no'), dataIndex: 'order_no', valueType: 'text', align: 'center', }, { title: t('task.order_errand.user_id'), dataIndex: 'user_id', valueType: 'text', align: 'center', }, { title: t('task.order_errand.runner_id'), dataIndex: 'runner_id', valueType: 'text', align: 'center', }, { title: t('task.order_errand.title'), dataIndex: 'title', valueType: 'text', align: 'center', }, { title: t('task.order_errand.price'), dataIndex: 'price', hideInForm: true, align: 'center', render: (value: string) => `¥${value || '0.00'}`, }, { title: t('task.order_errand.contact_name'), dataIndex: 'contact_name', valueType: 'text', align: 'center', }, { title: t('task.order_errand.contact_mobile'), dataIndex: 'contact_mobile', valueType: 'text', align: 'center', }, { title: t('task.order_errand.deadline'), dataIndex: 'deadline', valueType: 'text', align: 'center', }, { title: t('task.order_errand.pay_type'), dataIndex: 'pay_type', valueType: 'text', align: 'center', }, { title: t('task.order_errand.pay_status'), dataIndex: 'pay_status', valueType: 'radioButton', fieldProps: { options: [ { value: 0, label: t('task.order_errand.pay_status.0') }, { value: 1, label: t('task.order_errand.pay_status.1') }, ], }, render: (value: number) => { return value === 1 ? {t('task.order_errand.pay_status.1')} : {t('task.order_errand.pay_status.0')}; }, filters: [ { text: t('task.order_errand.pay_status.0'), value: 0 }, { text: t('task.order_errand.pay_status.1'), value: 1 }, ], align: 'center', }, { title: t('task.order_errand.status'), dataIndex: 'status', valueType: 'text', align: 'center', }, { title: t('task.order_errand.created_at'), hideInForm: true, hideInSearch: true, dataIndex: 'created_at', align: 'center', render: (value: string) => (value ? dayjs(value).fromNow() : '-'), }, { title: t('task.order_errand.updated_at'), hideInForm: true, hideInSearch: true, dataIndex: 'updated_at', align: 'center', render: (value: string) => (value ? dayjs(value).fromNow() : '-'), }, ]; const tableProps: XinTableProps = { api: '/task/order', columns, rowKey: 'id', accessName: 'task.order', requestParams: { category_slug: 'errand' }, scroll: { x: 1400 }, 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 ( <>
{t('task.order_errand.page.title')} {t('task.order_errand.page.description')}
{...tableProps} /> ); }; export default Table;