From 78d422f3f76474c762b21931a2712bd5b0710e6a Mon Sep 17 00:00:00 2001 From: huangjinysf Date: Mon, 29 Dec 2025 16:43:11 +0800 Subject: [PATCH] =?UTF-8?q?refactor(components):=20=E6=8F=90=E5=8F=96=20WM?= =?UTF-8?q?S=20=E8=A1=A8=E6=A0=BC=E4=B8=BA=E7=8B=AC=E7=AB=8B=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E5=B9=B6=E4=BC=98=E5=8C=96=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将 EnamellingMachineStatus.vue 中的 WMS 表格逻辑提取为独立组件 WmsTable 优化数据加载和修改逻辑,减少重复代码 添加组件 props 和 emits 实现更好的封装和复用 --- src/components/WmsTable/index.vue | 233 +++++++++++++++++++++ src/views/plan/EnamellingMachineStatus.vue | 83 +++----- 2 files changed, 266 insertions(+), 50 deletions(-) create mode 100644 src/components/WmsTable/index.vue diff --git a/src/components/WmsTable/index.vue b/src/components/WmsTable/index.vue new file mode 100644 index 0000000..eabb829 --- /dev/null +++ b/src/components/WmsTable/index.vue @@ -0,0 +1,233 @@ + + + + + diff --git a/src/views/plan/EnamellingMachineStatus.vue b/src/views/plan/EnamellingMachineStatus.vue index e0c7cd9..969809c 100644 --- a/src/views/plan/EnamellingMachineStatus.vue +++ b/src/views/plan/EnamellingMachineStatus.vue @@ -185,54 +185,14 @@ destroy-on-close @close="closeChart" > -
- - - - - - - - - - - - - - - - - +
时间范围: @@ -260,6 +220,14 @@

销售历史 - {{ salesChartTitle }}

关闭
+
时间范围: @@ -288,6 +256,7 @@ import { ref, computed, onMounted, nextTick, watch } from 'vue' import { API_CONFIG } from "@/config/api" import { getDateRangeByTimeRange } from '@/utils/dateFormat'; import * as echarts from 'echarts'; +import WmsTable from '@/components/WmsTable/index.vue' // 接收从父组件传递的数据 const props = defineProps({ @@ -323,6 +292,8 @@ const salesChartTitle = ref('') const currentSalesAxle = ref(null) const salesChartRef = ref(null) const salesChartDialogRef = ref(null) +const wmsTableRef = ref(null) +const wmsTableDialogRef = ref(null) let salesChart = null // 销售图表相关状态 @@ -556,7 +527,7 @@ const onCompletionLevelChange = () => { }; // 方法:显示销售历史图表 -const showSalesHistory = (row) => { +const showSalesHistory = async (row) => { if (!row.update_time || !row.model || !row.specification) { console.error('缺少必要的数据参数'); return; @@ -579,7 +550,13 @@ const showSalesHistory = (row) => { fetchSalesData(row.model, row.specification); fetchHistoryData(row.model, row.specification, row.wire_disc); - fetchWmsData(row.model, row.specification); + + await nextTick() + if (selectedEquipment.value === 'all' && wmsTableDialogRef.value) { + wmsTableDialogRef.value.fetchData() + } else if (showChart.value && wmsTableRef.value) { + wmsTableRef.value.fetchData() + } }; // 方法:关闭图表 @@ -592,6 +569,12 @@ const closeChart = () => { } }; +// WmsTable组件数据加载完成回调 +const onWmsDataLoaded = (loadedData) => { + wmsData.value = loadedData + recordWmsOriginalData() +}; + // 方法:图表时间范围变化 const onChartTimeRangeChange = () => { if (currentSalesAxle.value) {