<template>
  <div class="style-bar-serie">
    <div class="setting-title" @click="show = !show">
      <div>指标展示设置</div>
      <e class="el-icon-arrow-right" v-show="!show"></e>
      <e class="el-icon-arrow-down" v-show="show"></e>
    </div>
    <el-form size="mini" label-width="80px" v-show="show">
      <el-form-item
        v-for="(item, i) of option.serieSet"
        :key="i"
        :label="'指标' + (i + 1)"
      >
        <div class="serie-item">
          <el-select v-model="item.type">
            <el-option label="柱体" value="bar"></el-option>
            <el-option label="折线" value="line"></el-option>
          </el-select>
          <el-checkbox v-model="item.second" label="副轴"></el-checkbox>
          <i class="el-icon-delete" @click="onDel(i)"></i>
        </div>
      </el-form-item>
      <el-button
        size="mini"
        type="primary"
        plain
        icon="el-icon-plus"
        @click="onAdd"
      >
        添加
      </el-button>
    </el-form>
  </div>
</template>
<script>
export default {
  props: ["option"],
  data() {
    return {
      show: false,
    };
  },
  methods: {
    onAdd() {
      this.option.serieSet.push({ type: "bar", second: false });
    },
    onDel(i) {
      this.option.serieSet.splice(i, 1);
    },
  },
};
</script>
<style lang="scss">
.style-bar-serie {
  .el-form-item {
    margin-bottom: 8px;
  }
  .serie-item {
    height: 28px;
    display: flex;
    align-items: center;
    & > * {
      margin-left: 10px;
    }
  }
  .el-button {
    margin-left: 80px;
  }
}
</style>