<script>
import {getSiteAndBuByUserName} from "../../../api/eam/eam";

export default {
  name: "buSelect",
  data(){
    return{
      userBuList:[],
    }
  },
  methods:{
    handleQueryBu(){
      let params = {
        username: this.$store.state.user.name,
      }
      getSiteAndBuByUserName(params).then(({data}) => {
        if (data && data.code === 0) {
          this.userBuList = data.rows
        }else {
          this.$message.warning(data.message)
        }
      }).catch((error)=>{
        this.$message.error(error)
      })
    },
  },
  created() {
    this.handleQueryBu()
  }
}
</script>

<template>
  <el-select v-on="$listeners" v-bind="$attrs" style="width: 100%">
    <slot></slot>
    <el-option
      v-for = "i in userBuList"
      :key = "i.id"
      :label = "i.buDesc"
      :value = "i.id">
    </el-option>
  </el-select>
</template>

<style scoped>

</style>
