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