校园商户
This commit is contained in:
@@ -0,0 +1,139 @@
|
||||
import { Tag, Typography } from 'antd';
|
||||
import React from 'react';
|
||||
import XinTable from '@/components/XinTable';
|
||||
import type { XinTableColumn, XinTableProps } from '@/components/XinTable/typings';
|
||||
import type IPrinter from '@/domain/iPrinter';
|
||||
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<IPrinter>[] = [
|
||||
{
|
||||
title: t('merchant.printer.id'),
|
||||
dataIndex: 'id',
|
||||
hideInForm: true,
|
||||
sorter: true,
|
||||
align: 'center',
|
||||
width: 80,
|
||||
},
|
||||
{
|
||||
title: t('merchant.printer.name'),
|
||||
dataIndex: 'name',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
required: true,
|
||||
rules: [{ required: true, message: t('merchant.printer.name.required') }],
|
||||
},
|
||||
{
|
||||
title: t('merchant.printer.merchant_id'),
|
||||
dataIndex: 'merchant_id',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
title: t('merchant.printer.brand'),
|
||||
dataIndex: 'brand',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
hideInSearch: true,
|
||||
},
|
||||
{
|
||||
title: t('merchant.printer.model'),
|
||||
dataIndex: 'model',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
hideInSearch: true,
|
||||
},
|
||||
{
|
||||
title: t('merchant.printer.device_no'),
|
||||
dataIndex: 'device_no',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
hideInSearch: true,
|
||||
},
|
||||
{
|
||||
title: t('merchant.printer.secret_key'),
|
||||
dataIndex: 'secret_key',
|
||||
valueType: 'password',
|
||||
hideInTable: true,
|
||||
hideInSearch: true,
|
||||
},
|
||||
{
|
||||
title: t('merchant.printer.status'),
|
||||
dataIndex: 'status',
|
||||
valueType: 'radioButton',
|
||||
fieldProps: {
|
||||
options: [
|
||||
{ value: 0, label: t('merchant.printer.status.0') },
|
||||
{ value: 1, label: t('merchant.printer.status.1') },
|
||||
{ value: 2, label: t('merchant.printer.status.2') },
|
||||
],
|
||||
},
|
||||
render: (value: number) => {
|
||||
const colorMap: Record<number, string> = { 0: 'default', 1: 'success', 2: 'error' };
|
||||
const labelMap: Record<number, string> = {
|
||||
0: t('merchant.printer.status.0'), 1: t('merchant.printer.status.1'), 2: t('merchant.printer.status.2'),
|
||||
};
|
||||
return <Tag color={colorMap[value] || 'default'}>{labelMap[value] || '-'}</Tag>;
|
||||
},
|
||||
filters: [
|
||||
{ text: t('merchant.printer.status.0'), value: 0 },
|
||||
{ text: t('merchant.printer.status.1'), value: 1 },
|
||||
{ text: t('merchant.printer.status.2'), value: 2 },
|
||||
],
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: t('merchant.printer.created_at'),
|
||||
hideInForm: true,
|
||||
hideInSearch: true,
|
||||
dataIndex: 'created_at',
|
||||
align: 'center',
|
||||
render: (value: string) => (value ? dayjs(value).fromNow() : '-'),
|
||||
},
|
||||
{
|
||||
title: t('merchant.printer.updated_at'),
|
||||
hideInForm: true,
|
||||
hideInSearch: true,
|
||||
dataIndex: 'updated_at',
|
||||
align: 'center',
|
||||
render: (value: string) => (value ? dayjs(value).fromNow() : '-'),
|
||||
},
|
||||
];
|
||||
|
||||
const tableProps: XinTableProps<IPrinter> = {
|
||||
api: '/merchant/printer',
|
||||
columns,
|
||||
rowKey: 'id',
|
||||
accessName: 'merchant.printer',
|
||||
scroll: { x: 1200 },
|
||||
formProps: {
|
||||
grid: true,
|
||||
colProps: { span: 12 },
|
||||
rowProps: { gutter: [30, 0] },
|
||||
layout: 'vertical',
|
||||
},
|
||||
modalProps: { width: 700 },
|
||||
cardProps: { variant: 'borderless' },
|
||||
pagination: { size: 'small', style: { marginBottom: 0 } },
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="mb-5">
|
||||
<Title level={3}>{t('merchant.printer.page.title')}</Title>
|
||||
<Text type="secondary">{t('merchant.printer.page.description')}</Text>
|
||||
</div>
|
||||
<XinTable<IPrinter> {...tableProps} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default Table;
|
||||
Reference in New Issue
Block a user