From 3d072935109e65d314a9190d183b60974b1149c0 Mon Sep 17 00:00:00 2001 From: haoliang <821644@qq.com> Date: Tue, 28 Apr 2026 15:07:05 +0800 Subject: [PATCH] =?UTF-8?q?feat(dashboard):=20=E8=BD=A6=E9=97=B4=E5=B9=B3?= =?UTF-8?q?=E5=9D=87=E5=8D=95=E6=9C=BA=E4=BA=A7=E9=87=8Ftooltip=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E6=97=A5=E7=BB=88=E6=B1=87=E6=80=BB=E8=A7=84=E5=88=99?= =?UTF-8?q?=EF=BC=8C=E5=A4=9A=E5=A4=A9=E8=8C=83=E5=9B=B4=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E6=97=A5=E5=9D=87=E5=8D=95=E6=9C=BA=E4=BA=A7=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/mock/dashboard.ts | 22 +++++++++----- .../src/views/dashboard/DashboardPage.vue | 29 +++++++++++++++---- 2 files changed, 39 insertions(+), 12 deletions(-) diff --git a/frontend/mock/dashboard.ts b/frontend/mock/dashboard.ts index b0c9532..3fec756 100644 --- a/frontend/mock/dashboard.ts +++ b/frontend/mock/dashboard.ts @@ -4,6 +4,11 @@ import type { MockMethod, MockRequest } from './types' function getToday(): string { return new Date().toISOString().slice(0, 10) } function daysAgo(n: number): string { const d = new Date(); d.setDate(d.getDate() - n); return d.toISOString().slice(0, 10) } +// 计算日期范围天数 +function getDays(startDate: string, endDate: string): number { + return Math.max(1, Math.round((new Date(endDate).getTime() - new Date(startDate).getTime()) / 86400000) + 1) +} + // 不同日期范围的数据倍率(模拟不同日期的数据差异) function getMultiplier(startDate: string, endDate: string): number { const today = getToday() @@ -78,10 +83,11 @@ const mock: MockMethod[] = [ method: 'get', response: (req: MockRequest) => { const m = getMultiplier(req.query.startDate, req.query.endDate) + const days = getDays(req.query.startDate, req.query.endDate) return { code: 0, data: { - items: baseMachineRank.map(r => ({ ...r, quantity: Math.round(r.quantity * m) })), + items: baseMachineRank.map(r => ({ ...r, quantity: Math.round(r.quantity * m * days) })), }, } }, @@ -91,10 +97,11 @@ const mock: MockMethod[] = [ method: 'get', response: (req: MockRequest) => { const m = getMultiplier(req.query.startDate, req.query.endDate) + const days = getDays(req.query.startDate, req.query.endDate) return { code: 0, data: { - items: baseWorkerRank.map(r => ({ ...r, totalQuantity: Math.round(r.totalQuantity * m) })), + items: baseWorkerRank.map(r => ({ ...r, totalQuantity: Math.round(r.totalQuantity * m * days) })), }, } }, @@ -124,14 +131,15 @@ const mock: MockMethod[] = [ method: 'get', response: (req: MockRequest) => { const m = getMultiplier(req.query.startDate, req.query.endDate) + const days = getDays(req.query.startDate, req.query.endDate) return { code: 0, data: { - items: baseWorkshopProduction.map(w => ({ - ...w, - quantity: Math.round(w.quantity * m), - avgQuantity: Math.round(w.avgQuantity * m * 10) / 10, - })), + items: baseWorkshopProduction.map(w => { + const totalQty = Math.round(w.quantity * m * days) // 多天总量 = 单天 × 天数 + const avgQty = Math.round(totalQty / days / w.machineCount * 10) / 10 // 日均单机产量 + return { ...w, quantity: totalQty, avgQuantity: avgQty } + }), }, } }, diff --git a/frontend/src/views/dashboard/DashboardPage.vue b/frontend/src/views/dashboard/DashboardPage.vue index 0fea062..6d14633 100644 --- a/frontend/src/views/dashboard/DashboardPage.vue +++ b/frontend/src/views/dashboard/DashboardPage.vue @@ -136,7 +136,16 @@