fix(dashboard): 车间产量对比改为平均单机产量,消除机床数量差异

柱状图显示每台机床平均产量(件/台),tooltip显示总产量+机床数

Ultraworked with Sisyphus

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
main
haoliang 1 week ago
parent 8b52b3d872
commit dd583c73bb

@ -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 },
],
},
},

@ -204,10 +204,12 @@ export interface DashboardTrendItem {
quantity: number
}
/** 车间产量对比 */
/** 车间平均单机产量 */
export interface WorkshopProduction {
workshopName: string
quantity: number
machineCount: number
avgQuantity: number
}
/** 机床状态分布 */

@ -94,7 +94,7 @@
</el-col>
<el-col :span="12">
<el-card shadow="hover">
<template #header><span class="card-title">车间产量对比今日</span></template>
<template #header><span class="card-title">车间平均单机产量今日</span></template>
<div ref="workshopChartRef" style="height: 260px"></div>
</el-card>
</el-col>
@ -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}<br/>平均产量: ${params[0].value} 件/台<br/>总产量: ${d.quantity} 件<br/>机床数: ${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 },
}],
})
}

Loading…
Cancel
Save