| | |
| | | isGeneratingBarcode: false, lastGenerateTime: 0, generateRequestId: null, |
| | | nowTimeTimer: null, nowTime: '', |
| | | userSearch: '', |
| | | refreshTimer: null, // 新增:自动刷新定时器 |
| | | /* 新增:历史报工记录数组 */ |
| | | reportingHistory: [] |
| | | } |
| | |
| | | this.updateNowTime(); |
| | | // 秒级刷新;如不需动态跳秒可改为 60000 |
| | | this.nowTimeTimer = setInterval(this.updateNowTime, 1000); |
| | | |
| | | // 新增:每分钟自动刷新数据(60000毫秒 = 1分钟) |
| | | this.startAutoRefresh(); |
| | | }, |
| | | beforeDestroy() { if (this.nowTimeTimer) clearInterval(this.nowTimeTimer); }, |
| | | beforeDestroy() { |
| | | if (this.nowTimeTimer) clearInterval(this.nowTimeTimer); |
| | | // 新增:清理自动刷新定时器 |
| | | this.stopAutoRefresh(); |
| | | }, |
| | | methods: { |
| | | // 新增:开始自动刷新 |
| | | startAutoRefresh() { |
| | | // 先清除可能存在的旧定时器 |
| | | this.stopAutoRefresh(); |
| | | // 设置新的定时器,每分钟执行一次 |
| | | this.refreshTimer = setInterval(() => { |
| | | console.log('自动刷新数据...'); |
| | | this.refresh(); |
| | | }, 60000); // 60000毫秒 = 1分钟 |
| | | }, |
| | | // 新增:停止自动刷新 |
| | | stopAutoRefresh() { |
| | | if (this.refreshTimer) { |
| | | clearInterval(this.refreshTimer); |
| | | this.refreshTimer = null; |
| | | } |
| | | }, |
| | | |
| | | formatUser(u) { |
| | | if (!u) return ''; |
| | | const segs = u.split(':'); |
| | |
| | | this.isGeneratingBarcode = false; this.generateRequestId = null; this.lastGenerateTime = 0; |
| | | this.$showMessage("已重置条码生成状态"); |
| | | }, |
| | | // 修改:在手动刷新时也重置自动刷新计时器 |
| | | refresh() { |
| | | this.$sendPostRequest({ |
| | | url: "http://192.168.0.94:9095/Numerical/RefreshDevBycl", |
| | | data: { machineNo: this.order.machineNo }, |
| | | contentType: "application/json" |
| | | }).then(r => { r.code == 200 ? this.fetchData(true) : this.$showMessage("同步失败"); }); |
| | | }).then(r => { |
| | | if (r.code == 200) { |
| | | this.fetchData(true); |
| | | this.$showMessage("数据刷新成功"); |
| | | } else { |
| | | this.$showMessage("同步失败"); |
| | | } |
| | | }).catch(error => { |
| | | console.error('刷新失败:', error); |
| | | this.$showMessage("刷新失败,请检查网络连接"); |
| | | }); |
| | | }, |
| | | onDaa003Change(v) { |
| | | let o = this.lineList[this.DAA003List.indexOf(v)]; |