gaoluyang
5 天以前 8151c3253dc287a79914bc08414af17dfb380c96
src/views/mes/home/modules/production-trend.vue
@@ -1,7 +1,7 @@
<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';
@@ -9,16 +9,24 @@
import { getProductionTrend } from '#/api/mes/home';
import { useHomeAccess } from '#/utils/use-home-access';
import { getProductionTrendChartOptions } from '../chart-options';
import { HOME_BLOCK_MENUS } from '../data';
defineOptions({ name: 'MesHomeProductionTrend' });
const trendDays = ref(7); // 当前选中的天数范围
const chartRef = ref<EchartsUIType>();
const { renderEcharts } = useEcharts(chartRef);
const { canSeeMenu } = useHomeAccess();
/** 生产趋势取自生产报工,报工菜单没开就不展示、不请求 */
const showTrend = computed(() => canSeeMenu(HOME_BLOCK_MENUS.feedback));
/** 加载生产趋势数据并渲染图表 */
async function loadData() {
  if (!showTrend.value) return;
  const data = await getProductionTrend(trendDays.value);
  const dates = data.map((d) => d.date.slice(5));
  const quantities = data.map((d) => d.quantity);
@@ -40,7 +48,7 @@
</script>
<template>
  <Card title="生产趋势" class="h-full">
  <Card v-if="showTrend" title="生产趋势" class="h-full">
    <template #extra>
      <RadioGroup
        v-model:value="trendDays"