gaoluyang
2026-06-29 27cd042df9aca0383a49f3514bc21958dd890912
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<script lang="ts" setup>
import type { EchartsUIType } from '../../../../packages/effects/plugins/src/echarts';
 
import { onMounted, ref } from 'vue';
 
import { EchartsUI, useEcharts } from '../../../../packages/effects/plugins/src/echarts';
 
import { Card } from 'ant-design-vue';
 
import { getWorkOrderStatusDistribution } from '#/api/mes/home';
 
import { getWorkOrderStatusChartOptions } from '../chart-options';
import { WORK_ORDER_STATUS_COLOR_MAP } from '../data';
 
defineOptions({ name: 'MesHomeWorkOrderChart' });
 
const chartRef = ref<EchartsUIType>();
const { renderEcharts } = useEcharts(chartRef);
 
/** 加载工单状态分布数据并渲染饼图 */
async function loadData() {
  const data = await getWorkOrderStatusDistribution();
  const chartData = data.map((d) => ({
    itemStyle: { color: WORK_ORDER_STATUS_COLOR_MAP[d.status] || '#409EFF' },
    name: d.statusName,
    value: d.count,
  }));
  await renderEcharts(getWorkOrderStatusChartOptions(chartData));
}
 
onMounted(() => {
  loadData();
});
</script>
 
<template>
  <Card title="工单状态分布" class="h-full">
    <EchartsUI ref="chartRef" class="h-[280px] w-full" />
  </Card>
</template>