From 8151c3253dc287a79914bc08414af17dfb380c96 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期三, 14 十月 2026 14:34:33 +0800
Subject: [PATCH] refactor(首页): 展示模块改为跟随菜单权限自动隐藏
---
src/views/mes/home/index.vue | 67 +++++++++++++++++++++++++++++----
1 files changed, 59 insertions(+), 8 deletions(-)
diff --git a/src/views/mes/home/index.vue b/src/views/mes/home/index.vue
index 258fbca..da8595f 100644
--- a/src/views/mes/home/index.vue
+++ b/src/views/mes/home/index.vue
@@ -1,7 +1,7 @@
锘�<script lang="ts" setup>
import type { MesHomeApi } from '#/api/mes/home';
-import { onMounted, ref } from 'vue';
+import { computed, onMounted, ref } from 'vue';
import { useRouter } from 'vue-router';
import { Page } from '@vben/common-ui';
@@ -9,8 +9,14 @@
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 {
+ ALERT_MENUS,
+ defaultSummary,
+ HOME_BLOCK_MENUS,
+ HOME_SHORTCUTS,
+} from './data';
import AlertPanel from './modules/alert-panel.vue';
import KpiCards from './modules/kpi-cards.vue';
import ProductionTrend from './modules/production-trend.vue';
@@ -19,6 +25,19 @@
const router = useRouter();
const summary = ref<MesHomeApi.Summary>(defaultSummary); // 棣栭〉姹囨�荤粺璁�
+
+// 棣栭〉妯″潡璺熼殢渚ц竟鏍忚彍鍗曪細鑿滃崟娌″紑鐨勬ā鍧楁暣鍧椾笉灞曠ず
+const { canSeeMenu } = useHomeAccess();
+/** 鐢熶骇瓒嬪娍锛堝彇鑷敓浜ф姤宸ワ級 */
+const showTrend = computed(() => canSeeMenu(HOME_BLOCK_MENUS.feedback));
+/** 寰呭姙涓庡紓甯革細浠绘剰涓�鏉$殑鑿滃崟寮�鐫�灏辨覆鏌撹繖涓�鍒� */
+const showAlert = computed(() => ALERT_MENUS.some((menu) => canSeeMenu(menu)));
+/** 璁㈠崟鐘舵�佸垎甯冿紙鍙栬嚜鐢熶骇璁㈠崟锛� */
+const showChart = computed(() => canSeeMenu(HOME_BLOCK_MENUS.workOrder));
+/** 蹇嵎鍏ュ彛锛氫换鎰忎竴涓叆鍙g殑鑿滃崟寮�鐫�灏辨覆鏌撹繖涓�鍒� */
+const showShortcuts = computed(() =>
+ HOME_SHORTCUTS.some((item) => canSeeMenu(item.menu)),
+);
/** 璺宠浆鍒扮洰鏍囬〉闈紙鎸夎矾鐢� name锛� */
function handleNavigate(name: string) {
@@ -40,21 +59,53 @@
<KpiCards :summary="summary" class="mb-4" @navigate="handleNavigate" />
<!-- 绗簩琛岋細鐢熶骇瓒嬪娍 + 寰呭姙寮傚父 -->
- <Row :gutter="16" class="mb-4">
- <Col :lg="16" :md="24" :sm="24" :xl="16" :xs="24" class="mb-4">
+ <Row v-if="showTrend || showAlert" :gutter="16" class="mb-4">
+ <Col
+ v-if="showTrend"
+ :lg="showAlert ? 16 : 24"
+ :md="24"
+ :sm="24"
+ :xl="showAlert ? 16 : 24"
+ :xs="24"
+ class="mb-4"
+ >
<ProductionTrend />
</Col>
- <Col :lg="8" :md="24" :sm="24" :xl="8" :xs="24" class="mb-4">
+ <Col
+ v-if="showAlert"
+ :lg="showTrend ? 8 : 24"
+ :md="24"
+ :sm="24"
+ :xl="showTrend ? 8 : 24"
+ :xs="24"
+ class="mb-4"
+ >
<AlertPanel :summary="summary" @navigate="handleNavigate" />
</Col>
</Row>
<!-- 绗笁琛岋細璁㈠崟鍒嗗竷 + 蹇嵎鍏ュ彛 -->
- <Row :gutter="16">
- <Col :lg="12" :md="24" :sm="24" :xl="12" :xs="24" class="mb-4">
+ <Row v-if="showChart || showShortcuts" :gutter="16">
+ <Col
+ v-if="showChart"
+ :lg="showShortcuts ? 12 : 24"
+ :md="24"
+ :sm="24"
+ :xl="showShortcuts ? 12 : 24"
+ :xs="24"
+ class="mb-4"
+ >
<WorkOrderChart />
</Col>
- <Col :lg="12" :md="24" :sm="24" :xl="12" :xs="24" class="mb-4">
+ <Col
+ v-if="showShortcuts"
+ :lg="showChart ? 12 : 24"
+ :md="24"
+ :sm="24"
+ :xl="showChart ? 12 : 24"
+ :xs="24"
+ class="mb-4"
+ >
<Shortcuts @navigate="handleNavigate" />
</Col>
</Row>
--
Gitblit v1.9.3