index.vue 969 B

12345678910111213141516171819202122232425262728293031323334
  1. <template>
  2. <div class="app-table">
  3. <el-table v-bind="$attrs" border>
  4. <el-table-column type="expand" v-if="$slots.expand">
  5. <template #default="{ row }">
  6. <slot name="expand" :row="row"></slot>
  7. </template>
  8. </el-table-column>
  9. <el-table-column v-for="(item, index) in columns" :key="index" :filters="item.filters"
  10. :filter-method="item.filterMethod" :class-name="item.className" :label="item.label"
  11. :align="item.align ?? 'center'" :width="item.width">
  12. <template #default="{ row }">
  13. <slot :name="item.key" :row="row">{{ row[item.key] }}</slot>
  14. </template>
  15. </el-table-column>
  16. </el-table>
  17. </div>
  18. </template>
  19. <script lang="ts" setup>
  20. import { PropType } from 'vue'
  21. import { TableColumn } from './interface'
  22. defineProps({
  23. columns: {
  24. type: Array as PropType<TableColumn[]>,
  25. default: () => ([])
  26. },
  27. })
  28. </script>
  29. <style lang="less">
  30. @import './index.less';
  31. </style>