tableConfig.tsx 2.69 KB
import type { DataTableColumnsType } from '@/components';
import type { Contract, Sunshine } from '@/api';

/** 运营管理表格列的唯一配置位置;页面只负责数据和操作。 */
const cell = (v: unknown) => (v === undefined || v === null || v === '' ? '-' : String(v));

/**
 * 对齐源 contract/index.vue 的高频列;字典类暂以接口返回值直出(后端口径待真机核对)。
 *
 * 长文本列(车架号 / 车型 / 合同编号 / 评估单编号 / 合同模版)只给更宽的 width;
 * 省略 + hover 完整提示由 DataTable 默认处理(纯文本单行省略、超长自动 tip),这里不再逐列配 line。
 * 车型是 render 拼接串、无 dataIndex,tip 取 render 结果本身,完整可见。
 */
export const CONTRACT_COLUMNS: DataTableColumnsType<Contract> = [
  { title: '车牌号', dataIndex: 'licensePlate', render: cell },
  { title: '车架号', dataIndex: 'vin', width: 200, render: cell },
  {
    title: '车型',
    width: 280,
    render: (_, row) =>
      [row.carBrand, row.carSeriesName, row.carTypeName].filter(Boolean).join(' ') || '-',
  },
  { title: '合同编号', dataIndex: 'contractNo', width: 200, render: cell },
  { title: '评估单编号', dataIndex: 'evalOrderNo', width: 200, render: cell },
  {
    title: '合同类型',
    dataIndex: 'electronicContractType',
    render: cell,
  },
  { title: '合同模版', dataIndex: 'docTemplateName', width: 200, render: cell },
  { title: '签约时间', dataIndex: 'signTime', render: cell },
  { title: '驻店人员', dataIndex: 'createdBy', render: cell },
  { title: '车主姓名', dataIndex: 'previousOwnerName', render: cell },
  { title: '车主电话', dataIndex: 'previousOwnerPhone', render: cell },
  { title: '支付状态', dataIndex: 'oaFlowPaymentStatus', render: cell },
  { title: '企微审批单号', dataIndex: 'lastOaFlowCode', render: cell },
  { title: '合同金额', dataIndex: 'contractPrice', render: cell },
  { title: '合同状态', dataIndex: 'electronicContractStatus', render: cell },
];

/** 源 constants.js vehicleCategoryOpt:carType 存 confId,列表按字典翻译。 */
const CAR_TYPE_LABEL: Record<string, string> = { '1': '置换车', '2': '报废车' };

export const SUNSHINE_COLUMNS: DataTableColumnsType<Sunshine> = [
  { title: '4S门店', dataIndex: 'sellerMerchantName' },
  {
    title: '车辆类型',
    dataIndex: 'carType',
    render: (value) => {
      const v = String(value ?? '');
      return CAR_TYPE_LABEL[v] || v || '-';
    },
  },
  {
    title: '激励价格',
    dataIndex: 'sunlightInspiresPrice',
    render: (value) => (value === undefined ? '-' : `¥${String(value)}`),
  },
  { title: '录入时间', dataIndex: 'createdDate' },
];