<template>
  <el-select v-model="channelCode" placeholder="请选择" clearable :disabled="disabled">
    <el-option v-for="item in channelList" :key="item.id" :label="item.name" :value="item.id"></el-option>
  </el-select>
</template>

<script>
export default {
  name: 'channelSelect',
  props: {
    value: {},
    placeId: {},
    disabled: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      channelCode: '',
      channelList: []
    };
  },
  watch: {
    value(val) {
      this.channelCode = val;
    },
    placeId(val) {
      this.getList();
    },
    channelCode(val) {
      this.$emit('input', val);
    }
  },
  mounted() {},
  methods: {
    getList() {
      //场所列表
      this.ajax({ url: '/work/channel/select/all', data: { placeId: this.placeId, type: 0 } }).then((response) => {
        this.channelList = response.data;
      });
    }
  }
};
</script>
