supplierSelect.vue 1.03 KB
Newer Older
huhaiqing's avatar
huhaiqing committed
1
<template>
zhoutong's avatar
zhoutong committed
2 3 4 5 6 7 8 9 10 11 12 13 14
  <el-select
    filterable
    :value="value === 0 ? undefined : value"
    @change="change"
    v-bind="$attrs"
    clearable
  >
    <el-option
      v-for="supplier in getSuppliers"
      :key="supplier.id"
      :label="$l(supplier, 'company')"
      :value="supplier.id"
    ></el-option>
huhaiqing's avatar
huhaiqing committed
15 16 17 18 19 20 21 22 23 24 25 26
  </el-select>
</template>

<script>
/**
 * 供应商
 */
export default {
  name: "supplierSelect",
  props: {
    companyType: String,
    value: Number,
huhaiqing's avatar
huhaiqing committed
27
    allSupplier: Array,
zhoutong's avatar
zhoutong committed
28 29 30 31
    areaType: {
      type: Number,
      default: 0
    },
huhaiqing's avatar
huhaiqing committed
32 33 34 35 36 37
  },
  model: {
    prop: "value",
    event: "change",
  },
  data() {
huhaiqing's avatar
huhaiqing committed
38
    return {};
huhaiqing's avatar
huhaiqing committed
39 40 41
  },
  computed: {
    getSuppliers() {
zhoutong's avatar
zhoutong committed
42 43 44 45 46 47
      let allSupplier = this.allSupplier.filter(
        (item) => item.areaType == this.areaType
      );
      if(this.areaType == 1 || !this.companyType) return allSupplier;
      return allSupplier.filter((item) =>
        item.companyTypes.includes(this.companyType)
huhaiqing's avatar
huhaiqing committed
48 49 50 51 52 53 54 55 56 57
      );
    },
  },
  methods: {
    change(val) {
      this.$emit("change", val);
    },
  },
};
</script>