columns.tsx 9.39 KB
import { UTag } from '@uj/ui';
import type { TableProps } from 'antd';
import type { PolicyConfirmRow } from '../../tools/policyTableData';

const storeInfoHeaderStyle: React.CSSProperties = {
  background: '#EEF2FF',
  color: '#3730A3',
  fontWeight: 600,
  fontSize: 13,
};

const bizPolicyHeaderStyle: React.CSSProperties = {
  background: '#ECFDF5',
  color: '#047857',
  fontWeight: 600,
  fontSize: 13,
};

const costHeaderStyle: React.CSSProperties = {
  background: '#FFF7ED',
  color: '#C2410C',
  fontWeight: 600,
  fontSize: 13,
};

const cellStyle: React.CSSProperties = {
  fontSize: 12.5,
  color: '#374151',
  padding: '10px 12px',
};

function SceneTag({ text }: { text: string }) {
  return (
    <UTag
      color="processing"
      bordered={false}
      title={text}
      style={{
        fontSize: 12,
        maxWidth: '100%',
        whiteSpace: 'nowrap',
        overflow: 'hidden',
        textOverflow: 'ellipsis',
      }}
    >
      {text}
    </UTag>
  );
}

function CategoryTag({ text }: { text: string }) {
  return (
    <UTag
      color="success"
      bordered={false}
      title={text}
      style={{
        fontSize: 12,
        maxWidth: '100%',
        whiteSpace: 'nowrap',
        overflow: 'hidden',
        textOverflow: 'ellipsis',
      }}
    >
      {text}
    </UTag>
  );
}

/** 金额列渲染(加粗深灰) */
function MoneyCell({ value }: { value: string }) {
  return <span style={{ fontWeight: 600, color: '#1F2937' }}>{value}</span>;
}

/** 激励费列(数值加粗) */
function FeeValueCell({ value }: { value: string }) {
  return <span style={{ fontWeight: 600, color: '#1F2937' }}>{value}</span>;
}

