remote.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <script lang="ts" setup>
  2. import type { VxeGridProps } from '#/adapter/vxe-table';
  3. import { Page } from '@vben/common-ui';
  4. import { Button } from 'ant-design-vue';
  5. import { useVbenVxeGrid } from '#/adapter/vxe-table';
  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. ],
  29. exportConfig: {},
  30. height: 'auto',
  31. keepSource: true,
  32. proxyConfig: {
  33. ajax: {
  34. query: async ({ page }) => {
  35. return await getExampleTableApi({
  36. page: page.currentPage,
  37. pageSize: page.pageSize,
  38. });
  39. },
  40. },
  41. },
  42. toolbarConfig: {
  43. custom: true,
  44. export: true,
  45. // import: true,
  46. refresh: true,
  47. zoom: true,
  48. },
  49. };
  50. const [Grid, gridApi] = useVbenVxeGrid({
  51. gridOptions,
  52. });
  53. </script>
  54. <template>
  55. <Page auto-content-height>
  56. <Grid table-title="数据列表" table-title-help="提示">
  57. <template #toolbar-tools>
  58. <Button class="mr-2" type="primary" @click="() => gridApi.query()">
  59. 刷新当前页面
  60. </Button>
  61. <Button type="primary" @click="() => gridApi.reload()">
  62. 刷新并返回第一页
  63. </Button>
  64. </template>
  65. </Grid>
  66. </Page>
  67. </template>