edit-cell.vue 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <script lang="ts" setup>
  2. import type { VxeGridProps } from '#/adapter/vxe-table';
  3. import { Page } from '@vben/common-ui';
  4. import { useVbenVxeGrid } from '#/adapter/vxe-table';
  5. import { getExampleTableApi } from '#/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. { title: '序号', type: 'seq', width: 50 },
  17. { editRender: { name: 'input' }, field: 'category', title: 'Category' },
  18. { editRender: { name: 'input' }, field: 'color', title: 'Color' },
  19. {
  20. editRender: { name: 'input' },
  21. field: 'productName',
  22. title: 'Product Name',
  23. },
  24. { field: 'price', title: 'Price' },
  25. { field: 'releaseDate', formatter: 'formatDateTime', title: 'Date' },
  26. ],
  27. editConfig: {
  28. mode: 'cell',
  29. trigger: 'click',
  30. },
  31. height: 'auto',
  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. showOverflow: true,
  44. };
  45. const [Grid] = useVbenVxeGrid({ gridOptions });
  46. </script>
  47. <template>
  48. <Page auto-content-height>
  49. <Grid />
  50. </Page>
  51. </template>