From dd583c73bbe324d7314df77014a6f58627d81dd9 Mon Sep 17 00:00:00 2001 From: haoliang <821644@qq.com> Date: Tue, 28 Apr 2026 12:06:33 +0800 Subject: [PATCH] =?UTF-8?q?fix(dashboard):=20=E8=BD=A6=E9=97=B4=E4=BA=A7?= =?UTF-8?q?=E9=87=8F=E5=AF=B9=E6=AF=94=E6=94=B9=E4=B8=BA=E5=B9=B3=E5=9D=87?= =?UTF-8?q?=E5=8D=95=E6=9C=BA=E4=BA=A7=E9=87=8F=EF=BC=8C=E6=B6=88=E9=99=A4?= =?UTF-8?q?=E6=9C=BA=E5=BA=8A=E6=95=B0=E9=87=8F=E5=B7=AE=E5=BC=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 柱状图显示每台机床平均产量(件/台),tooltip显示总产量+机床数 Ultraworked with Sisyphus Co-authored-by: Sisyphus --- frontend/mock/dashboard.ts | 8 ++++---- frontend/src/types/index.ts | 4 +++- frontend/src/views/dashboard/DashboardPage.vue | 17 ++++++++++++----- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/frontend/mock/dashboard.ts b/frontend/mock/dashboard.ts index 7525cbc..bb8e99b 100644 --- a/frontend/mock/dashboard.ts +++ b/frontend/mock/dashboard.ts @@ -88,7 +88,7 @@ const mock: MockMethod[] = [ }, }, }, - // ===== 新增:车间产量对比 ===== + // ===== 新增:车间平均单机产量 ===== { url: '/mock-api/admin/dashboard/workshop-production', method: 'get', @@ -96,9 +96,9 @@ const mock: MockMethod[] = [ code: 0, data: { items: [ - { workshopName: 'A栋', quantity: 1280 }, - { workshopName: 'B栋', quantity: 860 }, - { workshopName: 'C栋', quantity: 707 }, + { workshopName: 'A栋', quantity: 1280, machineCount: 80, avgQuantity: 16.0 }, + { workshopName: 'B栋', quantity: 860, machineCount: 45, avgQuantity: 19.1 }, + { workshopName: 'C栋', quantity: 707, machineCount: 35, avgQuantity: 20.2 }, ], }, }, diff --git a/frontend/src/types/index.ts b/frontend/src/types/index.ts index de1ef84..a9d1a0c 100644 --- a/frontend/src/types/index.ts +++ b/frontend/src/types/index.ts @@ -204,10 +204,12 @@ export interface DashboardTrendItem { quantity: number } -/** 车间产量对比 */ +/** 车间平均单机产量 */ export interface WorkshopProduction { workshopName: string quantity: number + machineCount: number + avgQuantity: number } /** 机床状态分布 */ diff --git a/frontend/src/views/dashboard/DashboardPage.vue b/frontend/src/views/dashboard/DashboardPage.vue index 380db19..27d3468 100644 --- a/frontend/src/views/dashboard/DashboardPage.vue +++ b/frontend/src/views/dashboard/DashboardPage.vue @@ -94,7 +94,7 @@ - +
@@ -266,17 +266,24 @@ function initCharts() { }) } - // 车间产量柱状图 + // 车间平均单机产量柱状图 if (workshopChartRef.value && workshopData.value.length) { workshopChart = echarts.init(workshopChartRef.value) workshopChart.setOption({ - tooltip: { trigger: 'axis' }, + tooltip: { + trigger: 'axis', + formatter: (params: any) => { + const d = workshopData.value[params[0].dataIndex] + return `${d.workshopName}
平均产量: ${params[0].value} 件/台
总产量: ${d.quantity} 件
机床数: ${d.machineCount} 台` + }, + }, grid: { left: 50, right: 20, top: 20, bottom: 30 }, xAxis: { type: 'category', data: workshopData.value.map(i => i.workshopName), axisLabel: { fontSize: 12 } }, - yAxis: { type: 'value', axisLabel: { fontSize: 12 } }, + yAxis: { type: 'value', name: '件/台', axisLabel: { fontSize: 12 } }, series: [{ - type: 'bar', data: workshopData.value.map(i => i.quantity), + type: 'bar', data: workshopData.value.map(i => i.avgQuantity), itemStyle: { color: '#67C23A', borderRadius: [4, 4, 0, 0] }, barWidth: '40%', + label: { show: true, position: 'top', formatter: '{c} 件/台', fontSize: 12 }, }], }) }