<template>
  <el-select filterable :value="value" @change="change" v-bind="$attrs" clearable>
    <el-option v-for="supplier in getSuppliers" :key="supplier.id" :label="supplier.companyZh" :value="supplier.id"></el-option>
  </el-select>
</template>

<script>
/**
 * 供应商
 */
export default {
  name: "supplierSelect",
  props: {
    companyType: String,
    value: Number,
    allSupplier: Array,
  },
  model: {
    prop: "value",
    event: "change",
  },
  data() {
    return {};
  },
  computed: {
    getSuppliers() {
      if (!this.companyType) return this.allSupplier;
      return this.allSupplier.filter((item) =>
        item.companyTypes.includes(this.companyType)
      );
    },
  },
  methods: {
    change(val) {
      this.$emit("change", val);
    },
  },
};
</script>
