From 8217c63d1610a9d89419c69947beb4fb3bb7c7e4 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期三, 20 五月 2026 17:03:05 +0800
Subject: [PATCH] style(frontend): 格式化代码缩进并增强API调用安全性
---
src/views/index.vue | 491 +++++++++++++++++++++++++++++++++++++-----------------
1 files changed, 337 insertions(+), 154 deletions(-)
diff --git a/src/views/index.vue b/src/views/index.vue
index f3e6db3..49f8b05 100644
--- a/src/views/index.vue
+++ b/src/views/index.vue
@@ -7,28 +7,24 @@
</el-avatar>
<div class="welcome-text">
<div class="welcome-title">
- 鏅氫笂濂斤紝{{ userStore.nickName || userStore.name || "瓒呯骇绠$悊鍛�" }} 馃憢
+ {{ greetingText }}锛寋{ userStore.nickName || userStore.name || "瓒呯骇绠$悊鍛�" }} 馃憢
</div>
<div class="welcome-subtitle">涓撴敞宸ヤ笟鏁板瓧鍖栵紝鍔╁姏鏅洪�犲崌绾�</div>
</div>
</div>
<div class="welcome-meta">
<div class="meta-time digital-number">{{ nowTime }}</div>
- <div class="meta-extra">
- <span class="meta-date">{{ nowDate }}</span>
- <span class="meta-weather">{{ weatherText }}</span>
- </div>
<div class="meta-tip">MES / MOM 鐢熶骇杩愯惀椹鹃┒鑸�</div>
</div>
</section>
- <section class="top-row">
+ <section v-if="dashboardCards.length > 0" class="top-row">
<div class="stats-grid">
<article
- v-for="card in dashboardCards"
- :key="card.key"
- class="stat-card"
- :class="card.key"
+ v-for="card in dashboardCards"
+ :key="card.key"
+ class="stat-card"
+ :class="card.key"
>
<div class="stat-header">
<div class="stat-title-wrap">
@@ -52,9 +48,9 @@
</div>
</section>
- <section class="main-grid">
- <div class="left-column">
- <div class="cockpit-panel process-panel">
+ <section v-if="hasVisiblePanels" class="main-grid">
+ <div v-if="hasLeftPanels" class="left-column">
+ <div v-if="visiblePanels.process" class="cockpit-panel process-panel">
<div class="panel-title-row">
<div class="panel-title">宸ュ簭鏁版嵁鐢熶骇缁熻鏄庣粏</div>
<div class="panel-actions">
@@ -70,15 +66,15 @@
<div class="process-body">
<div class="process-chart" :class="{ empty: !hasProcessData }">
<Echarts
- :options="chartBaseOptions"
- :chartStyle="{ width: '100%', height: '100%' }"
- :grid="processGrid"
- :series="processSeries"
- :tooltip="processTooltip"
- :xAxis="processXAxis"
- :yAxis="processYAxis"
- :style="{ height: hasProcessData ? '340px' : '280px' }"
- @click="handleChartClick"
+ :options="chartBaseOptions"
+ :chartStyle="{ width: '100%', height: '100%' }"
+ :grid="processGrid"
+ :series="processSeries"
+ :tooltip="processTooltip"
+ :xAxis="processXAxis"
+ :yAxis="processYAxis"
+ :style="{ height: hasProcessData ? '340px' : '280px' }"
+ @click="handleChartClick"
/>
<div v-if="!hasProcessData" class="chart-empty">
<el-icon><DataAnalysis /></el-icon>
@@ -113,7 +109,7 @@
</div>
</div>
- <div class="cockpit-panel order-panel">
+ <div v-if="visiblePanels.order" class="cockpit-panel order-panel">
<div class="panel-title-row">
<div class="panel-title">鐢熶骇璁㈠崟杩涘害</div>
<el-radio-group v-model="orderFilter" size="small">
@@ -132,10 +128,10 @@
<template #default="{ row }">
<div class="table-progress">
<el-progress
- :stroke-width="8"
- :percentage="row.completionRate"
- :show-text="false"
- status="success"
+ :stroke-width="8"
+ :percentage="row.completionRate"
+ :show-text="false"
+ status="success"
/>
<span>{{ row.completionRate }}%</span>
</div>
@@ -152,54 +148,54 @@
</el-table>
</div>
- <div class="cockpit-panel contract-panel">
- <div class="panel-title">瀹㈡埛鍚堝悓閲戦鍒嗘瀽</div>
- <div class="contract-summary">
- <div class="contract-card">
- <div class="contract-name">鎬诲悎鍚岄噾棰�(鍏�)</div>
- <div class="contract-main digital-number">{{ formatNumber(sum) }}</div>
- <div class="contract-compare">
- 鍚屾瘮
- <span class="rise">{{ trendText(yny) }}</span>
- 鐜瘮
- <span class="rise">{{ trendText(chain) }}</span>
- </div>
+ <div v-if="visiblePanels.contract" class="cockpit-panel contract-panel">
+ <div class="panel-title">瀹㈡埛鍚堝悓閲戦鍒嗘瀽</div>
+ <div class="contract-summary">
+ <div class="contract-card">
+ <div class="contract-name">鎬诲悎鍚岄噾棰�(鍏�)</div>
+ <div class="contract-main digital-number">{{ formatNumber(sum) }}</div>
+ <div class="contract-compare">
+ 鍚屾瘮
+ <span class="rise">{{ trendText(yny) }}</span>
+ 鐜瘮
+ <span class="rise">{{ trendText(chain) }}</span>
</div>
- <div class="contract-chart-wrap">
- <Echarts
+ </div>
+ <div class="contract-chart-wrap">
+ <Echarts
:options="chartBaseOptions"
:legend="pieLegend"
:chartStyle="chartStylePie"
:series="materialPieSeries"
:tooltip="pieTooltip"
- />
- </div>
+ />
</div>
- <ul class="contract-list">
- <li v-for="item in materialPieSeries[0].data" :key="item.name">
- <span class="legend-dot" :style="{ backgroundColor: item.itemStyle?.color }"></span>
- <span class="contract-item-name">{{ item.name }}</span>
- <span class="contract-item-rate">{{ item.rate }}%</span>
- <span class="contract-item-value digital-number">楼{{ formatNumber(item.value) }}</span>
- </li>
- </ul>
</div>
+ <ul class="contract-list">
+ <li v-for="item in materialPieSeries[0].data" :key="item.name">
+ <span class="legend-dot" :style="{ backgroundColor: item.itemStyle?.color }"></span>
+ <span class="contract-item-name">{{ item.name }}</span>
+ <span class="contract-item-rate">{{ item.rate }}%</span>
+ <span class="contract-item-value digital-number">楼{{ formatNumber(item.value) }}</span>
+ </li>
+ </ul>
+ </div>
- <div class="cockpit-panel quality-panel">
- <div class="panel-title-row">
- <div class="panel-title">璐ㄩ噺缁熻</div>
- <el-radio-group v-model="qualityRange" size="small" @change="qualityStatisticsInfo">
- <el-radio-button :value="1">鍛�</el-radio-button>
- <el-radio-button :value="2">鏈�</el-radio-button>
- <el-radio-button :value="3">瀛e害</el-radio-button>
- </el-radio-group>
- </div>
- <div class="quality-cards">
- <div class="quality-card one">鍘熸潗鏂欏凡妫�鏁伴噺 <span>{{ qualityStatisticsObject.supplierNum }}浠�</span></div>
- <div class="quality-card two">杩囩▼妫�楠屾暟閲� <span>{{ qualityStatisticsObject.processNum }}浠�</span></div>
- <div class="quality-card three">鍑哄巶宸叉鏁伴噺 <span>{{ qualityStatisticsObject.factoryNum }}浠�</span></div>
- </div>
- <Echarts
+ <div v-if="visiblePanels.quality" class="cockpit-panel quality-panel">
+ <div class="panel-title-row">
+ <div class="panel-title">璐ㄩ噺缁熻</div>
+ <el-radio-group v-model="qualityRange" size="small" @change="qualityStatisticsInfo">
+ <el-radio-button :value="1">鍛�</el-radio-button>
+ <el-radio-button :value="2">鏈�</el-radio-button>
+ <el-radio-button :value="3">瀛e害</el-radio-button>
+ </el-radio-group>
+ </div>
+ <div class="quality-cards">
+ <div class="quality-card one">鍘熸潗鏂欏凡妫�鏁伴噺 <span>{{ qualityStatisticsObject.supplierNum }}浠�</span></div>
+ <div class="quality-card two">杩囩▼妫�楠屾暟閲� <span>{{ qualityStatisticsObject.processNum }}浠�</span></div>
+ <div class="quality-card three">鍑哄巶宸叉鏁伴噺 <span>{{ qualityStatisticsObject.factoryNum }}浠�</span></div>
+ </div>
+ <Echarts
:options="chartBaseOptions"
:chartStyle="chartStyle"
:grid="grid"
@@ -209,12 +205,12 @@
:xAxis="xAxis1"
:yAxis="yAxis1"
style="height: 270px"
- />
- </div>
+ />
+ </div>
</div>
- <div class="right-column">
- <div class="cockpit-panel todo-panel">
+ <div v-if="hasRightPanels" class="right-column">
+ <div v-if="visiblePanels.todo" class="cockpit-panel todo-panel">
<div class="panel-title-row">
<div class="panel-title">寰呭姙浜嬮」</div>
<span class="panel-more">鏇村</span>
@@ -232,7 +228,7 @@
<div v-else class="panel-empty">鏆傛棤鏁版嵁</div>
</div>
- <div class="cockpit-panel realtime-panel">
+ <div v-if="visiblePanels.realtime" class="cockpit-panel realtime-panel">
<div class="panel-title-row">
<div class="panel-title">鐢熶骇瀹炴椂鐪嬫澘</div>
<span class="panel-more">鏇村</span>
@@ -240,11 +236,11 @@
<div class="realtime-grid">
<div class="realtime-item" v-for="item in realtimeBoard" :key="item.key">
<el-progress
- type="circle"
- :percentage="item.percent"
- :stroke-width="10"
- :width="94"
- :color="item.color"
+ type="circle"
+ :percentage="item.percent"
+ :stroke-width="10"
+ :width="94"
+ :color="item.color"
>
<template #default>
<div class="realtime-value digital-number">{{ item.display }}</div>
@@ -256,17 +252,17 @@
</div>
</div>
- <div class="cockpit-panel quick-panel">
+ <div v-if="visiblePanels.quick" class="cockpit-panel quick-panel">
<div class="panel-title-row">
<div class="panel-title">蹇嵎鍔熻兘</div>
</div>
<div class="quick-grid">
<button
- v-for="item in quickEntries"
- :key="item.label"
- class="quick-item"
- type="button"
- @click="goToQuick(item.path)"
+ v-for="item in quickEntries"
+ :key="item.label"
+ class="quick-item"
+ type="button"
+ @click="goToQuick(item.path)"
>
<span class="quick-icon">
<el-icon>
@@ -278,7 +274,7 @@
</div>
</div>
- <div class="cockpit-panel plan-panel">
+ <div v-if="visiblePanels.plan" class="cockpit-panel plan-panel">
<div class="panel-title-row">
<div class="panel-title">浠婃棩鐢熶骇璁″垝</div>
<span class="panel-more">{{ todayPlanList.length }}椤�</span>
@@ -297,22 +293,26 @@
</ul>
</div>
- <div class="cockpit-panel receipt-panel">
+ <div v-if="visiblePanels.receipt" class="cockpit-panel receipt-panel">
<div class="panel-title">鍥炴涓庡紑绁ㄥ垎鏋�</div>
<Echarts
- :options="chartBaseOptions"
- :chartStyle="chartStyle"
- :grid="grid"
- :legend="lineLegend"
- :series="lineSeries"
- :tooltip="tooltipLine"
- :xAxis="xAxis2"
- :yAxis="yAxis2"
- style="height: 300px"
+ :options="chartBaseOptions"
+ :chartStyle="chartStyle"
+ :grid="grid"
+ :legend="lineLegend"
+ :series="lineSeries"
+ :tooltip="tooltipLine"
+ :xAxis="xAxis2"
+ :yAxis="yAxis2"
+ style="height: 300px"
/>
</div>
</div>
+ </section>
+
+ <section v-else class="cockpit-panel empty-home-panel">
+ 褰撳墠璐﹀彿娌℃湁鍙睍绀虹殑棣栭〉妯″潡
</section>
<el-dialog v-model="processDialogVisible" title="閫夋嫨宸ュ簭" width="500px" append-to-body>
@@ -355,6 +355,7 @@
UserFilled,
} from "@element-plus/icons-vue";
import Echarts from "@/components/Echarts/echarts.vue";
+import usePermissionStore from "@/store/modules/permission";
import useUserStore from "@/store/modules/user.js";
import {
analysisCustomerContractAmounts,
@@ -369,6 +370,7 @@
const router = useRouter();
const userStore = useUserStore();
+const permissionStore = usePermissionStore();
const defaultWelcomeAvatar = new URL("../assets/images/profile.jpg", import.meta.url).href;
const nowTime = ref("");
@@ -378,8 +380,18 @@
const nowDate = computed(() => (nowTime.value ? nowTime.value.slice(0, 10) : dayjs().format("YYYY-MM-DD")));
+const greetingText = computed(() => {
+ const hour = dayjs().hour();
+ if (hour < 6) return "鍑屾櫒濂�";
+ if (hour < 9) return "鏃╀笂濂�";
+ if (hour < 12) return "涓婂崍濂�";
+ if (hour < 14) return "涓崍濂�";
+ if (hour < 18) return "涓嬪崍濂�";
+ return "鏅氫笂濂�";
+});
+
const welcomeAvatar = computed(() =>
- welcomeAvatarLoadFailed.value || !userStore.avatar ? defaultWelcomeAvatar : userStore.avatar
+ welcomeAvatarLoadFailed.value || !userStore.avatar ? defaultWelcomeAvatar : userStore.avatar
);
const handleWelcomeAvatarError = () => {
@@ -389,10 +401,10 @@
};
watch(
- () => userStore.avatar,
- () => {
- welcomeAvatarLoadFailed.value = false;
- }
+ () => userStore.avatar,
+ () => {
+ welcomeAvatarLoadFailed.value = false;
+ }
);
const axisTextColor = "#5f6f86";
@@ -665,11 +677,11 @@
const name = params?.[0]?.name ?? "";
const list = Array.isArray(params) ? params : [];
const lines = list
- .map((p) => {
- const colorBox = `<span style="display:inline-block;margin-right:6px;border-radius:2px;width:10px;height:10px;background:${p.color}"></span>`;
- return `${colorBox}${p.seriesName}<b style="float:right;">${Number(p.value || 0).toFixed(2)}</b>`;
- })
- .join("<br/>");
+ .map((p) => {
+ const colorBox = `<span style="display:inline-block;margin-right:6px;border-radius:2px;width:10px;height:10px;background:${p.color}"></span>`;
+ return `${colorBox}${p.seriesName}<b style="float:right;">${Number(p.value || 0).toFixed(2)}</b>`;
+ })
+ .join("<br/>");
return `<div style="min-width:140px;"><div style="font-weight:700;margin-bottom:6px;">${name}</div>${lines}</div>`;
},
});
@@ -718,15 +730,15 @@
});
const processTotals = computed(() =>
- processChartData.value.reduce(
- (acc, cur) => {
- acc.input += Number(cur.input || 0);
- acc.scrap += Number(cur.scrap || 0);
- acc.output += Number(cur.output || 0);
- return acc;
- },
- { input: 0, scrap: 0, output: 0 }
- )
+ processChartData.value.reduce(
+ (acc, cur) => {
+ acc.input += Number(cur.input || 0);
+ acc.scrap += Number(cur.scrap || 0);
+ acc.output += Number(cur.output || 0);
+ return acc;
+ },
+ { input: 0, scrap: 0, output: 0 }
+ )
);
const hasProcessData = computed(() => {
@@ -749,6 +761,7 @@
subValue: formatNumber(businessInfo.value.monthSaleHaveMoney),
trend: `鍗犳瘮 ${ratioText(businessInfo.value.monthSaleHaveMoney, businessInfo.value.monthSaleMoney)}`,
icon: DataLine,
+ visible: visibleModules.value.sales,
},
{
key: "purchase",
@@ -758,10 +771,11 @@
subLabel: "寰呬粯娆鹃噾棰�",
subValue: formatNumber(businessInfo.value.monthPurchaseHaveMoney),
trend: `鍗犳瘮 ${ratioText(
- businessInfo.value.monthPurchaseHaveMoney,
- businessInfo.value.monthPurchaseMoney
+ businessInfo.value.monthPurchaseHaveMoney,
+ businessInfo.value.monthPurchaseMoney
)}`,
icon: ShoppingCartFull,
+ visible: visibleModules.value.procurement,
},
{
key: "inventory",
@@ -772,6 +786,7 @@
subValue: formatNumber(businessInfo.value.todayInventoryNum),
trend: "搴撳瓨缁撴瀯鎸佺画浼樺寲",
icon: Box,
+ visible: visibleModules.value.inventory,
},
{
key: "production",
@@ -782,8 +797,9 @@
subValue: formatNumber(processTotals.value.scrap),
trend: `鑹巼 ${ratioText(processTotals.value.output, processTotals.value.input)}`,
icon: Operation,
+ visible: visibleModules.value.production,
},
-]);
+].filter((item) => item.visible));
const productionOrders = ref([
{
@@ -831,10 +847,10 @@
});
const todayPlanList = computed(() =>
- productionOrders.value
- .slice()
- .sort((a, b) => dayjs(a.deliveryDate).valueOf() - dayjs(b.deliveryDate).valueOf())
- .slice(0, 5)
+ productionOrders.value
+ .slice()
+ .sort((a, b) => dayjs(a.deliveryDate).valueOf() - dayjs(b.deliveryDate).valueOf())
+ .slice(0, 5)
);
const avgCompletionRate = computed(() => {
@@ -901,16 +917,160 @@
},
]);
-const quickEntries = [
- { label: "鐢熶骇鎺掍骇", icon: Calendar, path: "/productionManagement/productionDispatching" },
- { label: "宸ュ簭鎶ュ伐", icon: EditPen, path: "/productionManagement/productionReporting" },
- { label: "鐢熶骇璁㈠崟", icon: Tickets, path: "/productionManagement/productionOrder" },
- { label: "鐗╂枡榻愬", icon: Box, path: "/productionManagement/workOrderManagement" },
- { label: "璐ㄩ噺妫�楠�", icon: Checked, path: "/qualityManagement/processInspection" },
- { label: "璁惧绠$悊", icon: Tools, path: "/equipmentManagement/deviceInfo" },
- { label: "搴撳瓨鏌ヨ", icon: Search, path: "/inventoryManagement/stockManage" },
- { label: "鏁版嵁鎶ヨ〃", icon: DataAnalysis, path: "/reportAnalysis/reportManagement" },
+const quickEntryConfigs = [
+ { label: "涓荤敓浜ц鍒�", icon: Calendar, titles: ["涓荤敓浜ц鍒�"], fallbackPath: "/productionPlan/productionPlan" },
+ { label: "鐢熶骇璁㈠崟", icon: Tickets, titles: ["鐢熶骇璁㈠崟"], fallbackPath: "/productionManagement/productionOrder" },
+ { label: "鐢熶骇鎶ュ伐", icon: EditPen, titles: ["鐢熶骇鎶ュ伐"], fallbackPath: "/productionManagement/productionReporting" },
+ { label: "璁惧鍙拌处", icon: Tools, titles: ["璁惧鍙拌处"], fallbackPath: "/equipmentManagement/ledger" },
+ { label: "閿�鍞彴璐�", icon: DataLine, titles: ["閿�鍞彴璐�"], fallbackPath: "/salesManagement/salesLedger" },
+ { label: "閲囪喘鍙拌处", icon: ShoppingCartFull, titles: ["閲囪喘鍙拌处"], fallbackPath: "/procurementManagement/procurementLedger" },
+ { label: "鍛樺伐鍙拌处", icon: UserFilled, titles: ["鍛樺伐鍙拌处", "鍦ㄨ亴鍛樺伐鍙拌处"], fallbackPath: "/personnelManagement/employeeRecord" },
+ { label: "搴撳瓨绠$悊", icon: Box, titles: ["搴撳瓨绠$悊"], fallbackPath: "/inventoryManagement/stockManage" },
];
+
+const normalizeMenuTitle = (title) => String(title || "").replace(/\s+/g, "").trim();
+const normalizeRoutePath = (path) =>
+ String(path || "")
+ .trim()
+ .replace(/\/+/g, "/")
+ .replace(/\/$/, "")
+ .toLowerCase();
+
+const resolveRoutePath = (route, parentPath = "") => {
+ const currentPath = String(route?.path || "").trim();
+ if (!currentPath) return parentPath || "";
+ if (/^(https?:)?\/\//.test(currentPath)) return currentPath;
+ if (currentPath.startsWith("/")) return currentPath;
+ const basePath = parentPath && parentPath !== "/" ? parentPath.replace(/\/$/, "") : "";
+ return `${basePath}/${currentPath}`.replace(/\/+/g, "/");
+};
+
+const collectAccessibleRoutes = (routes = [], parentPath = "") => {
+ const items = [];
+ (routes || []).forEach((route) => {
+ if (!route) return;
+ const fullPath = resolveRoutePath(route, parentPath);
+ const title = route.meta?.title ?? route.title ?? "";
+ if (title && fullPath && !String(route.redirect || "").includes("noRedirect")) {
+ items.push({
+ title: normalizeMenuTitle(title),
+ path: normalizeRoutePath(fullPath),
+ });
+ }
+ if (Array.isArray(route.children) && route.children.length > 0) {
+ items.push(...collectAccessibleRoutes(route.children, fullPath));
+ }
+ });
+ return items;
+};
+
+const accessibleMenuRoutes = computed(() => {
+ const routePool =
+ permissionStore.defaultRoutes?.length > 0
+ ? permissionStore.defaultRoutes
+ : permissionStore.sidebarRouters?.length > 0
+ ? permissionStore.sidebarRouters
+ : permissionStore.routes;
+ return collectAccessibleRoutes(routePool || []);
+});
+
+const moduleAccessConfig = {
+ sales: {
+ titles: ["閿�鍞鐞�", "閿�鍞彴璐�"],
+ pathPrefixes: ["/salesmanagement"],
+ },
+ procurement: {
+ titles: ["閲囪喘绠$悊", "閲囪喘鍙拌处"],
+ pathPrefixes: ["/procurementmanagement"],
+ },
+ inventory: {
+ titles: ["搴撳瓨绠$悊"],
+ pathPrefixes: ["/inventorymanagement"],
+ },
+ production: {
+ titles: ["鐢熶骇绠$悊", "涓荤敓浜ц鍒�", "鐢熶骇璁㈠崟", "鐢熶骇鎶ュ伐"],
+ pathPrefixes: ["/productionmanagement", "/productionplan"],
+ },
+ quality: {
+ titles: ["璐ㄩ噺绠$悊"],
+ pathPrefixes: ["/qualitymanagement"],
+ },
+ equipment: {
+ titles: ["璁惧绠$悊", "璁惧鍙拌处"],
+ pathPrefixes: ["/equipmentmanagement"],
+ },
+ personnel: {
+ titles: ["浜轰簨绠$悊", "鍛樺伐鍙拌处", "鍦ㄨ亴鍛樺伐鍙拌处"],
+ pathPrefixes: ["/personnelmanagement"],
+ },
+ approval: {
+ titles: ["鍗忓悓瀹℃壒", "寰呭姙浜嬮」"],
+ pathPrefixes: ["/collaborativeapproval"],
+ },
+ finance: {
+ titles: ["璐㈠姟绠$悊", "璐㈠姟鍒嗘瀽", "鍥炴绠$悊", "寮�绁ㄧ鐞�"],
+ pathPrefixes: ["/financesuite", "/financialmanagement"],
+ },
+};
+
+const hasModuleAccess = (config) =>
+ accessibleMenuRoutes.value.some((route) => {
+ const matchedTitle = (config.titles || []).some((title) => route.title === normalizeMenuTitle(title));
+ const matchedPath = (config.pathPrefixes || []).some(
+ (prefix) => route.path === prefix || route.path.startsWith(`${prefix}/`)
+ );
+ return matchedTitle || matchedPath;
+ });
+
+const visibleModules = computed(() => ({
+ sales: hasModuleAccess(moduleAccessConfig.sales),
+ procurement: hasModuleAccess(moduleAccessConfig.procurement),
+ inventory: hasModuleAccess(moduleAccessConfig.inventory),
+ production: hasModuleAccess(moduleAccessConfig.production),
+ quality: hasModuleAccess(moduleAccessConfig.quality),
+ equipment: hasModuleAccess(moduleAccessConfig.equipment),
+ personnel: hasModuleAccess(moduleAccessConfig.personnel),
+ approval: hasModuleAccess(moduleAccessConfig.approval),
+ finance: hasModuleAccess(moduleAccessConfig.finance),
+}));
+
+const visiblePanels = computed(() => ({
+ process: visibleModules.value.production,
+ order: visibleModules.value.production,
+ contract: visibleModules.value.sales,
+ quality: visibleModules.value.quality,
+ todo: visibleModules.value.approval,
+ realtime: visibleModules.value.production,
+ quick: quickEntries.value.length > 0,
+ plan: visibleModules.value.production,
+ receipt: visibleModules.value.sales || visibleModules.value.finance,
+}));
+
+const hasLeftPanels = computed(
+ () => visiblePanels.value.process || visiblePanels.value.order || visiblePanels.value.contract || visiblePanels.value.quality
+);
+const hasRightPanels = computed(
+ () => visiblePanels.value.todo || visiblePanels.value.realtime || visiblePanels.value.quick || visiblePanels.value.plan || visiblePanels.value.receipt
+);
+const hasVisiblePanels = computed(() => hasLeftPanels.value || hasRightPanels.value);
+
+const quickEntries = computed(() =>
+ quickEntryConfigs
+ .map((item) => {
+ const targetRoute = accessibleMenuRoutes.value.find((route) =>
+ item.titles.some((title) => route.title === normalizeMenuTitle(title))
+ );
+ const resolvedPath = targetRoute?.path || "";
+ return resolvedPath
+ ? {
+ label: item.label,
+ icon: item.icon,
+ path: resolvedPath,
+ }
+ : null;
+ })
+ .filter(Boolean)
+);
const updateNowTime = () => {
nowTime.value = dayjs().format("YYYY-MM-DD HH:mm:ss");
@@ -1074,20 +1234,33 @@
};
const goToQuick = (path) => {
+ if (!path) return;
router.push(path).catch(() => {});
};
onMounted(() => {
updateNowTime();
clockTimer = setInterval(updateNowTime, 1000);
- getBusinessData();
- analysisCustomer();
- todoInfoS();
- statisticsReceivable();
- qualityStatisticsInfo();
- getAmountHalfYearNum();
- getProcessList();
- refreshProcessStats();
+ if (dashboardCards.value.length > 0) {
+ getBusinessData();
+ }
+ if (visiblePanels.value.contract) {
+ analysisCustomer();
+ }
+ if (visiblePanels.value.todo) {
+ todoInfoS();
+ }
+ if (visiblePanels.value.quality) {
+ qualityStatisticsInfo();
+ }
+ if (visiblePanels.value.receipt) {
+ statisticsReceivable();
+ getAmountHalfYearNum();
+ }
+ if (visiblePanels.value.process) {
+ getProcessList();
+ refreshProcessStats();
+ }
});
onUnmounted(() => {
@@ -1107,6 +1280,7 @@
flex-direction: column;
gap: 16px;
overflow-x: clip;
+ margin-top: 10px;
}
.digital-number {
@@ -1131,8 +1305,8 @@
min-height: 92px;
padding: 18px 22px;
background:
- radial-gradient(circle at 8% 20%, rgba(59, 130, 246, 0.12), transparent 32%),
- linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(239, 246, 255, 0.88));
+ radial-gradient(circle at 8% 20%, rgba(59, 130, 246, 0.12), transparent 32%),
+ linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(239, 246, 255, 0.88));
}
.welcome-user {
@@ -1348,7 +1522,7 @@
z-index: 1;
pointer-events: none;
background:
- url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 340 40' preserveAspectRatio='none'%3E%3Cpath d='M0 31C20 16 44 36 66 24C87 12 107 31 129 18C148 8 169 28 193 16C214 5 237 25 259 14C280 3 306 19 340 8' fill='none' stroke='%236ea4ee' stroke-width='1.5'/%3E%3C/svg%3E")
+ url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 340 40' preserveAspectRatio='none'%3E%3Cpath d='M0 31C20 16 44 36 66 24C87 12 107 31 129 18C148 8 169 28 193 16C214 5 237 25 259 14C280 3 306 19 340 8' fill='none' stroke='%236ea4ee' stroke-width='1.5'/%3E%3C/svg%3E")
center / 100% 100% no-repeat;
}
@@ -1435,6 +1609,15 @@
color: var(--text-tertiary);
}
+.empty-home-panel {
+ min-height: 220px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ color: #64748b;
+ font-size: 14px;
+}
+
.main-grid {
display: grid;
grid-template-columns: minmax(0, 1fr) 400px;
@@ -1475,21 +1658,21 @@
border: 1px solid rgba(148, 163, 184, 0.24);
border-radius: 14px;
background:
- linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(244, 249, 255, 0.9)),
- repeating-linear-gradient(
- to right,
- rgba(148, 163, 184, 0.07) 0,
- rgba(148, 163, 184, 0.07) 1px,
- transparent 1px,
- transparent 48px
- ),
- repeating-linear-gradient(
- to bottom,
- rgba(148, 163, 184, 0.06) 0,
- rgba(148, 163, 184, 0.06) 1px,
- transparent 1px,
- transparent 34px
- );
+ linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(244, 249, 255, 0.9)),
+ repeating-linear-gradient(
+ to right,
+ rgba(148, 163, 184, 0.07) 0,
+ rgba(148, 163, 184, 0.07) 1px,
+ transparent 1px,
+ transparent 48px
+ ),
+ repeating-linear-gradient(
+ to bottom,
+ rgba(148, 163, 184, 0.06) 0,
+ rgba(148, 163, 184, 0.06) 1px,
+ transparent 1px,
+ transparent 34px
+ );
overflow: hidden;
padding: 10px;
}
--
Gitblit v1.9.3