ViewControl.vue 2.87 KB
<template>
  <div class="control">
    <div class="left flex user-select pointer">
      <template v-for="(i,index) in tab">
        <div
          :class="['item flex',index == 0?'text-center':'brand',{'active':i.active}]"
          :key="index"
          @click="chooseBrand(index)"
        >
          {{i.text}}
        </div>
      </template>
      <div
        class="options-box"
        v-show="showBrand"
      ></div>
    </div>
    <div class="right y-center flex user-select pointer">
      <template v-for="(i,index) in options">
        <div
          :key="index"
          @click="choose(index)"
          :class="['item text-center',{'active':reportIndex == index}]"
        >
          {{i}}
        </div>
      </template>
      <div :class="['line',`line-${reportIndex}`]"></div>
    </div>
  </div>
</template>

<script type='text/ecmascript-6'>
export default {
  name: 'ViewControl',
  data () {
    return {
      tab: [{ text: '广汇集团', active: true }, { text: '品牌概览' }],
      options: ['日表', '月表'],
      reportIndex: 1,
      showBrand: false
    }
  },
  mounted () {
  },
  methods: {
    chooseBrand (index) {
      let { tab } = this
      tab.map(e => e.active = false)
      tab[index].active = true
      this.showBrand = index == 1
    },
    choose (index) {
      let { reportIndex } = this
      if (reportIndex == index) return
      this.reportIndex = index

    }
  }
}
</script>

<style scoped lang='scss'>
.control {
  position: relative;
  .left {
    width: 280px;
    height: 3.9vh;
    background: #383737;
    border-radius: 4px;
    position: relative;
    .item {
      font-size: 14px;
      color: #eb6001;
      font-weight: 600;
      border-radius: 4px 0px 0px 4px;
    }
    .brand {
      padding-left: 16px;
      border-radius: 0 4px 4px 0;
    }
    .active {
      color: #fff;
      background: #eb6001;
    }
    .options-box {
      position: absolute;
      top: 32px;
      right: 0;
      width: 50%;
      height: 30vh;
      background: #383737;
      border: 1px solid rgba(96, 98, 102, 1);
      box-shadow: 0px 3px 2px 1px rgba(0, 0, 0, 0.5);
      border-radius: 4px;
      box-sizing: border-box;
      z-index: 2;
    }
  }
  .right {
    width: 120px;
    height: 3.4vh;
    background: #383737;
    border-radius: 2px;
    right: -144px;
    .item {
      font-size: 12px;
      color: #e8e8e8;
    }
    .active {
      font-weight: 500;
      font-size: 14px;
      color: #eb6001;
    }
    .line {
      border-radius: 2px;
      background: #eb6001;
      width: 32px;
      height: 0.4vh;
      position: absolute;
      bottom: 0;
      transform: translateX(-50%);
      transition: all 0.25s;
    }
    .line-0 {
      left: 26%;
    }
    .line-1 {
      left: 76%;
    }
  }
  .item {
    width: 50%;
    height: 100%;
    box-sizing: border-box;
    transition: all 0.25s;
    &:hover {
      opacity: 0.9;
    }
  }
}
</style>