PurchasePropertion.vue 2.26 KB
<template>
  <div class="purchase-propertion-box">
    <box-title title="商城采购额商品占比"></box-title>
    <RightViewContent v-if="propertionData.length" class="content-box" :chart="propertionChart" :listData="propertionData" :legentList="propertionLegend" :legendColors="propertionChart.colors"></RightViewContent>
    <div v-else class="empty">
        <Empty></Empty>
      </div>
  </div>
</template>

<script>
import RightViewContent from './RightViewContent.vue'
import { changeMixin } from '@/mixins'
export default {
  name: 'PurchasePropertion',
  mixins: [changeMixin],
  components: {
    RightViewContent
  },

  data() {
    return {
      // 采购占比饼图结构
      propertionChart: {
        id: 'propertion',
        keys: ['goodsname', 'purchaseamount'],
        height: '17.34vh',
        colors: ['#16E193', '#747DFF', '#E588FF', '#34AFFF', '#FFC200', '#EB6001'],
        formatter: 'price'
      },
      // 采购占比数据
      propertionData: [],
      propertionLegend: [
        {
          name: 'goodsname',
          width: '11.11vw'
        },
        {
          name: 'rate',
          type: 'decimal',
          width: '3.2vw'
        },
        // {
        //   name: 'purchaseamount',
        //   hasIcon: '¥',
        //   type: 'number',
        //   width: '4.06vw'
        // },
        // {
        //   name: 'averprice',
        //   hasIcon: '均价¥',
        //   type: 'number',
        //   width: '6.24vw'
        // }
      ]
    }
  },

  mounted() {},

  methods: {
    init() {
      this.getAllGoodsRatio()
    },
    // 获取商品采购占比
    getAllGoodsRatio() {
      this.api.solar.getAllGoodsRatio({ year: this.$store.state.app.solarYear }).then(res => {
        if (!res.code === '0') {
          this.openMessage('获取商品采购占比失败')
          return
        }
        this.propertionData = res.data.dataList[0].shopgoodsRatioList.slice(0, 6) || []
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.purchase-propertion-box {
  width: 100%;
  background: #061422;
  box-shadow: inset 0 0 20px 0 #3d57ff69;
  height: 25vh;
  .content-box {
    // padding: 2.78vh 1.39vw 2.78vh 0;
    height: 21.67vh;
  }
  .empty {
    height: 21.67vh;
    display: flex;
    align-items: center;
  }
}
</style>