gaoluyang
4 天以前 8151c3253dc287a79914bc08414af17dfb380c96
src/views/dashboard/analytics/index.vue
@@ -8,6 +8,8 @@
import { getHomeSummary } from '#/api/mes/home';
import { useHomeAccess } from '#/utils/use-home-access';
import { defaultSummary } from './data';
import AiInsights from './modules/ai-insights.vue';
import AlertPanel from './modules/alert-panel.vue';
@@ -15,13 +17,34 @@
import KpiCards from './modules/kpi-cards.vue';
import ProductionTrend from './modules/production-trend.vue';
import QuickActions from './modules/quick-actions.vue';
import { useHomeAccess } from './use-home-access';
defineOptions({ name: 'DashboardAnalytics' });
const router = useRouter();
const summary = ref(defaultSummary);
const { canNavigate, canViewHome } = useHomeAccess();
const { canNavigate, canSeeMenu, canViewHome } = useHomeAccess();
// 首页模块跟随侧边栏菜单:菜单没开的模块整块不展示
/** MES 生产 KPI:任意一张卡的菜单开着就渲染整行 */
const showKpi = computed(
  () =>
    canViewHome.value &&
    ['MesProWorkOrder', 'MesProFeedback', 'MesQcIqc', 'MesDvMachinery'].some(
      (name) => canSeeMenu(name),
    ),
);
/** AI 智能分析:AI 模块的菜单开着才渲染 */
const showAiInsights = computed(
  () => canViewHome.value && canSeeMenu('AiChat'),
);
/** 生产趋势:数据来自生产报工 */
const showTrend = computed(
  () => canViewHome.value && canSeeMenu('MesProFeedback'),
);
/** 工单状态分布:数据来自生产订单 */
const showWorkOrderStatus = computed(
  () => canViewHome.value && canSeeMenu('MesProWorkOrder'),
);
const greeting = computed(() => {
  const hour = new Date().getHours();
@@ -76,21 +99,29 @@
    </div>
    <!-- MES 生产 KPI -->
    <KpiCards v-if="canViewHome" :summary="summary" @navigate="handleNavigate" />
    <KpiCards v-if="showKpi" :summary="summary" @navigate="handleNavigate" />
    <!-- ERP/WMS/BPM 经营 KPI -->
    <BizCards @navigate="handleNavigate" />
    <!-- AI 智能分析 -->
    <AiInsights
      v-if="canViewHome && canNavigate('MesProWorkOrder')"
      v-if="showAiInsights"
      :active-order-count="summary.workOrderActiveCount"
      @navigate="handleNavigate"
    />
    <!-- 生产趋势 + 预警面板 -->
    <Row v-if="canViewHome" :gutter="16" class="mb-4">
      <Col :lg="14" :md="24" :sm="24" :xl="14" :xs="24" class="mb-4">
    <Row v-if="showTrend || showWorkOrderStatus" :gutter="16" class="mb-4">
      <Col
        v-if="showTrend"
        :lg="showWorkOrderStatus ? 14 : 24"
        :md="24"
        :sm="24"
        :xl="showWorkOrderStatus ? 14 : 24"
        :xs="24"
        class="mb-4"
      >
        <div class="glass-card rounded-2xl p-5">
          <h3 class="mb-4 text-base font-semibold text-gray-800 dark:text-gray-100">
            生产趋势(近7天)
@@ -98,7 +129,15 @@
          <ProductionTrend />
        </div>
      </Col>
      <Col :lg="10" :md="24" :sm="24" :xl="10" :xs="24" class="mb-4">
      <Col
        v-if="showWorkOrderStatus"
        :lg="showTrend ? 10 : 24"
        :md="24"
        :sm="24"
        :xl="showTrend ? 10 : 24"
        :xs="24"
        class="mb-4"
      >
        <AlertPanel
          :repair-active-count="summary.repairActiveCount"
          @navigate="handleNavigate"