diff --git a/frontend/index.html b/frontend/index.html index 337c08c..9598888 100755 --- a/frontend/index.html +++ b/frontend/index.html @@ -4,7 +4,7 @@ 韬智生产管理系统 - + @@ -36,7 +36,7 @@
韬智生产管理
diff --git a/frontend/js/components/dashboard.js b/frontend/js/components/dashboard.js index 81102ad..57cd499 100755 --- a/frontend/js/components/dashboard.js +++ b/frontend/js/components/dashboard.js @@ -1225,7 +1225,7 @@ const Dashboard = (() => { }; }; - const drawShipmentDonutChart = (stats) => { + const drawShipmentDonutChart = async (stats) => { const canvas = document.getElementById('shipment-donut-chart'); if(!canvas) return; const ctx = canvas.getContext('2d'); @@ -1243,6 +1243,20 @@ const Dashboard = (() => { const items = Object.entries(byPlatform).filter(([, v]) => (v || 0) > 0); items.sort((a, b) => (b[1] || 0) - (a[1] || 0)); + // 获取机种列表以映射自定义机种名称 + let platformList = []; + try { + const platformRes = await fetch('/api/shipments/platforms', { + headers: { 'Content-Type': 'application/json' }, + credentials: 'include' + }).then(r => r.ok ? r.json() : null); + if(platformRes && platformRes.list) { + platformList = platformRes.list; + } + } catch(e) { + // 忽略错误,使用默认映射 + } + const platformName = (k) => { const map = { pdd: '拼多多', @@ -1253,7 +1267,13 @@ const Dashboard = (() => { std: '标准版', unknown: '未知' }; - return map[k] || k; + // 先从固定映射查找 + if(map[k]) return map[k]; + // 再从机种列表查找自定义机种名称 + const customPlatform = platformList.find(p => p.value === k); + if(customPlatform) return customPlatform.label; + // 最后返回原始值 + return k; }; const platformColor = (k, fallbackIndex) => { @@ -1358,7 +1378,7 @@ const Dashboard = (() => { window.__shipmentStatsTs = window.__shipmentStatsTs || 0; const now = Date.now(); if(!force && (now - window.__shipmentStatsTs) < 60000 && window.__shipmentStatsCache) { - drawShipmentDonutChart(window.__shipmentStatsCache); + await drawShipmentDonutChart(window.__shipmentStatsCache); return; } try { @@ -1369,7 +1389,7 @@ const Dashboard = (() => { if(res && res.ok) { window.__shipmentStatsCache = res; window.__shipmentStatsTs = now; - drawShipmentDonutChart(res); + await drawShipmentDonutChart(res); } } catch(e) { } diff --git a/frontend/login.html b/frontend/login.html index fa625e7..68530e9 100755 --- a/frontend/login.html +++ b/frontend/login.html @@ -4,7 +4,7 @@ 登录 - 韬智生产管理系统 - + diff --git a/server/data.db b/server/data.db index 2ad9ee7..e194d65 100644 Binary files a/server/data.db and b/server/data.db differ