components/machine.vue
@@ -257,12 +257,20 @@ }) } }, mounted() { // 页面加载时,启动定时器,每隔5分钟自动保存(当前示例使用 30s,可改回 5 分钟) this.autoSaveTimer = setInterval(() => { this.save(); // 直接调用已有的保存方法(save 已返回 Promise) }, 1 * 30 * 1000); // 30秒 }, mounted() { // 页面加载时,启动定时器,每隔30秒自动保存 this.autoSaveTimer = setInterval(() => { // 1. 调机完成时间有了就不自动保存 if (this.maEndTime) { return; } // 2. 送检时间为空也不自动保存 if (!this.maShoutTime) { return; } this.save(); // 满足条件才自动保存 }, 1 * 30 * 1000); // 30秒 }, beforeDestroy() { // 页面卸载时清理定时器 clearInterval(this.autoSaveTimer);