import React, { useEffect, useState } from 'react'; import { Tag, Typography } from 'antd'; import XinTable from '@/components/XinTable'; import type { XinTableColumn, XinTableProps } from '@/components/XinTable/typings.ts'; import type IStore from '@/domain/iStore.ts'; import { STORE_STATUS_MAP } from '@/domain/iStore.ts'; import type ICustomerLevel from '@/domain/iCustomerLevel.ts'; import { getLevelOptions } from '@/api/customer/level.ts'; const { Title, Text } = Typography; /** * 门店管理 */ const StorePage: React.FC = () => { const [levels, setLevels] = useState([]); useEffect(() => { getLevelOptions().then((res) => setLevels(res.data.data ?? [])); }, []); const levelOptions = levels.map((l) => ({ label: l.name, value: l.id })); const columns: XinTableColumn[] = [ { title: 'ID', dataIndex: 'id', hideInForm: true, hideInSearch: true, width: 70, align: 'center', }, { title: '门店名称', dataIndex: 'name', valueType: 'text', required: true, rules: [{ required: true, message: '请输入门店名称' }], }, { title: '门店编码', dataIndex: 'code', valueType: 'text', hideInForm: true }, { title: '客户等级', dataIndex: 'level_id', valueType: 'select', required: true, rules: [{ required: true, message: '请选择客户等级' }], fieldProps: { options: levelOptions, showSearch: true, optionFilterProp: 'label', }, render: (_, record) => record.level ? {record.level.name} : 未设置, }, { title: '联系人', dataIndex: 'contact', valueType: 'text', hideInSearch: true, }, { title: '联系电话', dataIndex: 'phone', valueType: 'text', hideInSearch: true, }, { title: '门店地址', dataIndex: 'address', valueType: 'textarea', hideInSearch: true, fieldProps: { rows: 1 }, colProps: { span: 24 } }, { title: '回款周期(天)', dataIndex: 'payment_cycle_days', valueType: 'digit', hideInSearch: true, initialValue: 0, fieldProps: { min: 0, precision: 0 }, align: 'center', }, { title: '待回筐数量', dataIndex: 'pending_box_num', hideInForm: true, hideInSearch: true, align: 'center', render: (_, record) => ( 0 ? 'warning' : undefined}> {record.pending_box_num ?? 0} ), }, { title: '待回托盘数量', dataIndex: 'pending_tray_num', hideInForm: true, hideInSearch: true, align: 'center', render: (_, record) => ( 0 ? 'warning' : undefined}> {record.pending_tray_num ?? 0} ), }, { title: '状态', dataIndex: 'status', valueType: 'radioButton', initialValue: 1, fieldProps: { options: [ { value: 1, label: '正常' }, { value: 0, label: '停用' }, ], }, render: (_, record) => { const item = STORE_STATUS_MAP[record.status ?? 1]; return {item?.text}; }, }, { title: '备注', dataIndex: 'remark', valueType: 'textarea', hideInSearch: true, hideInTable: true, fieldProps: { rows: 2 }, colProps: { span: 24 } }, ]; const tableProps: XinTableProps = { api: '/customer/store', columns, rowKey: 'id', accessName: 'customer.store', formProps: { grid: true, colProps: { span: 12 }, rowProps: { gutter: 20 }, layout: 'vertical', }, modalProps: { width: 720 }, }; return ( <>
门店管理 门店即客户,小程序下单主体;客户等级决定商品价格,回款周期影响对账单应结算日期。
{...tableProps} /> ); }; export default StorePage;