From 5c1e0a47eea514f59f697133fe8a01bcbf6f7a78 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期四, 15 十月 2026 10:31:28 +0800
Subject: [PATCH] refactor(首页): 展示模块跟随菜单权限自动隐藏

---
 src/views/dashboard/analytics/index.vue |   62 ++++++++++++++++++++++++++++--
 1 files changed, 57 insertions(+), 5 deletions(-)

diff --git a/src/views/dashboard/analytics/index.vue b/src/views/dashboard/analytics/index.vue
index 13794de..46980f6 100644
--- a/src/views/dashboard/analytics/index.vue
+++ b/src/views/dashboard/analytics/index.vue
@@ -4,9 +4,11 @@
 
 import { Page } from '@vben/common-ui';
 
-import { Card, Col, Row } from 'ant-design-vue';
+import { Col, Row } from 'ant-design-vue';
 
 import { getHomeSummary } from '#/api/mes/home';
+
+import { useHomeAccess } from '#/utils/use-home-access';
 
 import { defaultSummary } from './data';
 import AiInsights from './modules/ai-insights.vue';
@@ -20,6 +22,38 @@
 
 const router = useRouter();
 const summary = ref(defaultSummary);
+
+const { canQuery, canSeeMenu } = useHomeAccess();
+
+/** 棣栭〉鍚勬ā鍧楃殑鎺ュ彛鏉冮檺閮芥槸 mes:home:query锛屽彇涓嶅埌鏁板氨鍏堝埆璇锋眰锛堝惁鍒欏脊銆屾病鏈夎鎿嶄綔鏉冮檺銆嶏級 */
+const canViewSummary = computed(() => canQuery('mes:home:query'));
+
+/** MES 鐢熶骇 KPI锛氭暟鎹彇鑷椤垫眹鎬绘帴鍙o紝涓斿搴旇彍鍗曞紑鐫�鎵嶆覆鏌� */
+const showKpi = computed(
+  () =>
+    canViewSummary.value &&
+    ['MesProWorkOrder', 'MesProFeedback', 'MesQcIqc', 'MesDvMachinery'].some(
+      (name) => canSeeMenu(name),
+    ),
+);
+
+/** 鐢熶骇瓒嬪娍锛氭暟鎹潵鑷敓浜ф姤宸� */
+const showTrend = computed(
+  () => canViewSummary.value && canSeeMenu('MesProFeedback'),
+);
+
+/** 宸ュ崟鐘舵�佸垎甯� + 缁翠慨棰勮 */
+const showAlert = computed(
+  () =>
+    canViewSummary.value &&
+    (canSeeMenu('MesProWorkOrder') || canSeeMenu('MesDvRepair')),
+);
+
+/** 鐢熶骇瓒嬪娍鍜岄璀﹂潰鏉垮悓涓�琛岋紝涓ゅ潡閮芥病寮�灏辨暣琛屼笉娓叉煋 */
+const showMonitorRow = computed(() => showTrend.value || showAlert.value);
+
+/** AI 鍒嗘瀽鍧楅噷銆孨 涓伐鍗曞彲鍒嗘瀽銆嶅彇鐨勪篃鏄椤垫眹鎬绘帴鍙o紝鍙栦笉鍒版暟灏卞埆鏄剧ず杩欎釜鍋囨暟瀛� */
+const showAiInsights = computed(() => canViewSummary.value);
 
 const greeting = computed(() => {
   const hour = new Date().getHours();
@@ -42,6 +76,7 @@
 }
 
 async function loadSummary() {
+  if (!canViewSummary.value) return;
   summary.value = await getHomeSummary();
 }
 
@@ -72,20 +107,29 @@
     </div>
 
     <!-- MES 鐢熶骇 KPI -->
-    <KpiCards :summary="summary" @navigate="handleNavigate" />
+    <KpiCards v-if="showKpi" :summary="summary" @navigate="handleNavigate" />
 
     <!-- ERP/WMS/BPM 缁忚惀 KPI -->
     <BizCards @navigate="handleNavigate" />
 
     <!-- AI 鏅鸿兘鍒嗘瀽 -->
     <AiInsights
+      v-if="showAiInsights"
       :active-order-count="summary.workOrderActiveCount"
       @navigate="handleNavigate"
     />
 
     <!-- 鐢熶骇瓒嬪娍 + 棰勮闈㈡澘 -->
-    <Row :gutter="16" class="mb-4">
-      <Col :lg="14" :md="24" :sm="24" :xl="14" :xs="24" class="mb-4">
+    <Row v-if="showMonitorRow" :gutter="16" class="mb-4">
+      <Col
+        v-if="showTrend"
+        :lg="showAlert ? 14 : 24"
+        :md="24"
+        :sm="24"
+        :xl="showAlert ? 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澶╋級
@@ -93,7 +137,15 @@
           <ProductionTrend />
         </div>
       </Col>
-      <Col :lg="10" :md="24" :sm="24" :xl="10" :xs="24" class="mb-4">
+      <Col
+        v-if="showAlert"
+        :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"

--
Gitblit v1.9.3