remote.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <script lang="ts" setup>
  2. import type { VxeGridProps } from '#/adapter';
  3. import { Page } from '@vben/common-ui';
  4. import { Button } from 'ant-design-vue';
  5. import { useVbenVxeGrid } from '#/adapter';
  6. import { getExampleTableApi } from '#/api';
  7. interface RowType {
  8. category: string;
  9. color: string;
  10. id: string;
  11. price: string;
  12. productName: string;
  13. releaseDate: string;
  14. }
  15. const gridOptions: VxeGridProps<RowType> = {
  16. checkboxConfig: {
  17. highlight: true,
  18. labelField: 'name',
  19. },
  20. columns: [
  21. { title: '序号', type: 'seq', width: 50 },
  22. { align: 'left', title: 'Name', type: 'checkbox', width: 100 },
  23. { field: 'category', title: 'Category' },
  24. { field: 'color', title: 'Color' },
  25. { field: 'productName', title: 'Product Name' },
  26. { field: 'price', title: 'Price' },
  27. { field: 'releaseDate', formatter: 'formatDateTime', title: 'DateTime' },
  28. { field: 'releaseDate', formatter: 'formatDate', title: 'Date' },
  29. ],
  30. height: 'auto',
  31. keepSource: true,
  32. pagerConfig: {},
  33. proxyConfig: {
  34. ajax: {
  35. query: async ({ page }) => {
  36. return await getExampleTableApi({
  37. page: page.currentPage,
  38. pageSize: page.pageSize,
  39. });
  40. },
  41. },
  42. },
  43. };
  44. const [Grid, gridApi] = useVbenVxeGrid({ gridOptions });
  45. </script>
  46. <template>
  47. <Page auto-content-height>
  48. <Grid>
  49. <template #toolbar-tools>
  50. <Button class="mr-2" type="primary" @click="() => gridApi.query()">
  51. 刷新当前页面
  52. </Button>
  53. <Button type="primary" @click="() => gridApi.reload()">
  54. 刷新并返回第一页
  55. </Button>
  56. </template>
  57. </Grid>
  58. </Page>
  59. </template>