index.vue 8.67 KB
<template>
  <div class='layout'>
    <view-container>
      <template #title>
        <view-title :title='bussinessTitle'>
        </view-title>
      </template>
      <template #content>
        <sass-plus-content @click='hideTitle' />
      </template>
    </view-container>
  </div>
</template>

<script>
import SassPlusContent from 'views/sassPlus/componts/sassPlusContent'

export default {
  // name: 'index'
  components: {
    SassPlusContent
  },
  data() {
    return {
      bussinessTitle: '1.1转换+业务',
      bussinessType: 'transWork',
      // isShowTransWork:true,
      systemType: 'gl',
      month: ''
    }
  },
  async created() {
    await this.bussinessInit(this.bussinessType)
  },

  mounted() {
    this.$bus.$on('changeBussiness', data => {
      const { bussinessType, bussinessTitle } = data
      this.bussinessTitle = bussinessTitle
      this.bussinessType = bussinessType

      this.bussinessInit(bussinessType)
      // this.isShowTransWork = bussinessType == 'transWork' || bussinessType == 'noWorries'
      // if (bussinessType == 'transWork' || bussinessType == 'noWorries') {
      //   this.bussinessInit(bussinessType)
      // }
      // if (bussinessType == 'expandedGold' || bussinessType == 'crowdFunding') {
      //   const { systemType } = this
      //   this.crowdFundingInit(bussinessType, systemType, '')
      // }
    })

    // this.$bus.$off('changeSystem')
    // this.$bus.$on('changeSystem', data => {
    //   this.systemType = data.systemType
    //   const { systemType, bussinessType, month } = this
    //   this.crowdFundingInit(bussinessType, systemType, month)
    // })

    this.$bus.$on('changeMonths', data => {
      this.month = data.month
      // const { bussinessType, systemType, month } = this
      // if (bussinessType == 'expandedGold' || bussinessType == 'crowdFunding') {
      //   this.getActivitiesMonthly(bussinessType, systemType, month)
      //   this.getTop5CouponMonthly(bussinessType, systemType, month)
      // }
    })
  },

  methods: {
    // 1.1转换+ 2.1无忧的初始化
    async bussinessInit(bussinessType) {
      await this.getTotal(bussinessType) // 获取订单详情
      await this.getMonth(bussinessType) // 获取可选月份
      await this.getOrderMonthlyTrend(bussinessType) // 获取月度趋势
      await this.getAllGoodsDistribution(bussinessType) // 获取商品统计——整体品类分布

      this.$bus.$emit('orderinfoMonthly', { bussinessType }) // 切换业务时更新各类商品每月订单数
    },

    // 1.2 1.3的初始化
    // crowdFundingInit(bussinessType, systemType, month) {
    //   this.getMonth(bussinessType) // 获取可选月份
    //   this.getTotal(bussinessType, systemType) // 获取订单详情
    //   this.getOrderMonthlyTrend(bussinessType, systemType) // 获取月度趋势
    //   this.getActivitiesMonthly(bussinessType, systemType, month) // 获取页面左边排名前五的数据
    //   this.getTop5CouponMonthly(bussinessType, systemType, month)// 获取页面右边排名前五的数据
    //   this.getTop10Coupon(bussinessType, systemType) // 获取页面右边排名前10的数据
    //   this.getTop10Acitivity(bussinessType, systemType)// 获取页面左边排名前10的数据
    // },

    // 获取订单总数、今年新增订单数、收入总额
    getTotal(val, type) {
      // val 通过不同业务调用不同的接口
      // transWork 1.1业务 expandedGold 1.2业务 crowdFunding 1.3 noWorries 2.1
      // type  通过不同系统调用不同的接口
      // gl 广联 广汇 gh
      const params = type ? { queryItem: type } : '' // 1.1 2.1没有参数
      this.api[val].getTotal(params).then(res => {
        if (res.code == 0) {
          const orderList = res.data.dataList[0]
          this.$bus.$emit('orderList', { orderList })
        }
      })
    },

    // 获取不同业务的月份
    async getMonth(val) {
      // val 通过不同业务调用不同的接口
      // transWork 1.1业务 expandedGold 1.2业务 crowdFunding 1.3 noWorries 2.1
      await this.api[val].getMonth().then(res => {
        if (res.code == 0) {
          const monthList = res.data.dataList
          // if (this.bussinessType == 'transWork' || this.bussinessType == 'noWorries') {
          //   monthList.unshift({ month: '' })
          // }
          monthList.unshift({ month: '' })
          this.$bus.$emit('monthList', { monthList })
        }
      })
    },

    // 获取订单月度趋势
    getOrderMonthlyTrend(val, queryItem) {
      // val 通过不同业务调用不同的接口
      // transWork 1.1业务 expandedGold 1.2业务 crowdFunding 1.3 noWorries 2.1
      // queryItem  通过不同系统调用不同的接口
      // gl 广联  gh 广汇
      const params = queryItem ? { queryItem } : ''
      this.api[val].getOrderMonthlyTrend(params).then(res => {
        if (res.code == 0) {
          const orderMonthlyTrend = res.data.dataList
          this.$bus.$emit('orderMonthlyTrend', { orderMonthlyTrend })
        }
      })
    },

    // 获取商品统计——整体品类分布
    getAllGoodsDistribution(val) {
      // val 通过不同业务调用不同的接口
      // transWork 1.1业务 expandedGold 1.2业务 crowdFunding 1.3 noWorries 2.1
      this.api[val].getAllGoodsDistribution().then(res => {
        if (res.code == 0) {
          const allGoodsDistribution = res.data.dataList
          this.$bus.$emit('allGoodsDistribution', { allGoodsDistribution, bussinessType: this.bussinessType })
        }
      })
    },

    // 点击了别处隐藏菜单选择
    hideTitle() {
      this.$bus.$emit('hideEvent', { title: '111' })
    },


    // 获取排名前十的数据 右边
    // getTop10Coupon(bussinessType, queryItem) {
    //   // bussinessType 通过不同业务调用不同的接口
    //   //  expandedGold 1.2业务 crowdFunding 1.3
    //   // queryItem 系统参数
    //   // gl 广联  gh 广汇
    //   bussinessType == 'expandedGold'
    //     ? this.getTopTenData(bussinessType, 'getTop10Coupon', queryItem, 'Top10Right')
    //     : this.getTopTenData(bussinessType, 'getVehicleBrandRanking', queryItem, 'Top10Right')
    // },

    // 获取排名前十的数据 左边
    // getTop10Acitivity(bussinessType, queryItem) {
    //   // bussinessType 通过不同业务调用不同的接口
    //   //  expandedGold 1.2业务 crowdFunding 1.3
    //   // queryItem 系统参数
    //   // gl 广联  gh 广汇
    //   bussinessType == 'expandedGold'
    //     ? this.getTopTenData(bussinessType, 'getTop5Activities', queryItem, 'Top10Left')
    //     : this.getTopTenData(bussinessType, 'getAllGoodsDistribution', queryItem, 'Top10Left')
    // },

    // 获取前十的数据
    // getTopTenData(bussinessType, method, queryItem, emitName) {
    //   const params = { queryItem }
    //   this.api[bussinessType][method](params).then(res => {
    //     if (res.code == 0) {
    //       this.$bus.$emit(emitName, { list: res.data.dataList, bussinessType })
    //     }
    //   })
    // },

    // 获取排名前5的数据 -左边
    // getActivitiesMonthly(bussinessType, systemType, month) {
    //   // bussinessType 通过不同业务调用不同的接口
    //   //  expandedGold 1.2业务 crowdFunding 1.3
    //   // systemType 系统参数
    //   // gl 广联  gh 广汇
    //   bussinessType == 'expandedGold'
    //     ? this.getMonthlyRankingData(bussinessType, 'getActivitiesMonthly', month, systemType, 'topFiveRankingTopLeft')
    //     : this.getMonthlyRankingData(bussinessType, 'getGoodsTop5Monthly', month, systemType, 'topFiveRankingTopLeft')
    // },

    // 获取排名前5的数据 -右边
    // getTop5CouponMonthly(bussinessType, systemType, month) {
    //   bussinessType == 'expandedGold'
    //     ? this.getMonthlyRankingData(bussinessType, 'getTop5CouponMonthly', month, systemType, 'topFiveRankingTopRight')
    //     : this.getMonthlyRankingData(bussinessType, 'getVehicleBrandTop5Monthly', month, systemType, 'topFiveRankingTopRight')
    // },

    // 获取排名前五数据
    // getMonthlyRankingData(bussinessType, method, month, queryItem, emitName) {
    //   let getmonth = month
    //   if (!getmonth) {
    //     const date = new Date() // 获取时间
    //     const year = date.getFullYear() // 获取年
    //     const month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1// 获取月
    //     getmonth = year + '-' + month
    //   }
    //   const params = {
    //     month: getmonth,
    //     queryItem
    //   }
    //   this.api[bussinessType][method](params).then(res => {
    //     if (res.code == 0) {
    //       this.$bus.$emit(emitName, { list: res.data.dataList, bussinessType })
    //     }
    //   })
    // }
  }
}
</script>

<style scoped>

</style>