<template>
  <a-select v-model="val" @change="handleChange" placeholder="请选择">
    <a-select-option v-for="(item,index) in list" :key="index" :value="item.id">
      {{ item.name }}
    </a-select-option>
  </a-select>
</template>
<script>
import { getGreyList } from '@/api/greylist'

export default {
  props: {
    value: {
      type: Number,
      default: null
    }
  },
  created () {
    this.getGreyList()
  },
  data () {
    return {
      val: null,
      list: []
    }
  },
  methods: {
    getGreyList () {
      getGreyList({ pageSize: 0 }).then(res => {
        this.list = res.extraInfo.list
      })
    },
    handleChange (e) {
      this.$emit('input', e)
      this.$emit('change', e)
    }
  },
  watch: {
    value: {
      handler (val) {
        this.val = val
      },
      immediate: true
    }
  }
}
</script>
<style lang="scss">

</style>
