商户后台
This commit is contained in:
@@ -0,0 +1,221 @@
|
||||
import { Tag, Typography } from 'antd';
|
||||
import React from 'react';
|
||||
import XinTable from '@/components/XinTable';
|
||||
import type { XinTableColumn, XinTableProps } from '@/components/XinTable/typings';
|
||||
import type IOrder from '@/domain/iOrder';
|
||||
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<IOrder>[] = [
|
||||
{
|
||||
title: t('merchant.portal.order.id'),
|
||||
dataIndex: 'id',
|
||||
hideInForm: true,
|
||||
sorter: true,
|
||||
align: 'center',
|
||||
width: 80,
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.order.order_no'),
|
||||
dataIndex: 'order_no',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
hideInSearch: true,
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.order.user_id'),
|
||||
dataIndex: 'user_id',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
hideInSearch: true,
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.order.total_amount'),
|
||||
dataIndex: 'total_amount',
|
||||
hideInForm: true,
|
||||
hideInSearch: true,
|
||||
align: 'center',
|
||||
render: (value: number) => `¥${value ?? '0.00'}`,
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.order.discount_amount'),
|
||||
dataIndex: 'discount_amount',
|
||||
hideInForm: true,
|
||||
hideInSearch: true,
|
||||
align: 'center',
|
||||
render: (value: number) => `¥${value ?? '0.00'}`,
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.order.delivery_fee'),
|
||||
dataIndex: 'delivery_fee',
|
||||
hideInForm: true,
|
||||
hideInSearch: true,
|
||||
align: 'center',
|
||||
render: (value: number) => `¥${value ?? '0.00'}`,
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.order.payment_amount'),
|
||||
dataIndex: 'payment_amount',
|
||||
hideInForm: true,
|
||||
hideInSearch: true,
|
||||
align: 'center',
|
||||
render: (value: number) => `¥${value ?? '0.00'}`,
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.order.pay_type'),
|
||||
dataIndex: 'pay_type',
|
||||
valueType: 'select',
|
||||
fieldProps: {
|
||||
options: [
|
||||
{ value: 0, label: t('merchant.portal.order.pay_type.0') },
|
||||
{ value: 1, label: t('merchant.portal.order.pay_type.1') },
|
||||
],
|
||||
},
|
||||
render: (value: number) => {
|
||||
const colorMap: Record<number, string> = { 0: 'default', 1: 'blue' };
|
||||
const labelMap: Record<number, string> = {
|
||||
0: t('merchant.portal.order.pay_type.0'),
|
||||
1: t('merchant.portal.order.pay_type.1'),
|
||||
};
|
||||
return <Tag color={colorMap[value] ?? 'default'}>{labelMap[value] ?? '-'}</Tag>;
|
||||
},
|
||||
filters: [
|
||||
{ text: t('merchant.portal.order.pay_type.0'), value: 0 },
|
||||
{ text: t('merchant.portal.order.pay_type.1'), value: 1 },
|
||||
],
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.order.pay_status'),
|
||||
dataIndex: 'pay_status',
|
||||
valueType: 'select',
|
||||
fieldProps: {
|
||||
options: [
|
||||
{ value: 0, label: t('merchant.portal.order.pay_status.0') },
|
||||
{ value: 1, label: t('merchant.portal.order.pay_status.1') },
|
||||
{ value: 2, label: t('merchant.portal.order.pay_status.2') },
|
||||
{ value: 3, label: t('merchant.portal.order.pay_status.3') },
|
||||
],
|
||||
},
|
||||
render: (value: number) => {
|
||||
const colorMap: Record<number, string> = { 0: 'warning', 1: 'success', 2: 'processing', 3: 'default' };
|
||||
const labelMap: Record<number, string> = {
|
||||
0: t('merchant.portal.order.pay_status.0'),
|
||||
1: t('merchant.portal.order.pay_status.1'),
|
||||
2: t('merchant.portal.order.pay_status.2'),
|
||||
3: t('merchant.portal.order.pay_status.3'),
|
||||
};
|
||||
return <Tag color={colorMap[value] ?? 'default'}>{labelMap[value] ?? '-'}</Tag>;
|
||||
},
|
||||
filters: [
|
||||
{ text: t('merchant.portal.order.pay_status.0'), value: 0 },
|
||||
{ text: t('merchant.portal.order.pay_status.1'), value: 1 },
|
||||
{ text: t('merchant.portal.order.pay_status.2'), value: 2 },
|
||||
{ text: t('merchant.portal.order.pay_status.3'), value: 3 },
|
||||
],
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.order.status'),
|
||||
dataIndex: 'status',
|
||||
valueType: 'select',
|
||||
fieldProps: {
|
||||
options: [
|
||||
{ value: 0, label: t('merchant.portal.order.status.0') },
|
||||
{ value: 1, label: t('merchant.portal.order.status.1') },
|
||||
{ value: 2, label: t('merchant.portal.order.status.2') },
|
||||
{ value: 3, label: t('merchant.portal.order.status.3') },
|
||||
{ value: 4, label: t('merchant.portal.order.status.4') },
|
||||
],
|
||||
},
|
||||
render: (value: number) => {
|
||||
const colorMap: Record<number, string> = { 0: 'warning', 1: 'processing', 2: 'processing', 3: 'success', 4: 'default' };
|
||||
const labelMap: Record<number, string> = {
|
||||
0: t('merchant.portal.order.status.0'),
|
||||
1: t('merchant.portal.order.status.1'),
|
||||
2: t('merchant.portal.order.status.2'),
|
||||
3: t('merchant.portal.order.status.3'),
|
||||
4: t('merchant.portal.order.status.4'),
|
||||
};
|
||||
return <Tag color={colorMap[value] ?? 'default'}>{labelMap[value] ?? '-'}</Tag>;
|
||||
},
|
||||
filters: [
|
||||
{ text: t('merchant.portal.order.status.0'), value: 0 },
|
||||
{ text: t('merchant.portal.order.status.1'), value: 1 },
|
||||
{ text: t('merchant.portal.order.status.2'), value: 2 },
|
||||
{ text: t('merchant.portal.order.status.3'), value: 3 },
|
||||
{ text: t('merchant.portal.order.status.4'), value: 4 },
|
||||
],
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.order.paid_at'),
|
||||
dataIndex: 'paid_at',
|
||||
hideInForm: true,
|
||||
hideInSearch: true,
|
||||
align: 'center',
|
||||
render: (value: string) => (value ? dayjs(value).format('YYYY-MM-DD HH:mm:ss') : '-'),
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.order.completed_at'),
|
||||
dataIndex: 'completed_at',
|
||||
hideInForm: true,
|
||||
hideInSearch: true,
|
||||
align: 'center',
|
||||
render: (value: string) => (value ? dayjs(value).format('YYYY-MM-DD HH:mm:ss') : '-'),
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.order.remark'),
|
||||
dataIndex: 'remark',
|
||||
valueType: 'text',
|
||||
hideInSearch: true,
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.order.created_at'),
|
||||
hideInForm: true,
|
||||
hideInSearch: true,
|
||||
dataIndex: 'created_at',
|
||||
align: 'center',
|
||||
render: (value: string) => (value ? dayjs(value).fromNow() : '-'),
|
||||
},
|
||||
];
|
||||
|
||||
const tableProps: XinTableProps<IOrder> = {
|
||||
api: '/merchant-portal/order',
|
||||
columns,
|
||||
rowKey: 'id',
|
||||
accessName: 'merchant.portal.order',
|
||||
addShow: false,
|
||||
editShow: false,
|
||||
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 (
|
||||
<>
|
||||
<div className="mb-5">
|
||||
<Title level={3}>{t('merchant.portal.order.page.title')}</Title>
|
||||
<Text type="secondary">{t('merchant.portal.order.page.description')}</Text>
|
||||
</div>
|
||||
<XinTable<IOrder> {...tableProps} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default Table;
|
||||
@@ -0,0 +1,138 @@
|
||||
import { Tag, Typography } from 'antd';
|
||||
import React from 'react';
|
||||
import XinTable from '@/components/XinTable';
|
||||
import type { XinTableColumn, XinTableProps } from '@/components/XinTable/typings';
|
||||
import type IOrderPayment from '@/domain/iOrderPayment';
|
||||
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<IOrderPayment>[] = [
|
||||
{
|
||||
title: t('merchant.portal.payment.id'),
|
||||
dataIndex: 'id',
|
||||
hideInForm: true,
|
||||
sorter: true,
|
||||
align: 'center',
|
||||
width: 80,
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.payment.payment_no'),
|
||||
dataIndex: 'payment_no',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
hideInSearch: true,
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.payment.order_id'),
|
||||
dataIndex: 'order_id',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
hideInSearch: true,
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.payment.amount'),
|
||||
dataIndex: 'amount',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
render: (value: number) => `¥${value ?? '0.00'}`,
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.payment.pay_type'),
|
||||
dataIndex: 'pay_type',
|
||||
valueType: 'select',
|
||||
fieldProps: {
|
||||
options: [
|
||||
{ value: 0, label: t('merchant.portal.payment.pay_type.0') },
|
||||
{ value: 1, label: t('merchant.portal.payment.pay_type.1') },
|
||||
],
|
||||
},
|
||||
render: (value: number) => {
|
||||
const colorMap: Record<number, string> = { 0: 'default', 1: 'blue' };
|
||||
const labelMap: Record<number, string> = {
|
||||
0: t('merchant.portal.payment.pay_type.0'),
|
||||
1: t('merchant.portal.payment.pay_type.1'),
|
||||
};
|
||||
return <Tag color={colorMap[value] ?? 'default'}>{labelMap[value] ?? '-'}</Tag>;
|
||||
},
|
||||
filters: [
|
||||
{ text: t('merchant.portal.payment.pay_type.0'), value: 0 },
|
||||
{ text: t('merchant.portal.payment.pay_type.1'), value: 1 },
|
||||
],
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.payment.status'),
|
||||
dataIndex: 'status',
|
||||
valueType: 'select',
|
||||
fieldProps: {
|
||||
options: [
|
||||
{ value: 0, label: t('merchant.portal.payment.status.0') },
|
||||
{ value: 1, label: t('merchant.portal.payment.status.1') },
|
||||
{ value: 2, label: t('merchant.portal.payment.status.2') },
|
||||
],
|
||||
},
|
||||
render: (value: number) => {
|
||||
const colorMap: Record<number, string> = { 0: 'warning', 1: 'success', 2: 'error' };
|
||||
const labelMap: Record<number, string> = {
|
||||
0: t('merchant.portal.payment.status.0'),
|
||||
1: t('merchant.portal.payment.status.1'),
|
||||
2: t('merchant.portal.payment.status.2'),
|
||||
};
|
||||
return <Tag color={colorMap[value] ?? 'default'}>{labelMap[value] ?? '-'}</Tag>;
|
||||
},
|
||||
filters: [
|
||||
{ text: t('merchant.portal.payment.status.0'), value: 0 },
|
||||
{ text: t('merchant.portal.payment.status.1'), value: 1 },
|
||||
{ text: t('merchant.portal.payment.status.2'), value: 2 },
|
||||
],
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.payment.paid_at'),
|
||||
dataIndex: 'paid_at',
|
||||
hideInForm: true,
|
||||
hideInSearch: true,
|
||||
align: 'center',
|
||||
render: (value: string) => (value ? dayjs(value).format('YYYY-MM-DD HH:mm:ss') : '-'),
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.payment.created_at'),
|
||||
hideInForm: true,
|
||||
hideInSearch: true,
|
||||
dataIndex: 'created_at',
|
||||
align: 'center',
|
||||
render: (value: string) => (value ? dayjs(value).fromNow() : '-'),
|
||||
},
|
||||
];
|
||||
|
||||
const tableProps: XinTableProps<IOrderPayment> = {
|
||||
api: '/merchant-portal/payment',
|
||||
columns,
|
||||
rowKey: 'id',
|
||||
accessName: 'merchant.portal.payment',
|
||||
addShow: false,
|
||||
editShow: false,
|
||||
scroll: { x: 1000 },
|
||||
cardProps: { variant: 'borderless' },
|
||||
pagination: { size: 'small', style: { marginBottom: 0 } },
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="mb-5">
|
||||
<Title level={3}>{t('merchant.portal.payment.page.title')}</Title>
|
||||
<Text type="secondary">{t('merchant.portal.payment.page.description')}</Text>
|
||||
</div>
|
||||
<XinTable<IOrderPayment> {...tableProps} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default Table;
|
||||
@@ -0,0 +1,128 @@
|
||||
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.portal.printer.id'),
|
||||
dataIndex: 'id',
|
||||
hideInForm: true,
|
||||
sorter: true,
|
||||
align: 'center',
|
||||
width: 80,
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.printer.name'),
|
||||
dataIndex: 'name',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
required: true,
|
||||
rules: [{ required: true, message: t('merchant.portal.printer.name.required') }],
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.printer.brand'),
|
||||
dataIndex: 'brand',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
hideInSearch: true,
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.printer.model'),
|
||||
dataIndex: 'model',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
hideInSearch: true,
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.printer.device_no'),
|
||||
dataIndex: 'device_no',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
hideInSearch: true,
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.printer.secret_key'),
|
||||
dataIndex: 'secret_key',
|
||||
valueType: 'password',
|
||||
align: 'center',
|
||||
hideInSearch: true,
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.printer.status'),
|
||||
dataIndex: 'status',
|
||||
valueType: 'radioButton',
|
||||
fieldProps: {
|
||||
options: [
|
||||
{ value: 0, label: t('merchant.portal.printer.status.0') },
|
||||
{ value: 1, label: t('merchant.portal.printer.status.1') },
|
||||
],
|
||||
},
|
||||
render: (value: number) => {
|
||||
return value === 1
|
||||
? <Tag color="success">{t('merchant.portal.printer.status.1')}</Tag>
|
||||
: <Tag color="default">{t('merchant.portal.printer.status.0')}</Tag>;
|
||||
},
|
||||
filters: [
|
||||
{ text: t('merchant.portal.printer.status.0'), value: 0 },
|
||||
{ text: t('merchant.portal.printer.status.1'), value: 1 },
|
||||
],
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.printer.created_at'),
|
||||
hideInForm: true,
|
||||
hideInSearch: true,
|
||||
dataIndex: 'created_at',
|
||||
align: 'center',
|
||||
render: (value: string) => (value ? dayjs(value).fromNow() : '-'),
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.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-portal/printer',
|
||||
columns,
|
||||
rowKey: 'id',
|
||||
accessName: 'merchant.portal.printer',
|
||||
scroll: { x: 1200 },
|
||||
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.portal.printer.page.title')}</Title>
|
||||
<Text type="secondary">{t('merchant.portal.printer.page.description')}</Text>
|
||||
</div>
|
||||
<XinTable<IPrinter> {...tableProps} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default Table;
|
||||
@@ -0,0 +1,134 @@
|
||||
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.portal.product-category.id'),
|
||||
dataIndex: 'id',
|
||||
hideInForm: true,
|
||||
sorter: true,
|
||||
align: 'center',
|
||||
width: 80,
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.product-category.name'),
|
||||
dataIndex: 'name',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
required: true,
|
||||
rules: [{ required: true, message: t('merchant.portal.product-category.name.required') }],
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.product-category.parent_id'),
|
||||
dataIndex: 'parent_id',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.product-category.slug'),
|
||||
dataIndex: 'slug',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
hideInSearch: true,
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.product-category.icon'),
|
||||
dataIndex: 'icon',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
hideInSearch: true,
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.product-category.sort'),
|
||||
dataIndex: 'sort',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
hideInSearch: true,
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.product-category.description'),
|
||||
dataIndex: 'description',
|
||||
valueType: 'text',
|
||||
hideInTable: true,
|
||||
hideInSearch: true,
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.product-category.status'),
|
||||
dataIndex: 'status',
|
||||
valueType: 'radioButton',
|
||||
fieldProps: {
|
||||
options: [
|
||||
{ value: 0, label: t('merchant.portal.product-category.status.0') },
|
||||
{ value: 1, label: t('merchant.portal.product-category.status.1') },
|
||||
],
|
||||
},
|
||||
render: (value: number) => {
|
||||
return value === 1
|
||||
? <Tag color="success">{t('merchant.portal.product-category.status.1')}</Tag>
|
||||
: <Tag color="default">{t('merchant.portal.product-category.status.0')}</Tag>;
|
||||
},
|
||||
filters: [
|
||||
{ text: t('merchant.portal.product-category.status.0'), value: 0 },
|
||||
{ text: t('merchant.portal.product-category.status.1'), value: 1 },
|
||||
],
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.product-category.created_at'),
|
||||
hideInForm: true,
|
||||
hideInSearch: true,
|
||||
dataIndex: 'created_at',
|
||||
align: 'center',
|
||||
render: (value: string) => (value ? dayjs(value).fromNow() : '-'),
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.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-portal/product-category',
|
||||
columns,
|
||||
rowKey: 'id',
|
||||
accessName: 'merchant.portal.product-category',
|
||||
scroll: { x: 1200 },
|
||||
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.portal.product-category.page.title')}</Title>
|
||||
<Text type="secondary">{t('merchant.portal.product-category.page.description')}</Text>
|
||||
</div>
|
||||
<XinTable<IProductCategory> {...tableProps} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default Table;
|
||||
@@ -0,0 +1,173 @@
|
||||
import { Tag, Typography } from 'antd';
|
||||
import React from 'react';
|
||||
import XinTable from '@/components/XinTable';
|
||||
import type { XinTableColumn, XinTableProps } from '@/components/XinTable/typings';
|
||||
import type IMerchantProduct from '@/domain/iMerchantProduct';
|
||||
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<IMerchantProduct>[] = [
|
||||
{
|
||||
title: t('merchant.portal.product.id'),
|
||||
dataIndex: 'id',
|
||||
hideInForm: true,
|
||||
sorter: true,
|
||||
align: 'center',
|
||||
width: 80,
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.product.name'),
|
||||
dataIndex: 'name',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
required: true,
|
||||
rules: [{ required: true, message: t('merchant.portal.product.name.required') }],
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.product.category_id'),
|
||||
dataIndex: 'category_id',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.product.price'),
|
||||
dataIndex: 'price',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
render: (value: number) => `¥${value || '0.00'}`,
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.product.original_price'),
|
||||
dataIndex: 'original_price',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
hideInSearch: true,
|
||||
render: (value: number) => value ? `¥${value}` : '-',
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.product.stock'),
|
||||
dataIndex: 'stock',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
hideInSearch: true,
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.product.sales'),
|
||||
dataIndex: 'sales',
|
||||
hideInForm: true,
|
||||
hideInSearch: true,
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.product.unit'),
|
||||
dataIndex: 'unit',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
hideInSearch: true,
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.product.description'),
|
||||
dataIndex: 'description',
|
||||
valueType: 'text',
|
||||
hideInTable: true,
|
||||
hideInSearch: true,
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.product.status'),
|
||||
dataIndex: 'status',
|
||||
valueType: 'radioButton',
|
||||
fieldProps: {
|
||||
options: [
|
||||
{ value: 0, label: t('merchant.portal.product.status.0') },
|
||||
{ value: 1, label: t('merchant.portal.product.status.1') },
|
||||
],
|
||||
},
|
||||
render: (value: number) => {
|
||||
return value === 1
|
||||
? <Tag color="success">{t('merchant.portal.product.status.1')}</Tag>
|
||||
: <Tag color="default">{t('merchant.portal.product.status.0')}</Tag>;
|
||||
},
|
||||
filters: [
|
||||
{ text: t('merchant.portal.product.status.0'), value: 0 },
|
||||
{ text: t('merchant.portal.product.status.1'), value: 1 },
|
||||
],
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.product.is_recommend'),
|
||||
dataIndex: 'is_recommend',
|
||||
valueType: 'radioButton',
|
||||
fieldProps: {
|
||||
options: [
|
||||
{ value: 0, label: t('merchant.portal.product.is_recommend.0') },
|
||||
{ value: 1, label: t('merchant.portal.product.is_recommend.1') },
|
||||
],
|
||||
},
|
||||
render: (value: number) => {
|
||||
return value === 1
|
||||
? <Tag color="orange">{t('merchant.portal.product.is_recommend.1')}</Tag>
|
||||
: <Tag>{t('merchant.portal.product.is_recommend.0')}</Tag>;
|
||||
},
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.product.sort'),
|
||||
dataIndex: 'sort',
|
||||
valueType: 'text',
|
||||
align: 'center',
|
||||
hideInSearch: true,
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.product.created_at'),
|
||||
hideInForm: true,
|
||||
hideInSearch: true,
|
||||
dataIndex: 'created_at',
|
||||
align: 'center',
|
||||
render: (value: string) => (value ? dayjs(value).fromNow() : '-'),
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.product.updated_at'),
|
||||
hideInForm: true,
|
||||
hideInSearch: true,
|
||||
dataIndex: 'updated_at',
|
||||
align: 'center',
|
||||
render: (value: string) => (value ? dayjs(value).fromNow() : '-'),
|
||||
},
|
||||
];
|
||||
|
||||
const tableProps: XinTableProps<IMerchantProduct> = {
|
||||
api: '/merchant-portal/product',
|
||||
columns,
|
||||
rowKey: 'id',
|
||||
accessName: 'merchant.portal.product',
|
||||
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 (
|
||||
<>
|
||||
<div className="mb-5">
|
||||
<Title level={3}>{t('merchant.portal.product.page.title')}</Title>
|
||||
<Text type="secondary">{t('merchant.portal.product.page.description')}</Text>
|
||||
</div>
|
||||
<XinTable<IMerchantProduct> {...tableProps} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default Table;
|
||||
@@ -0,0 +1,107 @@
|
||||
import { Typography } from 'antd';
|
||||
import React from 'react';
|
||||
import XinForm from '@/components/XinForm';
|
||||
import type { FormColumn } from '@/components/XinForm/typings';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import createAxios from '@/utils/request';
|
||||
|
||||
const { Title, Text } = Typography;
|
||||
|
||||
const Store: React.FC = () => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const columns: FormColumn[] = [
|
||||
{
|
||||
title: t('merchant.portal.store.name'),
|
||||
dataIndex: 'name',
|
||||
valueType: 'text',
|
||||
rules: [{ required: true, message: t('merchant.portal.store.name.required') }],
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.store.logo'),
|
||||
dataIndex: 'logo',
|
||||
valueType: 'text',
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.store.banner'),
|
||||
dataIndex: 'banner',
|
||||
valueType: 'text',
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.store.description'),
|
||||
dataIndex: 'description',
|
||||
valueType: 'textarea',
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.store.contact_name'),
|
||||
dataIndex: 'contact_name',
|
||||
valueType: 'text',
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.store.contact_mobile'),
|
||||
dataIndex: 'contact_mobile',
|
||||
valueType: 'text',
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.store.province'),
|
||||
dataIndex: 'province',
|
||||
valueType: 'text',
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.store.city'),
|
||||
dataIndex: 'city',
|
||||
valueType: 'text',
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.store.district'),
|
||||
dataIndex: 'district',
|
||||
valueType: 'text',
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.store.address'),
|
||||
dataIndex: 'address',
|
||||
valueType: 'text',
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.store.business_hours'),
|
||||
dataIndex: 'business_hours',
|
||||
valueType: 'text',
|
||||
},
|
||||
{
|
||||
title: t('merchant.portal.store.min_price'),
|
||||
dataIndex: 'min_price',
|
||||
valueType: 'text',
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="mb-5">
|
||||
<Title level={3}>{t('merchant.portal.store.page.title')}</Title>
|
||||
<Text type="secondary">{t('merchant.portal.store.page.description')}</Text>
|
||||
</div>
|
||||
<XinForm
|
||||
columns={columns}
|
||||
layoutType="Form"
|
||||
grid
|
||||
request={async () => {
|
||||
const { data } = await createAxios<any>({
|
||||
url: '/merchant-portal/store',
|
||||
method: 'get',
|
||||
});
|
||||
return data.data;
|
||||
}}
|
||||
onFinish={async (values) => {
|
||||
await createAxios({
|
||||
url: '/merchant-portal/store',
|
||||
method: 'put',
|
||||
data: values,
|
||||
});
|
||||
return true;
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default Store;
|
||||
Reference in New Issue
Block a user