Resident.vue 4.62 KB
<template>
  <div class="content">
    <EquityLeft ref="equityLeftRef" :equitylList="equitylList" :merchantDataList="merchantDataList" :dataList="dataList"></EquityLeft>
    <EquityRight :storeOutputList="storeOutputList" :storePercentList="storePercentList" :storePriceList="storePriceList"></EquityRight>
  </div>
</template>

<script>
import EquityLeft from './EquityLeft.vue'
import EquityRight from './EquityRight.vue'
export default {
  name: 'Resident',
  components: {
    EquityLeft,
    EquityRight
  },
  data() {
    return {
      equitylList: [
        {
          name: '总产值',
          valueName: 'outputvalue',
          value: '0',
          unit: '¥',
          unitType: 'left',
          bottomType: 'ratio',
          ratioLeftLabel: '周同比',
          ratioLeftValueName: 'outputvalueTB',
          ratioLeftValue: '0',
          ratioRightLabel: '日环比',
          ratioRightValueName: 'outputvalueHB',
          ratioRightValue: '0'
        },
        {
          name: '推荐量',
          valueName: 'recommNum',
          value: '0',
          bottomType: 'slot'
        },
        {
          name: '成交量',
          valueName: 'payOrderNum',
          value: '0',
          bottomType: 'ratio',
          ratioLeftLabel: '周同比',
          ratioLeftValueName: 'payOrderNumTB',
          ratioLeftValue: '0',
          ratioRightLabel: '日环比',
          ratioRightValueName: 'payOrderNumHB',
          ratioRightValue: '0'
        },
        {
          name: '转化率',
          valueName: 'conversionRate',
          value: '20',
          unit: '%',
          unitType: 'right',
          bottomType: 'slot'
        },
        {
          name: '客单价',
          valueName: 'perCusTrans',
          value: '0',
          unit: '¥',
          unitType: 'left',
          bottomType: 'slot'
        }
      ],
      dataList: [],
      area: '',
      month: '',
      merchantDataList: [
        {
          name: '在营门店数',
          valueName: 'openNum',
          val: 0
        },
        {
          name: '停业门店',
          valueName: 'closeNum',
          val: 0
        }
      ],
      // 门店产值排名数据
      storeOutputList: [],
      // 门店转化率排名数据
      storePercentList: [],
      // 门店客单价排名数据
      storePriceList: []
    }
  },

  watch: {
    area: {
      handler(newVal) {
        this.getRetailOverview()
        this.getRetailTrend()
        this.getRetailRank()
      }
    },
    month: {
      handler(newVal) {
        this.getRetailOverview()
        this.getRetailTrend()
        this.getRetailRank()
      }
    }
  },
  created() {
    this.$bus.$on('selectAreaChange', val => {
      if (val === '全部') val = ''
      this.area = val
    })
    this.$bus.$on('selectMonthChange', val => {
      if (val === '全部') val = ''
      this.month = val
    })
    this.getRetailOverview()
    this.getRetailTrend()
    this.getRetailRank()
  },

  mounted() {},

  methods: {
    async getRetailOverview() {
      const params = {
        province: this.area,
        statMonth: this.month
      }
      const _result = await this.api.equity.getRetailOverview(params)
      const _data = _result.data.dataList[0]
      this.equitylList.forEach(item => {
        item.value = _data[item.valueName]
        item.bottomValue = _data[item.bottemName]
        item.ratioLeftValue = _data[item.ratioLeftValueName]
        item.ratioRightValue = _data[item.ratioRightValueName]
      })
      this.merchantDataList.forEach(item => {
        item.val = _data[item.valueName]
      })
    },
    async getRetailTrend() {
      const params = {
        province: this.area,
        statMonth: this.month
      }
      const _result = await this.api.equity.getRetailTrend(params)
      this.dataList = _result.data.dataList
      this.$nextTick(() => {
        this.$refs.equityLeftRef.$refs.productionTrend.$refs.productionTrendsRef.drawBarLine()
        this.$refs.equityLeftRef.$refs.orderTrends.$refs.orderTrendsRef.drawBarLine()
      })
    },
    async getRetailRank() {
      const params = {
        province: this.area,
        statMonth: this.month
      }
      const _result = await this.api.equity.getRetailRank(params)
      const { outputvalueRank, perCusTransRank, conversionRateRank } = _result.data.dataList[0]
      this.storeOutputList = outputvalueRank.slice(0, 5)
      this.storePercentList = conversionRateRank.slice(0, 5)
      this.storePriceList = perCusTransRank.slice(0, 5)
    }
  }
}
</script>

<style lang="scss" scoped>
.content {
  display: flex;
  justify-content: space-between;
  // padding: 1.78vh 0 0;
  // margin-top: 1.78vh;
}
</style>