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 @@
@@ -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)
})