<template>
  <div>
    <n-card :bordered="false" class="proCard">
      <BasicTable
        :columns="columns"
        :request="loadDataTable"
        :row-key="(row) => row.id"
        ref="actionRef"
        @update:checked-row-keys="onCheckedRow"
        :scroll-x="1090"
        :flex-height="false"
        :pagination="{ pageSize: 10 }"
        :resizeHeightOffset="-500"
      />
    </n-card>
  </div>
</template>

<script lang="ts" setup>
  import { ref } from 'vue';
  import { BasicTable } from '@/components/Table';
  import { RedeemCodeList } from '@/api/cdk/cdk';
  import { columns } from './redeemCodeListTableColumns';

  interface Props {
    groupSn?: string;
  }
  const props = withDefaults(defineProps<Props>(), { groupSn: "" });

  const actionRef = ref();
  const dataSource = ref({
    successful_order: 0,
    transaction_money: 0,
  });

  const loadDataTable = async (res) => {
    dataSource.value = await RedeemCodeList({ ...res, ...{ sn: props.groupSn } });
    return dataSource.value;
  };

  function onCheckedRow(rowKeys) {
    console.log(rowKeys);
  }

  function reloadTable() {
    actionRef.value.reload();
  }
</script>

<style lang="less" scoped></style>
./exchangeRecordTableColumns