<template>
  <el-table v-loading="loading" :data="tableData" :stripe="true">
      <el-table-column label="用户实际到余额" align="center" prop="totalPrice">
        <template #default="scope">
          {{ fenToYuan(scope.row.totalPrice) }}
        </template>
      </el-table-column>
      <el-table-column label="实际支付金额" align="center" prop="payPrice">
        <template #default="scope">
          {{ fenToYuan(scope.row.payPrice) }}
        </template>
      </el-table-column>
      <el-table-column label="钱包赠送金额" align="center" prop="bonusPrice">
        <template #default="scope">
          {{ fenToYuan(scope.row.bonusPrice) }}
        </template>
      </el-table-column>
      <el-table-column label="是否已支付" align="center" prop="payStatus">
        <template #default="scope">
          {{ scope.row.payStatus ? '已支付': '未支付' }}
        </template>
      </el-table-column>
      <el-table-column label="支付成功的支付渠道" align="center" prop="payChannelCode">
        <template #default="scope">
          <dict-tag :type="DICT_TYPE.PAY_CHANNEL_CODE" :value="scope.row.payChannelCode" />
        </template>
      </el-table-column>
      <el-table-column label="支付成功的外部订单号" align="center" prop="payOrderChannelOrderNo" />
      <el-table-column label="退款状态" align="center" prop="refundStatus">
        <template #default="scope">
          <dict-tag v-if="scope.row.payStatus && scope.row.refundStatus !== 0" :type="DICT_TYPE.PAY_REFUND_STATUS" :value="scope.row.refundStatus" />
          <span v-else></span>
        </template>
      </el-table-column>
      <el-table-column
        label="订单支付时间"
        align="center"
        prop="payTime"
        :formatter="dateFormatter"
        width="180px"
      />
    </el-table>

  <Pagination
    :total="total"
    v-model:page="queryParams.pageNo"
    v-model:limit="queryParams.pageSize"
    @pagination="getList"
  />
</template>

<script setup>
/* 充值订单 */
defineOptions({ name: 'PersonRechargeOrderList'})
import { PersonInfoApi } from '@/api/menduner/system/person'
import { DICT_TYPE } from '@/utils/dict'
import { dateFormatter } from '@/utils/formatTime'
import { fenToYuan } from '@/utils'

const props = defineProps({
  userId: String
})

const loading = ref(false)
const tableData = ref([])
const total = ref(0)
const queryParams = reactive({
  pageNo: 1,
  pageSize: 10,
  userId: props.userId
})

const getList = async () => {
  loading.value = true
  try {
    const data = await PersonInfoApi.getPersonWalletRechargePage(queryParams)
    tableData.value = data.list
    total.value = data.total
  } finally {
    loading.value = false
  }
}
getList()
</script>
