<template>
 <el-select
    placeholder="请选择视频版权方"
    @focus="getAssetTypeData"
    multiple
    v-model="assetTypeIdList"
    @change="getSelectDep"
  >
    <el-checkbox :style="selfstyle" v-model="checkedThing" @change="selectAllThing">全选</el-checkbox>
    <el-option v-for="item in videoContentCat" :label="item.name" :value="item.id" :key="item.id"></el-option>
  </el-select>
</template>

<script>
export default {
  data() {
    return {
      videoContentCat: [],
      assetTypeIdList: [],
      checkedThing: false,
      selfstyle: {
        textAlign: "right",
        width: "100%",
        paddingRight: "10px"
      }
    };
  },
  watch: {
    assetTypeIdList(val, newval) {
      console.log(val)
      this.$emit('videoCopyright', val)
    }
  },
  methods: {
    // this.$refs.mulDisplay.videoContentCat	// 使用时父组件直接获取此值即可
    // 获取视频版权方
    getAssetTypeData() {
      let vm = this;
      vm.$https({
        url: "copyrightOwner/getList",
        method: "get",
        authType: this.backToken
      },
      // _this.$qs.stringify(_this.permisform)
      {copyrightOwnerType:'VIDEO_CONTENT'}
      )
        .then(res => {
          let data = res.data.data;
          this.videoContentCat = data;
          // this.value1[0]=data.expireDateEnd
          //this.value1[1]=data.expireDateStart
        })
        .catch(function(err) {
          console.log(err);
        });
    },
    getSelectDep(assetTypeIdList) {
      if (assetTypeIdList.length === this.videoContentCat.length) {
        this.checkedThing = true;
      } else {
        this.checkedThing = false;
      }
    },

    selectAllThing() {
      // debugger
      this.assetTypeIdList = [];
      if (this.checkedThing) {
        this.videoContentCat.map(item => {
          this.assetTypeIdList.push(item.id);
        });
      } else {
        this.assetTypeIdList = [];
      }
    }
  }
};
</script>

<style>
</style>