1
0

vxe-table.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import { h } from 'vue';
  2. import { setupVbenVxeTable, useVbenVxeGrid } from '@vben/plugins/vxe-table';
  3. import { ElButton, ElImage } from 'element-plus';
  4. import { useVbenForm } from './form';
  5. setupVbenVxeTable({
  6. configVxeTable: (vxeUI) => {
  7. vxeUI.setConfig({
  8. grid: {
  9. align: 'center',
  10. border: true,
  11. minHeight: 180,
  12. proxyConfig: {
  13. autoLoad: true,
  14. response: {
  15. result: 'items',
  16. total: 'total',
  17. list: 'items',
  18. },
  19. showActiveMsg: true,
  20. showResponseMsg: false,
  21. },
  22. round: true,
  23. size: 'small',
  24. },
  25. });
  26. // 表格配置项可以用 cellRender: { name: 'CellImage' },
  27. vxeUI.renderer.add('CellImage', {
  28. renderDefault(_renderOpts, params) {
  29. const { column, row } = params;
  30. const src = row[column.field];
  31. return h(ElImage, { src, previewSrcList: [src] });
  32. },
  33. });
  34. // 表格配置项可以用 cellRender: { name: 'CellLink' },
  35. vxeUI.renderer.add('CellLink', {
  36. renderDefault(renderOpts) {
  37. const { props } = renderOpts;
  38. return h(
  39. ElButton,
  40. { size: 'small', link: true },
  41. { default: () => props?.text },
  42. );
  43. },
  44. });
  45. // 这里可以自行扩展 vxe-table 的全局配置,比如自定义格式化
  46. // vxeUI.formats.add
  47. },
  48. useVbenForm,
  49. });
  50. export { useVbenVxeGrid };
  51. export type * from '@vben/plugins/vxe-table';