wsj
3 days ago cd2b7d36f3610417c268d062454b7ec43e9ca937
src/pages/customers/list/columns.tsx
@@ -1,25 +1,29 @@
import { Tag } from 'antd';
import { Button, Space, Tag } from 'antd';
import type { ProColumns } from '@ant-design/pro-components';
import type {
  CustomerLevel,
  CustomerSource,
  CustomerStage,
  CustomerType,
  CustomerVO,
  FollowMethod,
  FollowRecordType,
  FollowStatus,
} from './types';
const customerTypeMeta: Record<CustomerType, { text: string; color: string }> = {
export const customerTypeMeta: Record<CustomerType, { text: string; color: string }> = {
  ENTERPRISE: { text: '企业', color: 'blue' },
  PERSONAL: { text: '个人', color: 'default' },
};
const levelMeta: Record<CustomerLevel, { text: string; color: string }> = {
export const levelMeta: Record<CustomerLevel, { text: string; color: string }> = {
  VIP: { text: 'VIP', color: 'purple' },
  A: { text: 'A 类', color: 'gold' },
  B: { text: 'B 类', color: 'blue' },
  C: { text: 'C 类', color: 'default' },
};
const stageMeta: Record<CustomerStage, { text: string; color: string }> = {
export const stageMeta: Record<CustomerStage, { text: string; color: string }> = {
  NEW_LEAD: { text: '新线索', color: 'default' },
  PENDING_ASSIGN: { text: '待分配', color: 'orange' },
  CONTACTING: { text: '沟通中', color: 'processing' },
@@ -30,7 +34,35 @@
  LOST: { text: '已流失', color: 'error' },
};
const renderTags = (tags?: string) => {
export const sourceMeta: Record<CustomerSource, string> = {
  MINI_PROGRAM: '小程序',
  SALES_INPUT: '销售录入',
  EXHIBITION: '展会',
  REFERRAL: '转介绍',
  WEBSITE: '官网',
};
export const followMethodMeta: Record<FollowMethod, string> = {
  PHONE: '电话',
  WECHAT: '微信',
  VISIT: '拜访',
  EMAIL: '邮件',
  MEETING: '会议',
};
export const followStatusMeta: Record<FollowStatus, { text: string; color: string }> = {
  DONE: { text: '已完成', color: 'success' },
  PENDING: { text: '待跟进', color: 'processing' },
  OVERDUE: { text: '已逾期', color: 'error' },
};
export const followRecordTypeMeta: Record<FollowRecordType, { text: string; color: string }> = {
  FOLLOW: { text: '跟进', color: 'blue' },
  PLAN: { text: '计划', color: 'default' },
  STAGE_CHANGE: { text: '阶段变更', color: 'purple' },
};
export const renderTags = (tags?: string) => {
  const items = tags?.split(/[,,]/).map((tag) => tag.trim()).filter(Boolean) ?? [];
  if (!items.length) return '-';
@@ -45,7 +77,10 @@
  );
};
export const customerColumns: ProColumns<CustomerVO>[] = [
export const createCustomerColumns = (options: {
  onDetail: (record: CustomerVO) => void;
  onFollowUp: (record: CustomerVO) => void;
}): ProColumns<CustomerVO>[] => [
  {
    title: '客户名称',
    dataIndex: 'name',
@@ -139,7 +174,7 @@
    valueType: 'digit',
    tooltip: '按归属销售员 ID 筛选,不填表示全部',
    fieldProps: { placeholder: '销售员 ID', min: 1, precision: 0 },
    render: (_value, record) => (record.ownerId ? `#${record.ownerId}` : '-'),
    render: (_value, record) => record.ownerName ?? '-',
  },
  {
    title: '最近跟进',
@@ -155,4 +190,21 @@
    search: false,
    render: (_value, record) => renderTags(record.tags),
  },
  {
    title: '操作',
    key: 'action',
    valueType: 'option',
    width: 150,
    fixed: 'right',
    render: (_value, record) => (
      <Space size={0}>
        <Button type="link" size="small" onClick={() => options.onDetail(record)}>
          详情
        </Button>
        <Button type="link" size="small" onClick={() => options.onFollowUp(record)}>
          跟进记录
        </Button>
      </Space>
    ),
  },
];