校园商户

This commit is contained in:
liu
2026-06-17 09:13:49 +08:00
parent 86be1c230e
commit 254823e308
50 changed files with 2186 additions and 40 deletions
+11
View File
@@ -0,0 +1,11 @@
export default interface IMerchantCategory {
id?: number;
name?: string;
slug?: string;
description?: string;
icon?: string;
sort?: number;
status?: number;
created_at?: string;
updated_at?: string;
}
+19
View File
@@ -0,0 +1,19 @@
export default interface IMerchantProduct {
id?: number;
merchant_id?: number;
category_id?: number;
name?: string;
description?: string;
images?: string[];
price?: number;
original_price?: number;
stock?: number;
unit?: string;
sales?: number;
status?: number;
is_recommend?: number;
sort?: number;
created_at?: string;
updated_at?: string;
deleted_at?: string;
}
+25
View File
@@ -0,0 +1,25 @@
export default interface IMerchantStore {
id?: number;
user_id?: number;
category_id?: number;
name?: string;
logo?: string;
banner?: string;
description?: string;
contact_name?: string;
contact_mobile?: string;
province?: string;
city?: string;
district?: string;
address?: string;
latitude?: string;
longitude?: string;
business_hours?: string;
balance?: number;
total_income?: number;
min_price?: number;
status?: number;
reject_reason?: string;
created_at?: string;
updated_at?: string;
}
+12
View File
@@ -0,0 +1,12 @@
export default interface IPrintTask {
id?: number;
printer_id?: number;
order_id?: number;
content?: string;
copies?: number;
status?: number;
error_msg?: string;
printed_at?: string;
created_at?: string;
updated_at?: string;
}
+13
View File
@@ -0,0 +1,13 @@
export default interface IPrinter {
id?: number;
merchant_id?: number;
name?: string;
brand?: string;
model?: string;
device_no?: string;
secret_key?: string;
status?: number;
config?: Record<string, unknown>;
created_at?: string;
updated_at?: string;
}
+13
View File
@@ -0,0 +1,13 @@
export default interface IProductCategory {
id?: number;
merchant_id?: number;
parent_id?: number;
name?: string;
slug?: string;
description?: string;
icon?: string;
sort?: number;
status?: number;
created_at?: string;
updated_at?: string;
}
+13
View File
@@ -31,6 +31,13 @@ import forumSensitiveWord from "./forum/sensitive-word";
import forumPostLike from "./forum/post-like";
import forumPostFavorite from "./forum/post-favorite";
import merchantCategory from "./merchant/category";
import merchantStore from "./merchant/store";
import merchantProductCategory from "./merchant/product-category";
import merchantProduct from "./merchant/product";
import merchantPrinter from "./merchant/printer";
import merchantPrintTask from "./merchant/print-task";
import userProfile from "./user/profile";
import xinForm from "./components/xin-form";
@@ -67,6 +74,12 @@ export default {
...forumSensitiveWord,
...forumPostLike,
...forumPostFavorite,
...merchantCategory,
...merchantStore,
...merchantProductCategory,
...merchantProduct,
...merchantPrinter,
...merchantPrintTask,
...userProfile,
...xinForm,
...xinTable,
+7
View File
@@ -54,5 +54,12 @@ export default {
"menu.forum.sensitive-word": "Sensitive Words",
"menu.forum.post-like": "Like Records",
"menu.forum.post-favorite": "Favorite Records",
"menu.merchant": "Campus Merchant",
"menu.merchant.category": "Categories",
"menu.merchant.store": "Merchants",
"menu.merchant.product-category": "Product Categories",
"menu.merchant.product": "Products",
"menu.merchant.printer": "Printers",
"menu.merchant.print-task": "Print Tasks",
"menu.xin-admin": "XinAdmin",
}
+17
View File
@@ -0,0 +1,17 @@
export default {
"merchant.category.page.title": "Merchant Categories",
"merchant.category.page.description": "Manage campus merchant categories for grouping",
"merchant.category.id": "ID",
"merchant.category.name": "Name",
"merchant.category.name.required": "Category name is required",
"merchant.category.slug": "Slug",
"merchant.category.slug.required": "Category slug is required",
"merchant.category.description": "Description",
"merchant.category.icon": "Icon",
"merchant.category.sort": "Sort",
"merchant.category.status": "Status",
"merchant.category.status.0": "Disabled",
"merchant.category.status.1": "Active",
"merchant.category.created_at": "Created At",
"merchant.category.updated_at": "Updated At",
};
+18
View File
@@ -0,0 +1,18 @@
export default {
"merchant.print-task.page.title": "Print Tasks",
"merchant.print-task.page.description": "View and manage merchant printer task records",
"merchant.print-task.id": "ID",
"merchant.print-task.printer_id": "Printer",
"merchant.print-task.order_id": "Order",
"merchant.print-task.content": "Content",
"merchant.print-task.copies": "Copies",
"merchant.print-task.status": "Status",
"merchant.print-task.status.0": "Pending",
"merchant.print-task.status.1": "Printing",
"merchant.print-task.status.2": "Completed",
"merchant.print-task.status.3": "Failed",
"merchant.print-task.error_msg": "Error",
"merchant.print-task.printed_at": "Printed At",
"merchant.print-task.created_at": "Created At",
"merchant.print-task.updated_at": "Updated At",
};
+20
View File
@@ -0,0 +1,20 @@
export default {
"merchant.printer.page.title": "Printer Management",
"merchant.printer.page.description": "Manage merchant printer devices with online/offline status monitoring",
"merchant.printer.id": "ID",
"merchant.printer.merchant_id": "Merchant",
"merchant.printer.merchant_id.required": "Merchant is required",
"merchant.printer.name": "Name",
"merchant.printer.name.required": "Printer name is required",
"merchant.printer.brand": "Brand",
"merchant.printer.model": "Model",
"merchant.printer.device_no": "Device No",
"merchant.printer.secret_key": "Secret Key",
"merchant.printer.status": "Status",
"merchant.printer.status.0": "Offline",
"merchant.printer.status.1": "Online",
"merchant.printer.status.2": "Fault",
"merchant.printer.config": "Config",
"merchant.printer.created_at": "Created At",
"merchant.printer.updated_at": "Updated At",
};
@@ -0,0 +1,20 @@
export default {
"merchant.product-category.page.title": "Product Categories",
"merchant.product-category.page.description": "Manage product categories under merchants with parent-child structure",
"merchant.product-category.id": "ID",
"merchant.product-category.merchant_id": "Merchant",
"merchant.product-category.merchant_id.required": "Merchant is required",
"merchant.product-category.parent_id": "Parent",
"merchant.product-category.name": "Name",
"merchant.product-category.name.required": "Category name is required",
"merchant.product-category.slug": "Slug",
"merchant.product-category.slug.required": "Category slug is required",
"merchant.product-category.description": "Description",
"merchant.product-category.icon": "Icon",
"merchant.product-category.sort": "Sort",
"merchant.product-category.status": "Status",
"merchant.product-category.status.0": "Disabled",
"merchant.product-category.status.1": "Active",
"merchant.product-category.created_at": "Created At",
"merchant.product-category.updated_at": "Updated At",
};
+27
View File
@@ -0,0 +1,27 @@
export default {
"merchant.product.page.title": "Product Management",
"merchant.product.page.description": "Manage merchant products, support listing, delisting, recommend and more",
"merchant.product.id": "ID",
"merchant.product.merchant_id": "Merchant",
"merchant.product.merchant_id.required": "Merchant is required",
"merchant.product.category_id": "Category",
"merchant.product.name": "Name",
"merchant.product.name.required": "Product name is required",
"merchant.product.description": "Description",
"merchant.product.images": "Images",
"merchant.product.price": "Price",
"merchant.product.price.required": "Price is required",
"merchant.product.original_price": "Original Price",
"merchant.product.stock": "Stock",
"merchant.product.unit": "Unit",
"merchant.product.sales": "Sales",
"merchant.product.status": "Status",
"merchant.product.status.0": "Delisted",
"merchant.product.status.1": "Listed",
"merchant.product.is_recommend": "Recommended",
"merchant.product.is_recommend.0": "No",
"merchant.product.is_recommend.1": "Yes",
"merchant.product.sort": "Sort",
"merchant.product.created_at": "Created At",
"merchant.product.updated_at": "Updated At",
};
+31
View File
@@ -0,0 +1,31 @@
export default {
"merchant.store.page.title": "Merchant Management",
"merchant.store.page.description": "Manage campus merchants/stores, support review, enable, disable and more",
"merchant.store.id": "ID",
"merchant.store.user_id": "Owner",
"merchant.store.user_id.required": "Owner is required",
"merchant.store.category_id": "Category",
"merchant.store.name": "Store Name",
"merchant.store.name.required": "Store name is required",
"merchant.store.logo": "Logo",
"merchant.store.banner": "Banner",
"merchant.store.description": "Description",
"merchant.store.contact_name": "Contact",
"merchant.store.contact_mobile": "Phone",
"merchant.store.province": "Province",
"merchant.store.city": "City",
"merchant.store.district": "District",
"merchant.store.address": "Address",
"merchant.store.business_hours": "Business Hours",
"merchant.store.balance": "Balance",
"merchant.store.total_income": "Total Income",
"merchant.store.min_price": "Min Price",
"merchant.store.status": "Status",
"merchant.store.status.0": "Pending",
"merchant.store.status.1": "Active",
"merchant.store.status.2": "Disabled",
"merchant.store.status.3": "Closed",
"merchant.store.reject_reason": "Reject Reason",
"merchant.store.created_at": "Joined At",
"merchant.store.updated_at": "Updated At",
};
+13
View File
@@ -31,6 +31,13 @@ import forumSensitiveWord from "./forum/sensitive-word";
import forumPostLike from "./forum/post-like";
import forumPostFavorite from "./forum/post-favorite";
import merchantCategory from "./merchant/category";
import merchantStore from "./merchant/store";
import merchantProductCategory from "./merchant/product-category";
import merchantProduct from "./merchant/product";
import merchantPrinter from "./merchant/printer";
import merchantPrintTask from "./merchant/print-task";
import userProfile from "./user/profile";
import xinForm from "./components/xin-form";
@@ -67,6 +74,12 @@ export default {
...forumSensitiveWord,
...forumPostLike,
...forumPostFavorite,
...merchantCategory,
...merchantStore,
...merchantProductCategory,
...merchantProduct,
...merchantPrinter,
...merchantPrintTask,
...userProfile,
...xinForm,
...xinTable,
+7
View File
@@ -54,5 +54,12 @@ export default {
"menu.forum.sensitive-word": "敏感词管理",
"menu.forum.post-like": "点赞记录",
"menu.forum.post-favorite": "收藏记录",
"menu.merchant": "校园商户",
"menu.merchant.category": "商户分类",
"menu.merchant.store": "商户管理",
"menu.merchant.product-category": "商品分类",
"menu.merchant.product": "商品管理",
"menu.merchant.printer": "打印机管理",
"menu.merchant.print-task": "打印任务",
"menu.xin-admin": "XinAdmin",
};
+17
View File
@@ -0,0 +1,17 @@
export default {
"merchant.category.page.title": "商户分类",
"merchant.category.page.description": "管理校园商户分类,方便对商户进行归类管理",
"merchant.category.id": "ID",
"merchant.category.name": "分类名称",
"merchant.category.name.required": "分类名称不能为空",
"merchant.category.slug": "标识",
"merchant.category.slug.required": "分类标识不能为空",
"merchant.category.description": "描述",
"merchant.category.icon": "图标",
"merchant.category.sort": "排序",
"merchant.category.status": "状态",
"merchant.category.status.0": "禁用",
"merchant.category.status.1": "正常",
"merchant.category.created_at": "创建时间",
"merchant.category.updated_at": "更新时间",
};
+18
View File
@@ -0,0 +1,18 @@
export default {
"merchant.print-task.page.title": "打印任务",
"merchant.print-task.page.description": "查看和管理商户打印机任务记录",
"merchant.print-task.id": "ID",
"merchant.print-task.printer_id": "打印机",
"merchant.print-task.order_id": "关联订单",
"merchant.print-task.content": "打印内容",
"merchant.print-task.copies": "打印份数",
"merchant.print-task.status": "状态",
"merchant.print-task.status.0": "待打印",
"merchant.print-task.status.1": "打印中",
"merchant.print-task.status.2": "已完成",
"merchant.print-task.status.3": "失败",
"merchant.print-task.error_msg": "错误信息",
"merchant.print-task.printed_at": "打印时间",
"merchant.print-task.created_at": "创建时间",
"merchant.print-task.updated_at": "更新时间",
};
+20
View File
@@ -0,0 +1,20 @@
export default {
"merchant.printer.page.title": "打印机管理",
"merchant.printer.page.description": "管理商户打印机设备,支持在线、离线状态监控",
"merchant.printer.id": "ID",
"merchant.printer.merchant_id": "所属商户",
"merchant.printer.merchant_id.required": "所属商户不能为空",
"merchant.printer.name": "打印机名称",
"merchant.printer.name.required": "打印机名称不能为空",
"merchant.printer.brand": "品牌",
"merchant.printer.model": "型号",
"merchant.printer.device_no": "设备编号",
"merchant.printer.secret_key": "密钥",
"merchant.printer.status": "状态",
"merchant.printer.status.0": "离线",
"merchant.printer.status.1": "在线",
"merchant.printer.status.2": "故障",
"merchant.printer.config": "打印配置",
"merchant.printer.created_at": "创建时间",
"merchant.printer.updated_at": "更新时间",
};
@@ -0,0 +1,20 @@
export default {
"merchant.product-category.page.title": "商品分类",
"merchant.product-category.page.description": "管理商户下的商品分类,支持父子级分类结构",
"merchant.product-category.id": "ID",
"merchant.product-category.merchant_id": "所属商户",
"merchant.product-category.merchant_id.required": "所属商户不能为空",
"merchant.product-category.parent_id": "父级分类",
"merchant.product-category.name": "分类名称",
"merchant.product-category.name.required": "分类名称不能为空",
"merchant.product-category.slug": "标识",
"merchant.product-category.slug.required": "分类标识不能为空",
"merchant.product-category.description": "描述",
"merchant.product-category.icon": "图标",
"merchant.product-category.sort": "排序",
"merchant.product-category.status": "状态",
"merchant.product-category.status.0": "禁用",
"merchant.product-category.status.1": "正常",
"merchant.product-category.created_at": "创建时间",
"merchant.product-category.updated_at": "更新时间",
};
+27
View File
@@ -0,0 +1,27 @@
export default {
"merchant.product.page.title": "商品管理",
"merchant.product.page.description": "管理商户商品,支持上架、下架、推荐等操作",
"merchant.product.id": "ID",
"merchant.product.merchant_id": "所属商户",
"merchant.product.merchant_id.required": "所属商户不能为空",
"merchant.product.category_id": "商品分类",
"merchant.product.name": "商品名称",
"merchant.product.name.required": "商品名称不能为空",
"merchant.product.description": "商品描述",
"merchant.product.images": "商品图片",
"merchant.product.price": "售价",
"merchant.product.price.required": "售价不能为空",
"merchant.product.original_price": "原价",
"merchant.product.stock": "库存",
"merchant.product.unit": "单位",
"merchant.product.sales": "销量",
"merchant.product.status": "状态",
"merchant.product.status.0": "下架",
"merchant.product.status.1": "上架",
"merchant.product.is_recommend": "推荐",
"merchant.product.is_recommend.0": "否",
"merchant.product.is_recommend.1": "是",
"merchant.product.sort": "排序",
"merchant.product.created_at": "创建时间",
"merchant.product.updated_at": "更新时间",
};
+31
View File
@@ -0,0 +1,31 @@
export default {
"merchant.store.page.title": "商户管理",
"merchant.store.page.description": "管理校园商户/店铺,支持审核、启用、停用等操作",
"merchant.store.id": "ID",
"merchant.store.user_id": "所属用户",
"merchant.store.user_id.required": "所属用户不能为空",
"merchant.store.category_id": "商户分类",
"merchant.store.name": "店铺名称",
"merchant.store.name.required": "店铺名称不能为空",
"merchant.store.logo": "Logo",
"merchant.store.banner": "横幅",
"merchant.store.description": "店铺简介",
"merchant.store.contact_name": "联系人",
"merchant.store.contact_mobile": "联系电话",
"merchant.store.province": "省",
"merchant.store.city": "市",
"merchant.store.district": "区",
"merchant.store.address": "详细地址",
"merchant.store.business_hours": "营业时间",
"merchant.store.balance": "账户余额",
"merchant.store.total_income": "累计收入",
"merchant.store.min_price": "起送价",
"merchant.store.status": "状态",
"merchant.store.status.0": "待审核",
"merchant.store.status.1": "正常",
"merchant.store.status.2": "停用",
"merchant.store.status.3": "已关闭",
"merchant.store.reject_reason": "拒绝原因",
"merchant.store.created_at": "入驻时间",
"merchant.store.updated_at": "更新时间",
};
+121
View File
@@ -0,0 +1,121 @@
import { Tag, Typography } from 'antd';
import React from 'react';
import XinTable from '@/components/XinTable';
import type { XinTableColumn, XinTableProps } from '@/components/XinTable/typings';
import type IMerchantCategory from '@/domain/iMerchantCategory';
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<IMerchantCategory>[] = [
{
title: t('merchant.category.id'),
dataIndex: 'id',
hideInForm: true,
sorter: true,
align: 'center',
width: 80,
},
{
title: t('merchant.category.name'),
dataIndex: 'name',
valueType: 'text',
align: 'center',
required: true,
rules: [{ required: true, message: t('merchant.category.name.required') }],
},
{
title: t('merchant.category.slug'),
dataIndex: 'slug',
valueType: 'text',
align: 'center',
required: true,
rules: [{ required: true, message: t('merchant.category.slug.required') }],
},
{
title: t('merchant.category.description'),
dataIndex: 'description',
valueType: 'text',
align: 'center',
hideInSearch: true,
},
{
title: t('merchant.category.sort'),
dataIndex: 'sort',
valueType: 'text',
align: 'center',
hideInSearch: true,
},
{
title: t('merchant.category.status'),
dataIndex: 'status',
valueType: 'radioButton',
fieldProps: {
options: [
{ value: 0, label: t('merchant.category.status.0') },
{ value: 1, label: t('merchant.category.status.1') },
],
},
render: (value: number) => {
return value === 1
? <Tag color="success">{t('merchant.category.status.1')}</Tag>
: <Tag color="error">{t('merchant.category.status.0')}</Tag>;
},
filters: [
{ text: t('merchant.category.status.0'), value: 0 },
{ text: t('merchant.category.status.1'), value: 1 },
],
align: 'center',
},
{
title: t('merchant.category.created_at'),
hideInForm: true,
hideInSearch: true,
dataIndex: 'created_at',
align: 'center',
render: (value: string) => (value ? dayjs(value).fromNow() : '-'),
},
{
title: t('merchant.category.updated_at'),
hideInForm: true,
hideInSearch: true,
dataIndex: 'updated_at',
align: 'center',
render: (value: string) => (value ? dayjs(value).fromNow() : '-'),
},
];
const tableProps: XinTableProps<IMerchantCategory> = {
api: '/merchant/category',
columns,
rowKey: 'id',
accessName: 'merchant.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.category.page.title')}</Title>
<Text type="secondary">{t('merchant.category.page.description')}</Text>
</div>
<XinTable<IMerchantCategory> {...tableProps} />
</>
);
};
export default Table;
+135
View File
@@ -0,0 +1,135 @@
import { Tag, Typography } from 'antd';
import React from 'react';
import XinTable from '@/components/XinTable';
import type { XinTableColumn, XinTableProps } from '@/components/XinTable/typings';
import type IPrintTask from '@/domain/iPrintTask';
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<IPrintTask>[] = [
{
title: t('merchant.print-task.id'),
dataIndex: 'id',
hideInForm: true,
sorter: true,
align: 'center',
width: 80,
},
{
title: t('merchant.print-task.printer_id'),
dataIndex: 'printer_id',
valueType: 'text',
align: 'center',
},
{
title: t('merchant.print-task.order_id'),
dataIndex: 'order_id',
valueType: 'text',
align: 'center',
hideInSearch: true,
},
{
title: t('merchant.print-task.content'),
dataIndex: 'content',
valueType: 'text',
hideInTable: true,
hideInSearch: true,
},
{
title: t('merchant.print-task.copies'),
dataIndex: 'copies',
valueType: 'text',
align: 'center',
hideInSearch: true,
},
{
title: t('merchant.print-task.status'),
dataIndex: 'status',
valueType: 'radioButton',
fieldProps: {
options: [
{ value: 0, label: t('merchant.print-task.status.0') },
{ value: 1, label: t('merchant.print-task.status.1') },
{ value: 2, label: t('merchant.print-task.status.2') },
{ value: 3, label: t('merchant.print-task.status.3') },
],
},
render: (value: number) => {
const colorMap: Record<number, string> = { 0: 'default', 1: 'processing', 2: 'success', 3: 'error' };
const labelMap: Record<number, string> = {
0: t('merchant.print-task.status.0'), 1: t('merchant.print-task.status.1'),
2: t('merchant.print-task.status.2'), 3: t('merchant.print-task.status.3'),
};
return <Tag color={colorMap[value] || 'default'}>{labelMap[value] || '-'}</Tag>;
},
filters: [
{ text: t('merchant.print-task.status.0'), value: 0 },
{ text: t('merchant.print-task.status.1'), value: 1 },
{ text: t('merchant.print-task.status.2'), value: 2 },
{ text: t('merchant.print-task.status.3'), value: 3 },
],
align: 'center',
},
{
title: t('merchant.print-task.error_msg'),
dataIndex: 'error_msg',
valueType: 'text',
hideInSearch: true,
align: 'center',
},
{
title: t('merchant.print-task.printed_at'),
dataIndex: 'printed_at',
hideInForm: true,
hideInSearch: true,
align: 'center',
render: (value: string) => (value ? dayjs(value).format('YYYY-MM-DD HH:mm:ss') : '-'),
},
{
title: t('merchant.print-task.created_at'),
hideInForm: true,
hideInSearch: true,
dataIndex: 'created_at',
align: 'center',
render: (value: string) => (value ? dayjs(value).fromNow() : '-'),
},
];
const tableProps: XinTableProps<IPrintTask> = {
api: '/merchant/print-task',
columns,
rowKey: 'id',
accessName: 'merchant.print-task',
createShow: false,
editShow: false,
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.print-task.page.title')}</Title>
<Text type="secondary">{t('merchant.print-task.page.description')}</Text>
</div>
<XinTable<IPrintTask> {...tableProps} />
</>
);
};
export default Table;
+139
View File
@@ -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;
@@ -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;
+180
View File
@@ -0,0 +1,180 @@
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.product.id'),
dataIndex: 'id',
hideInForm: true,
sorter: true,
align: 'center',
width: 80,
},
{
title: t('merchant.product.name'),
dataIndex: 'name',
valueType: 'text',
align: 'center',
required: true,
rules: [{ required: true, message: t('merchant.product.name.required') }],
},
{
title: t('merchant.product.merchant_id'),
dataIndex: 'merchant_id',
valueType: 'text',
align: 'center',
required: true,
},
{
title: t('merchant.product.category_id'),
dataIndex: 'category_id',
valueType: 'text',
align: 'center',
},
{
title: t('merchant.product.price'),
dataIndex: 'price',
valueType: 'text',
align: 'center',
render: (value: number) => `¥${value || '0.00'}`,
},
{
title: t('merchant.product.original_price'),
dataIndex: 'original_price',
valueType: 'text',
align: 'center',
hideInSearch: true,
render: (value: number) => value ? `¥${value}` : '-',
},
{
title: t('merchant.product.stock'),
dataIndex: 'stock',
valueType: 'text',
align: 'center',
hideInSearch: true,
},
{
title: t('merchant.product.sales'),
dataIndex: 'sales',
hideInForm: true,
hideInSearch: true,
align: 'center',
},
{
title: t('merchant.product.unit'),
dataIndex: 'unit',
valueType: 'text',
align: 'center',
hideInSearch: true,
},
{
title: t('merchant.product.description'),
dataIndex: 'description',
valueType: 'text',
hideInTable: true,
hideInSearch: true,
},
{
title: t('merchant.product.status'),
dataIndex: 'status',
valueType: 'radioButton',
fieldProps: {
options: [
{ value: 0, label: t('merchant.product.status.0') },
{ value: 1, label: t('merchant.product.status.1') },
],
},
render: (value: number) => {
return value === 1
? <Tag color="success">{t('merchant.product.status.1')}</Tag>
: <Tag color="default">{t('merchant.product.status.0')}</Tag>;
},
filters: [
{ text: t('merchant.product.status.0'), value: 0 },
{ text: t('merchant.product.status.1'), value: 1 },
],
align: 'center',
},
{
title: t('merchant.product.is_recommend'),
dataIndex: 'is_recommend',
valueType: 'radioButton',
fieldProps: {
options: [
{ value: 0, label: t('merchant.product.is_recommend.0') },
{ value: 1, label: t('merchant.product.is_recommend.1') },
],
},
render: (value: number) => {
return value === 1
? <Tag color="orange">{t('merchant.product.is_recommend.1')}</Tag>
: <Tag>{t('merchant.product.is_recommend.0')}</Tag>;
},
align: 'center',
},
{
title: t('merchant.product.sort'),
dataIndex: 'sort',
valueType: 'text',
align: 'center',
hideInSearch: true,
},
{
title: t('merchant.product.created_at'),
hideInForm: true,
hideInSearch: true,
dataIndex: 'created_at',
align: 'center',
render: (value: string) => (value ? dayjs(value).fromNow() : '-'),
},
{
title: t('merchant.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/product',
columns,
rowKey: 'id',
accessName: 'merchant.product',
scroll: { x: 1600 },
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.product.page.title')}</Title>
<Text type="secondary">{t('merchant.product.page.description')}</Text>
</div>
<XinTable<IMerchantProduct> {...tableProps} />
</>
);
};
export default Table;
+165
View File
@@ -0,0 +1,165 @@
import { Tag, Typography } from 'antd';
import React from 'react';
import XinTable from '@/components/XinTable';
import type { XinTableColumn, XinTableProps } from '@/components/XinTable/typings';
import type IMerchantStore from '@/domain/iMerchantStore';
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<IMerchantStore>[] = [
{
title: t('merchant.store.id'),
dataIndex: 'id',
hideInForm: true,
sorter: true,
align: 'center',
width: 80,
},
{
title: t('merchant.store.name'),
dataIndex: 'name',
valueType: 'text',
align: 'center',
required: true,
rules: [{ required: true, message: t('merchant.store.name.required') }],
},
{
title: t('merchant.store.user_id'),
dataIndex: 'user_id',
valueType: 'text',
align: 'center',
required: true,
hideInSearch: true,
},
{
title: t('merchant.store.category_id'),
dataIndex: 'category_id',
valueType: 'text',
align: 'center',
},
{
title: t('merchant.store.contact_name'),
dataIndex: 'contact_name',
valueType: 'text',
align: 'center',
hideInSearch: true,
},
{
title: t('merchant.store.contact_mobile'),
dataIndex: 'contact_mobile',
valueType: 'text',
align: 'center',
hideInSearch: true,
},
{
title: t('merchant.store.address'),
dataIndex: 'address',
valueType: 'text',
hideInTable: true,
hideInSearch: true,
},
{
title: t('merchant.store.description'),
dataIndex: 'description',
valueType: 'text',
hideInTable: true,
hideInSearch: true,
},
{
title: t('merchant.store.balance'),
dataIndex: 'balance',
hideInForm: true,
hideInSearch: true,
align: 'center',
render: (value: number) => `¥${value || '0.00'}`,
},
{
title: t('merchant.store.min_price'),
dataIndex: 'min_price',
valueType: 'text',
align: 'center',
hideInSearch: true,
render: (value: number) => `¥${value || '0.00'}`,
},
{
title: t('merchant.store.status'),
dataIndex: 'status',
valueType: 'radioButton',
fieldProps: {
options: [
{ value: 0, label: t('merchant.store.status.0') },
{ value: 1, label: t('merchant.store.status.1') },
{ value: 2, label: t('merchant.store.status.2') },
{ value: 3, label: t('merchant.store.status.3') },
],
},
render: (value: number) => {
const colorMap: Record<number, string> = { 0: 'processing', 1: 'success', 2: 'warning', 3: 'error' };
const labelMap: Record<number, string> = {
0: t('merchant.store.status.0'), 1: t('merchant.store.status.1'),
2: t('merchant.store.status.2'), 3: t('merchant.store.status.3'),
};
return <Tag color={colorMap[value] || 'default'}>{labelMap[value] || '-'}</Tag>;
},
filters: [
{ text: t('merchant.store.status.0'), value: 0 },
{ text: t('merchant.store.status.1'), value: 1 },
{ text: t('merchant.store.status.2'), value: 2 },
{ text: t('merchant.store.status.3'), value: 3 },
],
align: 'center',
},
{
title: t('merchant.store.created_at'),
hideInForm: true,
hideInSearch: true,
dataIndex: 'created_at',
align: 'center',
render: (value: string) => (value ? dayjs(value).fromNow() : '-'),
},
{
title: t('merchant.store.updated_at'),
hideInForm: true,
hideInSearch: true,
dataIndex: 'updated_at',
align: 'center',
render: (value: string) => (value ? dayjs(value).fromNow() : '-'),
},
];
const tableProps: XinTableProps<IMerchantStore> = {
api: '/merchant/store',
columns,
rowKey: 'id',
accessName: 'merchant.store',
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.store.page.title')}</Title>
<Text type="secondary">{t('merchant.store.page.description')}</Text>
</div>
<XinTable<IMerchantStore> {...tableProps} />
</>
);
};
export default Table;