From c56ecca13dd617305147b2064c409c72c202bd57 Mon Sep 17 00:00:00 2001 From: hwj Date: Thu, 29 Jan 2026 14:14:51 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E6=99=BA=E8=83=BD=E5=88=B6?= =?UTF-8?q?=E9=80=A0=E4=BA=A7=E7=BA=BF=E5=A4=A7=E5=B1=8F-=E6=97=A5?= =?UTF-8?q?=E4=BA=A7/=E6=9C=88=E4=BA=A7=E6=A8=A1=E5=9D=97=E5=AF=B9?= =?UTF-8?q?=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/mes/plan/index.ts | 3 ++ .../dashboard8/components/DayCapacity.vue | 54 +++++++++++++++---- .../dashboard8/components/MonthCapacity.vue | 54 +++++++++++++++---- 3 files changed, 91 insertions(+), 20 deletions(-) diff --git a/src/api/mes/plan/index.ts b/src/api/mes/plan/index.ts index 29fc2af4..cceb4431 100644 --- a/src/api/mes/plan/index.ts +++ b/src/api/mes/plan/index.ts @@ -103,5 +103,8 @@ export const PlanApi = { // 周生产趋势 getWeekTrend: async () => { return await request.get({ url: `/mes/plan/getWeekTrend` }) + }, + getPlanCapacity: async (type: number) => { + return await request.get({ url: `/mes/plan/getPlanCapacity?type=` + type }) } } diff --git a/src/views/report/dashboardPage/dashboard8/components/DayCapacity.vue b/src/views/report/dashboardPage/dashboard8/components/DayCapacity.vue index 5b9ce2d0..8d1cc1e8 100644 --- a/src/views/report/dashboardPage/dashboard8/components/DayCapacity.vue +++ b/src/views/report/dashboardPage/dashboard8/components/DayCapacity.vue @@ -22,17 +22,17 @@
-
排产数量
+
已排产数量
-
待生产数量
-
+
已生产数量
+
-
产能达成率
+
产能合格率
@@ -47,8 +47,21 @@ import { ref, onMounted, onUnmounted } from 'vue' import * as echarts from 'echarts' import { colors, animateCount, style } from '../utils' +import { PlanApi } from '@/api/mes/plan' -const day = { orders: 36, plan: 18000, pending: 3200, rate: 82.2 } +type CapacityData = { + orders: number + scheduled: number + produced: number + rate: number +} + +const day: CapacityData = { + orders: 0, + scheduled: 0, + produced: 0, + rate: 0 +} const chartRef = ref(null) const dayOrderEl = ref(null) @@ -58,6 +71,26 @@ const dayRateEl = ref(null) let chart: echarts.ECharts | null = null +const mapCapacity = (raw: any): CapacityData => { + const orderCount = Number(raw?.orders ?? raw?.order ?? 0) + const scheduled = Number(raw?.plan ?? 0) + const produced = Number(raw?.pending ?? 0) + const rate = Number(raw?.rate ?? raw?.passRate ?? raw?.qualifiedRate ?? 0) + return { orders: orderCount, scheduled, produced, rate } +} + +const loadDayCapacity = async () => { + try { + const raw = await PlanApi.getPlanCapacity(1) + const mapped = mapCapacity(raw || {}) + day.orders = mapped.orders + day.scheduled = mapped.scheduled + day.produced = mapped.produced + day.rate = mapped.rate + } catch { + } +} + const initChart = () => { if (!chartRef.value) return chart = echarts.init(chartRef.value, 'dark', { renderer: 'canvas' }) @@ -73,8 +106,8 @@ const initChart = () => { label: { show: false }, emphasis: { scale: false }, data: [ - { value: day.plan - day.pending, name: '已排产', itemStyle: { color: colors.cyan } }, - { value: day.pending, name: '已生产', itemStyle: { color: colors.green } } + { value: day.scheduled, name: '已排产', itemStyle: { color: colors.cyan } }, + { value: day.produced, name: '已生产', itemStyle: { color: colors.green } } ] } ] @@ -85,11 +118,12 @@ const resizeHandler = () => { chart?.resize() } -onMounted(() => { +onMounted(async () => { + await loadDayCapacity() initChart() animateCount(dayOrderEl.value, day.orders, '', 900) - animateCount(dayPlanEl.value, day.plan, '', 900) - animateCount(dayPendingEl.value, day.pending, '', 900) + animateCount(dayPlanEl.value, day.scheduled, '', 900) + animateCount(dayPendingEl.value, day.produced, '', 900) animateCount(dayRateEl.value, day.rate, '%', 900) window.addEventListener('resize', resizeHandler) }) diff --git a/src/views/report/dashboardPage/dashboard8/components/MonthCapacity.vue b/src/views/report/dashboardPage/dashboard8/components/MonthCapacity.vue index 82c10cb8..d258a89f 100644 --- a/src/views/report/dashboardPage/dashboard8/components/MonthCapacity.vue +++ b/src/views/report/dashboardPage/dashboard8/components/MonthCapacity.vue @@ -22,17 +22,17 @@
同比 +8.6%
-
排产数量
+
已排产数量
较计划 +3.2%
-
待生产数量
-
+
已生产数量
+
剩余 5 天完成
-
产能达成率
+
产能合格率
目标 ≥ 85%接近预期
@@ -47,8 +47,21 @@ import { ref, onMounted, onUnmounted } from 'vue' import * as echarts from 'echarts' import { colors, animateCount, style } from '../utils' +import { PlanApi } from '@/api/mes/plan' -const month = { orders: 158, plan: 420000, pending: 75600, rate: 82.0 } +type CapacityData = { + orders: number + scheduled: number + produced: number + rate: number +} + +const month: CapacityData = { + orders: 0, + scheduled: 0, + produced: 0, + rate: 0 +} const chartRef = ref(null) const monthOrderEl = ref(null) @@ -58,6 +71,26 @@ const monthRateEl = ref(null) let chart: echarts.ECharts | null = null +const mapCapacity = (raw: any): CapacityData => { + const orderCount = Number(raw?.orders ?? raw?.order ?? 0) + const scheduled = Number(raw?.plan ?? 0) + const produced = Number(raw?.pending ?? 0) + const rate = Number(raw?.rate ?? raw?.passRate ?? raw?.qualifiedRate ?? 0) + return { orders: orderCount, scheduled, produced, rate } +} + +const loadMonthCapacity = async () => { + try { + const raw = await PlanApi.getPlanCapacity(2) + const mapped = mapCapacity(raw || {}) + month.orders = mapped.orders + month.scheduled = mapped.scheduled + month.produced = mapped.produced + month.rate = mapped.rate + } catch { + } +} + const initChart = () => { if (!chartRef.value) return chart = echarts.init(chartRef.value, 'dark', { renderer: 'canvas' }) @@ -73,8 +106,8 @@ const initChart = () => { label: { show: false }, emphasis: { scale: false }, data: [ - { value: month.plan - month.pending, name: '已完成', itemStyle: { color: colors.green } }, - { value: month.pending, name: '待生产', itemStyle: { color: 'rgba(15,23,42,0.8)' } } + { value: month.scheduled, name: '已排产', itemStyle: { color: colors.cyan } }, + { value: month.produced, name: '已生产', itemStyle: { color: colors.green } } ] } ] @@ -85,11 +118,12 @@ const resizeHandler = () => { chart?.resize() } -onMounted(() => { +onMounted(async () => { + await loadMonthCapacity() initChart() animateCount(monthOrderEl.value, month.orders, '', 900) - animateCount(monthPlanEl.value, month.plan, '', 900) - animateCount(monthPendingEl.value, month.pending, '', 900) + animateCount(monthPlanEl.value, month.scheduled, '', 900) + animateCount(monthPendingEl.value, month.produced, '', 900) animateCount(monthRateEl.value, month.rate, '%', 900) window.addEventListener('resize', resizeHandler) })