Ranking.vue 3.96 KB
<template>
  <div class="ranking-wrap" v-if="fastData.length > 0">
    <template v-for="item in fastData">
      <div class="ranking-line flex" :key="item.icon">
        <div :class="['sprite-icon', ' icon-' + item.icon]"></div>
        <div class="small-text">
          {{ item.text }}
          <template v-if="item.info">
            <span>{{ item.info }}</span>
          </template>
          <template v-else>
            <span>{{ item.value(reportData) }}</span>
          </template>
        </div>
      </div>
    </template>
  </div>
</template>

<script type='text/ecmascript-6'>
import { mapState } from 'vuex'
export default {
  name: 'Ranking',
  data() {
    return {
      fastData: []
    }
  },

  mounted() {},
  computed: {
    ...mapState({
      reportData: state => state.report.reportData,
      tabIndex: state => state.report.tabIndex,
      userInfo: state => state.report.userInfo
    })
  },
  watch: {
    reportData() {
      this.initFastData()
    }
  },
  methods: {
    initFastData() {
      let {
        userInfo: { accountLevel }
      } = this
      this.fastData = []
      let text = '-'
      if (this.tabIndex == 1) {
        //增长速度最快业务1商城订单2直播订单3活动订单4会员套餐5精品升级6权益提单
        let { fastOrderSource } = this.reportData
        if (fastOrderSource) {
          text =
            fastOrderSource == 7
              ? '商城订单'
              : fastOrderSource == 2
              ? '直播订单'
              : fastOrderSource == 3
              ? '活动订单'
              : fastOrderSource == 4
              ? '门店服务套餐'
              : fastOrderSource == 5
              ? '精品升级'
              : '权益提单'
        }
        // console.log(fastOrderSource)
        // console.log(text)
        if (accountLevel !== 4) {
          this.fastData.push(
            { text: '增长速度最快的业务:', info: text, icon: 'rank' },
            {
              text: '产值排行榜冠军店:',
              value: obj => {
                return obj.mostProductionValueMerchantName ? obj.mostProductionValueMerchantName : '-'
              },
              icon: 'helmet'
            }
          )
        } else {
          this.fastData.push({ text: '增长速度最快的业务:', info: text, icon: 'masonry' })
        }
      } else {
        if (accountLevel !== 4) {
          this.fastData.push(
            {
              text: '企微客户占比最高的门店:',
              value: obj => {
                return obj.newlyQyHighestRatioMerchant ? obj.newlyQyHighestRatioMerchant : '-'
              },
              icon: 'proportion'
            },
            {
              text: '企微增长速度最快的门店:',
              value: obj => {
                return obj.newlyQyFastestGrowthMerchant ? obj.newlyQyFastestGrowthMerchant : '-'
              },
              icon: 'speed'
            },
            {
              text: '企微客户数最多的门店:',
              value: obj => {
                return obj.newlyQyMostMerchant ? obj.newlyQyMostMerchant : '-'
              },
              icon: 'client'
            }
          )
        } else {
          this.fastData.push({
            text: '企业微信客户占比:',
            value: obj => {
              return obj.qyCustomerRatio ? (obj.qyCustomerRatio * 100).toFixed(0) + '%' : '-'
            },
            icon: 'qycustomer'
          })
        }
      }
    }
  }
}
</script>

<style lang='scss'>
.ranking-wrap {
  width: 345px;
  height: auto;
  background: #ffffff;
  box-shadow: 0px 5px 8px 0px rgba(182, 188, 197, 0.15);
  border-radius: 4px;
  padding: 0 20px;
  box-sizing: border-box;
  .ranking-line {
    height: 56px;
    border-bottom: 1px solid rgba(57, 117, 198, 0.09);
    &:last-child {
      border-bottom: 1px solid #ffffff;
    }
  }
  .sprite-icon {
    margin-right: 10px;
  }
  .small-text {
    color: #666666;
    span {
      color: #333333;
    }
  }
}
</style>