approval-columns.tsx 2.78 KB
import { UTag } from '@uj/ui';
import type { DataTableColumnsType } from '@/components';
import type { ApprovalRow } from '@/api';
import { APPROVAL_STATUS, statusMeta } from '@/features/shared/dictionaries';
import { dateTimeOr, numberOr, textOr } from '@/features/shared/format';

/**
 * 列顺序、标题与宽度逐字对齐老系统 approve.vue 的 tableColumns(15 列)。
 * 状态一列老系统用的是 constants.tableStatus(审批七个状态),与筛选项的 statusList 同一份字典,
 * 这里也用 APPROVAL_STATUS 一处维护。
 */
export function buildApprovalColumns(): DataTableColumnsType<ApprovalRow> {
  return [
    { title: '批次号', dataIndex: 'batchNo', width: 120, render: (value) => textOr(value) },
    {
      title: '客户数量',
      dataIndex: 'customerCount',
      width: 110,
      render: (value) => numberOr(value),
    },
    { title: '积分总额', dataIndex: 'pointTotal', width: 110, render: (value) => numberOr(value) },
    {
      title: '付款总额/元',
      dataIndex: 'paymentTotal',
      width: 120,
      render: (value) => numberOr(value),
    },
    {
      title: '付款渠道',
      dataIndex: 'paymentChannel',
      width: 200,
      render: (value) => textOr(value),
    },
    {
      title: '付款主体',
      dataIndex: 'paymentSubject',
      width: 200,
      render: (value) => textOr(value),
    },
    {
      title: '代征主体',
      dataIndex: 'channelAccount',
      width: 200,
      // 老系统这列读的是行对象里嵌套的 channelAccount.levyName,没有就显示占位符。
      render: (_value, row) => textOr(row.channelAccount?.levyName),
    },
    {
      title: '状态',
      dataIndex: 'status',
      width: 140,
      render: (value) => {
        const meta = statusMeta(APPROVAL_STATUS, value);
        return meta ? <UTag color={meta.color}>{meta.label}</UTag> : textOr(value);
      },
    },
    {
      title: '批次生成时间',
      dataIndex: 'createdDate',
      width: 180,
      render: (value) => dateTimeOr(value),
    },
    { title: '审批人', dataIndex: 'approver', width: 150, render: (value) => textOr(value) },
    {
      title: '审批时间',
      dataIndex: 'approvalTime',
      width: 180,
      render: (value) => dateTimeOr(value),
    },
    { title: 'OA审批编号', dataIndex: 'oaSpNo', width: 200, render: (value) => textOr(value) },
    {
      title: 'OA审批时间',
      dataIndex: 'oaApprovalTime',
      width: 180,
      render: (value) => dateTimeOr(value),
    },
    {
      title: '渠道到账时间',
      dataIndex: 'channelSettleTime',
      width: 180,
      render: (value) => dateTimeOr(value),
    },
    {
      title: '用户到账时间',
      dataIndex: 'userSettleTime',
      width: 180,
      render: (value) => dateTimeOr(value),
    },
  ];
}