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


<script setup>
import { ref, defineProps, reactive, onMounted } 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: 'applyTime',
    width: 200,
    key: 'applyTime',
    align: 'center'
  },
  {
    title: '所属区域',
    dataIndex: 'operate',
    width: 200,
    key: 'operate',
    align: 'center'
  },
  {
    title: '订单编号',
    dataIndex: 'orderId',
    width: 200,
    key: 'orderId',
    align: 'center'
  },
  {
    title: '用户手机',
    dataIndex: 'phone',
    width: 200,
    key: 'phone',
    align: 'center'
  },
  {
    title: '订单实付金额(元)',
    dataIndex: 'actualPayAmount',
    width: 200,
    key: 'actualPayAmount',
    align: 'center'
  },
  {
    title: '退款金额(元)',
    dataIndex: 'refundAmount',
    width: 200,
    key: 'refundAmount',
    align: 'center'
  },
  {
    title: '处理状态',
    dataIndex: 'handleState',
    width: 200,
    key: 'handleState',
    align: 'center'
  },
  {
    title: '到账状态',
    dataIndex: 'arrivedState',
    width: 200,
    key: 'arrivedState',
    align: 'center'
  },
  {
    title: '退款到账时间',
    dataIndex: 'arrivedTime',
    width: 200,
    key: 'arrivedTime',
    align: 'center'
  },
  {
    title: '退款方式',
    dataIndex: 'refundMethod',
    width: 200,
    key: 'refundMethod',
    align: 'center'
  },
  {
    title: '退款申请人',
    dataIndex: 'applicant',
    width: 200,
    key: 'applicant',
    align: 'center'
  },
  {
    title: '申请理由',
    dataIndex: 'applyReason',
    width: 200,
    key: 'applyReason',
    align: 'center'
  },
  {
    title: '订单支付方式',
    dataIndex: 'payMethod',
    width: 200,
    key: 'payMethod',
    align: 'center'
  },
  {
    title: '订单支付时间',
    dataIndex: 'payTime',
    width: 200,
    key: 'payTime',
    align: 'center'
  },
  {
    title: '来源',
    dataIndex: 'source',
    width: 200,
    key: 'source',
    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/refundApplyRefundRecord", queryform.value).then(res => {
    if (res.code == 200) {
      dataSource.value = res.data.records
    } else {
      message.error(res.message)
    }
  })
}
</script> 