Commit 12a50e3d58d137b54514969d62c05a9d694fd164

Authored by fengtao
1 parent ff86c880

feat:首页新增饼状图和调整部分样式

... ... @@ -7,7 +7,11 @@
7 7 >
8 8 <div class="flex container">
9 9 <div class="mr-4 flex chart-top">
10   - <PieChartDeviceSub :legendData="legendData" :seriesData="seriesData" />
  10 + <PieChartDeviceSub
  11 + :legendData="legendData"
  12 + :seriesData="seriesData"
  13 + :radisData="radisData"
  14 + />
11 15 </div>
12 16 <div class="ml-20 flex justify-around right-text">
13 17 <div class="text"> 直连设备:4个 </div>
... ... @@ -23,7 +27,11 @@
23 27 >
24 28 <div class="flex container">
25 29 <div class="mr-4 flex chart-top">
26   - <PieChartDeviceSub :legendData="legendStatusData" :seriesData="seriesStatusData" />
  30 + <PieChartDeviceSub
  31 + :legendData="legendStatusData"
  32 + :seriesData="seriesStatusData"
  33 + :radisData="radisStatusData"
  34 + />
27 35 </div>
28 36 <div class="ml-20 flex justify-around right-text">
29 37 <div class="text"> 待激活设备:2个 </div>
... ... @@ -35,7 +43,7 @@
35 43 </div>
36 44 </template>
37 45 <script lang="ts" setup>
38   - import { ref, onMounted, defineComponent } from 'vue';
  46 + import { ref, onMounted, defineComponent, Ref } from 'vue';
39 47 import { Card } from 'ant-design-vue';
40 48 import { getHomeData } from '/@/api/dashboard';
41 49 import { isAdmin } from '/@/enums/roleEnum';
... ... @@ -73,20 +81,31 @@
73 81 todayMessageAdd: number;
74 82 };
75 83 }
  84 + type seriesDataT = {
  85 + value: number;
  86 + name: string;
  87 + itemStyle: object;
  88 + };
  89 + const radisData: any = ref('70%');
  90 + const radisStatusData = ref<string[]>(['40%', '70%']);
76 91 const growCardList = ref<CardList>();
77   - const legendData = ref<string[]>(['gateway', 'directly', 'sub-device']);
78   - const seriesData = ref([
79   - { value: 1048, name: 'gateway', itemStyle: { color: '#3aa0ff' } },
80   - { value: 735, name: 'directly', itemStyle: { color: '#36cbcb' } },
81   - { value: 580, name: 'sub-device', itemStyle: { color: '#4ecb73' } },
82   - ]);
83   - const legendStatusData = ref<string[]>(['inactive', 'online', 'offline']);
84   - const seriesStatusData = ref([
85   - { value: 1048, name: 'inactive', itemStyle: { color: '#3aa0ff' } },
86   - { value: 735, name: 'online', itemStyle: { color: '#36cbcb' } },
87   - { value: 580, name: 'offline', itemStyle: { color: '#4ecb73' } },
88   - ]);
  92 + const legendData = ref(['gateway', 'directly', 'sub-device']);
  93 + const seriesData: Ref<seriesDataT[]> = ref([]);
  94 + const legendStatusData = ref(['inactive', 'online', 'offline']);
  95 + const seriesStatusData: Ref<seriesDataT[]> = ref([]);
89 96 onMounted(async () => {
  97 + const mockData = [
  98 + { value: 1048, name: 'gateway', itemStyle: { color: '#3aa0ff' } },
  99 + { value: 735, name: 'directly', itemStyle: { color: '#36cbcb' } },
  100 + { value: 580, name: 'sub-device', itemStyle: { color: '#4ecb73' } },
  101 + ];
  102 + const mockTestData = [
  103 + { value: 1048, name: 'inactive', itemStyle: { color: '#3aa0ff' } },
  104 + { value: 735, name: 'online', itemStyle: { color: '#36cbcb' } },
  105 + { value: 580, name: 'offline', itemStyle: { color: '#4ecb73' } },
  106 + ];
  107 + seriesData.value = mockData;
  108 + seriesStatusData.value = mockTestData;
90 109 const res = await getHomeData();
91 110 growCardList.value = res;
92 111 });
... ...
... ... @@ -28,13 +28,19 @@
28 28 type: Array,
29 29 default: () => [],
30 30 },
  31 + radisData: {
  32 + type: Array || String,
  33 + default: () => ['40%', '70%'] || '70%',
  34 + },
31 35 },
32 36 setup(props) {
33   - const { legendData, seriesData } = toRefs(props);
  37 + const { legendData, seriesData, radisData } = toRefs(props);
34 38 const dataSeries = ref<any>([]);
35 39 const legendDatas = ref<any>([]);
  40 + const radisDatas = ref<any>([]);
36 41 dataSeries.value = seriesData.value;
37 42 legendDatas.value = legendData.value;
  43 + radisDatas.value = radisData.value;
38 44
39 45 const chartRef = ref<HTMLDivElement | null>(null);
40 46 const { setOptions, resize } = useECharts(chartRef as Ref<HTMLDivElement>);
... ... @@ -55,7 +61,7 @@
55 61 series: [
56 62 {
57 63 type: 'pie',
58   - radius: '60%',
  64 + radius: radisDatas.value,
59 65 data: dataSeries,
60 66 emphasis: {
61 67 itemStyle: {
... ...