<template>
  <div>
    <el-select v-bind="$attrs" v-on="$listeners" :value="value" style="width: 100%" @change="changeDictData">
      <el-option v-for="(item, index) in options" :key="index" :label="item.dictLabel" :value="item.dictValue" :disabled="item.status === 'N'"></el-option>
    </el-select>
  </div>
</template>
<script>
import {selectDictDataList} from "../../../api/dict";
export default {
  name:'dict-data-select',
  model:{
    prop:'value',
    event:'change'
  },
  props:{
    dictType: {
      type: String,
      required: true
    },
    value:{
      required: true,
    }
  },
  data () {
    return {
      options: []
    }
  },
  created () {
    this.initOption()
  },
  methods: {
    //初始化options
    async initOption () {
      let params = {
        site:this.$store.state.user.site,
        dictType:this.dictType
      }
      let {data} = await selectDictDataList(params);
      this.options = data.rows;
    },
    changeDictData(val){
      this.$emit('change',val)
    }
  }
}
</script>
