<template>
  <el-table-column :label="coloumnHeader[label]" :prop="coloumnHeader[prop]">
    <template v-for="(item, index) in coloumnHeader.children">
      <tableColumn
        v-if="item.children && item.children.length"
        :key="item[label] + index"
        :coloumn-header="item"
        :label="label"
        :prop="prop"
      ></tableColumn>
      <el-table-column
        v-else
        :key="item[label] + index"
        :label="item[label]"
        :prop="item[prop]"
        :align="item.align"
        :width="item.width"
        show-overflow-tooltip
      ></el-table-column>
    </template>
  </el-table-column>
</template>

<script>
export default {
  name: 'tableColumn',
  props: {
    coloumnHeader: {
      type: Object,
      required: true
    },
    prop: {
      type: String,
      default: 'name'
    },
    label: {
      type: String,
      default: 'desc'
    }
  }
}
</script>

<style scoped></style>
