<template>
  <div class="add-adv-group" ref="">
    <template v-for="(item, index) in advGroupBtn">
      <el-button
        :key="item.value"
        :type="index == currIndex ? 'primary' : ''"
        plain
        @click="handleCurrAdv(item, index)"
        >广告组 {{ item.value }}</el-button
      >
    </template>
    <el-button type="primary" @click="handleAddAdvGroup">添加广告组</el-button>
  </div>
</template>

<script>
export default {
  props: {
    putinBaseInfo: {
      type: Object,
      require: true,
    },
    makeCreative: {
      type: Object,
      require: true,
    },
  },

  data() {
    return {
      advGroupBtn: [{ value: 1 }],
      currIndex: 0,
    };
  },

  methods: {
    // 进入页面的初始化
    init() {},

    // 添加广告组
    handleAddAdvGroup() {
      let lastVal = this.advGroupBtn[this.advGroupBtn.length - 1];
      this.advGroupBtn.push({ value: lastVal.value + 1 });
      this.currIndex = this.advGroupBtn.length - 1;
    },

    // 选中当前的广告组
    handleCurrAdv(item, i) {
      this.currIndex = i;
    },

    // 添加广告组时的数据初始化
    initData() {
      this.putinBaseInfo = {
        deliveryRange: "DEFAULT", // 投放范围
        unionVideoType: "", // 投放形式
        putinInventoryType: "smartInventory", // 投放位置的类型
      };
    },
  },
};
</script>

<style>
</style>