import { parseTime } from '@/utils'
import { optionsFilter } from '@/quickComponents/utils'
// 支付类型
export const payTypeOptions = [
  {
    label: '实名认证',
    value: 'REAL_NAME_AUTHENTICATION'
  },
  {
    label: '生成证书',
    value: 'ELECTRONIC_CERTIFICATE_SINGLE_PAYMENT'
  },
  {
    label: '查验他人',
    value: 'INSPECTION_SINGLE_PAYMENT'
  },
  {
    label: '年费会员',
    value: 'ANNUAL_FEE'
  },
]
export const statusOptions = [
  {
    label: '待支付',
    value: 'WAIT'
  },
  {
    label: '已退款',
    value: 'REFUND'
  },
  {
    label: '已失效',
    value: 'INVALID'
  },
  {
    label: '已支付',
    value: 'PAID'
  },
]
// 表格字段
export const tableFields = {
  'id': '流水号',
  'payType': {
    label: '消费类型',
    filter: (type) => optionsFilter(type, payTypeOptions)
  },
  'amount': {
    label: '消费金额',
    filter: (money) => money / 100
  },
  'staffId': '用户ID',
  'staffName': '用户姓名',
  'staffUsername': '用户手机号',
  'outTradeNo': '订单号',
  'payDate': {
    label: '订单时间',
    filter: (time) => parseTime(time)
  },
  'status': {
    label: '订单状态',
    filter: (status) => optionsFilter(status, statusOptions)
  },
  'businessNames': {
    label: '所属机构',
    filter: (names) => names ? names.join(', ') : ''
  }
}
// 头部筛选字段
export const filterFields = [
  {
    prop: 'name',
    props: {
      placeholder: '请输入姓名'
    }
  },
  {
    prop: 'phone',
    props: {
      placeholder: '请输入手机号'
    }
  },
  {
    type: 'select',
    prop: 'payType',
    props: {
      placeholder: '请选择消费类型',
      options: payTypeOptions
    }
  },
  {
    type: 'select',
    prop: 'status',
    props: {
      placeholder: '请选择订单状态',
      options: statusOptions
    }
  },
]
