| | |
| | | <script lang="ts" setup> |
| | | import type { EchartsUIType } from '@vben/plugins/echarts'; |
| | | |
| | | import { onMounted, ref } from 'vue'; |
| | | import { computed, onMounted, ref } from 'vue'; |
| | | |
| | | import { EchartsUI, useEcharts } from '@vben/plugins/echarts'; |
| | | |
| | |
| | | |
| | | import { getWorkOrderStatusDistribution } from '#/api/mes/home'; |
| | | |
| | | import { useHomeAccess } from '#/utils/use-home-access'; |
| | | |
| | | import { getWorkOrderStatusChartOptions } from '../chart-options'; |
| | | import { WORK_ORDER_STATUS_COLOR_MAP } from '../data'; |
| | | import { HOME_BLOCK_MENUS, WORK_ORDER_STATUS_COLOR_MAP } from '../data'; |
| | | |
| | | defineOptions({ name: 'MesHomeWorkOrderChart' }); |
| | | |
| | | const chartRef = ref<EchartsUIType>(); |
| | | const { renderEcharts } = useEcharts(chartRef); |
| | | const { canSeeMenu } = useHomeAccess(); |
| | | |
| | | /** 菜单没开就不展示、不请求 */ |
| | | const showChart = computed(() => canSeeMenu(HOME_BLOCK_MENUS.workOrder)); |
| | | |
| | | /** 加载订单状态分布数据并渲染饼图 */ |
| | | async function loadData() { |
| | | if (!showChart.value) return; |
| | | const data = await getWorkOrderStatusDistribution(); |
| | | const chartData = data.map((d) => ({ |
| | | itemStyle: { color: WORK_ORDER_STATUS_COLOR_MAP[d.status] || '#409EFF' }, |
| | |
| | | </script> |
| | | |
| | | <template> |
| | | <Card title="订单状态分布" class="h-full"> |
| | | <Card v-if="showChart" title="订单状态分布" class="h-full"> |
| | | <EchartsUI ref="chartRef" class="h-[280px] w-full" /> |
| | | </Card> |
| | | </template> |