approvalTransfer.tsx 3.53 KB
import { UTag } from '@uj/ui';
import type { DataTableColumnsType, FieldSchema } from '@/components';
import type { WithdrawRow } from '@/api';
import { PAY_MODE, TRANSFER_STATUS, optionLabel, statusMeta } from './dictionaries';
import { centsToYuan, dateTimeOr, numberOr, textOr } from './format';

/** 批次编辑与到账明细两个子页面的筛选项,老系统两处是同一份两个输入框。 */
export const APPROVAL_TRANSFER_FIELDS: FieldSchema<Record<string, unknown>>[] = [
  {
    name: 'customerName',
    label: '客户名称',
    type: 'input',
    placeholder: '请输入客户名称',
    inputProps: { maxLength: 20 },
  },
  {
    name: 'customerPhone',
    label: '手机号',
    type: 'input',
    placeholder: '请输入手机号',
    inputProps: { maxLength: 11 },
  },
];

/**
 * 批次内提现记录的列(老系统 approveEdit.vue 与 approveDetail.vue 各抄了一遍同样的 12 列)。
 * 到账明细页在这 12 列前面加「提现单号」、后面加「到账情况」与「到账时间」,其余逐字相同。
 */
export function buildApprovalTransferColumns(
  kind: 'batch' | 'arrival',
): DataTableColumnsType<WithdrawRow> {
  const shared: DataTableColumnsType<WithdrawRow> = [
    { title: '客户名称', dataIndex: 'customerName', width: 150, render: (value) => textOr(value) },
    {
      title: '提现方式',
      dataIndex: 'mode',
      width: 200,
      render: (value) => optionLabel(PAY_MODE, value) || '—',
    },
    {
      title: '手机号',
      dataIndex: 'customerPhone',
      width: 140,
      render: (value) => <span className="uj-code">{textOr(value)}</span>,
    },
    {
      title: '所属门店',
      dataIndex: 'merchantName',
      line: 1,
      width: 150,
      render: (value) => textOr(value),
    },
    {
      title: '提现积分',
      dataIndex: 'integralAmount',
      width: 100,
      render: (value) => numberOr(value),
    },
    {
      title: '提现金额/元',
      dataIndex: 'payAmount',
      width: 110,
      render: (value) => centsToYuan(value),
    },
    {
      title: '提现时间',
      dataIndex: 'createdDate',
      width: 180,
      render: (value) => dateTimeOr(value),
    },
    { title: '收款人姓名', dataIndex: 'name', width: 110, render: (value) => textOr(value) },
    {
      title: '收款人身份证',
      dataIndex: 'idCardNo',
      width: 180,
      render: (value) => <span className="uj-code">{textOr(value)}</span>,
    },
    {
      title: '收款银行卡号',
      dataIndex: 'recvBankCardNo',
      width: 230,
      render: (value) => <span className="uj-code">{textOr(value)}</span>,
    },
    {
      title: '收款银行',
      dataIndex: 'recvBank',
      line: 1,
      width: 150,
      render: (value) => textOr(value),
    },
    {
      title: '收款手机号',
      dataIndex: 'mobile',
      width: 130,
      render: (value) => <span className="uj-code">{textOr(value)}</span>,
    },
  ];
  if (kind === 'batch') return shared;
  return [
    {
      title: '提现单号',
      dataIndex: 'outSettleOrderId',
      width: 200,
      render: (value) => <span className="uj-code">{textOr(value)}</span>,
    },
    ...shared,
    {
      title: '到账情况',
      dataIndex: 'status',
      width: 200,
      render: (value) => {
        const meta = statusMeta(TRANSFER_STATUS, value);
        return meta ? <UTag color={meta.color}>{meta.label}</UTag> : textOr(value);
      },
    },
    {
      title: '到账时间',
      dataIndex: 'receiptDate',
      width: 180,
      render: (value) => dateTimeOr(value),
    },
  ];
}