<template>
  <BzTable @register="registerTable">
    <template #toolbar>
      <bz-button type="primary" @click="handleReloadCurrent"> 刷新当前页 </bz-button>
      <bz-button type="primary" @click="handleReload"> 刷新并返回第一页 </bz-button>
    </template>
  </BzTable>
</template>
<script lang="ts">
  import { defineComponent } from 'vue';
  import { BzTable, useTable } from '/@/index';
  import { getBasicColumns } from './tableData';

  import { demoListApi } from './tableData';
  export default defineComponent({
    components: { BzTable },
    setup() {
      const [registerTable, { reload }] = useTable({
        title: '远程加载示例',
        api: demoListApi,
        columns: getBasicColumns(),
        pagination: { pageSize: 10 },
      });
      function handleReloadCurrent() {
        reload();
      }

      function handleReload() {
        reload({
          page: 1,
        });
      }
      return {
        registerTable,
        handleReloadCurrent,
        handleReload,
      };
    },
  });
</script>
