Newer
Older
smartKitchenFront / src / views / dashboard / components / supplierStatus.vue
<template>
  <div class="chart-container" :style="{ height: height, width: width }">
    <div class="chart-header">
      <!--标题  -->
      <span class="title">供应商状态统计</span>
    </div>
    <div class="chart-content"  :style="{ 'height': parseInt(height) - 40 + 'px'}">
      <!-- echarts内容 -->
      <doughnutChart :seriesData="seriesData" :title="title" />
    </div>
  </div>
</template>
  
<script>
import doughnutChart from "../../../components/echart/pieChart/doughnutChart.vue";
import { getSupplierStatus } from "@/api/cockpit/cockpit";
export default {
  name: "supplierStatus",
  components: {
    doughnutChart,
  },
  props: {
    name: {
      type: String,
      default: "",
    },
    width: {
      type: String,
      default: "500px",
    },
    height: {
      type: String,
      default: "300px",
    },
  },
  data() {
    return {
      seriesData: [],
      indicator: [],
      title: ''
    };
  },
  mounted() {
    this.fetchData();  //真实获取数据,后期接口完成直接使用
  },
  methods: {
    fetchData() {
      getSupplierStatus().then((res) => {
        this.seriesData = res.data.map((item) => {
          return {
            value: item.supplierCount,
            name: item.statusName,
          };
        });
        this.indicator = res.data.map((item) => {
          return {
            name: item.statusName,
            max: item.supplierCount + 10,
          };
        });
        let arr = []
        res.data.forEach(element => {
          arr.push(element.supplierCount)
        });
        this.title = `总\n\n${arr.reduce((pre, cur) => pre + cur)}`
      });
    },
  },
};
</script>
  
<style lang="scss" scoped>
.chart-container {
  background: #edf5f8;
  border-radius: 8px;
  margin: 10px;
  padding: 10px;

  .chart-header {
    font-size: 14px;
    color: #2076A1;
    font-weight: 700;

  }

  .chart-content {
    // width: 600px;
    // height: 400px;
  }
}
</style>