<template>
  <el-table-column :type="type" :selectable="selectable" :label="label" :prop="prop" :min-width="minWidth" :formatter="dictFormatter" />
</template>

<script>
import { mapGetters } from 'vuex'

export default {
    name: 'DictColumn',
    props: {
        type: {
            type: String,
            default: ''
        },
        selectable: {
            type: Function
        },
        label: {
            type: String,
            default: ''
        },
        prop: {
            type: String
        },
        minWidth: {
            type: Number,
            default: 150
        },
        dictType: {
            type: String,
            required: true
        }
    },
  computed: {
    ...mapGetters(['dict'])
  },
  methods: {
      dictFormatter(row,column,cellValue){
          return  this.dict[this.dictType]?.filter(({value}) => String(value) === String(cellValue))[0]?.label
      }
  }
}
</script>