<template>
  <div class="place-input">
    <v-autocomplete label="请选择员工" v-model="model" :placeholder="placeholder" :items="empList" @change="changeSelect" :multiple="multiple" clearable outlined dense class="mr-2" style="width:200px;"></v-autocomplete>
  </div>
</template>

<script>
import { getEmps } from '@/api/statistics'
export default {
  name: 'selectEmployee',
  props: {
    value: {
      type: [Number, String, Array]
    },

    multiple: {
      type: Boolean,
      default: false
    },
    change: Function,
    placeholder: {
      type: String,
      default: ''
    }
  },
  data () {
    return {
      model: null,
      empList: []
    }
  },
  async created () {
    await this.fetchGetdepts()
  },
  methods: {
    changeSelect (e) {
      this.$emit('input', e)
      this.$emit('change', e)
    },
    async fetchGetdepts () {
      try {
        const { data } = await getEmps({})
        this.empList = data.map((val) => {
          return val.employeeName
        })
      } catch (error) {
        this.$snackbar.error(error)
      }
    }
  }
}
</script>
