<template>
  <el-select
    v-model="selected"
    v-bind="$attrs"
    :loading="loading"
    v-on="$listeners"
  >
    <el-option
      v-for="item in options"
      :key="item.categoryNumber"
      :label="item.categoryName"
      :value="item.categoryNumber"
    >
      <el-row :gutter="20">
        <el-col :span="12">{{ item.categoryNumber }}</el-col>
        <el-col :span="12" class="text-right">{{ item.categoryName }}</el-col>
      </el-row>
    </el-option>
  </el-select>

</template>

<script>
import { getCategoryDropDownList } from '@/api/wms/inquirePurchase/inventoryInquire'

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.fetchCategoryList()
  },
  methods: {
    fetchCategoryList() {
      this.loading = true
      getCategoryDropDownList().then(res => {
        // const { list = [] } = res.data || {}
        this.options = res.data
      }).finally(() => {
        this.loading = false
      })
    }
  }
}
</script>

    <style>

    </style>

