diff --git a/index.html b/index.html
index 767aff3..356478a 100644
--- a/index.html
+++ b/index.html
@@ -10,7 +10,7 @@
<% }else { %>
-
+
diff --git a/src/views/modules/dashboard/buffer-board.vue b/src/views/modules/dashboard/buffer-board.vue
index ed1a558..a0398ef 100644
--- a/src/views/modules/dashboard/buffer-board.vue
+++ b/src/views/modules/dashboard/buffer-board.vue
@@ -162,10 +162,8 @@ export default {
},
mounted() {
- this.updateTime()
- this.timeInterval = setInterval(() => {
- this.updateTime()
- }, 1000)
+ // 时间由HTTP API响应自动更新,不再使用定时器
+ this.currentTime = '等待服务器时间同步...'
// 首次加载数据
this.getDataList()
@@ -177,9 +175,6 @@ export default {
},
beforeDestroy() {
- if (this.timeInterval) {
- clearInterval(this.timeInterval)
- }
if (this.dataInterval) {
clearInterval(this.dataInterval)
}
@@ -193,6 +188,12 @@ export default {
bufferBoard({}).then(({data}) => {
if (data && data.code === 200) {
console.log('获取缓存区数据成功:', data.data)
+
+ // 更新服务器时间
+ if (data.serverTime) {
+ this.currentTime = data.serverTime
+ }
+
// TODO: 处理返回的数据,覆盖而非追加,避免内存累积
// if (data.data) {
// this.bufferList = data.data.bufferList || []
diff --git a/src/views/modules/dashboard/exception-board.vue b/src/views/modules/dashboard/exception-board.vue
index 6cbf0a3..75c63d4 100644
--- a/src/views/modules/dashboard/exception-board.vue
+++ b/src/views/modules/dashboard/exception-board.vue
@@ -292,10 +292,8 @@ export default {
},
mounted() {
- this.updateTime()
- this.timeInterval = setInterval(() => {
- this.updateTime()
- }, 1000)
+ // 时间由HTTP API响应自动更新,不再使用定时器
+ this.currentTime = '等待服务器时间同步...'
// 首次加载数据
this.getDataList()
@@ -307,9 +305,6 @@ export default {
},
beforeDestroy() {
- if (this.timeInterval) {
- clearInterval(this.timeInterval)
- }
if (this.dataInterval) {
clearInterval(this.dataInterval)
}
@@ -323,6 +318,12 @@ export default {
exceptionBoard({}).then(({data}) => {
if (data && data.code === 200) {
console.log('获取异常处理区数据成功:', data.data)
+
+ // 更新服务器时间
+ if (data.serverTime) {
+ this.currentTime = data.serverTime
+ }
+
// TODO: 处理返回的数据,覆盖而非追加,避免内存累积
// if (data.data) {
// this.exceptionList = data.data.exceptionList || []
diff --git a/src/views/modules/dashboard/finished-product-board.vue b/src/views/modules/dashboard/finished-product-board.vue
index bd9333a..6059cb8 100644
--- a/src/views/modules/dashboard/finished-product-board.vue
+++ b/src/views/modules/dashboard/finished-product-board.vue
@@ -136,6 +136,7 @@ export default {
return {
currentTime: '',
timeInterval: null,
+ serverTimeOffset: 0, // 服务器时间偏移量(毫秒)
// WebSocket相关
useWebSocket: true, // 是否使用WebSocket(可切换为false降级到轮询)
@@ -151,8 +152,10 @@ export default {
},
mounted() {
- // 启动时钟
- this.updateTime()
+ // 初始化时间显示
+ this.currentTime = '等待服务器时间同步...'
+
+ // 启动时钟定时器(每秒更新)
this.timeInterval = setInterval(() => {
this.updateTime()
}, 1000)
@@ -164,11 +167,10 @@ export default {
},
beforeDestroy() {
- // 清理时钟
+ // 清理时间更新定时器
if (this.timeInterval) {
clearInterval(this.timeInterval)
}
-
// 断开WebSocket连接
this.disconnectWebSocket()
},
@@ -209,6 +211,11 @@ export default {
*/
handleWebSocketMessage(message) {
if (message && message.code === 0) {
+ // 更新服务器时间偏移量
+ if (message.serverTime) {
+ this.updateServerTimeOffset(message.serverTime)
+ }
+
this.packagingList = message.data.packagingList || []
this.inboundList = message.data.inboundList || []
}
@@ -275,10 +282,27 @@ export default {
},
/**
- * 更新当前时间
+ * 更新服务器时间偏移量
+ */
+ updateServerTimeOffset(serverTimeString) {
+ try {
+ const timeStr = serverTimeString.split(' ')[0] + ' ' + serverTimeString.split(' ')[1]
+ const serverTime = new Date(timeStr).getTime()
+ const localTime = new Date().getTime()
+
+ if (!isNaN(serverTime)) {
+ this.serverTimeOffset = serverTime - localTime
+ }
+ } catch (error) {
+ console.warn('解析服务器时间失败:', error)
+ }
+ },
+
+ /**
+ * 更新当前时间(使用服务器时间偏移量)
*/
updateTime() {
- const now = new Date()
+ const now = new Date(new Date().getTime() + this.serverTimeOffset)
const year = now.getFullYear()
const month = String(now.getMonth() + 1).padStart(2, '0')
const day = String(now.getDate()).padStart(2, '0')
@@ -288,7 +312,7 @@ export default {
const weekDays = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
const weekDay = weekDays[now.getDay()]
- this.currentTime = `${year}-${month}-${day} ${weekDay} ${hours}:${minutes}:${seconds}`
+ this.currentTime = `${year}-${month}-${day} ${hours}:${minutes}:${seconds} ${weekDay}`
},
/**
diff --git a/src/views/modules/dashboard/material-receiving-board.vue b/src/views/modules/dashboard/material-receiving-board.vue
index dcee28c..d26c362 100644
--- a/src/views/modules/dashboard/material-receiving-board.vue
+++ b/src/views/modules/dashboard/material-receiving-board.vue
@@ -134,6 +134,7 @@ export default {
return {
currentTime: '',
timeInterval: null,
+ serverTimeOffset: 0, // 服务器时间偏移量(毫秒)
// WebSocket相关
useWebSocket: true, // 是否使用WebSocket(可切换为false降级到轮询)
@@ -149,8 +150,10 @@ export default {
},
mounted() {
- // 启动时钟
- this.updateTime()
+ // 初始化时间显示
+ this.currentTime = '等待服务器时间同步...'
+
+ // 启动时钟定时器(每秒更新)
this.timeInterval = setInterval(() => {
this.updateTime()
}, 1000)
@@ -162,11 +165,10 @@ export default {
},
beforeDestroy() {
- // 清理时钟
+ // 清理时间更新定时器
if (this.timeInterval) {
clearInterval(this.timeInterval)
}
-
// 断开WebSocket连接
this.disconnectWebSocket()
},
@@ -207,6 +209,11 @@ export default {
*/
handleWebSocketMessage(message) {
if (message && message.code === 0) {
+ // 更新服务器时间偏移量
+ if (message.serverTime) {
+ this.updateServerTimeOffset(message.serverTime)
+ }
+
this.receivingList = message.data.receivingList || []
this.inboundList = message.data.inboundList || []
}
@@ -275,10 +282,27 @@ export default {
},
/**
- * 更新当前时间
+ * 更新服务器时间偏移量
+ */
+ updateServerTimeOffset(serverTimeString) {
+ try {
+ const timeStr = serverTimeString.split(' ')[0] + ' ' + serverTimeString.split(' ')[1]
+ const serverTime = new Date(timeStr).getTime()
+ const localTime = new Date().getTime()
+
+ if (!isNaN(serverTime)) {
+ this.serverTimeOffset = serverTime - localTime
+ }
+ } catch (error) {
+ console.warn('解析服务器时间失败:', error)
+ }
+ },
+
+ /**
+ * 更新当前时间(使用服务器时间偏移量)
*/
updateTime() {
- const now = new Date()
+ const now = new Date(new Date().getTime() + this.serverTimeOffset)
const year = now.getFullYear()
const month = String(now.getMonth() + 1).padStart(2, '0')
const day = String(now.getDate()).padStart(2, '0')
@@ -288,7 +312,7 @@ export default {
const weekDays = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
const weekDay = weekDays[now.getDay()]
- this.currentTime = `${year}-${month}-${day} ${weekDay} ${hours}:${minutes}:${seconds}`
+ this.currentTime = `${year}-${month}-${day} ${hours}:${minutes}:${seconds} ${weekDay}`
},
/**
diff --git a/src/views/modules/dashboard/picking-board.vue b/src/views/modules/dashboard/picking-board.vue
index 3f7577e..1db810d 100644
--- a/src/views/modules/dashboard/picking-board.vue
+++ b/src/views/modules/dashboard/picking-board.vue
@@ -145,10 +145,8 @@ export default {
},
mounted() {
- this.updateTime()
- this.timeInterval = setInterval(() => {
- this.updateTime()
- }, 1000)
+ // 时间由HTTP API响应自动更新,不再使用定时器
+ this.currentTime = '等待服务器时间同步...'
// 首次加载数据
this.getDataList()
@@ -160,9 +158,6 @@ export default {
},
beforeDestroy() {
- if (this.timeInterval) {
- clearInterval(this.timeInterval)
- }
if (this.dataInterval) {
clearInterval(this.dataInterval)
}
@@ -174,6 +169,12 @@ export default {
manualPicking({}).then(({data}) => {
if (data && data.code === 200) {
console.log('获取数据成功:', data.data)
+
+ // 更新服务器时间
+ if (data.serverTime) {
+ this.currentTime = data.serverTime
+ }
+
// TODO: 处理返回的数据,覆盖而非追加,避免内存累积
// if (data.data) {
// this.leftPanelList = data.data.leftPanelList || []
diff --git a/src/views/modules/dashboard/robot-picking-board.vue b/src/views/modules/dashboard/robot-picking-board.vue
index 78d24d1..2edaa0d 100644
--- a/src/views/modules/dashboard/robot-picking-board.vue
+++ b/src/views/modules/dashboard/robot-picking-board.vue
@@ -140,6 +140,7 @@ export default {
return {
currentTime: '',
timeInterval: null,
+ serverTimeOffset: 0, // 服务器时间偏移量(毫秒)
// WebSocket相关
useWebSocket: true, // 是否使用WebSocket(可切换为false降级到轮询)
@@ -155,8 +156,10 @@ export default {
},
mounted() {
- // 启动时钟
- this.updateTime()
+ // 初始化时间显示
+ this.currentTime = '等待服务器时间同步...'
+
+ // 启动时钟定时器(每秒更新)
this.timeInterval = setInterval(() => {
this.updateTime()
}, 1000)
@@ -168,11 +171,10 @@ export default {
},
beforeDestroy() {
- // 清理时钟
+ // 清理时间更新定时器
if (this.timeInterval) {
clearInterval(this.timeInterval)
}
-
// 断开WebSocket连接
this.disconnectWebSocket()
},
@@ -220,10 +222,27 @@ export default {
},
/**
- * 更新当前时间
+ * 更新服务器时间偏移量
+ */
+ updateServerTimeOffset(serverTimeString) {
+ try {
+ const timeStr = serverTimeString.split(' ')[0] + ' ' + serverTimeString.split(' ')[1]
+ const serverTime = new Date(timeStr).getTime()
+ const localTime = new Date().getTime()
+
+ if (!isNaN(serverTime)) {
+ this.serverTimeOffset = serverTime - localTime
+ }
+ } catch (error) {
+ console.warn('解析服务器时间失败:', error)
+ }
+ },
+
+ /**
+ * 更新当前时间(使用服务器时间偏移量)
*/
updateTime() {
- const now = new Date()
+ const now = new Date(new Date().getTime() + this.serverTimeOffset)
const year = now.getFullYear()
const month = String(now.getMonth() + 1).padStart(2, '0')
const day = String(now.getDate()).padStart(2, '0')
@@ -233,7 +252,7 @@ export default {
const weekDays = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
const weekDay = weekDays[now.getDay()]
- this.currentTime = `${year}-${month}-${day} ${weekDay} ${hours}:${minutes}:${seconds}`
+ this.currentTime = `${year}-${month}-${day} ${hours}:${minutes}:${seconds} ${weekDay}`
},
/**
@@ -283,6 +302,11 @@ export default {
*/
handleWebSocketMessage(message) {
if (message && message.code === 0) {
+ // 更新服务器时间偏移量
+ if (message.serverTime) {
+ this.updateServerTimeOffset(message.serverTime)
+ }
+
this.containerPickingList = message.data.containerList || []
this.materialPickingList = message.data.materialList || []
diff --git a/src/views/modules/dashboard/slitting-board.vue b/src/views/modules/dashboard/slitting-board.vue
index d38a9d8..1f2d39d 100644
--- a/src/views/modules/dashboard/slitting-board.vue
+++ b/src/views/modules/dashboard/slitting-board.vue
@@ -136,6 +136,7 @@ export default {
return {
currentTime: '',
timeInterval: null,
+ serverTimeOffset: 0, // 服务器时间偏移量(毫秒)
// WebSocket相关
useWebSocket: true, // 是否使用WebSocket(可切换为false降级到轮询)
@@ -151,8 +152,10 @@ export default {
},
mounted() {
- // 启动时钟
- this.updateTime()
+ // 初始化时间显示
+ this.currentTime = '等待服务器时间同步...'
+
+ // 启动时钟定时器(每秒更新)
this.timeInterval = setInterval(() => {
this.updateTime()
}, 1000)
@@ -164,11 +167,10 @@ export default {
},
beforeDestroy() {
- // 清理时钟
+ // 清理时间更新定时器
if (this.timeInterval) {
clearInterval(this.timeInterval)
}
-
// 断开WebSocket连接
this.disconnectWebSocket()
},
@@ -214,8 +216,28 @@ export default {
/**
* 更新当前时间
*/
+ /**
+ * 更新服务器时间偏移量
+ */
+ updateServerTimeOffset(serverTimeString) {
+ try {
+ const timeStr = serverTimeString.split(' ')[0] + ' ' + serverTimeString.split(' ')[1]
+ const serverTime = new Date(timeStr).getTime()
+ const localTime = new Date().getTime()
+
+ if (!isNaN(serverTime)) {
+ this.serverTimeOffset = serverTime - localTime
+ }
+ } catch (error) {
+ console.warn('解析服务器时间失败:', error)
+ }
+ },
+
+ /**
+ * 更新当前时间(使用服务器时间偏移量)
+ */
updateTime() {
- const now = new Date()
+ const now = new Date(new Date().getTime() + this.serverTimeOffset)
const year = now.getFullYear()
const month = String(now.getMonth() + 1).padStart(2, '0')
const day = String(now.getDate()).padStart(2, '0')
@@ -225,7 +247,7 @@ export default {
const weekDays = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
const weekDay = weekDays[now.getDay()]
- this.currentTime = `${year}-${month}-${day} ${weekDay} ${hours}:${minutes}:${seconds}`
+ this.currentTime = `${year}-${month}-${day} ${hours}:${minutes}:${seconds} ${weekDay}`
},
/**
@@ -277,6 +299,11 @@ export default {
*/
handleWebSocketMessage(message) {
if (message && message.code === 0) {
+ // 更新服务器时间偏移量
+ if (message.serverTime) {
+ this.updateServerTimeOffset(message.serverTime)
+ }
+
this.assistArmList = message.data.assistArmList || []
this.slittingInboundList = message.data.slittingInboundList || []
}
diff --git a/src/views/modules/dashboard/warehouse-3d-board.vue b/src/views/modules/dashboard/warehouse-3d-board.vue
index a2eceed..cfa6c50 100644
--- a/src/views/modules/dashboard/warehouse-3d-board.vue
+++ b/src/views/modules/dashboard/warehouse-3d-board.vue
@@ -292,6 +292,9 @@ export default {
data() {
return {
currentTime: '',
+ timeInterval: null, // 时间更新定时器
+ serverTimeOffset: 0, // 服务器时间偏移量(毫秒)
+ refreshCheckInterval: null, // 定时刷新检查定时器
// WebSocket相关
useWebSocket: true, // 是否使用WebSocket(可切换为false降级到本地数据)
@@ -373,7 +376,7 @@ export default {
const empty = this.storageData.emptyContainerInventory || {}
return (empty.flatPallet || 0) + (empty.framePallet || 0) + (empty.steelPallet || 0)
},
-
+
/**
* 计算可用库位数(总库位 - 已使用库位)
*/
@@ -383,8 +386,16 @@ export default {
},
mounted() {
- this.updateTime()
- this.timeInterval = setInterval(this.updateTime, 1000)
+ // 初始化时间显示
+ this.currentTime = '等待服务器时间同步...'
+
+ // 启动时钟定时器(每秒更新)
+ this.timeInterval = setInterval(() => {
+ this.updateTime()
+ }, 1000)
+
+ // 启动定时刷新检查(每分钟检查一次)
+ this.startRefreshCheck()
// 延迟初始化图表,确保DOM已渲染
this.$nextTick(() => {
@@ -407,9 +418,14 @@ export default {
},
beforeDestroy() {
+ // 清理时间更新定时器
if (this.timeInterval) {
clearInterval(this.timeInterval)
}
+ // 清理定时刷新检查定时器
+ if (this.refreshCheckInterval) {
+ clearInterval(this.refreshCheckInterval)
+ }
// 移除窗口resize监听
window.removeEventListener('resize', this.handleResize)
// 销毁所有图表
@@ -421,6 +437,34 @@ export default {
},
methods: {
+ /**
+ * 启动定时刷新检查
+ * 每分钟检查一次,如果到达凌晨5点则自动刷新页面
+ */
+ startRefreshCheck() {
+ console.log('[智能立体仓库看板] 已启动定时刷新检查,将在每天凌晨5:00自动刷新页面')
+
+ // 每分钟检查一次
+ this.refreshCheckInterval = setInterval(() => {
+ this.checkAndRefreshPage()
+ }, 60000) // 60秒 = 1分钟
+
+ // 立即执行一次检查
+ this.checkAndRefreshPage()
+ },
+
+ /**
+ * 检查当前时间,如果是凌晨5点则刷新页面
+ */
+ checkAndRefreshPage() {
+ const now = new Date()
+ const hours = now.getHours()
+ const minutes = now.getMinutes()
+ // 判断是否为凌晨5:00-5:10之间
+ if (hours === 5 && minutes === 10) {
+ location.reload()
+ }
+ },
/**
* 处理窗口大小变化
@@ -435,10 +479,32 @@ export default {
},
/**
- * 更新时间显示
+ * 更新服务器时间偏移量
+ *
+ * @param {string} serverTimeString - 服务器时间字符串
+ */
+ updateServerTimeOffset(serverTimeString) {
+ try {
+ // 解析服务器时间字符串 "2025-11-01 14:30:25 星期五"
+ const timeStr = serverTimeString.split(' ')[0] + ' ' + serverTimeString.split(' ')[1]
+ const serverTime = new Date(timeStr).getTime()
+ const localTime = new Date().getTime()
+
+ if (!isNaN(serverTime)) {
+ this.serverTimeOffset = serverTime - localTime
+ console.log('服务器时间偏移量更新:', this.serverTimeOffset, 'ms')
+ }
+ } catch (error) {
+ console.warn('解析服务器时间失败:', error)
+ }
+ },
+
+ /**
+ * 更新时间显示(使用服务器时间偏移量)
*/
updateTime() {
- const now = new Date()
+ // 使用本地时间 + 偏移量来计算服务器时间
+ const now = new Date(new Date().getTime() + this.serverTimeOffset)
const year = now.getFullYear()
const month = String(now.getMonth() + 1).padStart(2, '0')
const date = String(now.getDate()).padStart(2, '0')
@@ -498,6 +564,11 @@ export default {
handleWebSocketMessage(message) {
if (message && message.code === 0) {
console.log('[智能立体仓库看板] 收到WebSocket推送数据:', message.data)
+
+ // 更新服务器时间偏移量
+ if (message.serverTime) {
+ this.updateServerTimeOffset(message.serverTime)
+ }
// 更新任务统计数据
if (message.data.taskData && Object.keys(message.data.taskData).length > 0) {
@@ -519,9 +590,9 @@ export default {
...(message.data.storageData.emptyContainerInventory || {})
}
}
-
+
console.log('[智能立体仓库看板] 库位数据已更新:', this.storageData)
-
+
// 重新初始化库位利用率图表
this.$nextTick(() => {
this.initStorageChart()
@@ -644,7 +715,7 @@ export default {
const materialSteelPallet = materialInventory.steelPallet || 0
const materialFramePallet = materialInventory.framePallet || 0
const materialFlatPallet = materialInventory.flatPallet || 0
-
+
// 计算可用库位数
const availableSlots = this.availableSlots
@@ -759,7 +830,7 @@ export default {
},
{
value: availableSlots,
- name: '可用库位数(' + availableSlots + ')',
+ name: '可用库位(' + availableSlots + ')',
itemStyle: {
color: {
type: 'linear',
diff --git a/src/views/modules/dashboard/workshop-feeding-board.vue b/src/views/modules/dashboard/workshop-feeding-board.vue
index 23e0739..3593bbb 100644
--- a/src/views/modules/dashboard/workshop-feeding-board.vue
+++ b/src/views/modules/dashboard/workshop-feeding-board.vue
@@ -135,10 +135,8 @@ export default {
},
mounted() {
- this.updateTime()
- this.timeInterval = setInterval(() => {
- this.updateTime()
- }, 1000)
+ // 时间由HTTP API响应自动更新,不再使用定时器
+ this.currentTime = '等待服务器时间同步...'
// 首次加载数据
this.getDataList()
@@ -150,9 +148,6 @@ export default {
},
beforeDestroy() {
- if (this.timeInterval) {
- clearInterval(this.timeInterval)
- }
if (this.dataInterval) {
clearInterval(this.dataInterval)
}
@@ -166,6 +161,12 @@ export default {
workshopFeedingBoard({}).then(({data}) => {
if (data && data.code === 200) {
console.log('获取车间AGV放料区数据成功:', data.data)
+
+ // 更新服务器时间
+ if (data.serverTime) {
+ this.currentTime = data.serverTime
+ }
+
// TODO: 处理返回的数据,覆盖而非追加,避免内存累积
// if (data.data) {
// this.feedingList = data.data.feedingList || []
diff --git a/static/config/init.js b/static/config/init.js
index 9c464d6..65df102 100644
--- a/static/config/init.js
+++ b/static/config/init.js
@@ -3,7 +3,7 @@
*/
;(function() {
var resList = {
- icon: window.SITE_CONFIG.cdnUrl + '/static/img/favicon.ico',
+ icon: window.SITE_CONFIG.cdnUrl + '/static/img/ccl.ico',
css: [
window.SITE_CONFIG.cdnUrl + '/static/css/app.css',
],
@@ -73,4 +73,4 @@
createScripts();
}
};
-})();
\ No newline at end of file
+})();