import { defineComponent, PropType } from 'vue'
export type ConfColumn = Array<any & {slot: (value: any) => any;}>
export default defineComponent({
  name: 'SkConfColumn',
  props: {
    options: {
      type: Array as PropType<ConfColumn>,
      default: () => {
        return []
      },
    },
  },
  setup (props) {
    function getColoum (arr: any) {
      return arr.map((item: any) => {
        if (item.slot) return (
          <el-table-column {...item}>
            {{ default: (value: any) => item.slot(value) }}
          </el-table-column>
        )
        else if (item.mchildren) {
          return (<el-table-column {...item}>
            {{ default: () => getColoum(item.mchildren) }}
          </el-table-column>)

        } else return (
          <el-table-column {...item}></el-table-column>
        )
      })
    }
    return () => getColoum(props.options)
  },
})

