<template>
  <a-table
    bordered
    :pagination="pagination"
    :columns="columns"
    :dataSource="dataSource"
    :scroll="{ x: 'max-content' }"
    @change="handleTableChange"
  >
  </a-table>
</template>


<script setup>
import { ref, defineProps, onMounted, reactive } from 'vue'
import { callPayment } from '@/apis/call.js'
import { message } from 'ant-design-vue'
import _ from 'lodash'
import config from '@/utils/config.js'

const props = defineProps({
  orderParams: {
    type: Object,
    required: true
  }
});

// 表格行数据
const dataSource = ref([])
const queryform = ref({
  phone: "",
  pageParam: {
    pageNum: config.pageParam.pageNum,
    pageSize: config.pageParam.pageSize
  }
})
let pagination = reactive({
  total: dataSource.value.length,
  current: 10,
  pageSize: config.pageParam.pageSize,
  showSizeChanger: true,
  pageSizeOptions: config.pageParam.pageSizeOptions,
  showQuickJumper: true
})

const columns = ref([
  {
    title: '交易类型',
    dataIndex: 'transactionType',
    width: 200,
    key: 'transactionType',
    align: 'center'
  },
  {
    title: '金额（元）',
    dataIndex: 'amount',
    width: 200,
    key: 'amount',
    align: 'center'
  },
  {
    title: '交易内容',
    dataIndex: 'transactionContent',
    width: 200,
    key: 'transactionContent',
    align: 'center'
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    width: 200,
    key: 'createTime',
    align: 'center'
  }
]);

onMounted(() => {
  if (props.orderParams['phone']) {
    queryform.value.phone = props.orderParams['phone'];
    getData()
  }
})

let handleTableChange = (pagina) => {
  pagination.current = pagina.current
  pagination.pageSize = pagina.pageSize
  queryform.value.pageParam.pageNum = pagina.current
  queryform.value.pageParam.pageSize = pagina.pageSize
  getData()
}

const getData = () => {
  callPayment("/wxPayment/refundApplyTradeRecord", queryform.value).then(res => {
    if (res.code == 200) {
      dataSource.value = res.data.records
    } else {
      message.error(res.message)
    }
  })
}
</script> 