<template>
  <div>
    <el-select v-model="selectValue" filterable placeholder="请选择" @change="handleChange">
      <el-option
        v-for="item in list"
        :key="item.id"
        :value="item.value"
        :label="item.label"
      />
    </el-select>
  </div>
</template>

<script>
import { menuSelectApps } from "@/api/report";
export default {
  name: "ZxSourceSelect",
  model: {
    prop: "value",
    event: "change",
  },
  props: {
    defaultValue: {
      type: String,
      required: false,
    },
    addAllOption: {
      type: [String, Boolean],
      required: false,
    },
  },
  data() {
    return {
      queryDate: [],
      selectValue: "",
      list: [],
    };
  },
  created() {
    this.init();
  },
  // 子组件监控日期组件的值发生变化的时候，通过emit传给父组件，父组件用v-model接收。这样就把子组件的v-model功能，传给了父组件
  watch: {
    selectValue(val) {
      this.$emit("input", val);
    },
  },

  methods: {
    // 获取App名称配置列表
    init: function () {
      this.selectValue = this.defaultValue;
      this.list = [
        { label: "Facebook", value: "facebook" },
        { label: "Google", value: "google" },
      ];
      if (this.addAllOption) {
        this.list.unshift({
          label: "全部",
          value: "",
        });
      }
    },
    handleChange(value) {
      this.$emit("change", value);
    },
  },
};
</script>
