From 1378fc4cd7abc24ed3a982e09437c2c8a74e9f2f Mon Sep 17 00:00:00 2001
From: 647556386 <647556386@qq.com>
Date: 星期二, 27 一月 2026 19:06:32 +0800
Subject: [PATCH] 代码优化
---
项目代码/WIDESEA_WMSClient/src/views/charts/wms-dashboard.vue | 163 +++++++++++++++++++++++++++++-------------------------
1 files changed, 88 insertions(+), 75 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/views/charts/wms-dashboard.vue" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/views/charts/wms-dashboard.vue"
index 5f50fb5..3561bfe 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/views/charts/wms-dashboard.vue"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/views/charts/wms-dashboard.vue"
@@ -258,7 +258,6 @@
// 鑾峰彇鍚庣澶у睆鏁版嵁
const fetchBigGreenData = async () => {
try {
- debugger
const res = await http.get('/api/BigScreen/GetBigGreenData');
console.log('澶у睆鏁版嵁', res);
@@ -271,10 +270,13 @@
? [...bigscreendata.value.taskList.slice(0,5)]
: [...bigscreendata.value.taskList];
startTaskCarousel(); // 鍚姩浠诲姟杞挱
- refreshCharts();
+ // refreshCharts(); // 绉婚櫎杩欓噷鐨勮皟鐢紝鏀逛负鍦ㄦ暟鎹幏鍙栧悗缁熶竴鍒濆鍖�
});
+ // 杩斿洖Promise锛屼互渚垮湪鏁版嵁鑾峰彇鎴愬姛鍚庡垵濮嬪寲鍥捐〃
+ return Promise.resolve();
} catch (error) {
ElMessage.error('鏁版嵁鑾峰彇澶辫触锛岃妫�鏌ュ悗绔帴鍙f槸鍚︽甯�');
+ return Promise.reject(error);
}
};
@@ -362,68 +364,45 @@
};
// 鍒濆鍖栬繎7鏃ュ嚭鍏ュ簱瓒嬪娍鍥撅紙鍏宠仈鍚庣鏁版嵁锛�
-const initStockTrend = () => {
- debugger
- if (!stockTrendRef.value) return;
-
- if (stockTrendChart) {
- stockTrendChart.dispose();
- }
-
- stockTrendChart = echarts.init(stockTrendRef.value);
- // 浼樺厛浣跨敤鍚庣鏁版嵁
- const trendData = bigscreendata.value.dailyInOutBoundList;
- console.log('鍑哄叆搴撹秼鍔挎暟鎹�', trendData);
-
- const option = {
- tooltip: {
- trigger: 'axis',
- axisPointer: {
- type: 'cross'
- }
- },
- legend: {
- data: ['鍏ュ簱閲�', '鍑哄簱閲�'],
- top: 10
- },
- grid: {
- left: '3%',
- right: '4%',
- bottom: '3%',
- top: '15%',
- containLabel: true
- },
- xAxis: {
- type: 'category',
- boundaryGap: true,
- data: trendData.map(item => item.date)
- },
- yAxis: {
- type: 'value',
- name: '鏁伴噺锛堝崈浠讹級',
- max: 25
- },
- series: [
- {
- name: '鍏ュ簱閲�',
- type: 'bar',
- barWidth: '30%',
- data: trendData.map(item => item.inNum),
- itemStyle: { color: '#52c41a' }
- },
- {
- name: '鍑哄簱閲�',
- type: 'bar',
- barWidth: '30%',
- data: trendData.map(item => item.outNum),
- itemStyle: { color: '#1890ff' }
- }
- ]
- };
-
- stockTrendChart.setOption(option);
- return stockTrendChart;
-};
+// const initStockTrend = () => {
+// const chart = echarts.init(efficiencyChartRef.value)
+// const option = {
+// tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' } },
+// grid: {
+// left: '3%', right: '4%', bottom: '3%', top: '10%',
+// containLabel: true
+// },
+// xAxis: {
+// type: 'category',
+// data: ['鍏ュ簱浣滀笟', '鍑哄簱浣滀笟', '鐩樼偣浣滀笟', '璋冩嫧浣滀笟', '琛ヨ揣浣滀笟'],
+// axisLine: { lineStyle: { color: '#fff' } },
+// axisLabel: { color: '#fff' }
+// },
+// yAxis: {
+// type: 'value',
+// name: '鏁堢巼(鍗曚綅/灏忔椂)',
+// axisLine: { lineStyle: { color: '#fff' } },
+// splitLine: { lineStyle: { color: 'rgba(255,255,255,0.1)' } },
+// axisLabel: { color: '#fff' }
+// },
+// series: [
+// {
+// data: [180, 156, 95, 78, 120],
+// type: 'bar',
+// barWidth: '40%',
+// itemStyle: {
+// color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
+// { offset: 0, color: '#83bff6' },
+// { offset: 1, color: '#188df0' }
+// ]),
+// borderRadius: [5, 5, 0, 0]
+// }
+// }
+// ]
+// }
+// chart.setOption(option)
+// return chart
+// };
// 鍒濆鍖栧簱浣嶅埄鐢ㄧ巼鐜舰鍥撅紙淇锛氱粺涓�瀹炰緥绠$悊锛屽叧鑱斿悗绔暟鎹級
const initLocationRate = () => {
@@ -589,11 +568,13 @@
return exceptionTrendChart;
};
-// 鍒锋柊鎵�鏈夊浘琛紙绉婚櫎鏃犳晥闆疯揪鍥鹃�昏緫锛�
+// 鍒锋柊鎵�鏈夊浘琛�
const refreshCharts = () => {
const charts = [
+ initInventoryPie,
initStockTrend,
initLocationRate,
+ initExceptionTrend,
];
charts.forEach(initFunc => {
@@ -622,15 +603,44 @@
// 缁勪欢鎸傝浇鏃讹細鍏堣姹傛暟鎹紝鍐嶅垵濮嬪寲鍥捐〃
onMounted(() => {
+ console.log('缁勪欢宸叉寕杞斤紝寮�濮嬪垵濮嬪寲');
+
// 鍏堣幏鍙栧悗绔暟鎹�
- fetchBigGreenData();
- // 鍒濆鍖栧浘琛紙纭繚DOM宸叉覆鏌擄級
- nextTick(() => {
- initInventoryPie();
- initStockTrend();
- initLocationRate();
- initExceptionTrend();
- window.addEventListener('resize', handleResize);
+ fetchBigGreenData().then(() => {
+ console.log('鏁版嵁鑾峰彇鎴愬姛锛屽紑濮嬪垵濮嬪寲鍥捐〃');
+
+ // 鏁版嵁鑾峰彇鎴愬姛鍚庡啀鍒濆鍖栧浘琛�
+ nextTick(() => {
+ console.log('DOM宸叉洿鏂帮紝寮�濮嬪垵濮嬪寲鍥捐〃');
+
+ try {
+ // 绔嬪嵆鍒濆鍖栧浘琛�
+ initInventoryPie();
+ console.log('搴撳瓨鍒嗗竷楗煎浘鍒濆鍖栧畬鎴�');
+
+ // 鐗瑰埆澶勭悊鍑哄叆搴撹秼鍔垮浘
+ if (stockTrendRef.value) {
+ console.log('鍑哄叆搴撹秼鍔垮浘瀹瑰櫒瀛樺湪锛屽紑濮嬪垵濮嬪寲');
+ initStockTrend();
+ console.log('鍑哄叆搴撹秼鍔垮浘鍒濆鍖栧畬鎴�');
+ } else {
+ console.error('鍑哄叆搴撹秼鍔垮浘瀹瑰櫒涓嶅瓨鍦�');
+ }
+
+ initLocationRate();
+ console.log('搴撲綅鍒╃敤鐜囧浘鍒濆鍖栧畬鎴�');
+
+ initExceptionTrend();
+ console.log('寮傚父瓒嬪娍鍥惧垵濮嬪寲瀹屾垚');
+
+ window.addEventListener('resize', handleResize);
+ console.log('鎵�鏈夊浘琛ㄥ垵濮嬪寲瀹屾垚');
+ } catch (error) {
+ console.error('鍥捐〃鍒濆鍖栬繃绋嬩腑鍑洪敊:', error);
+ }
+ });
+ }).catch(error => {
+ console.error('鑾峰彇鏁版嵁澶辫触:', error);
});
});
@@ -767,6 +777,7 @@
transition: all 0.3s ease;
overflow: hidden;
position: relative;
+ min-height: 400px;
}
.chart-card:hover {
@@ -781,9 +792,11 @@
flex: 1;
position: relative;
border-radius: 8px;
- background: rgba(255, 255, 255, 0.7);
- backdrop-filter: blur(5px);
+ background: rgba(255, 255, 255, 0.9);
box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.03);
+ overflow: hidden;
+ z-index: 1;
+ display: block;
}
--
Gitblit v1.9.3