supplierSelect.vue 825 Bytes
Newer Older
huhaiqing's avatar
huhaiqing committed
1
<template>
huhaiqing's avatar
huhaiqing committed
2
  <el-select filterable :value="value === 0 ? undefined : value" @change="change" v-bind="$attrs" clearable>
3
    <el-option v-for="supplier in getSuppliers" :key="supplier.id" :label="$l(supplier, 'company')" :value="supplier.id"></el-option>
huhaiqing's avatar
huhaiqing committed
4 5 6 7 8 9 10 11 12 13 14 15
  </el-select>
</template>

<script>
/**
 * 供应商
 */
export default {
  name: "supplierSelect",
  props: {
    companyType: String,
    value: Number,
huhaiqing's avatar
huhaiqing committed
16
    allSupplier: Array,
huhaiqing's avatar
huhaiqing committed
17 18 19 20 21 22
  },
  model: {
    prop: "value",
    event: "change",
  },
  data() {
huhaiqing's avatar
huhaiqing committed
23
    return {};
huhaiqing's avatar
huhaiqing committed
24 25 26
  },
  computed: {
    getSuppliers() {
huhaiqing's avatar
huhaiqing committed
27 28
      if (!this.companyType) return this.allSupplier;
      return this.allSupplier.filter((item) =>
huhaiqing's avatar
huhaiqing committed
29 30 31 32 33 34 35 36 37 38 39
        item.companyTypes.includes(this.companyType)
      );
    },
  },
  methods: {
    change(val) {
      this.$emit("change", val);
    },
  },
};
</script>