<template>
  <el-select
    v-model="selected"
    v-bind="$attrs"
    :loading="loading"
    :disabled="disabled"
    @change="change"
  >
    <el-option
      v-for="item in options"
      :key="item.id"
      :label="item.columnName"
      :value="item.id"
    >
      <el-row :gutter="20">
        <el-col :span="12">{{ item.columnName }}</el-col>
        <el-col :span="12" class="text-right">{{ item.columnComment }}</el-col>
      </el-row>
    </el-option>
  </el-select>

</template>

<script>
// import { getCodegenDetail } from '@/api/infra/codegen'

export default {
  props: {
    value: {
      type: [String, Number],
      default: ''
    },
    disabled: {
      type: [String, Boolean, Number],
      default: false
    },
    options: {
      type: Array,
      default: () => []
    }
  },
  data() {
    return {
      // options: [],
      loading: false
    }
  },
  computed: {
    selected: {
      get() {
        return this.value
      },
      set(v) {
        this.$emit('input', v)
      }
    }
  },
  created() {
    // this.fetchFormList()
  },
  methods: {
    // fetchFormList() {
    //   this.loading = true
    //   if (this.tableId) {
    //     getCodegenDetail(this.tableId).then(res => {
    //       const { list = [] } = res.data.column || {}
    //       this.options = list
    //     }).finally(() => {
    //       this.loading = false
    //     })
    //   }
    // },
    change(value) {
      const item = this.options.find(item => item.id === value)
      this.$emit('change', item)
    }
  }
}
</script>

    <style>

    </style>

