<template>
  <el-select
    v-model="selected"
    v-bind="$attrs"
    :loading="loading"
    v-on="$listeners"
  >
    <el-option
      v-for="item in options"
      :key="item.id"
      :label="item.name"
      :value="item.id"
    />
  </el-select>

</template>

<script>
import { getStockLogicList } from '@/api/wms/incoming/production'

export default {
  props: {
    value: {
      type: [String, Number],
      default: ''
    }
  },
  data() {
    return {
      options: [],
      loading: false
    }
  },
  computed: {
    selected: {
      get() {
        return this.value
      },
      set(v) {
        this.$emit('input', v)
      }
    }
  },
  created() {
    this.fetchFactoryList()
  },
  methods: {
    fetchFactoryList() {
      this.loading = true
      const params = {
        pageNo: 1,
        pageSize: 100,
        type: 1
      }
      getStockLogicList(params).then(res => {
        this.options = res.data
      }).finally(() => {
        this.loading = false
      })
    }
  }
}
</script>

  <style>

  </style>

