import { $t } from '#/locales';

/**
 * 列
 */
const columns = [
      {
    title: '分组',
    dataIndex: 'robotGroupName',
    width: 120,
  },
  {
    title: $t('robot.consumptionRecord.robotAccount'),
    dataIndex: 'robotAccount',
    width: 150,
  },
  {
    title: $t('robot.consumptionRecord.robotNickName'),
    dataIndex: 'robotNickName',
    width: 120,
  },
  {
    title: $t('robot.consumptionRecord.consumptionAmount'),
    dataIndex: 'consumptionAmount',
sorter: true,
    width: 100,
    customRender: ({ text }) => `${text}`,
  },
  {
    title: $t('robot.consumptionRecord.consumptionTime'),
    dataIndex: 'consumptionTime',

    sorter: true,
    width: 160,
  },
    {
    title: '礼物Id',
    dataIndex: 'giftId',
    width: 80
  },
  {
    title: '礼物信息',
    dataIndex: 'giftInfo',

    width: 200,
    customRender: ({ record }) => {
      if (!record.giftName) return '-'
      return `${record.giftName} x ${record.giftQuantity || 1}`
    },
  },
  {
    title: '礼物图片',
    dataIndex: 'giftIcon',
    
    width: 80,
    customRender: ({ text }) => {
      if (!text) return '-'
      return `<img src="${text}" style="width: 40px; height: 40px; object-fit: cover; border-radius: 4px;" alt="礼物图片" />`
    },
  },
  
  {
    title: '礼物单价',
    dataIndex: 'giftUnitPrice',

    width: 80,
    customRender: ({ text }) => text ? `${text}` : '-',
  },
  {
    title: '礼物总价',
    dataIndex: 'giftTotalPrice',

    width: 80,
    customRender: ({ text }) => text ? `${text}` : '-',
  },
  ,
  {
    title: '主播ID',
    dataIndex: 'anchorId',
width: 150
  },
  {
    title: '主播',
    dataIndex: 'anchorName',
width: 150
  },
  // {
  //   title: '主播头像',
  //   dataIndex: 'anchorAvatar',
    
  //   width: 80,
  //   customRender: ({ text }) => {
  //     if (!text) return '-'
  //     return `<img src="${text}" style="width: 40px; height: 40px; object-fit: cover; border-radius: 50%;" alt="主播头像" />`
  //   },
  // },
    {
    title: '直播间ID',
    dataIndex: 'roomId',
width: 100,
  },
  {
    title: '直播间',
    dataIndex: 'roomName',
width: 150
  },
  // {
  //   title: $t('robot.consumptionRecord.consumptionInfo'),
  //   dataIndex: 'consumptionInfo',
  //  
    
  //   width: 200,
  // },
  // {
  //   title: $t('robot.consumptionRecord.notes'),
  //   dataIndex: 'notes',
  //  
    
  //   width: 120,
  // },
];

/**
 * 消费方式映射
 */
const consumptionMethodMap = {
  '微信支付': $t('robot.consumptionRecord.consumptionMethodOptions.wechat'),
  '支付宝': $t('robot.consumptionRecord.consumptionMethodOptions.alipay'),
  '银行卡': $t('robot.consumptionRecord.consumptionMethodOptions.bankCard'),
  '现金': $t('robot.consumptionRecord.consumptionMethodOptions.cash'),
  '其他': $t('robot.consumptionRecord.consumptionMethodOptions.other')
};

/**
 * 消费方式选项
 */
const consumptionMethodOptions = [
  { label: $t('robot.consumptionRecord.consumptionMethodOptions.zhuanshi'), value: '砖石' },
  { label: $t('robot.consumptionRecord.consumptionMethodOptions.liwu'), value: '礼物' },
  { label: $t('robot.consumptionRecord.consumptionMethodOptions.wechat'), value: '微信支付' },
  { label: $t('robot.consumptionRecord.consumptionMethodOptions.alipay'), value: '支付宝' },
  { label: $t('robot.consumptionRecord.consumptionMethodOptions.bankCard'), value: '银行卡' },
  { label: $t('robot.consumptionRecord.consumptionMethodOptions.cash'), value: '现金' },
  { label: $t('robot.consumptionRecord.consumptionMethodOptions.other'), value: '其他' }
];

/**
 * 查询参数
 */
const query = {
  robotAccount: '',
  consumptionAmount: undefined,
  consumptionTime: '',
  consumptionMethod: undefined,
  consumptionInfo: '',
  notes: '',
  sourceId: '',
  creator: '',
  creatorUuid: '',
  createTime: '',
  
  // 新增查询字段
  giftName: '',
  anchorName: '',
  roomName: '',
  
  // 分组筛选字段
  groupName: undefined
};

export const d = {
  isShowQuery: true,
  loading: false,
  pagination: {
    total: 0,
    current: 1,
    pageSize: 10,
    showTotal: (total, range) => `共 ${total} 条`,
    showSizeChanger: true,
    pageSizeOptions: ['10', '20', '50', '100', '500', '1000'],
    showQuickJumper: true,
  },
  datas: [],
  query,
  columns,
  consumptionMethodMap,
  consumptionMethodOptions,
};