From 7d75ab8d8ea26276e50d6eee6c06abf3b633dd1e Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 30 May 2026 13:23:19 +0800 Subject: [PATCH] =?UTF-8?q?feat(mes):=20=E8=BF=81=E7=A7=BB=20home=20?= =?UTF-8?q?=E9=A6=96=E9=A1=B5=EF=BC=88=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/mes/home/chart-options.ts | 60 +++++++++++++++++++ .../src/views/mes/home/chart-options.ts | 60 +++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 apps/web-antd/src/views/mes/home/chart-options.ts create mode 100644 apps/web-ele/src/views/mes/home/chart-options.ts diff --git a/apps/web-antd/src/views/mes/home/chart-options.ts b/apps/web-antd/src/views/mes/home/chart-options.ts new file mode 100644 index 000000000..f2390563a --- /dev/null +++ b/apps/web-antd/src/views/mes/home/chart-options.ts @@ -0,0 +1,60 @@ +/** 生产趋势折线图配置 */ +export function getProductionTrendChartOptions( + dates: string[], + quantities: number[], + qualified: number[], + unqualified: number[], +): any { + return { + grid: { bottom: 40, left: 50, right: 20, top: 20 }, + legend: { bottom: 0, data: ['产量', '合格品', '不良品'] }, + series: [ + { + areaStyle: { color: 'rgba(64,158,255,0.15)' }, + data: quantities, + itemStyle: { color: '#409EFF' }, + name: '产量', + smooth: true, + type: 'line', + }, + { + data: qualified, + itemStyle: { color: '#67C23A' }, + name: '合格品', + smooth: true, + type: 'line', + }, + { + data: unqualified, + itemStyle: { color: '#F56C6C' }, + name: '不良品', + smooth: true, + type: 'line', + }, + ], + tooltip: { axisPointer: { type: 'cross' }, trigger: 'axis' }, + xAxis: { boundaryGap: false, data: dates, type: 'category' }, + yAxis: { minInterval: 1, type: 'value' }, + }; +} + +/** 工单状态分布饼图配置 */ +export function getWorkOrderStatusChartOptions( + data: Array<{ itemStyle: { color: string }; name: string; value: number }>, +): any { + return { + legend: { bottom: 0, type: 'scroll' }, + series: [ + { + avoidLabelOverlap: true, + data, + emphasis: { label: { fontSize: 14, fontWeight: 'bold', show: true } }, + itemStyle: { borderColor: '#fff', borderRadius: 6, borderWidth: 2 }, + label: { formatter: '{b}\n{c}', show: true }, + radius: ['40%', '70%'], + type: 'pie', + }, + ], + tooltip: { formatter: '{b}: {c} ({d}%)', trigger: 'item' }, + }; +} diff --git a/apps/web-ele/src/views/mes/home/chart-options.ts b/apps/web-ele/src/views/mes/home/chart-options.ts new file mode 100644 index 000000000..f2390563a --- /dev/null +++ b/apps/web-ele/src/views/mes/home/chart-options.ts @@ -0,0 +1,60 @@ +/** 生产趋势折线图配置 */ +export function getProductionTrendChartOptions( + dates: string[], + quantities: number[], + qualified: number[], + unqualified: number[], +): any { + return { + grid: { bottom: 40, left: 50, right: 20, top: 20 }, + legend: { bottom: 0, data: ['产量', '合格品', '不良品'] }, + series: [ + { + areaStyle: { color: 'rgba(64,158,255,0.15)' }, + data: quantities, + itemStyle: { color: '#409EFF' }, + name: '产量', + smooth: true, + type: 'line', + }, + { + data: qualified, + itemStyle: { color: '#67C23A' }, + name: '合格品', + smooth: true, + type: 'line', + }, + { + data: unqualified, + itemStyle: { color: '#F56C6C' }, + name: '不良品', + smooth: true, + type: 'line', + }, + ], + tooltip: { axisPointer: { type: 'cross' }, trigger: 'axis' }, + xAxis: { boundaryGap: false, data: dates, type: 'category' }, + yAxis: { minInterval: 1, type: 'value' }, + }; +} + +/** 工单状态分布饼图配置 */ +export function getWorkOrderStatusChartOptions( + data: Array<{ itemStyle: { color: string }; name: string; value: number }>, +): any { + return { + legend: { bottom: 0, type: 'scroll' }, + series: [ + { + avoidLabelOverlap: true, + data, + emphasis: { label: { fontSize: 14, fontWeight: 'bold', show: true } }, + itemStyle: { borderColor: '#fff', borderRadius: 6, borderWidth: 2 }, + label: { formatter: '{b}\n{c}', show: true }, + radius: ['40%', '70%'], + type: 'pie', + }, + ], + tooltip: { formatter: '{b}: {c} ({d}%)', trigger: 'item' }, + }; +}