export function buildPolicyColumns(): TableProps<PolicyConfirmRow>['columns'] {
  return [
    // ------------- 第一组:门店信息(4 列) -------------
    {
      title: '门店信息',
      align: 'center',
      children: [
        {
          title: '门店名称',
          dataIndex: 'storeName',
          key: 'storeName',
          width: 200,
          onHeaderCell: () => ({ style: storeInfoHeaderStyle }),
          onCell: () => ({ style: cellStyle }),
          render: (v) => <span style={{ color: '#1A202C', fontWeight: 500 }}>{v}</span>,
        },
        {
          title: '门店商户号',
          dataIndex: 'storeMerchantNo',
          key: 'storeMerchantNo',
          width: 130,
          align: 'center',
          onHeaderCell: () => ({ style: storeInfoHeaderStyle }),
          onCell: () => ({ style: cellStyle }),
          render: (v) => <a style={{ color: '#2563EB', fontSize: 12.5 }}>{v}</a>,
        },
        {
          title: '业务场景',
          dataIndex: 'businessScene',
          key: 'businessScene',
          width: 130,
          align: 'center',
          onHeaderCell: () => ({ style: storeInfoHeaderStyle }),
          onCell: () => ({ style: cellStyle }),
          render: (v: string) => <SceneTag text={v} />,
        },
        {
          title: '产品分类',
          dataIndex: 'productCategory',
          key: 'productCategory',
          width: 280,
          align: 'center',
          onHeaderCell: () => ({ style: storeInfoHeaderStyle }),
          onCell: () => ({
            style: {
              ...cellStyle,
              // 确保 tableLayout=fixed 下,Tag 内容超长时单元格不会溢出到右侧列
              overflow: 'hidden',
              whiteSpace: 'nowrap',
            },
          }),
          render: (v: string) => <CategoryTag text={v} />,
        },
      ],
    },
    // ------------- 第二组:商务政策(14 列) -------------
    {
      title: '商务政策',
      align: 'center',
      children: [
        // 管理层市场费 1
        {
          title: '管理层市场费1计算模式',
          dataIndex: 'mgmtFee1Mode',
          key: 'mgmtFee1Mode',
          width: 150,
          align: 'center',
          onHeaderCell: () => ({ style: bizPolicyHeaderStyle }),
          onCell: () => ({ style: cellStyle }),
        },
        {
          title: '管理层市场费1计算方式',
          dataIndex: 'mgmtFee1CalcMethod',
          key: 'mgmtFee1CalcMethod',
          width: 150,
          align: 'center',
          onHeaderCell: () => ({ style: bizPolicyHeaderStyle }),
          onCell: () => ({ style: cellStyle }),
        },
        {
          title: '管理层市场费1',
          dataIndex: 'mgmtFee1Value',
          key: 'mgmtFee1Value',
          width: 130,
          align: 'center',
          onHeaderCell: () => ({ style: bizPolicyHeaderStyle }),
          onCell: () => ({ style: cellStyle }),
          render: (v) => <FeeValueCell value={v as string} />,
        },
        // 管理层市场费 2
        {
          title: '管理层市场费2计算模式',
          dataIndex: 'mgmtFee2Mode',
          key: 'mgmtFee2Mode',
          width: 150,
          align: 'center',
          onHeaderCell: () => ({ style: bizPolicyHeaderStyle }),
          onCell: () => ({ style: cellStyle }),
        },
        {
          title: '管理层市场费2计算方式',
          dataIndex: 'mgmtFee2CalcMethod',
          key: 'mgmtFee2CalcMethod',
          width: 150,
          align: 'center',
          onHeaderCell: () => ({ style: bizPolicyHeaderStyle }),
          onCell: () => ({ style: cellStyle }),
        },
        {
          title: '管理层市场费2',
          dataIndex: 'mgmtFee2Value',
          key: 'mgmtFee2Value',
          width: 130,
          align: 'center',
          onHeaderCell: () => ({ style: bizPolicyHeaderStyle }),
          onCell: () => ({ style: cellStyle }),
          render: (v) => <FeeValueCell value={v as string} />,
        },
        // 一线阳光 1
        {
          title: '一线阳光是否开启线上积分',
          dataIndex: 'sunshineOnlinePoints',
          key: 'sunshineOnlinePoints',
          width: 170,
          align: 'center',
          onHeaderCell: () => ({ style: bizPolicyHeaderStyle }),
          onCell: () => ({ style: cellStyle }),
        },
        {
          title: '一线阳光计算模式',
          dataIndex: 'sunshineCalcMode',
          key: 'sunshineCalcMode',
          width: 140,
          align: 'center',
          onHeaderCell: () => ({ style: bizPolicyHeaderStyle }),
          onCell: () => ({ style: cellStyle }),
        },
        {
          title: '一线阳光计算方式',
          dataIndex: 'sunshineCalcMethod',
          key: 'sunshineCalcMethod',
          width: 140,
          align: 'center',
          onHeaderCell: () => ({ style: bizPolicyHeaderStyle }),
          onCell: () => ({ style: cellStyle }),
        },
        {
          title: '一线阳光激励费',
          dataIndex: 'sunshineValue',
          key: 'sunshineValue',
          width: 140,
          align: 'center',
          onHeaderCell: () => ({ style: bizPolicyHeaderStyle }),
          onCell: () => ({ style: cellStyle }),
          render: (v) => <FeeValueCell value={v as string} />,
        },
        // 一线阳光 2
        {
          title: '一线阳光2是否开启线上积分',
          dataIndex: 'sunshine2OnlinePoints',
          key: 'sunshine2OnlinePoints',
          width: 180,
          align: 'center',
          onHeaderCell: () => ({ style: bizPolicyHeaderStyle }),
          onCell: () => ({ style: cellStyle }),
        },
        {
          title: '一线阳光2计算模式',
          dataIndex: 'sunshine2CalcMode',
          key: 'sunshine2CalcMode',
          width: 150,
          align: 'center',
          onHeaderCell: () => ({ style: bizPolicyHeaderStyle }),
          onCell: () => ({ style: cellStyle }),
        },
        {
          title: '一线阳光2计算方式',
          dataIndex: 'sunshine2CalcMethod',
          key: 'sunshine2CalcMethod',
          width: 150,
          align: 'center',
          onHeaderCell: () => ({ style: bizPolicyHeaderStyle }),
          onCell: () => ({ style: cellStyle }),
        },
        {
          title: '一线阳光2激励费',
          dataIndex: 'sunshine2Value',
          key: 'sunshine2Value',
          width: 150,
          align: 'center',
          onHeaderCell: () => ({ style: bizPolicyHeaderStyle }),
          onCell: () => ({ style: cellStyle }),
          render: (v) => <FeeValueCell value={v as string} />,
        },
      ],
    },
    // ------------- 第三组:运营成本(3 列) -------------
    {
      title: '运营成本',
      align: 'center',
      children: [
        {
          title: '装修、设备总投入',
          dataIndex: 'costDecoration',
          key: 'costDecoration',
          width: 160,
          align: 'center',
          onHeaderCell: () => ({ style: costHeaderStyle }),
          onCell: () => ({ style: cellStyle }),
          render: (v) => <MoneyCell value={v as string} />,
        },
        {
          title: '当月产生(房租、水电、耗材等)',
          dataIndex: 'costMonthly',
          key: 'costMonthly',
          width: 220,
          align: 'center',
          onHeaderCell: () => ({ style: costHeaderStyle }),
          onCell: () => ({ style: cellStyle }),
          render: (v) => <MoneyCell value={v as string} />,
        },
        {
          title: '人工成本',
          dataIndex: 'costLabor',
          key: 'costLabor',
          width: 140,
          align: 'center',
          onHeaderCell: () => ({ style: costHeaderStyle }),
          onCell: () => ({ style: cellStyle }),
          render: (v) => <MoneyCell value={v as string} />,
        },
      ],
    },
  ];
}