ViewTabs.vue 2.35 KB
<!--
 * @Description: 
 * @Author: huyue
 * @Date: 2023-08-16 14:44:03
 * @LastEditors: huyue
 * @LastEditTime: 2024-07-12 17:01:01
-->
<template>
  <div class="tabs flex">
    <div class="tab" :style="{width: `calc((100% - ${(tabs.length - 1) * 0.56 + 0.83 * 2}vw) / ${tabs.length})`}" v-for="item in tabs" :key="item.key">
      <div v-if="item.key != 'retention'" class="tab-text">{{ numAddSymbol(dataList[item.key]) }}</div>
      <div v-else class="tab-text">{{ toFixNum(dataList[item.key]) }}</div>
      <div class="tab-title">{{ item.title }}</div>
    </div>
  </div>
</template>

<script type="text/ecmascript-6">
export default {
  name: 'ViewTabs',
  data() {
    return {
      dataList: {},
      tabs: [
        {
          title: '总门店数',
          key: 'totalNum'
        },
        {
          title: '当年新增',
          key: 'incrNum'
        },
        {
          title: '订阅留存率',
          key: 'retention'
        // },
        // {
        //   title: '单店产值',
        //   key: 'outputValue'
        }
      ]
    }
  },
  created() {
    this.getEnterpriseOverview()
  },
  methods: {
    toFixNum(val) {
      if(!val){
        return '0.0%'
      }
      return (Number(val) * 100).toFixed(1) + '%'
    },
    getEnterpriseOverview() {
      this.api.operational.getEnterpriseOverview().then(res => {
        if (res.code == 0) {
          this.dataList = res.data.dataList[0]
        }
      })
    }
  }
}
</script>

<style scoped lang="scss">
.tabs {
  padding: 3.22vh 0.83vw 0;
  // padding: 20px 1.67vw;
  height: 7.78vh;
  width: 100%;
  // box-sizing: border-box;
  // justify-content: space-between;
  .tab {
    box-sizing: border-box;
    padding: 1.98vh 0.56vw 0;
    height: 100%;
    // background: #061422;
    // box-shadow: inset 0 0 10.42px 0 #3d57ff69;
    margin-right: 0.56vw;
    background: url(../../../assets/images/operation/tab-bg.png) no-repeat;
    background-size: 100% 100%;
    text-align: center;
    &:last-child {
      margin-right: 0;
    }
    // padding: 2vh 0;
    .tab-title {
      font-weight: 400;
      font-size: 12px;
      color: #e8e8e8;
      margin-bottom: 0.24vh;
    }
    .tab-text {
      font-weight: 700;
      font-size: 24px;
      line-height: 30px;
      color: #fff;
    }
  }
}
</style>