快乐的昕的电脑
2025-10-31 5403069a0ca726d75266b40b62cd85aa2875b6d9
重新加载
已修改1个文件
74 ■■■■ 文件已修改
components/machine.vue 74 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
components/machine.vue
@@ -157,40 +157,46 @@
            },
            // 保存并生效,将时间等信息提交到后端
            // 变更:返回 Promise;成功后局部刷新(调用 findByOrderId)而不是整页 reload
            save() {
                if (!this.statusForm.id) {
                    this.$showMessage("id为空,不允许推送");
                    return Promise.resolve();
                }
                return this.$post({
                    url: "/MesOrderSta/ChangeMachineTime",
                    data: {
                        maStartTime: this.maStartTime,
                        maShoutTime: this.maShoutTime,
                        maEndTime: this.maEndTime,
                        id: this.statusForm.id,
                        orderId: this.orderId,
                        machineNo: this.machineNo,
                        flag: this.flag
                    }
                }).then(res => {
                    if (res && res.data && res.data.tbBillList) {
                        this.$showMessage("呼叫成功");
                        // 局部刷新:重新拉取当前工单状态并更新当前组件数据
                        this.findByOrderId();
                        // 如果需要在保存后关闭对话框或返回上一级,可在这里处理
                    } else {
                        this.$showMessage("呼叫失败");
                        this.cancel();
                    }
                    return res;
                }).catch(err => {
                    // 保持友好的错误提示并将错误抛出以便外部链式处理
                    console.error('保存失败:', err);
                    this.$showMessage("保存时发生错误");
                    throw err;
                });
            },
            save() {
                if (!this.statusForm.id) {
                    this.$showMessage("id为空,不允许推送");
                    return Promise.resolve();
                }
                return this.$post({
                    url: "/MesOrderSta/ChangeMachineTime",
                    data: {
                        maStartTime: this.maStartTime,
                        maShoutTime: this.maShoutTime,
                        maEndTime: this.maEndTime,
                        id: this.statusForm.id,
                        orderId: this.orderId,
                        machineNo: this.machineNo,
                        flag: this.flag
                    }
                }).then(res => {
                    if (res && res.data && res.data.tbBillList) {
                        this.$showMessage("呼叫成功");
                        // 方案2:完全刷新当前页面
                        // 延迟一下让用户看到成功提示
                        setTimeout(() => {
                            // 方法1:使用 uni.reLaunch 重新加载(推荐)
                            uni.reLaunch({
                                url: '/' + getCurrentPages()[0].route
                            });
                        }, 1500);
                    } else {
                        this.$showMessage("呼叫失败");
                        this.cancel();
                    }
                    return res;
                }).catch(err => {
                    console.error('保存失败:', err);
                    this.$showMessage("保存时发生错误");
                    throw err;
                });
            },
            // 取消操作,恢复为上次保存的数据
            cancel() {
                this.maShoutTime = this.statusForm.maShoutTime;