From cd718c2363f8a0426d5bf7365c0df146f86b055f Mon Sep 17 00:00:00 2001
From: 快乐的昕的电脑 <快乐的昕的电脑@DESKTOP-C2BQPQU>
Date: 星期三, 19 十一月 2025 10:59:59 +0800
Subject: [PATCH] 定时刷新
---
components/WorkOrderPrint.vue | 61 ++++++++++++++++++++++++------
1 files changed, 49 insertions(+), 12 deletions(-)
diff --git a/components/WorkOrderPrint.vue b/components/WorkOrderPrint.vue
index 357c5b6..eaaa0fd 100644
--- a/components/WorkOrderPrint.vue
+++ b/components/WorkOrderPrint.vue
@@ -238,9 +238,10 @@
printNum: 1, reportingList: [], printLoading: false, customAmount: '',
isGeneratingBarcode: false, lastGenerateTime: 0, generateRequestId: null,
nowTimeTimer: null, nowTime: '',
- userSearch: '',
+ userSearch: '',
+ refreshTimer: null, // 鏂板锛氳嚜鍔ㄥ埛鏂板畾鏃跺櫒
/* 鏂板锛氬巻鍙叉姤宸ヨ褰曟暟缁� */
- reportingHistory: []
+ reportingHistory: []
}
},
computed: {
@@ -278,10 +279,35 @@
this.getXS0101();
this.updateNowTime();
// 绉掔骇鍒锋柊锛涘涓嶉渶鍔ㄦ�佽烦绉掑彲鏀逛负 60000
- this.nowTimeTimer = setInterval(this.updateNowTime, 1000);
+ this.nowTimeTimer = setInterval(this.updateNowTime, 1000);
+
+ // 鏂板锛氭瘡鍒嗛挓鑷姩鍒锋柊鏁版嵁锛�60000姣 = 1鍒嗛挓锛�
+ this.startAutoRefresh();
},
- beforeDestroy() { if (this.nowTimeTimer) clearInterval(this.nowTimeTimer); },
- methods: {
+ 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(':');
@@ -303,13 +329,24 @@
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("鍚屾澶辫触"); });
- },
+ // 淇敼锛氬湪鎵嬪姩鍒锋柊鏃朵篃閲嶇疆鑷姩鍒锋柊璁℃椂鍣�
+ refresh() {
+ this.$sendPostRequest({
+ url: "http://192.168.0.94:9095/Numerical/RefreshDevBycl",
+ data: { machineNo: this.order.machineNo },
+ contentType: "application/json"
+ }).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)];
this.orderId = o.id; this.orderNo = o.daa001;
--
Gitblit v1.9.3