<template>
  <el-select
    :value="value"
    :placeholder="placeholder"
    :multiple="multiple"
    clearable
    filterable
    style="width:100%;"
    @change="$emit('input', $event)"
  >
    <el-option
      v-for="item in dataList"
      :key="item.id"
      :label="item.name"
      :value="item.id"
    />
  </el-select>
</template>
<script>
export default {
  props: {
    value: { type: Array, default: () => [] },
    multiple: { type: Boolean, default: false },
    placeholder: { type: String, default: '请选择' }
  },
  data() {
    return {
      dataList: []
    }
  },
  mounted() { this.getDataList() },
  methods: {
    getDataList(id) {
      return this.$http.get('/checkItem/project/getList').then(({ data: res }) => {
        if (res.code === 0) { this.dataList = res.data } else { this.$message.error(res.msg) }
      }).catch(() => {})
    }
  }
}
</script>
