122 lines
2.9 KiB
TypeScript
122 lines
2.9 KiB
TypeScript
import React from 'react';
|
|
import { Tag, Typography, Image } from 'antd';
|
|
import XinTable from '@/components/XinTable';
|
|
import type { XinTableColumn, XinTableProps } from '@/components/XinTable/typings.ts';
|
|
import type ICustomerLevel from '@/domain/iCustomerLevel.ts';
|
|
import { CUSTOMER_LEVEL_STATUS_MAP } from '@/domain/iCustomerLevel.ts';
|
|
|
|
const { Title, Text } = Typography;
|
|
|
|
/**
|
|
* 客户等级管理
|
|
*/
|
|
const CustomerLevelPage: React.FC = () => {
|
|
const columns: XinTableColumn<ICustomerLevel>[] = [
|
|
{
|
|
title: 'ID',
|
|
dataIndex: 'id',
|
|
hideInForm: true,
|
|
hideInSearch: true,
|
|
width: 70,
|
|
align: 'center',
|
|
},
|
|
{
|
|
title: '等级名称',
|
|
dataIndex: 'name',
|
|
valueType: 'text',
|
|
required: true,
|
|
align: 'center',
|
|
rules: [{ required: true, message: '请输入等级名称' }],
|
|
},
|
|
{
|
|
title: '排序',
|
|
dataIndex: 'sort',
|
|
valueType: 'digit',
|
|
hideInSearch: true,
|
|
initialValue: 0,
|
|
fieldProps: { min: 0 },
|
|
},
|
|
{
|
|
title: '图片等级',
|
|
dataIndex: 'icon_id',
|
|
valueType: 'image',
|
|
fieldProps: {
|
|
action: '/customer/level/upload',
|
|
mode: 'single',
|
|
maxCount: 1,
|
|
changeType: "id"
|
|
},
|
|
render: (_, record: ICustomerLevel) => {
|
|
const url = record.icon_url
|
|
if (!url) return '-';
|
|
return (
|
|
<Image
|
|
src={url}
|
|
width={30}
|
|
height={30}
|
|
style={{ objectFit: 'cover', borderRadius: 4 }}
|
|
/>
|
|
);
|
|
},
|
|
align: 'center',
|
|
hideInSearch: true,
|
|
},
|
|
{
|
|
title: '状态',
|
|
dataIndex: 'status',
|
|
valueType: 'radioButton',
|
|
initialValue: 1,
|
|
fieldProps: {
|
|
options: [
|
|
{ value: 1, label: '正常' },
|
|
{ value: 0, label: '停用' },
|
|
],
|
|
},
|
|
render: (_, record) => {
|
|
const item = CUSTOMER_LEVEL_STATUS_MAP[record.status ?? 1];
|
|
return <Tag color={item?.color}>{item?.text}</Tag>;
|
|
},
|
|
},
|
|
{
|
|
title: '创建时间',
|
|
dataIndex: 'updated_at',
|
|
hideInForm: true,
|
|
hideInSearch: true,
|
|
align: 'center',
|
|
},
|
|
{
|
|
title: '创建时间',
|
|
dataIndex: 'created_at',
|
|
hideInForm: true,
|
|
hideInSearch: true,
|
|
align: 'center',
|
|
},
|
|
];
|
|
|
|
const tableProps: XinTableProps<ICustomerLevel> = {
|
|
api: '/customer/level',
|
|
columns,
|
|
rowKey: 'id',
|
|
accessName: 'customer.level',
|
|
formProps: {
|
|
grid: true,
|
|
colProps: { span: 12 },
|
|
rowProps: { gutter: 20 },
|
|
layout: 'vertical',
|
|
},
|
|
modalProps: { width: 640 },
|
|
};
|
|
|
|
return (
|
|
<>
|
|
<div className="mb-5">
|
|
<Title level={3}>客户等级</Title>
|
|
<Text type="secondary">同一商品按客户等级显示不同单价,门店绑定等级后小程序端按对应价格展示。</Text>
|
|
</div>
|
|
<XinTable<ICustomerLevel> {...tableProps} />
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default CustomerLevelPage;
|