<template>
  <el-select v-model="Datasource" multiple collapse-tags placeholder="全部" filterable @change="changeType">
    <el-option v-for="item in sourceList" :key="item" :label="item" :value="item"></el-option>
  </el-select>
</template>
<script>
import { dynamicDataSource } from "@/api/scan/request";
import { mapGetters, mapActions } from "vuex";
export default {
  data() {
    return {
      sourceList: [], //数据字典设备类型
      timer: null,
      Datasource: []
    };
  },
  props: {
    Related: {},
    typeName: {}
  },
  created() {
    this.init();
  },
  computed: {
    ...mapGetters("layout", ["projectId"])
  },
  methods: {
    init() {
      this.Datasource = [];
      let param = { Related: this.Related, TypeName: this.typeName };
      //数据源
      dynamicDataSource(param, res => {
        if (res.Result == "success") {
          this.sourceList = res.Content;
        }
      });
    },
    changeType(val) {
      clearTimeout(this.timer);
      this.timer = setTimeout(() => {
        this.$emit("change", val);
      }, 500);
    }
  },
  watch: {
    projectId(n, o) {
      this.init();
    }
  }
};
</script>
<style lang="less" scoped>
</style>

