index.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <script lang="ts" setup>
  2. import type { VxeGridProps } from '#/adapter/vxe-table';
  3. import { Button } from 'ant-design-vue';
  4. import { useVbenVxeGrid } from '#/adapter/vxe-table';
  5. import { getExampleTableApi } from '../mock-api';
  6. interface RowType {
  7. category: string;
  8. color: string;
  9. id: string;
  10. price: string;
  11. productName: string;
  12. releaseDate: string;
  13. }
  14. const gridOptions: VxeGridProps<RowType> = {
  15. columns: [
  16. { fixed: 'left', title: '序号', type: 'seq', width: 50 },
  17. { field: 'category', title: 'Category', width: 300 },
  18. { field: 'color', title: 'Color', width: 300 },
  19. { field: 'productName', title: 'Product Name', width: 300 },
  20. { field: 'price', title: 'Price', width: 300 },
  21. {
  22. field: 'releaseDate',
  23. formatter: 'formatDateTime',
  24. title: 'DateTime',
  25. width: 500,
  26. },
  27. {
  28. field: 'action',
  29. fixed: 'right',
  30. slots: { default: 'action' },
  31. title: '操作',
  32. width: 120,
  33. },
  34. ],
  35. pagerConfig: {},
  36. proxyConfig: {
  37. ajax: {
  38. query: async ({ page }) => {
  39. return await getExampleTableApi({
  40. page: page.currentPage,
  41. pageSize: page.pageSize,
  42. });
  43. },
  44. },
  45. },
  46. rowConfig: {
  47. isHover: true,
  48. },
  49. };
  50. const [Grid] = useVbenVxeGrid({ gridOptions });
  51. </script>
  52. <template>
  53. <div class="vp-raw w-full">
  54. <Grid>
  55. <template #action>
  56. <Button type="link">编辑</Button>
  57. </template>
  58. </Grid>
  59. </div>
  60. </template>