<template>
  <CtTable
    class="mt-3"
    :items="dataList"
    :headers="headers"
    :loading="false"
    :elevation="0"
    :isTools="false"
    height="calc(100vh - 310px)"
    :showPage="true"
    :total="total"
    :page-info="query"
    itemKey="id"
    @pageHandleChange="handleChangePage"
  >
  </CtTable>
</template>

<script setup>
defineOptions({ name: 'trading-order-recharge'})
import { ref } from 'vue'
import { timesTampChange } from '@/utils/date'
import { FenYuanTransform, rechargeRatio } from '@/utils/position'
import { getEnterpriseCurrencyRechargePage } from '@/api/recruit/enterprise/member/points'

const dataList = ref([])
const headers = [
  { title: '充值M豆', key: '点数', value: item => rechargeRatio()*FenYuanTransform(item.payPrice), sortable: false },
  { title: '支付金额', key: 'payPrice', value: item => FenYuanTransform(item.payPrice)+'元', sortable: false },
  { title: '订单支付时间', key: 'payTime', value: item =>  timesTampChange(item.payTime), sortable: false },
  { title: '支付成功的外部订单号', key: 'payOrderChannelOrderNo', sortable: false },
  { title: '支付渠道名', key: 'payChannelName', sortable: false }
]

const total = ref(0)
const query = ref({
  pageNo: 1,
  pageSize: 10,
  payStatus: true, // 支付状态，订单数据true只显示已支付的
})

const getData = async () => {
  dataList.value = []; total.value = 0
  const res = await getEnterpriseCurrencyRechargePage(query.value)
  dataList.value = res?.list || []
  total.value = res.total
}
getData()

const handleChangePage = (e) => {
  query.value.pageNo = e
  getData()
}
</script>

<style scoped lang="scss">

</style>
