index.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <template>
  2. <template v-for="(col, index) in columns" :key="index">
  3. <el-table-column v-if="col.children" :label="col.label" align="center">
  4. <template v-for="(child, childIndex) in col.children" :key="childIndex">
  5. <el-table-column v-if="child.isTag" v-bind="child" align="center" resizable>
  6. <template #default="scope">
  7. <dict-tag :type="child.dictType!" :value="scope.row[child.prop!]" />
  8. </template>
  9. </el-table-column>
  10. <el-table-column v-else v-bind="child" align="center" resizable />
  11. </template>
  12. </el-table-column>
  13. <el-table-column v-else-if="col.isTag" v-bind="col" align="center" resizable>
  14. <template #default="scope">
  15. <dict-tag :type="col.dictType!" :value="scope.row[col.prop!]" />
  16. </template>
  17. </el-table-column>
  18. <el-table-column v-else v-bind="col" align="center" resizable />
  19. </template>
  20. </template>
  21. <script setup lang="ts">
  22. defineOptions({
  23. name: 'DailyTableColumn'
  24. })
  25. interface ColumnProps {
  26. label: string
  27. prop?: string
  28. children?: ColumnProps[]
  29. isTag?: boolean
  30. dictType?: string
  31. [key: string]: any
  32. }
  33. const props = defineProps<{
  34. columns: ColumnProps[]
  35. }>()
  36. const { columns } = toRefs(props)
  37. </script>