footer.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <template>
  2. <el-table-v2
  3. :columns="columns"
  4. :data="data"
  5. :row-height="40"
  6. :width="700"
  7. :height="400"
  8. :footer-height="50"
  9. fixed
  10. >
  11. <template #footer
  12. ><div
  13. class="flex items-center"
  14. style="
  15. justify-content: center;
  16. height: 100%;
  17. background-color: var(--el-color-primary-light-7);
  18. "
  19. >
  20. Display a message in the footer
  21. </div>
  22. </template>
  23. </el-table-v2>
  24. </template>
  25. <script lang="ts" setup>
  26. const generateColumns = (length = 10, prefix = 'column-', props?: any) =>
  27. Array.from({ length }).map((_, columnIndex) => ({
  28. ...props,
  29. key: `${prefix}${columnIndex}`,
  30. dataKey: `${prefix}${columnIndex}`,
  31. title: `Column ${columnIndex}`,
  32. width: 150,
  33. }))
  34. const generateData = (
  35. columns: ReturnType<typeof generateColumns>,
  36. length = 200,
  37. prefix = 'row-'
  38. ) =>
  39. Array.from({ length }).map((_, rowIndex) => {
  40. return columns.reduce(
  41. (rowData, column, columnIndex) => {
  42. rowData[column.dataKey] = `Row ${rowIndex} - Col ${columnIndex}`
  43. return rowData
  44. },
  45. {
  46. id: `${prefix}${rowIndex}`,
  47. parentId: null,
  48. }
  49. )
  50. })
  51. const columns = generateColumns(10)
  52. const data = generateData(columns, 200)
  53. </script>