<template> <div class="chart-container"> <div class="chart-header"> <!--标题 --> <span class="title">供应商状态统计</span> </div> <div class="chart-content" :style="{ height: height, width: width }"> <!-- echarts内容 --> <doughnutChart :seriesData="seriesData"/> </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: [], }; }, mounted() { // this.fetchData(); //真实获取数据,后期接口完成直接使用 setTimeout(() => { // 模拟数据后期注释掉 let data = [ { status: "1", statusName: "审核通过", supplierCount: 70, }, { status: "2", statusName: "审核中", supplierCount: 30, }, { status: "3", statusName: "审核不通过", supplierCount: 20, }, ]; this.seriesData = data.map((item) => { return { value: item.supplierCount, name: item.statusName, }; }); this.indicator = data.map((item) => { return { name: item.statusName, max: item.supplierCount + 10, }; }); }, 2000); }, 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, }; }); }); }, }, }; </script> <style lang="scss" scoped> .chart-container { .chart-header { width: 600px; align-items: center; display: flex; justify-content: space-between; } .chart-content { // width: 600px; // height: 400px; } } </style>